20260227-1

This commit is contained in:
cyh666666
2026-02-27 16:51:56 +08:00
1526 changed files with 2457 additions and 38509 deletions

View File

@@ -83,7 +83,7 @@
type="number"
:value="quantity.toString()"
:min="1"
:max="getMaxQuantity()"
:max="getMaxQuantity()"
@input="validateQuantity" />
<view class="quantity-btn plus" @click="increaseQuantity">
<text class="quantity-btn-text">+</text>
@@ -265,7 +265,7 @@ export default {
showSpec: false,
selectedSkuId: '',
selectedSpec: '',
quantity: 1,
quantity: 1 as number,
isFavorite: false,
showParams: false,
// 新增: 优惠券相关
@@ -348,15 +348,21 @@ export default {
}
// 移除已存在的相同商品(为了将其移到最新位置)
footprints = footprints.filter(item => item.id !== productId)
const productIdStr = productId
footprints = footprints.filter(function(item: any): boolean {
const itemObj = item as UTSJSONObject
const itemId = itemObj.getString('id') ?? ''
return itemId != productIdStr
})
// 添加到头部
const productImage = this.product.images.length > 0 ? this.product.images[0] : '/static/default-product.png'
footprints.unshift({
id: this.product.id,
name: this.product.name,
price: this.product.price,
original_price: this.product.original_price, // 添加原价
image: this.product.images[0],
original_price: this.product.original_price,
image: productImage,
sales: this.product.sales,
shopId: this.merchant.id,
shopName: this.merchant.shop_name,
@@ -386,6 +392,7 @@ export default {
if (dbProduct != null) {
// Map DB product to local product
const dbObj = dbProduct as UTSJSONObject
this.product = {
id: dbProduct['id'] as string,
merchant_id: (dbProduct['merchant_id'] ?? dbProduct['shop_id'] ?? '') as string,
@@ -453,7 +460,6 @@ export default {
// Merge attributes into product if they match keys
if (attrs['specification'] != null) this.product.specification = attrs['specification'] as string
if (attrs['usage'] != null) this.product.usage = attrs['usage'] as string
// ... augment as needed
}
} catch(e) {}
}
@@ -686,7 +692,7 @@ export default {
// 简化处理,直接返回 JSON 字符串
return JSON.stringify(specs)
}
return sku.sku_code
return sku.sku_code ?? ''
},
async addToCart() {
@@ -704,7 +710,8 @@ export default {
const success = await supabaseService.addToCart(
this.product.id,
this.quantity,
this.selectedSkuId
this.selectedSkuId,
this.product.merchant_id
)
uni.hideLoading()
@@ -740,7 +747,10 @@ export default {
product_image: (sku != null && sku.image_url != null) ? sku!.image_url : this.product.images[0],
sku_specifications: sku != null ? sku!.specifications : {},
price: parseFloat((sku != null ? sku!.price : this.product.price).toString()).toFixed(2) as string,
quantity: this.quantity as number
quantity: this.quantity as number,
shop_id: this.merchant.id,
shop_name: this.merchant.shop_name,
merchant_id: this.merchant.user_id ?? this.product.merchant_id
}
uni.setStorageSync('checkout_type', 'buy_now')