2026-04-21 15:57:37 +08:00
|
|
|
<script setup lang="ts">
|
2026-05-27 11:29:37 +08:00
|
|
|
import { ref, onMounted, onUnmounted, reactive, toRefs } from 'vue'
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
url: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: ''
|
|
|
|
|
},
|
|
|
|
|
name: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'aaa'
|
|
|
|
|
},
|
|
|
|
|
price: {
|
|
|
|
|
type: [String, Number],
|
|
|
|
|
default: ''
|
|
|
|
|
},
|
|
|
|
|
download: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false
|
|
|
|
|
},
|
|
|
|
|
showPrice: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
const emit = defineEmits(['addShopping', 'openDetail', 'download'])
|
|
|
|
|
let data = reactive({})
|
|
|
|
|
const addShopping = () => {
|
|
|
|
|
if (props.download) {
|
|
|
|
|
emit('download')
|
|
|
|
|
} else {
|
|
|
|
|
emit('addShopping')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const openDetail = () => {
|
|
|
|
|
emit('openDetail')
|
|
|
|
|
}
|
|
|
|
|
onMounted(() => {})
|
|
|
|
|
onUnmounted(() => {})
|
|
|
|
|
defineExpose({})
|
|
|
|
|
const {} = toRefs(data)
|
2026-04-21 15:57:37 +08:00
|
|
|
</script>
|
|
|
|
|
<template>
|
2026-05-27 11:29:37 +08:00
|
|
|
<div class="commodity-item" :class="{ 'is-download': download }">
|
|
|
|
|
<img :src="props.url" alt="" @click="openDetail" />
|
|
|
|
|
<div class="detail">
|
|
|
|
|
<div class="text">
|
|
|
|
|
<div class="name">
|
|
|
|
|
{{ props.name }}
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
class="price"
|
|
|
|
|
:class="{ 'is-download': download }"
|
|
|
|
|
v-if="props.showPrice && props.price"
|
|
|
|
|
>
|
2026-06-01 10:40:11 +08:00
|
|
|
HK${{ props.price }}
|
2026-05-27 11:29:37 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="btn" @click="addShopping">
|
|
|
|
|
<div class="text">
|
|
|
|
|
<SvgIcon
|
|
|
|
|
:name="download ? 'download' : 'add'"
|
|
|
|
|
size="26"
|
|
|
|
|
color="#232323"
|
|
|
|
|
></SvgIcon>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-04-21 15:57:37 +08:00
|
|
|
</template>
|
|
|
|
|
<style lang="less" scoped>
|
2026-05-27 11:29:37 +08:00
|
|
|
.commodity-item {
|
|
|
|
|
width: var(--commodity-width, 100%);
|
|
|
|
|
&.is-download {
|
|
|
|
|
img {
|
|
|
|
|
cursor: initial;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
> img {
|
|
|
|
|
width: 100%;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
height: var(--commodity-height, auto);
|
|
|
|
|
margin-bottom: var(--commodity-marginBottom, 1rem);
|
|
|
|
|
}
|
|
|
|
|
> .detail {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
> .text {
|
|
|
|
|
color: #232323;
|
|
|
|
|
> .name {
|
|
|
|
|
font-family: 'KaiseiOpti-Regular';
|
2026-06-01 10:40:11 +08:00
|
|
|
font-weight: 700;
|
|
|
|
|
font-size: var(--commodity-name-fontSize, 2rem);
|
2026-05-27 11:29:37 +08:00
|
|
|
line-height: var(--commodity-name-lineHeight, 2.3rem);
|
|
|
|
|
margin-bottom: var(--commodity-name-marginBottom, 0rem);
|
|
|
|
|
}
|
|
|
|
|
> .price {
|
|
|
|
|
font-family: 'KaiseiOpti-Regular';
|
|
|
|
|
font-weight: 400;
|
2026-06-01 10:40:11 +08:00
|
|
|
font-size: var(--commodity-price-fontSize, 1.6rem);
|
2026-05-27 11:29:37 +08:00
|
|
|
line-height: var(--commodity-price-lineHeight, 2.3rem);
|
2026-06-01 10:40:11 +08:00
|
|
|
margin-top: .8rem;
|
2026-05-27 11:29:37 +08:00
|
|
|
&.is-download {
|
|
|
|
|
color: #979797;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.btn {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-23 17:29:15 +08:00
|
|
|
</style>
|