feat: 分端显示
This commit is contained in:
@@ -2,6 +2,43 @@ import { defineStore } from 'pinia'
|
||||
import type { User } from '@/typings/mall'
|
||||
import { mockMember } from '@/mock/member'
|
||||
|
||||
/**
|
||||
* 客户端类型枚举
|
||||
* - user: 用户端(消费者)
|
||||
* - merchant: 商家端
|
||||
* - bank: 银行端
|
||||
*/
|
||||
export enum ClientType {
|
||||
USER = 'user',
|
||||
MERCHANT = 'merchant',
|
||||
BANK = 'bank',
|
||||
}
|
||||
|
||||
/** 客户端类型配置 */
|
||||
export const CLIENT_TYPE_CONFIG = {
|
||||
[ClientType.USER]: {
|
||||
label: '用户端',
|
||||
icon: 'i-carbon-user',
|
||||
color: '#4d80f0',
|
||||
description: '购物消费、查看订单',
|
||||
homePage: '/pages/index/index',
|
||||
},
|
||||
[ClientType.MERCHANT]: {
|
||||
label: '商家端',
|
||||
icon: 'i-carbon-store',
|
||||
color: '#ff8f0d',
|
||||
description: '商品管理、订单处理',
|
||||
homePage: '/pagesMerchant/dashboard/index',
|
||||
},
|
||||
[ClientType.BANK]: {
|
||||
label: '银行端',
|
||||
icon: 'i-carbon-bank',
|
||||
color: '#00c05a',
|
||||
description: '账款审核、金融服务',
|
||||
homePage: '/pagesBank/dashboard/index',
|
||||
},
|
||||
}
|
||||
|
||||
export const useUserStore = defineStore('user', {
|
||||
state: () => ({
|
||||
userInfo: {
|
||||
@@ -10,23 +47,48 @@ export const useUserStore = defineStore('user', {
|
||||
nickname: '王明阳',
|
||||
avatar: '/static/images/avatar.jpg',
|
||||
phone: '13800138000',
|
||||
creditLimits: [], // 实际应从 financeStore 获取或关联
|
||||
creditLimits: [],
|
||||
member: mockMember,
|
||||
} as User | null,
|
||||
isLogin: true, // 默认已登录
|
||||
isLogin: true,
|
||||
clientType: ClientType.USER as ClientType,
|
||||
}),
|
||||
|
||||
getters: {
|
||||
// 获取当前客户端类型配置
|
||||
currentClientConfig(state) {
|
||||
return CLIENT_TYPE_CONFIG[state.clientType]
|
||||
},
|
||||
// 是否为用户端
|
||||
isUserClient(state) {
|
||||
return state.clientType === ClientType.USER
|
||||
},
|
||||
// 是否为商家端
|
||||
isMerchantClient(state) {
|
||||
return state.clientType === ClientType.MERCHANT
|
||||
},
|
||||
// 是否为银行端
|
||||
isBankClient(state) {
|
||||
return state.clientType === ClientType.BANK
|
||||
},
|
||||
},
|
||||
|
||||
actions: {
|
||||
// 登录(模拟)
|
||||
// 设置客户端类型
|
||||
setClientType(type: ClientType) {
|
||||
this.clientType = type
|
||||
},
|
||||
|
||||
// 登录
|
||||
login(data: any) {
|
||||
this.isLogin = true
|
||||
// ...
|
||||
},
|
||||
|
||||
// 退出登录
|
||||
logout() {
|
||||
this.isLogin = false
|
||||
this.userInfo = null
|
||||
this.clientType = ClientType.USER
|
||||
},
|
||||
},
|
||||
|
||||
@@ -38,3 +100,4 @@ export const useUserStore = defineStore('user', {
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user