添加mock数据

This commit is contained in:
2026-04-13 11:32:31 +08:00
parent 334e5936c9
commit 37141c1d6b
17 changed files with 1843 additions and 330 deletions

View File

@@ -47,6 +47,7 @@
<script lang="uts">
import supa from '@/components/supadb/aksupainstance.uts'
import { USE_MOCK, MOCK_MERCHANT_ID, getMockPromotions } from '@/pages/mall/merchant/mock/merchant-mock-data.uts'
type PromotionType = {
id: string
@@ -75,21 +76,39 @@
},
onShow() {
this.loadPromotions()
if (this.merchantId !== '') {
this.loadPromotions()
}
},
methods: {
async initMerchantId() {
if (USE_MOCK) {
this.merchantId = MOCK_MERCHANT_ID
this.loadPromotions()
return
}
try {
const session = supa.getSession()
this.merchantId = session?.user?.getString('id') || uni.getStorageSync('user_id') || ''
} catch (e) {}
this.loadPromotions()
this.loadPromotions()
},
async loadPromotions() {
if (USE_MOCK) {
this.promotions = getMockPromotions(this.currentTab)
this.loading = false
this.refreshing = false
return
}
this.loading = true
try {
const response = await supa
.from('ml_coupon_templates')
.select('*')
.eq('merchant_id', this.merchantId)
.eq('coupon_type', this.currentTab)
.order('created_at', { ascending: false })
.limit(50)
.execute()
@@ -118,7 +137,7 @@
this.promotions = promos
} catch (e) {
console.error('加载失败:', e)
console.error('加载活动失败:', e)
} finally {
this.loading = false
this.refreshing = false