添加mock数据
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user