From 5d0c0ae95a68f3797348cc853ffdcd6edcfcf538 Mon Sep 17 00:00:00 2001 From: huangzhenbao <17818024429@163.com> Date: Thu, 4 Jun 2026 21:54:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BC=98=E6=83=A0=E5=88=B8?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E9=93=BE=E8=B7=AF=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/mall/consumer/coupons.uvue | 76 +- pages/mall/consumer/product-detail.uvue | 29 +- utils/supabaseService.uts | 76 +- 报错信息.txt | 2016 +---------------------- 4 files changed, 123 insertions(+), 2074 deletions(-) diff --git a/pages/mall/consumer/coupons.uvue b/pages/mall/consumer/coupons.uvue index 5816b6cc..83c56a8c 100644 --- a/pages/mall/consumer/coupons.uvue +++ b/pages/mall/consumer/coupons.uvue @@ -1,15 +1,25 @@ @@ -28,28 +38,45 @@ import type { UserCoupon } from '@/utils/supabaseService.uts' type Coupon = { title: string - amount: string + displayAmount: string + typeLabel: string expiry: string id: string } const coupons = ref([]) +const loading = ref(true) +const loadError = ref(false) const loadCoupons = async () => { - uni.showLoading({ title: '加载中...' }) + loading.value = true + loadError.value = false try { const userCoupons = await supabaseService.getUserCoupons(1) const couponList: Coupon[] = [] for (let i = 0; i < userCoupons.length; i++) { const item = userCoupons[i] const amountVal = item.amount ?? 0 + const discountType = item.discount_type ?? 1 const expiryVal = (item.expire_at != null && item.expire_at !== '') ? item.expire_at.substring(0, 10) : '长期有效' + + let displayAmount = '' + let typeLabel = '优惠券' + if (discountType == 2) { + displayAmount = Math.round(amountVal * 100) / 10 + '折' + typeLabel = '折扣券' + } else { + displayAmount = '¥' + amountVal.toString() + typeLabel = '优惠券' + } + const coupon: Coupon = { id: item.id, title: (item.template_name != null && item.template_name !== '') ? item.template_name : '优惠券', - amount: `¥${amountVal}`, + displayAmount: displayAmount, + typeLabel: typeLabel, expiry: expiryVal } as Coupon couponList.push(coupon) @@ -57,9 +84,14 @@ const loadCoupons = async () => { coupons.value = couponList } catch (e) { console.error('加载优惠券失败', e) + loadError.value = true coupons.value = [] + uni.showToast({ + title: '优惠券加载失败,请稍后重试', + icon: 'none' + }) } finally { - uni.hideLoading() + loading.value = false } } @@ -76,9 +108,15 @@ const useCoupon = (coupon: Coupon) => {