解决登录显示、首页显示bug
This commit is contained in:
@@ -1,12 +1,6 @@
|
||||
<!-- 医养综合服务商城 · 机构工作台首页 -->
|
||||
<template>
|
||||
<view class="merchant-container">
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<!-- Tab 页无返回按钮,展示顶部安全区 + 蓝色顶栏 -->
|
||||
<view class="mp-tab-navbar">
|
||||
<text class="mp-tab-title">机构工作台</text>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
<scroll-view direction="vertical" class="main-scroll" :refresher-enabled="true" :refresher-triggered="refreshing" @refresherrefresh="onRefresh">
|
||||
|
||||
<!-- ===== 顶部工作台头部(浅蓝渐变,老年友好) ===== -->
|
||||
@@ -280,6 +274,7 @@
|
||||
<script lang="uts">
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
import MerchantTabBar from '@/components/merchant-tabbar/MerchantTabBar.uvue'
|
||||
import { requireMerchantAuth } from '@/utils/merchantAuth.uts'
|
||||
|
||||
type ShopInfoType = {
|
||||
id: string | null
|
||||
@@ -351,6 +346,7 @@
|
||||
data() {
|
||||
return {
|
||||
merchantId: '',
|
||||
authChecking: false,
|
||||
shopInfo: {
|
||||
id: null,
|
||||
merchant_id: null,
|
||||
@@ -407,7 +403,7 @@
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.initMerchantId()
|
||||
this.ensureMerchantAuth()
|
||||
},
|
||||
|
||||
onShow() {
|
||||
@@ -436,19 +432,7 @@
|
||||
this.isPageReady = true
|
||||
}
|
||||
} catch(e) {}
|
||||
// 后台刷新数据
|
||||
if (this.merchantId) {
|
||||
this.loadAllData()
|
||||
this.startRealtimeSubscription()
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
// 等待 initMerchantId 完成后再检查,若仍无有效 ID 则不请求
|
||||
if (this.merchantId) {
|
||||
this.loadAllData()
|
||||
this.startRealtimeSubscription()
|
||||
}
|
||||
}, 500)
|
||||
}
|
||||
this.handlePageShow()
|
||||
},
|
||||
|
||||
onHide() {
|
||||
@@ -460,6 +444,47 @@
|
||||
},
|
||||
|
||||
methods: {
|
||||
async ensureMerchantAuth(): Promise<boolean> {
|
||||
if (this.authChecking) {
|
||||
return false
|
||||
}
|
||||
this.authChecking = true
|
||||
try {
|
||||
const result = await requireMerchantAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
if (!result.ok) {
|
||||
this.merchantId = ''
|
||||
this.stopRealtimeSubscription()
|
||||
return false
|
||||
}
|
||||
|
||||
const uid = result.userInfo != null && result.userInfo.id != null ? result.userInfo.id : ''
|
||||
this.merchantId = uid
|
||||
if (result.merchantInfo != null) {
|
||||
this.shopInfo.id = result.merchantInfo.id
|
||||
this.shopInfo.merchant_id = result.merchantInfo.merchant_id
|
||||
this.shopInfo.shop_name = result.merchantInfo.shop_name !== '' ? result.merchantInfo.shop_name : this.shopInfo.shop_name
|
||||
this.shopInfo.shop_logo = result.merchantInfo.shop_logo !== '' ? result.merchantInfo.shop_logo : this.shopInfo.shop_logo
|
||||
this.shopInfo.shop_banner = result.merchantInfo.shop_banner !== '' ? result.merchantInfo.shop_banner : this.shopInfo.shop_banner
|
||||
this.shopInfo.description = result.merchantInfo.description !== '' ? result.merchantInfo.description : this.shopInfo.description
|
||||
this.shopInfo.contact_name = result.merchantInfo.contact_name !== '' ? result.merchantInfo.contact_name : this.shopInfo.contact_name
|
||||
this.shopInfo.contact_phone = result.merchantInfo.contact_phone !== '' ? result.merchantInfo.contact_phone : this.shopInfo.contact_phone
|
||||
this.shopInfo.status = result.merchantInfo.status
|
||||
}
|
||||
return this.merchantId !== ''
|
||||
} finally {
|
||||
this.authChecking = false
|
||||
}
|
||||
},
|
||||
|
||||
async handlePageShow() {
|
||||
const passed = await this.ensureMerchantAuth()
|
||||
if (!passed) {
|
||||
return
|
||||
}
|
||||
this.loadAllData()
|
||||
this.startRealtimeSubscription()
|
||||
},
|
||||
|
||||
/** UUID 格式校验,非 UUID 不得用于 Supabase 过滤(否则 PostgREST 400)*/
|
||||
isValidUUID(id: string): boolean {
|
||||
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id)
|
||||
@@ -964,7 +989,7 @@
|
||||
|
||||
/* ===== 顶部工作台头部(浅蓝渐变,贴近 mall merchant 风格) ===== */
|
||||
.wt-header { background: linear-gradient(135deg, #A6F1E4 0%, #69DFC2 100%); padding-bottom: 0; }
|
||||
.wt-header-top { padding: 32rpx 28rpx 24rpx; }
|
||||
.wt-header-top { padding: calc(32rpx + var(--status-bar-height)) 28rpx 24rpx; }
|
||||
.wt-shop-row { display: flex; flex-direction: row; align-items: center; }
|
||||
.wt-shop-logo { width: 100rpx; height: 100rpx; border-radius: 16rpx; border-width: 3rpx; border-style: solid; border-color: rgba(255,255,255,0.7); margin-right: 20rpx; background-color: #fff; flex-shrink: 0; }
|
||||
.wt-shop-info { flex: 1; }
|
||||
|
||||
Reference in New Issue
Block a user