重构项目文件夹目录

This commit is contained in:
2026-06-15 15:53:55 +08:00
parent 8093e07190
commit 7cbe5b3de5
1098 changed files with 34 additions and 4441 deletions
@@ -0,0 +1,251 @@
/**
* Purpose: authApi supports index.js by holding or executing the auth api page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const authApi = require('../../api/auth')
/**
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const navigation = require('../../utils/navigation')
/**
* Purpose: permission supports index.js by holding or executing the permission page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const permission = require('../../utils/permission')
const sessionSwitch = require('../../../utils/session-switch')
Page({
/**
* Purpose: data supports index.js by holding or executing the data page or API role.
* Usage: import, call, read, or update this page-data from the owning page/module while preserving the surrounding loading and permission flow.
*/
data: {
/**
* Purpose: userInfo supports index.js by holding or executing the user info page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
userInfo: null,
/**
* Purpose: currentShop supports index.js by holding or executing the current shop page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
currentShop: null,
/**
* Purpose: permissionCodes supports index.js by holding or executing the permission codes page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
permissionCodes: [],
/**
* Purpose: roleLabel supports index.js by holding or executing the role label page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
roleLabel: '',
/**
* Purpose: shopScopeText supports index.js by holding or executing the shop scope text page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
shopScopeText: '',
/**
* Purpose: currentShopText supports index.js by holding or executing the current shop text page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
currentShopText: ''
},
/**
* Purpose: onShow supports index.js by holding or executing the on show page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
onShow() {
if (!navigation.ensureLogin('进入个人中心')) {
return
}
const app = getApp()
const userInfo = app.globalData.userInfo
const currentShop = app.globalData.currentShop
const shopScopeText = userInfo
? (Array.isArray(userInfo.shopNames) && userInfo.shopNames.length
? userInfo.shopNames.join(' / ')
: (userInfo.shopName || '--'))
: '--'
this.setData({
userInfo,
currentShop,
/**
* Purpose: permissionCodes supports index.js by holding or executing the permission codes page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
permissionCodes: app.globalData.permissionCodes || [],
/**
* Purpose: roleLabel supports index.js by holding or executing the role label page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
roleLabel: userInfo ? permission.getRoleLabel(userInfo.type) : '--',
shopScopeText,
/**
* Purpose: currentShopText supports index.js by holding or executing the current shop text page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
currentShopText: currentShop ? `当前店铺:${currentShop.shopName}` : '当前为平台总览模式'
})
},
/**
* Purpose: handleOpenOrders supports index.js by holding or executing the handle open orders page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
handleOpenOrders() {
navigation.switchTab('/pages/orders/index').catch(() => undefined)
},
/**
* Purpose: handleOpenManage supports index.js by holding or executing the handle open manage page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
handleOpenManage() {
navigation.switchTab('/pages/manage/index').catch(() => undefined)
},
handleOpenWorkbench() {
navigation.switchTab('/pages/workbench/index').catch(() => undefined)
},
handleOpenCustomerHome() {
sessionSwitch.openCustomerHome()
},
async handleSwitchShop() {
const userInfo = this.data.userInfo
if (!userInfo || !userInfo.account) {
return
}
try {
const result = await authApi.getLoginShops(userInfo.account)
const shops = Array.isArray(result && result.shops) ? result.shops : []
const allowShoplessLogin = Boolean(result && result.allowShoplessLogin)
if (allowShoplessLogin && permission.isPlatformAdmin(userInfo)) {
wx.showToast({
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: '平台管理员固定为总览模式',
/**
* Purpose: icon supports index.js by holding or executing the icon page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
icon: 'none'
})
return
}
const items = shops.map(shop => ({
/**
* Purpose: label supports index.js by holding or executing the label page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
label: shop.shopName,
/**
* Purpose: value supports index.js by holding or executing the value page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
value: shop.id
}))
if (!items.length) {
wx.showToast({
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: '当前账号没有可切换的店铺',
/**
* Purpose: icon supports index.js by holding or executing the icon page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
icon: 'none'
})
return
}
wx.showActionSheet({
/**
* Purpose: itemList supports index.js by holding or executing the item list page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
itemList: items.map(item => item.label),
/**
* Purpose: success supports index.js by holding or executing the success page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
success: async action => {
const target = items[action.tapIndex]
if (!target) {
return
}
try {
await getApp().switchAdminShop(target.value || undefined)
wx.showToast({
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: '店铺已切换',
/**
* Purpose: icon supports index.js by holding or executing the icon page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
icon: 'none'
})
this.onShow()
} catch (error) {
wx.showToast({
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: error.message || '切换店铺失败',
/**
* Purpose: icon supports index.js by holding or executing the icon page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
icon: 'none'
})
}
}
})
} catch (error) {
wx.showToast({
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: error.message || '店铺列表加载失败',
/**
* Purpose: icon supports index.js by holding or executing the icon page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
icon: 'none'
})
}
},
async handleLogout() {
try {
await authApi.logout().catch(() => undefined)
} finally {
getApp().clearAdminSession()
wx.reLaunch({
/**
* Purpose: url supports index.js by holding or executing the url page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
url: '/admin/pages/login/index'
})
}
}
})
@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/admin/components/navigation-bar/navigation-bar"
}
}
@@ -0,0 +1,61 @@
<navigation-bar title="我的" back="{{false}}" color="#f6efe7" background="#081518"></navigation-bar>
<view class="page-shell">
<view class="page-stack">
<view class="hero-panel">
<text class="hero-kicker">{{userInfo.account || '后台账号'}}</text>
<text class="hero-title">{{userInfo.nickname || '未设置昵称'}}</text>
<text class="hero-desc">当前角色:{{roleLabel}}。{{currentShopText}}</text>
</view>
<view class="surface-card">
<text class="section-title">账号信息</text>
<view class="meta-grid">
<view class="meta-item">
<text class="meta-label">账号</text>
<text class="meta-value">{{userInfo.account || '--'}}</text>
</view>
<view class="meta-item">
<text class="meta-label">权限数</text>
<text class="meta-value">{{permissionCodes.length}}</text>
</view>
<view class="meta-item">
<text class="meta-label">店铺状态</text>
<text class="meta-value">{{currentShop ? currentShop.shopName : '平台总览模式'}}</text>
</view>
<view class="meta-item">
<text class="meta-label">可登录店铺</text>
<text class="meta-value">{{shopScopeText}}</text>
</view>
</view>
<view wx:if="{{currentShop}}" class="action-row">
<button class="secondary-btn" bindtap="handleSwitchShop">切换店铺</button>
</view>
</view>
<view class="surface-card">
<text class="section-title">常用入口</text>
<view class="list-actions">
<view class="mini-btn primary" bindtap="handleOpenOrders">查看订单</view>
<view class="mini-btn" bindtap="handleOpenManage">经营模块</view>
</view>
</view>
<view class="surface-card">
<text class="section-title">退出登录</text>
<text class="section-desc">退出后会清理管理端会话、当前店铺和权限快照;再次进入需要重新登录。</text>
<view class="action-row">
<button class="danger-btn" bindtap="handleLogout">退出当前账号</button>
</view>
</view>
<view class="admin-bottom-nav">
<view class="admin-bottom-link" bindtap="handleOpenWorkbench">工作台</view>
<view class="admin-bottom-link" bindtap="handleOpenOrders">订单</view>
<view class="admin-bottom-link" bindtap="handleOpenManage">经营</view>
<view class="admin-bottom-link active">我的</view>
</view>
<view class="customer-switch-link" bindtap="handleOpenCustomerHome">返回前台</view>
</view>
</view>
@@ -0,0 +1,14 @@
@import "../../app.wxss";
.page-shell {
background: transparent;
}
.customer-switch-link {
display: flex;
align-items: center;
justify-content: center;
min-height: 72rpx;
color: #f7dba7;
font-size: 26rpx;
font-weight: 700;
}