解决登录显示、首页显示bug
This commit is contained in:
@@ -181,15 +181,7 @@
|
||||
|
||||
onShow() {
|
||||
console.log('chat page onShow, chatUserId:', this.chatUserId, 'merchantId:', this.merchantId)
|
||||
if (this.merchantId) {
|
||||
this.loadChatMessages()
|
||||
this.setupRealtimeSubscription()
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.loadChatMessages()
|
||||
this.setupRealtimeSubscription()
|
||||
}, 300)
|
||||
}
|
||||
this.handlePageShow()
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
@@ -199,21 +191,27 @@
|
||||
},
|
||||
|
||||
methods: {
|
||||
async initMerchantId() {
|
||||
try {
|
||||
const session = supa.getSession()
|
||||
if (session != null && session.user != null) {
|
||||
this.merchantId = session.user.getString('id') || ''
|
||||
}
|
||||
if (!this.merchantId) {
|
||||
this.merchantId = uni.getStorageSync('user_id') || ''
|
||||
}
|
||||
|
||||
// 加载店铺头像
|
||||
this.loadShopAvatar()
|
||||
} catch (e) {
|
||||
console.error('获取商户ID失败:', e)
|
||||
async ensureMerchantAuth(): Promise<boolean> {
|
||||
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 !== ''
|
||||
},
|
||||
|
||||
async handlePageShow() {
|
||||
const passed = await this.ensureMerchantAuth()
|
||||
if (!passed) return
|
||||
this.loadChatMessages()
|
||||
this.setupRealtimeSubscription()
|
||||
},
|
||||
|
||||
async initMerchantId() {
|
||||
const passed = await this.ensureMerchantAuth()
|
||||
if (!passed) return
|
||||
this.loadShopAvatar()
|
||||
},
|
||||
|
||||
async loadShopAvatar() {
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
}
|
||||
},
|
||||
|
||||
onLoad(options: any) {
|
||||
async onLoad(options: any) {
|
||||
if (options['user_id']) {
|
||||
this.userId = String(options['user_id'])
|
||||
} else if (options.user_id) {
|
||||
@@ -124,6 +124,11 @@
|
||||
},
|
||||
|
||||
methods: {
|
||||
async ensureMerchantAuth(): Promise<boolean> {
|
||||
const result = await requireMerchantAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
return result.ok
|
||||
},
|
||||
|
||||
async openProductSelect() {
|
||||
this.showProductSelect = true
|
||||
if (this.allProducts.length === 0) {
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
|
||||
<script lang="uts">
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
import { requireMerchantAuth } from '@/utils/merchantAuth.uts'
|
||||
import { USE_MOCK, MOCK_MERCHANT_ID, MOCK_BALANCE, MOCK_FINANCE_STATS, getMockFinanceRecords } from '@/pages/mall/merchant/mock/merchant-mock-data.uts'
|
||||
|
||||
type RecordType = {
|
||||
@@ -108,11 +109,28 @@
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.loadBalance()
|
||||
this.loadRecords()
|
||||
this.handlePageShow()
|
||||
},
|
||||
|
||||
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 !== ''
|
||||
},
|
||||
|
||||
async handlePageShow() {
|
||||
const passed = await this.ensureMerchantAuth()
|
||||
if (!passed) return
|
||||
this.loadBalance()
|
||||
this.loadRecords()
|
||||
},
|
||||
|
||||
async initMerchantId() {
|
||||
if (USE_MOCK) {
|
||||
this.merchantId = MOCK_MERCHANT_ID
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
<!-- 机构端 - 机构成长页(安读Tab4 -->
|
||||
<template>
|
||||
<view class="growth-page">
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<!-- Tab 页无返回按钮,显示顶部安全区 + 页面标题 -->
|
||||
<view class="mp-tab-navbar">
|
||||
<text class="mp-tab-title">机构成长</text>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
|
||||
<scroll-view direction="vertical" class="growth-scroll" :refresher-enabled="true" :refresher-triggered="refreshing" @refresherrefresh="onRefresh">
|
||||
|
||||
<!-- 成长等级卡片 -->
|
||||
@@ -139,6 +132,7 @@
|
||||
|
||||
<script lang="uts">
|
||||
import MerchantTabBar from '@/components/merchant-tabbar/MerchantTabBar.uvue'
|
||||
import { requireMerchantAuth } from '@/utils/merchantAuth.uts'
|
||||
|
||||
type TipType = {
|
||||
icon: string
|
||||
@@ -317,10 +311,15 @@
|
||||
},
|
||||
|
||||
onShow() {
|
||||
// 预留:后续可对接成长等级接口
|
||||
this.ensureMerchantAuth()
|
||||
},
|
||||
|
||||
methods: {
|
||||
async ensureMerchantAuth(): Promise<boolean> {
|
||||
const result = await requireMerchantAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
return result.ok
|
||||
},
|
||||
|
||||
onRefresh() {
|
||||
this.refreshing = true
|
||||
// 预留:刷新成长数据
|
||||
@@ -372,7 +371,7 @@
|
||||
|
||||
.growth-scroll {
|
||||
flex: 1;
|
||||
padding: 24rpx;
|
||||
padding: calc(24rpx + var(--status-bar-height)) 24rpx 24rpx;
|
||||
}
|
||||
|
||||
/* 成长等级卡片 */
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -96,6 +96,7 @@
|
||||
|
||||
<script lang="uts">
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
import { requireMerchantAuth } from '@/utils/merchantAuth.uts'
|
||||
import { USE_MOCK, MOCK_MERCHANT_ID, getMockInventoryStats, MOCK_INVENTORY_PRODUCTS } from '@/pages/mall/merchant/mock/merchant-mock-data.uts'
|
||||
|
||||
type ProductType = {
|
||||
@@ -131,12 +132,29 @@
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.page = 1
|
||||
this.loadProducts()
|
||||
this.loadStats()
|
||||
this.handlePageShow()
|
||||
},
|
||||
|
||||
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 !== ''
|
||||
},
|
||||
|
||||
async handlePageShow() {
|
||||
const passed = await this.ensureMerchantAuth()
|
||||
if (!passed) return
|
||||
this.page = 1
|
||||
this.loadProducts()
|
||||
this.loadStats()
|
||||
},
|
||||
|
||||
async initMerchantId() {
|
||||
if (USE_MOCK) {
|
||||
this.merchantId = MOCK_MERCHANT_ID
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
<!-- 机构端 - 消息中心(客服工作台) -->
|
||||
<template>
|
||||
<view class="messages-page">
|
||||
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<view class="mp-tab-navbar">
|
||||
<view class="wb-navbar-content">
|
||||
<text class="mp-tab-title">客服工作台</text>
|
||||
<view class="wb-header-right">
|
||||
<view class="wb-status-wrap">
|
||||
<view class="wb-status-dot"></view>
|
||||
@@ -15,9 +10,6 @@
|
||||
<text class="wb-pending-text">{{ pendingCount }}条待处理</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- ===== 三模块 Tab 切换栏 ===== -->
|
||||
<view class="wb-tabs">
|
||||
@@ -347,6 +339,7 @@ class="msg-row"
|
||||
|
||||
<script lang="uts">
|
||||
import MerchantTabBar from '@/components/merchant-tabbar/MerchantTabBar.uvue'
|
||||
import { requireMerchantAuth } from '@/utils/merchantAuth.uts'
|
||||
|
||||
type ProductCardData = {
|
||||
emoji: string
|
||||
@@ -556,10 +549,21 @@ return total
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.scrollToBottom()
|
||||
this.handlePageShow()
|
||||
},
|
||||
|
||||
methods: {
|
||||
async ensureMerchantAuth(): Promise<boolean> {
|
||||
const result = await requireMerchantAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
return result.ok
|
||||
},
|
||||
|
||||
async handlePageShow() {
|
||||
const passed = await this.ensureMerchantAuth()
|
||||
if (!passed) return
|
||||
this.scrollToBottom()
|
||||
},
|
||||
|
||||
selectSession(id: string) {
|
||||
this.currentSessionId = id
|
||||
this.showQuickReplies = false
|
||||
@@ -680,7 +684,10 @@ this.activeTab = 0
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 16rpx;
|
||||
padding: calc(16rpx + var(--status-bar-height)) 24rpx 16rpx;
|
||||
background-color: #09C39D;
|
||||
}
|
||||
.wb-status-wrap {
|
||||
display: flex;
|
||||
|
||||
@@ -294,6 +294,7 @@
|
||||
|
||||
<script lang="uts">
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
import { requireMerchantAuth } from '@/utils/merchantAuth.uts'
|
||||
|
||||
type OrderItemType = {
|
||||
id: string
|
||||
@@ -511,13 +512,17 @@
|
||||
}
|
||||
},
|
||||
|
||||
onLoad(options: any) {
|
||||
async onLoad(options: any) {
|
||||
let id = ''
|
||||
if (options['id'] != null) {
|
||||
id = options['id'] as string
|
||||
} else if (options.id != null) {
|
||||
id = options.id as string
|
||||
}
|
||||
const authResult = await requireMerchantAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
if (!authResult.ok) {
|
||||
return
|
||||
}
|
||||
if (id !== '') {
|
||||
this.orderId = id
|
||||
this.loadOrderDetail()
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
<!-- 机构端 - 服务订单管理页面 -->
|
||||
<template>
|
||||
<view class="orders-page">
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<view class="mp-tab-navbar">
|
||||
<text class="mp-tab-title">服务订单</text>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- 一级切换:服务订单 / 取消售后 -->
|
||||
<view class="lvl1-tabs">
|
||||
<view
|
||||
@@ -348,6 +342,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'
|
||||
import { USE_MOCK, MOCK_MERCHANT_ID, getMockOrdersByStatus, getMockAftersaleByStatus, getMockOrderTabCounts, getMockAftersaleTabCounts } from '@/pages/mall/merchant/mock/merchant-mock-data.uts'
|
||||
|
||||
type OrderItemType = {
|
||||
@@ -475,16 +470,27 @@
|
||||
},
|
||||
|
||||
onShow() {
|
||||
if (this.merchantId) {
|
||||
this.refreshCurrentTab()
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.refreshCurrentTab()
|
||||
}, 500)
|
||||
}
|
||||
this.handlePageShow()
|
||||
},
|
||||
|
||||
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 !== ''
|
||||
},
|
||||
|
||||
async handlePageShow() {
|
||||
const passed = await this.ensureMerchantAuth()
|
||||
if (!passed) return
|
||||
this.refreshCurrentTab()
|
||||
},
|
||||
|
||||
// 计算底部安全区
|
||||
initSafeArea() {
|
||||
// #ifdef MP-WEIXIN
|
||||
@@ -1062,6 +1068,7 @@
|
||||
.lvl1-tabs {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
padding-top: var(--status-bar-height);
|
||||
background-color: #ffffff;
|
||||
border-bottom-width: 1rpx;
|
||||
border-bottom-style: solid;
|
||||
|
||||
@@ -181,6 +181,7 @@ type ReviewType = {
|
||||
created_at: string
|
||||
}
|
||||
|
||||
import { requireMerchantAuth } from '@/utils/merchantAuth.uts'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -212,7 +213,11 @@ export default {
|
||||
recentReviews: [] as Array<ReviewType>
|
||||
}
|
||||
},
|
||||
onLoad(options: any) {
|
||||
async onLoad(options: any) {
|
||||
const authResult = await requireMerchantAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
if (!authResult.ok) {
|
||||
return
|
||||
}
|
||||
const productId = options.productId as string
|
||||
if (productId) {
|
||||
this.loadProductDetail(productId)
|
||||
|
||||
@@ -308,6 +308,13 @@
|
||||
} else {
|
||||
uni.setNavigationBarTitle({ title: '发布服务' })
|
||||
}
|
||||
|
||||
const authResult = await requireMerchantAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
if (!authResult.ok) {
|
||||
this.merchantId = ''
|
||||
return
|
||||
}
|
||||
this.merchantId = authResult.userInfo != null && authResult.userInfo.id != null ? authResult.userInfo.id : ''
|
||||
this.initMerchantId()
|
||||
|
||||
// ── 先探活,通过后再加载业务数据 ──
|
||||
|
||||
@@ -148,6 +148,7 @@
|
||||
|
||||
<script lang="uts">
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
import { requireMerchantAuth } from '@/utils/merchantAuth.uts'
|
||||
|
||||
type ProductType = {
|
||||
id: string
|
||||
@@ -200,10 +201,26 @@ async onLoad(options: any) {
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.loadProducts()
|
||||
this.handlePageShow()
|
||||
},
|
||||
|
||||
methods: {
|
||||
async ensureMerchantAuth(): Promise<boolean> {
|
||||
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 !== ''
|
||||
},
|
||||
|
||||
async handlePageShow() {
|
||||
const passed = await this.ensureMerchantAuth()
|
||||
if (!passed) return
|
||||
this.loadProducts()
|
||||
},
|
||||
|
||||
async initMerchantId() {
|
||||
try {
|
||||
const session = supa.getSession()
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
<!-- 商家端 - 机构中心 -->
|
||||
<template>
|
||||
<view class="merchant-profile">
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<view class="mp-tab-navbar">
|
||||
<text class="mp-tab-title">机构中心</text>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
<scroll-view direction="vertical" class="profile-scroll">
|
||||
<!-- 店铺信息头部:与 index 同源数据 -->
|
||||
<view class="profile-header">
|
||||
@@ -181,6 +176,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'
|
||||
import { USE_MOCK, MOCK_MERCHANT_ID, MOCK_SHOP_INFO, MOCK_TODAY_STATS, MOCK_PENDING_COUNTS, getMockRecentOrders } from '@/pages/mall/merchant/mock/merchant-mock-data.uts'
|
||||
|
||||
// ---- 复用 index 的类型定义 ----
|
||||
@@ -303,15 +299,27 @@
|
||||
}
|
||||
}
|
||||
} catch(e) {}
|
||||
// 后台完整刷新
|
||||
if (this.merchantId) {
|
||||
this.loadAllData()
|
||||
} else {
|
||||
setTimeout(() => { this.loadAllData() }, 500)
|
||||
}
|
||||
this.handlePageShow()
|
||||
},
|
||||
|
||||
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 !== ''
|
||||
},
|
||||
|
||||
async handlePageShow() {
|
||||
const passed = await this.ensureMerchantAuth()
|
||||
if (!passed) return
|
||||
this.loadAllData()
|
||||
},
|
||||
|
||||
// 底部安全区动态高度,与 orders.uvue 方式一致
|
||||
initSafeArea() {
|
||||
// #ifdef MP-WEIXIN
|
||||
@@ -711,7 +719,7 @@
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
padding: 40rpx 30rpx;
|
||||
padding: calc(40rpx + var(--status-bar-height)) 30rpx 40rpx;
|
||||
background: linear-gradient(135deg, #A6F1E4 0%, #69DFC2 100%);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
|
||||
<script lang="uts">
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
import { requireMerchantAuth } from '@/utils/merchantAuth.uts'
|
||||
import { USE_MOCK, MOCK_MERCHANT_ID, getMockPromotions } from '@/pages/mall/merchant/mock/merchant-mock-data.uts'
|
||||
|
||||
type PromotionType = {
|
||||
@@ -76,12 +77,27 @@
|
||||
},
|
||||
|
||||
onShow() {
|
||||
if (this.merchantId !== '') {
|
||||
this.loadPromotions()
|
||||
}
|
||||
this.handlePageShow()
|
||||
},
|
||||
|
||||
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 !== ''
|
||||
},
|
||||
|
||||
async handlePageShow() {
|
||||
const passed = await this.ensureMerchantAuth()
|
||||
if (!passed) return
|
||||
this.loadPromotions()
|
||||
},
|
||||
|
||||
async initMerchantId() {
|
||||
if (USE_MOCK) {
|
||||
this.merchantId = MOCK_MERCHANT_ID
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
|
||||
<script lang="uts">
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
import { requireMerchantAuth } from '@/utils/merchantAuth.uts'
|
||||
import { USE_MOCK, MOCK_MERCHANT_ID, getMockReviews } from '@/pages/mall/merchant/mock/merchant-mock-data.uts'
|
||||
|
||||
type ReviewType = {
|
||||
@@ -106,19 +107,35 @@
|
||||
this.loadReviews()
|
||||
return
|
||||
}
|
||||
// 同步设置 merchantId,不用 async 包裹,避免 generator 内 this 绑定异常
|
||||
try {
|
||||
const session = supa.getSession()
|
||||
this.merchantId = session?.user?.getString('id') || uni.getStorageSync('user_id') || ''
|
||||
} catch (e) {}
|
||||
this.loadReviews()
|
||||
this.ensureMerchantAuth().then((passed: boolean) => {
|
||||
if (passed) {
|
||||
this.loadReviews()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.loadReviews()
|
||||
this.handlePageShow()
|
||||
},
|
||||
|
||||
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 !== ''
|
||||
},
|
||||
|
||||
async handlePageShow() {
|
||||
const passed = await this.ensureMerchantAuth()
|
||||
if (!passed) return
|
||||
this.loadReviews()
|
||||
},
|
||||
|
||||
async loadReviews() {
|
||||
if (!this.merchantId || this.merchantId.split('-').length !== 5) return
|
||||
if (this.loading) return
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
|
||||
<script lang="uts">
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
import { requireMerchantAuth } from '@/utils/merchantAuth.uts'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -83,19 +84,20 @@
|
||||
},
|
||||
|
||||
methods: {
|
||||
async initMerchantId() {
|
||||
try {
|
||||
const session = supa.getSession()
|
||||
if (session != null && session.user != null) {
|
||||
this.merchantId = session.user.getString('id') || ''
|
||||
}
|
||||
if (!this.merchantId) {
|
||||
this.merchantId = uni.getStorageSync('user_id') || ''
|
||||
}
|
||||
this.loadShop()
|
||||
} catch (e) {
|
||||
console.error('获取商户ID失败:', e)
|
||||
async ensureMerchantAuth(): Promise<boolean> {
|
||||
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 !== ''
|
||||
},
|
||||
|
||||
async initMerchantId() {
|
||||
const passed = await this.ensureMerchantAuth()
|
||||
if (!passed) return
|
||||
this.loadShop()
|
||||
},
|
||||
|
||||
async loadShop() {
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
|
||||
<script lang="uts">
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
import { requireMerchantAuth } from '@/utils/merchantAuth.uts'
|
||||
import { USE_MOCK, MOCK_MERCHANT_ID, getMockStats, getMockTrendData, MOCK_HOT_PRODUCTS } from '@/pages/mall/merchant/mock/merchant-mock-data.uts'
|
||||
|
||||
type ProductType = {
|
||||
@@ -102,7 +103,7 @@
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.loadStatistics()
|
||||
this.handlePageShow()
|
||||
},
|
||||
|
||||
computed: {
|
||||
@@ -116,6 +117,23 @@
|
||||
},
|
||||
|
||||
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 !== ''
|
||||
},
|
||||
|
||||
async handlePageShow() {
|
||||
const passed = await this.ensureMerchantAuth()
|
||||
if (!passed) return
|
||||
this.loadStatistics()
|
||||
},
|
||||
|
||||
async initMerchantId() {
|
||||
if (USE_MOCK) {
|
||||
this.merchantId = MOCK_MERCHANT_ID
|
||||
|
||||
Reference in New Issue
Block a user