解决登录显示、首页显示bug
This commit is contained in:
@@ -97,6 +97,7 @@
|
||||
|
||||
<script lang="uts">
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
import { requireMerchantAuth } from '@/utils/merchantAuth.uts'
|
||||
import { USE_MOCK, MOCK_MEMBER_LEVELS, MOCK_SERVICE_USERS } from '@/pages/mall/merchant/mock/merchant-mock-data.uts'
|
||||
|
||||
type MemberLevel = {
|
||||
@@ -138,13 +139,14 @@
|
||||
merchantId: ''
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
async onLoad() {
|
||||
if (USE_MOCK) {
|
||||
this.merchantId = 'mock-merchant'
|
||||
this.loadLevels()
|
||||
return
|
||||
}
|
||||
this.merchantId = uni.getStorageSync('user_id') || ''
|
||||
const passed = await this.ensureMerchantAuth()
|
||||
if (!passed) return
|
||||
this.loadLevels()
|
||||
},
|
||||
watch: {
|
||||
@@ -155,6 +157,17 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async ensureMerchantAuth(): Promise<boolean> {
|
||||
if (USE_MOCK) return true
|
||||
const result = await requireMerchantAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
if (!result.ok) {
|
||||
this.merchantId = ''
|
||||
return false
|
||||
}
|
||||
this.merchantId = result.userInfo != null && result.userInfo.id != null ? result.userInfo.id : ''
|
||||
return this.merchantId !== ''
|
||||
},
|
||||
|
||||
handleSearch() {
|
||||
console.log('按钮被点击,触发 handleSearch');
|
||||
this.loadUsers();
|
||||
|
||||
Reference in New Issue
Block a user