backup: 紫色UI换肤前完整备份(当前橙色逍遥梦主题)
保留改造前全部页面样式与功能代码,便于回滚。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
|
||||
import { createPage, ensureRoleOnCenterPage, lockPrimaryRole, parseSceneOptions, request } from '../../utils/base-page.js';
|
||||
import { ensureLogin } from '../../utils/login.js';
|
||||
import {
|
||||
STAFF_API, isStaffMode, isMerchantPortalUser, refreshStaffContext, syncStaffUi, getStaffContext,
|
||||
restoreStaffContextAfterAuth, applyStaffStatsToPage, guardMerchantOwnerAction, clearStaffSession,
|
||||
} from '../../utils/staff-api.js';
|
||||
import { clearCacheAndEnterNormal } from '../../utils/base-page.js';
|
||||
|
||||
const app = getApp();
|
||||
|
||||
@@ -32,7 +37,15 @@ Page(createPage({
|
||||
|
||||
// 商家状态
|
||||
isShangjia: false,
|
||||
isStaffMode: false,
|
||||
staffRoleName: '',
|
||||
quotaAvailable: '0.00',
|
||||
canDispatch: true,
|
||||
canStaffManage: true,
|
||||
canAudit: true,
|
||||
showRechargeWithdraw: true,
|
||||
isAutoRegistering: false,
|
||||
staffBooting: false,
|
||||
|
||||
// 用户基础信息
|
||||
uid: '',
|
||||
@@ -57,7 +70,7 @@ Page(createPage({
|
||||
navBar: 44,
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
async onLoad(options) {
|
||||
const sys = wx.getSystemInfoSync();
|
||||
this.setData({
|
||||
statusBar: sys.statusBarHeight || 20,
|
||||
@@ -65,6 +78,9 @@ Page(createPage({
|
||||
});
|
||||
const parsed = parseSceneOptions(options);
|
||||
this.setupImageUrls();
|
||||
if (wx.getStorageSync('token')) {
|
||||
await restoreStaffContextAfterAuth();
|
||||
}
|
||||
this.checkRoleStatus();
|
||||
|
||||
const inviteCode = parsed.inviteCode;
|
||||
@@ -97,13 +113,33 @@ Page(createPage({
|
||||
this.checkColdStartPopup('shangjiaduan');
|
||||
},
|
||||
|
||||
onShow() {
|
||||
async onShow() {
|
||||
this.registerNotificationComponent();
|
||||
if (this.data.isShangjia) {
|
||||
ensureRoleOnCenterPage(this, 'shangjia');
|
||||
this.refreshShangjiaInfo();
|
||||
this.loadPendingCount();
|
||||
this.loadPunishPending();
|
||||
try {
|
||||
const token = wx.getStorageSync('token');
|
||||
const isOwner = Number(wx.getStorageSync('shangjiastatus')) === 1;
|
||||
if (token && !isOwner) {
|
||||
await restoreStaffContextAfterAuth();
|
||||
} else if (isStaffMode()) {
|
||||
await refreshStaffContext(request);
|
||||
}
|
||||
this.checkRoleStatus();
|
||||
syncStaffUi(this);
|
||||
if (this.data.isShangjia) {
|
||||
ensureRoleOnCenterPage(this, 'shangjia');
|
||||
if (isStaffMode()) {
|
||||
await this.loadStaffProfile();
|
||||
} else {
|
||||
this.refreshShangjiaInfo();
|
||||
}
|
||||
this.loadPendingCount();
|
||||
if (!isStaffMode()) {
|
||||
this.loadPunishPending();
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('商家个人中心 onShow', err);
|
||||
this.setData({ isLoading: false, staffBooting: false });
|
||||
}
|
||||
},
|
||||
|
||||
@@ -137,27 +173,102 @@ Page(createPage({
|
||||
});
|
||||
},
|
||||
|
||||
// 商家状态检查(覆盖基类 checkRoleStatus,增加 getShangjiaInfo 调用)
|
||||
// 商家状态检查(子客服与老板均可进入;子客服绝不走商家注册接口)
|
||||
checkRoleStatus() {
|
||||
try {
|
||||
const shangjiastatus = wx.getStorageSync('shangjiastatus');
|
||||
const uid = wx.getStorageSync('uid');
|
||||
if (shangjiastatus) {
|
||||
this.setData({ isShangjia: true, uid: uid || '' });
|
||||
this.loadAvatar();
|
||||
this.getShangjiaInfo();
|
||||
const portal = isMerchantPortalUser();
|
||||
const staffFlag = Number(wx.getStorageSync('staffstatus')) === 1;
|
||||
|
||||
if (portal) {
|
||||
this.setData({ isShangjia: true, uid: uid || '', staffBooting: false, isLoading: false });
|
||||
syncStaffUi(this);
|
||||
if (isStaffMode()) {
|
||||
this.loadStaffProfile();
|
||||
} else if (Number(wx.getStorageSync('shangjiastatus')) === 1) {
|
||||
this.loadAvatar();
|
||||
this.getShangjiaInfo();
|
||||
} else if (staffFlag) {
|
||||
this.bootStaffPortal(uid);
|
||||
}
|
||||
ensureRoleOnCenterPage(this, 'shangjia');
|
||||
} else {
|
||||
this.setData({ isShangjia: false });
|
||||
return;
|
||||
}
|
||||
|
||||
if (staffFlag) {
|
||||
this.bootStaffPortal(uid);
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({ isShangjia: false, staffBooting: false, isLoading: false });
|
||||
syncStaffUi(this);
|
||||
} catch (error) {
|
||||
console.error('读取商家状态失败', error);
|
||||
this.setData({ isShangjia: false });
|
||||
this.setData({ isShangjia: false, staffBooting: false, isLoading: false });
|
||||
syncStaffUi(this);
|
||||
}
|
||||
},
|
||||
|
||||
// 获取商家信息
|
||||
/** 已绑定客服、尚未拉到 context 时恢复身份(不展示商家邀请码) */
|
||||
async bootStaffPortal(uid) {
|
||||
this.setData({ staffBooting: true, isLoading: true, uid: uid || '' });
|
||||
syncStaffUi(this);
|
||||
await restoreStaffContextAfterAuth();
|
||||
if (isMerchantPortalUser()) {
|
||||
this.setData({ isShangjia: true, staffBooting: false, isLoading: false });
|
||||
syncStaffUi(this);
|
||||
if (isStaffMode()) {
|
||||
await this.loadStaffProfile();
|
||||
}
|
||||
ensureRoleOnCenterPage(this, 'shangjia');
|
||||
return;
|
||||
}
|
||||
this.setData({ staffBooting: false, isLoading: false, isShangjia: false });
|
||||
syncStaffUi(this);
|
||||
wx.showToast({ title: '客服身份已失效,请联系商家老板', icon: 'none' });
|
||||
},
|
||||
|
||||
onInviteCodeInput(e) {
|
||||
this.setData({ inviteCode: (e.detail.value || '').trim() });
|
||||
},
|
||||
|
||||
goToStaffJoin() {
|
||||
wx.navigateTo({ url: '/pages/staff-join/staff-join' });
|
||||
},
|
||||
|
||||
clearCache() {
|
||||
wx.showModal({
|
||||
title: '清除缓存',
|
||||
content: '将清除所有登录与身份数据,并回到点单端,确定继续?',
|
||||
confirmText: '确定',
|
||||
cancelText: '取消',
|
||||
success: (r) => {
|
||||
if (!r.confirm) return;
|
||||
clearStaffSession();
|
||||
clearCacheAndEnterNormal(this);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
async loadStaffProfile() {
|
||||
const ctx = await refreshStaffContext(request);
|
||||
const profile = wx.getStorageSync('nicheng') || (ctx && ctx.display_name) || '商家客服';
|
||||
this.loadAvatar();
|
||||
this.setData({
|
||||
nicheng: (ctx && ctx.display_name) || profile,
|
||||
sjyue: (ctx && ctx.wallet && ctx.wallet.quota_available) || '0.00',
|
||||
chenghaoList: [],
|
||||
isLoading: false,
|
||||
});
|
||||
syncStaffUi(this);
|
||||
applyStaffStatsToPage(this, ctx);
|
||||
},
|
||||
|
||||
// 获取商家信息(仅商家老板;子客服禁止调用)
|
||||
async getShangjiaInfo() {
|
||||
if (isStaffMode() || Number(wx.getStorageSync('staffstatus')) === 1) {
|
||||
return this.loadStaffProfile();
|
||||
}
|
||||
await this.loadData({
|
||||
url: '/yonghu/shangjiaxinxi',
|
||||
method: 'POST',
|
||||
@@ -192,13 +303,17 @@ Page(createPage({
|
||||
},
|
||||
|
||||
refreshShangjiaInfo() {
|
||||
if (isStaffMode()) {
|
||||
this.throttledRefresh(() => this.loadStaffProfile());
|
||||
return;
|
||||
}
|
||||
this.throttledRefresh(() => this.getShangjiaInfo());
|
||||
},
|
||||
|
||||
async loadPendingCount() {
|
||||
try {
|
||||
const res = await request({
|
||||
url: '/dingdan/sjdingdanhq',
|
||||
url: isStaffMode() ? STAFF_API.orderList : '/dingdan/sjdingdanhq',
|
||||
method: 'POST',
|
||||
data: { zhuangtai_list: [8], page: 1, page_size: 1 },
|
||||
});
|
||||
@@ -273,8 +388,16 @@ Page(createPage({
|
||||
goToHome() { wx.redirectTo({ url: '/pages/merchant-home/merchant-home' }); },
|
||||
goToKefuKey() { wx.navigateTo({ url: '/pages/merchant-kefu-key/merchant-kefu-key' }); },
|
||||
goToKefuList() { wx.navigateTo({ url: '/pages/merchant-kefu-list/merchant-kefu-list' }); },
|
||||
goToRecharge() { wx.navigateTo({ url: '/pages/merchant-recharge/merchant-recharge' }); },
|
||||
goToWithdraw() { wx.navigateTo({ url: '/pages/withdraw/withdraw' }); },
|
||||
goToAuditLog() { wx.navigateTo({ url: '/pages/merchant-staff-audit/merchant-staff-audit' }); },
|
||||
goToStaffRank() { wx.navigateTo({ url: '/pages/merchant-staff-audit/merchant-staff-audit?tab=rank' }); },
|
||||
goToRecharge() {
|
||||
if (!guardMerchantOwnerAction('子客服无法充值,请联系商家老板')) return;
|
||||
wx.navigateTo({ url: '/pages/merchant-recharge/merchant-recharge' });
|
||||
},
|
||||
goToWithdraw() {
|
||||
if (!guardMerchantOwnerAction('子客服无法提现,请联系商家老板')) return;
|
||||
wx.navigateTo({ url: '/pages/withdraw/withdraw' });
|
||||
},
|
||||
goToRanking() { wx.navigateTo({ url: '/pages/fighter-rank/fighter-rank?type=shangjia' }); },
|
||||
goToMessages() { wx.navigateTo({ url: '/pages/merchant-msg/merchant-msg' }); },
|
||||
}, {
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
<!-- 商家端个人中心 - 逍遥梦布局,逻辑/接口不变 -->
|
||||
<block wx:if="{{!isShangjia}}">
|
||||
<block wx:if="{{staffBooting}}">
|
||||
<view class="sj-page user-page">
|
||||
<view class="sj-page-header">
|
||||
<view class="status-bar" style="height:{{statusBar}}px"></view>
|
||||
<view class="nav-bar flexm" style="height:{{navBar - statusBar}}px"><text class="sj-nav-title">我的</text></view>
|
||||
</view>
|
||||
<view class="unreg-area sj-mx20">
|
||||
<view class="sj-panel unreg-card">
|
||||
<text class="unreg-title">客服身份加载中</text>
|
||||
<text class="unreg-desc">请稍候,正在同步您的派单员权限…</text>
|
||||
</view>
|
||||
</view>
|
||||
<tab-bar/>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:elif="{{!isShangjia && !isStaffMode}}">
|
||||
<view class="sj-page user-page">
|
||||
<view class="sj-page-header">
|
||||
<view class="status-bar" style="height:{{statusBar}}px"></view>
|
||||
@@ -8,8 +24,10 @@
|
||||
<view class="unreg-area sj-mx20">
|
||||
<view class="sj-panel unreg-card">
|
||||
<text class="unreg-title">商家入驻</text>
|
||||
<input class="unreg-input" placeholder="请输入邀请码" maxlength="100" value="{{inviteCode}}" bindinput="onInviteCodeInput"/>
|
||||
<view class="sj-btn-bg unreg-btn flexm" bindtap="onRegister">立即注册</view>
|
||||
<text class="unreg-desc">商家老板请填写商家邀请码;若您是客服/派单员,请走下方入口</text>
|
||||
<input class="unreg-input" placeholder="商家邀请码(老板专用)" maxlength="100" value="{{inviteCode}}" bindinput="onInviteCodeInput"/>
|
||||
<view class="sj-btn-bg unreg-btn flexm" bindtap="onRegister">商家注册</view>
|
||||
<view class="unreg-link staff-link" bindtap="goToStaffJoin">我是客服 / 派单员,绑定客服秘钥</view>
|
||||
<view class="unreg-link" bindtap="switchToNormal">返回点单端</view>
|
||||
<view class="unreg-link" bindtap="clearCache">清除缓存,重新登录</view>
|
||||
</view>
|
||||
@@ -36,7 +54,7 @@
|
||||
<view>
|
||||
<view class="nickname-row flex">
|
||||
<text class="nickname">{{nicheng || '商家'}}</text>
|
||||
<view class="sj-identity-tag">商家</view>
|
||||
<view class="sj-identity-tag">{{isStaffMode ? (staffRoleName || '商家客服') : '商家'}}</view>
|
||||
</view>
|
||||
<view class="sn-row flex" bindtap="copyUid">
|
||||
<text class="sn">ID: {{uid || '--'}}</text>
|
||||
@@ -56,11 +74,12 @@
|
||||
|
||||
<view class="sj-wallet-card flexb">
|
||||
<view>
|
||||
<view class="sj-w-label">商家余额(元)</view>
|
||||
<view class="sj-w-label">{{isStaffMode ? '可用派单额度(元)' : '商家余额(元)'}}</view>
|
||||
<view class="sj-w-num">¥{{sjyue}}</view>
|
||||
<view class="sj-w-sub">发单总量 {{fabu}} · 退款 {{tuikuan}}</view>
|
||||
<view class="sj-w-sub" wx:if="{{!isStaffMode}}">发单总量 {{fabu}} · 退款 {{tuikuan}}</view>
|
||||
<view class="sj-w-sub" wx:else>角色:{{staffRoleName}}</view>
|
||||
</view>
|
||||
<view class="wallet-btns flex">
|
||||
<view class="wallet-btns flex" wx:if="{{showRechargeWithdraw}}">
|
||||
<view class="sj-btn-outline" catchtap="goToRecharge">充值</view>
|
||||
<view class="sj-btn-outline" catchtap="goToWithdraw">去提现</view>
|
||||
</view>
|
||||
@@ -106,27 +125,35 @@
|
||||
<view class="sj-panel sj-mx20">
|
||||
<view class="sj-section-hd">交易与发单</view>
|
||||
<view class="sj-func-grid">
|
||||
<view class="sj-func-item" bindtap="goToPaiDan">
|
||||
<view class="sj-func-item" bindtap="goToPaiDan" wx:if="{{canDispatch}}">
|
||||
<image class="sj-func-icon" src="{{imgUrls.iconRelease}}" mode="aspectFit"/>
|
||||
<text class="sj-func-txt">自定义单</text>
|
||||
</view>
|
||||
<view class="sj-func-item" bindtap="goToJiSuPaiDan">
|
||||
<view class="sj-func-item" bindtap="goToJiSuPaiDan" wx:if="{{canDispatch}}">
|
||||
<image class="sj-func-icon" src="{{imgUrls.iconFast}}" mode="aspectFit"/>
|
||||
<text class="sj-func-txt">常规单</text>
|
||||
</view>
|
||||
<view class="sj-func-item" bindtap="goToKefuKey">
|
||||
<view class="sj-func-item" bindtap="goToKefuKey" wx:if="{{canStaffManage}}">
|
||||
<image class="sj-func-icon" src="{{imgUrls.iconService}}" mode="aspectFit"/>
|
||||
<text class="sj-func-txt">客服邀请码</text>
|
||||
</view>
|
||||
<view class="sj-func-item" bindtap="goToKefuList">
|
||||
<view class="sj-func-item" bindtap="goToKefuList" wx:if="{{canStaffManage}}">
|
||||
<image class="sj-func-icon" src="{{imgUrls.iconService}}" mode="aspectFit"/>
|
||||
<text class="sj-func-txt">客服列表</text>
|
||||
</view>
|
||||
<view class="sj-func-item" bindtap="goToMessages">
|
||||
<view class="sj-func-item" bindtap="goToAuditLog" wx:if="{{canAudit}}">
|
||||
<image class="sj-func-icon" src="{{imgUrls.iconOrders}}" mode="aspectFit"/>
|
||||
<text class="sj-func-txt">操作日志</text>
|
||||
</view>
|
||||
<view class="sj-func-item" bindtap="goToStaffRank" wx:if="{{canAudit}}">
|
||||
<image class="sj-func-icon" src="{{imgUrls.iconRank}}" mode="aspectFit"/>
|
||||
<text class="sj-func-txt">客服排行</text>
|
||||
</view>
|
||||
<view class="sj-func-item" bindtap="goToMessages" wx:if="{{!isStaffMode}}">
|
||||
<image class="sj-func-icon" src="{{imgUrls.iconPunish}}" mode="aspectFit"/>
|
||||
<text class="sj-func-txt">处罚记录</text>
|
||||
</view>
|
||||
<view class="sj-func-item" bindtap="goToRanking">
|
||||
<view class="sj-func-item" bindtap="goToRanking" wx:if="{{!isStaffMode}}">
|
||||
<image class="sj-func-icon" src="{{imgUrls.iconRank}}" mode="aspectFit"/>
|
||||
<text class="sj-func-txt">商家排行</text>
|
||||
</view>
|
||||
|
||||
@@ -149,6 +149,20 @@ page {
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.unreg-desc {
|
||||
display: block;
|
||||
font-size: 24rpx;
|
||||
color: #888;
|
||||
text-align: center;
|
||||
line-height: 1.5;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.unreg-link.staff-link {
|
||||
color: #1976d2;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.unreg-input {
|
||||
height: 80rpx;
|
||||
border-radius: 12rpx;
|
||||
|
||||
Reference in New Issue
Block a user