修复和平小店商品图片和库存展示
This commit is contained in:
@@ -12,9 +12,16 @@ const priceLabel = computed(() => {
|
||||
})
|
||||
const stockText = computed(() => {
|
||||
if (!selectedProduct.value) return ''
|
||||
if (isXiaodian.value && selectedProduct.value.stockLabel) return selectedProduct.value.stockLabel
|
||||
if (isXiaodian.value && selectedProduct.value.count < 0) return '库存未公开'
|
||||
return `库存 ${selectedProduct.value.count}`
|
||||
})
|
||||
|
||||
const stockIsLow = computed(() => {
|
||||
if (!selectedProduct.value) return false
|
||||
if (isXiaodian.value && selectedProduct.value.stockLabel) return false
|
||||
return selectedProduct.value.count >= 0 && selectedProduct.value.count < 500
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -24,7 +31,7 @@ const stockText = computed(() => {
|
||||
<div class="selected-product-meta">
|
||||
<template v-if="selectedProduct">
|
||||
<span class="chip chip-score">{{ selectedProduct.score }} {{ priceLabel }}</span>
|
||||
<span class="chip chip-stock" :class="{ low: selectedProduct.count >= 0 && selectedProduct.count < 500 }">
|
||||
<span class="chip chip-stock" :class="{ low: stockIsLow }">
|
||||
{{ stockText }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
@@ -8,7 +8,13 @@ const { filteredProducts, selectedProductId, selectProduct, searchQuery, xiaodia
|
||||
const { currentActivity } = useActivity()
|
||||
const isXiaodian = computed(() => currentActivity.value?.id === 'xiaodian')
|
||||
const priceLabel = (product: { payLabel?: string }) => isXiaodian.value ? (product.payLabel || '点券') : '积分'
|
||||
const stockText = (count: number) => isXiaodian.value && count < 0 ? '库存未公开' : `库存 ${count}`
|
||||
const stockText = (product: { count: number; stockLabel?: string }) => {
|
||||
if (isXiaodian.value && product.stockLabel) return product.stockLabel
|
||||
if (isXiaodian.value && product.count < 0) return '库存未公开'
|
||||
return `库存 ${product.count}`
|
||||
}
|
||||
const stockIsLow = (product: { count: number; stockLabel?: string }) =>
|
||||
(!isXiaodian.value || !product.stockLabel) && product.count >= 0 && product.count < 500
|
||||
|
||||
const parentRef = ref<HTMLElement | null>(null)
|
||||
const itemSize = 72
|
||||
@@ -80,10 +86,10 @@ watch(xiaodianTab, () => {
|
||||
>{{ filteredProducts[item.index].score }} {{ priceLabel(filteredProducts[item.index]) }}</span>
|
||||
<span
|
||||
class="chip chip-stock"
|
||||
:class="{ low: filteredProducts[item.index].count >= 0 && filteredProducts[item.index].count < 500 }"
|
||||
:title="stockText(filteredProducts[item.index].count)"
|
||||
:class="{ low: stockIsLow(filteredProducts[item.index]) }"
|
||||
:title="stockText(filteredProducts[item.index])"
|
||||
>
|
||||
{{ stockText(filteredProducts[item.index].count) }}
|
||||
{{ stockText(filteredProducts[item.index]) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user