初步完成merchant和admin不同role的展示内容逻辑2

This commit is contained in:
2026-03-12 16:07:38 +08:00
parent f19dd093bf
commit a81509e1fc
11 changed files with 124 additions and 39 deletions

View File

@@ -1,4 +1,4 @@
<template>
<template>
<view class="product-edit-page">
<view class="page-header">
<view class="back-link" @click="goBack">
@@ -186,7 +186,7 @@ const categoryName = ref('')
onMounted(async () => {
await ensureSupabaseReady()
const mId = uni.getStorageSync('merchant_id') as string | null
const mId = supa.getSession().user?.id as string | null
if (!mId) {
uni.showToast({ title: '商家未获取到信息,请重新登录', icon: 'none' })
return
@@ -346,7 +346,7 @@ async function doSaveProduct(targetStatus: number) {
// 必须获取正确的 merchant_id并且存在
if (!formData.value.merchant_id || formData.value.merchant_id.startsWith('merchant_123')) {
const mId = uni.getStorageSync('merchant_id') as string | null
const mId = supa.getSession().user?.id as string | null
if (!mId) {
uni.showToast({ title: '未获取到商家信息,请重新登录', icon: 'none' })
return

View File

@@ -1,4 +1,4 @@
<template>
<template>
<view class="product-list-page">
<!-- 1. 搜索表单 -->
<view class="search-card">
@@ -197,7 +197,7 @@ async function fetchProducts() {
await ensureSupabaseReady()
// 从本地缓存获取 current merchant_id
const currentMerchantId = uni.getStorageSync('merchant_id') as string | null
const currentMerchantId = supa.getSession().user?.id as string | null
if (!currentMerchantId) {
uni.showToast({ title: '未获取到商家信息,请重新登录', icon: 'none' })

View File

@@ -398,10 +398,10 @@ const handleLogin = async () => {
const currRole = accessData.getString('role')
const currId = accessData.getString('id')
uni.setStorageSync('adminRole', currRole)
// uni.setStorageSync('adminRole', currRole) // 移除本地缓存依赖,强制按单例会话状态
if (currRole === 'merchant') {
uni.setStorageSync('merchant_id', currId)
// uni.setStorageSync('merchant_id', currId) // 移除本地缓存依赖,强制按单例会话状态
} else {
uni.removeStorageSync('merchant_id')
}