consumer模块完成95%,在和商家端对接聊天购物闭环

This commit is contained in:
2026-02-06 17:10:31 +08:00
parent 06b7369494
commit e2f1dfb097
1454 changed files with 5425 additions and 210555 deletions

View File

@@ -23,6 +23,8 @@
<script setup lang="uts">
import { ref, onMounted } from 'vue'
import supabaseService from '@/utils/supabaseService.uts'
import type { UserCoupon } from '@/utils/supabaseService.uts'
type Coupon = {
title: string
@@ -37,21 +39,24 @@ onMounted(() => {
loadCoupons()
})
const loadCoupons = () => {
// 从本地存储获取已领取的优惠券详情
// 假设存储格式为 JSON 字符串数组
const storedCoupons = uni.getStorageSync('myCoupons')
if (storedCoupons) {
const loadCoupons = async () => {
uni.showLoading({ title: '加载中...' })
try {
coupons.value = JSON.parse(storedCoupons as string) as Coupon[]
const userCoupons = await supabaseService.getUserCoupons(1) // 1: unused
coupons.value = userCoupons.map((item: UserCoupon) => {
return {
id: item.id,
title: item.template_name || '优惠券',
amount: `¥${item.amount || 0}`,
expiry: item.expire_at ? item.expire_at.substring(0, 10) : '长期有效'
} as Coupon
})
} catch (e) {
console.error('Failed to parse coupons', e)
coupons.value = []
console.error('加载优惠券失败', e)
coupons.value = []
} finally {
uni.hideLoading()
}
} else {
// 默认空或者是mock一些基础数据如果需要
coupons.value = []
}
}
const useCoupon = (coupon: Coupon) => {