完善下单逻辑及其ui展示,修复支付倒计时显示错误bug
This commit is contained in:
@@ -52,13 +52,13 @@
|
||||
:key="product.id + '-' + pIndex"
|
||||
class="hmall-recommend-product"
|
||||
>
|
||||
<image class="hmall-recommend-product-image" :src="getChannelProductImage(product)" mode="aspectFill" />
|
||||
<text class="hmall-recommend-product-name">{{ product.shortName }}</text>
|
||||
<image class="hmall-recommend-product-image" :src="getChannelProductImage(product)" mode="aspectFill" @error="handleChannelProductImageError(product.id)" />
|
||||
<text class="hmall-recommend-product-name">{{ getChannelProductTitle(product) }}</text>
|
||||
<view class="hmall-recommend-price-row">
|
||||
<text class="hmall-recommend-product-tag" :style="{ color: channel.themeColor }">{{ product.tag }}</text>
|
||||
<text class="hmall-recommend-product-price" :style="{ color: channel.themeColor }">¥{{ formatChannelPrice(product.price) }}</text>
|
||||
<text class="hmall-recommend-product-tag" :style="{ color: channel.themeColor }">{{ getChannelProductTag(product) }}</text>
|
||||
<text class="hmall-recommend-product-price" :style="{ color: channel.themeColor }">¥{{ formatChannelPrice(getChannelSalePrice(product)) }}</text>
|
||||
</view>
|
||||
<text v-if="product.marketPrice > product.price" class="hmall-recommend-market-price">¥{{ formatChannelPrice(product.marketPrice) }}</text>
|
||||
<text v-if="showChannelMarketPrice(product)" class="hmall-recommend-market-price">¥{{ formatChannelPrice(getChannelMarketPrice(product)) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -167,6 +167,7 @@ import type { Category, Product } from '@/utils/supabaseService.uts'
|
||||
import type { MarketingChannel, ChannelProduct, SimpleCategoryChannel } from '@/utils/mockChannelData.uts'
|
||||
|
||||
const failedProductImageIds = ref<string[]>([])
|
||||
const failedChannelImageIds = ref<string[]>([])
|
||||
|
||||
type SecondaryCategoryPage = {
|
||||
id: string
|
||||
@@ -266,9 +267,50 @@ function getCategoryDisplayIcon(category: Category): string {
|
||||
}
|
||||
|
||||
function getChannelProductImage(product: ChannelProduct): string {
|
||||
if (failedChannelImageIds.value.indexOf(product.id) != -1) {
|
||||
return '/static/images/default.png'
|
||||
}
|
||||
return product.image != '' ? product.image : '/static/images/default.png'
|
||||
}
|
||||
|
||||
function handleChannelProductImageError(productId: string): void {
|
||||
if (productId == '') {
|
||||
return
|
||||
}
|
||||
if (failedChannelImageIds.value.indexOf(productId) == -1) {
|
||||
failedChannelImageIds.value.push(productId)
|
||||
}
|
||||
}
|
||||
|
||||
function getChannelProductTitle(product: ChannelProduct): string {
|
||||
if (product.shortName != null && product.shortName != '') {
|
||||
return product.shortName
|
||||
}
|
||||
if (product.name != null && product.name != '') {
|
||||
return product.name
|
||||
}
|
||||
return '商品补充中'
|
||||
}
|
||||
|
||||
function getChannelProductTag(product: ChannelProduct): string {
|
||||
if (product.tag != null && product.tag != '') {
|
||||
return product.tag
|
||||
}
|
||||
return '活动价'
|
||||
}
|
||||
|
||||
function getChannelSalePrice(product: ChannelProduct): number {
|
||||
return product.price > 0 ? product.price : 0
|
||||
}
|
||||
|
||||
function getChannelMarketPrice(product: ChannelProduct): number {
|
||||
return product.marketPrice > 0 ? product.marketPrice : 0
|
||||
}
|
||||
|
||||
function showChannelMarketPrice(product: ChannelProduct): boolean {
|
||||
return getChannelMarketPrice(product) > getChannelSalePrice(product)
|
||||
}
|
||||
|
||||
function formatChannelPrice(price: number): string {
|
||||
const rounded = Math.round(price)
|
||||
if (Math.abs(price - rounded) < 0.001) {
|
||||
|
||||
Reference in New Issue
Block a user