restore: 恢复橙色逍遥梦UI版本(2ea2860)到主分支

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-09 00:17:03 +08:00
parent 267de7c780
commit 566aeaa3b7
228 changed files with 22076 additions and 11864 deletions

114
app.js
View File

@@ -3,6 +3,11 @@ import GoEasy from './static/lib/goeasy-2.13.24.esm.min';
const ChatCore = require('./utils/chat-core');
import { ensurePhoneAuth } from './utils/phone-auth';
import { getPrimaryRole, lockPrimaryRole, migrateLegacyCenterRole, PRIMARY_DEFAULT_PAGES } from './utils/primary-role';
import { setClubId, getConfiguredClubId, buildClubHeaders, getClubId } from './utils/club-context';
import { CLUB_ID, WX_APP_ID } from './config/club-config';
import { applyMiniappAssetsFromConfig, warmupPindaoConfig } from './utils/miniapp-icons.js';
import { refreshDashouMembership } from './utils/dashou-profile.js';
const { getDefaultAvatarUrl, resolveAvatarFromStorage } = require('./utils/avatar.js');
// 三端固定首页
const roleDefaultPage = PRIMARY_DEFAULT_PAGES;
@@ -36,7 +41,8 @@ App({
guanshiqun: '',
guanshiqunid: '',
appId:'wx0e4be86faac4a8d1',
appId: WX_APP_ID,
clubId: CLUB_ID,
shangjiastatus: 0,
dashoustatus: 0,
@@ -49,11 +55,7 @@ App({
yajin: null,
chenghao: '',
jinfen: null,
clumber: [{
huiyuanid: '',
huiyuanming: '',
daoqi: ''
}],
clumber: [],
chengjiaoliang: null,
zaixianZhuangtai: null,
@@ -80,6 +82,8 @@ App({
xshenfen: 1,
goEasyConfig: null,
chatEnabled: false,
groupInfoMap: {},
kefuConfig: {
link: '',
enterpriseId: ''
@@ -151,6 +155,7 @@ App({
pageState: {
currentPage: '',
isInChatPage: false,
isInGroupChat: false,
currentChatId: '',
lastPageUpdate: 0
},
@@ -159,11 +164,23 @@ App({
debugMode: false,
currentUser: null,
currentRole: 'normal',
primaryRole: 'normal'
},
primaryRole: 'normal',
/** 客服浮钮full | minionLaunch 重置为 full */
kefuFloatMode: 'full',
/** 本次启动内隐藏客服浮钮(不持久化,杀进程后恢复) */
kefuFloatSessionHidden: false,
kefuFloatY: null,
/** 从「我的」跳抢单页时高亮指定单 */
_acceptOrderHighlight: '',
},
// 核心启动流程
async onLaunch() {
this.globalData.kefuFloatMode = 'full';
this.globalData.kefuFloatSessionHidden = false;
try { wx.removeStorageSync('kefuFloatPermanentHidden'); } catch (e) {}
setClubId(getConfiguredClubId(), this);
this.globalData.clubId = CLUB_ID;
// ① 隐藏返回首页按钮
wx.hideHomeButton();
wx.onAppRoute((res) => {
@@ -193,6 +210,11 @@ App({
if (!phoneOk) return;
}
// ②c 打手端冷启动:同步会员/押金等到 globalData抢单页依赖 clumber
if (wx.getStorageSync('token') && savedRole === 'dashou') {
refreshDashouMembership(this).catch(() => {});
}
const targetPage = roleDefaultPage[savedRole] || '/pages/index/index';
if (savedRole !== 'normal') {
setTimeout(() => {
@@ -214,13 +236,11 @@ App({
this.emitEvent('staffContextChanged', {});
}
// ⑤ 建立连接
const saved = this.getSavedConnection();
console.log('【启动】缓存身份:', saved ? saved.identityType : '无',
'userId:', saved ? saved.userId : '无');
// ⑤ 建立连接(文赫式:全局监听,不反复 disconnect
setTimeout(() => {
if (this.startImWhenReady) this.startImWhenReady();
else if (this.ensureConnection) this.ensureConnection();
if (this.globalData.chatEnabled && this.ensureConnection) {
this.ensureConnection();
}
}, 300);
// ⑥ 获取远程配置
@@ -228,10 +248,16 @@ App({
.then(latestConfig => {
this.saveConfigToStorage(latestConfig);
this.applyDynamicConfig(latestConfig);
warmupPindaoConfig(this);
try {
const { fetchGonggaoLunbo } = require('./utils/display-config');
fetchGonggaoLunbo(this, 'accept_order').catch(() => {});
} catch (e) {}
this.initGoEasyWithConfig();
this.initCurrentUser();
if (this.startImWhenReady) this.startImWhenReady();
else if (this.connectForCurrentRole) this.connectForCurrentRole();
if (this.globalData.chatEnabled && this.ensureConnection) {
this.ensureConnection();
}
console.log('远程配置更新完成');
})
.catch(err => {
@@ -239,10 +265,25 @@ App({
});
},
/** 从后台切回前台时再次向后端校验 */
/** 从后台切回前台时再次向后端校验,并维持 IM 连接 */
async onShow() {
if (!wx.getStorageSync('token')) return;
await ensurePhoneAuth({ redirect: true });
if (this.globalData.chatEnabled && typeof this.startImWhenReady === 'function') {
this.startImWhenReady();
} else if (this.globalData.chatEnabled && typeof this.ensureConnection === 'function') {
this.globalData.goEasyConnection.autoReconnect = true;
if (typeof this.restoreTabBarBadge === 'function') {
this.restoreTabBarBadge();
}
this.ensureConnection();
if (typeof this.syncConnectionStatus === 'function') {
setTimeout(() => this.syncConnectionStatus(), 800);
}
if (typeof this.loadConversations === 'function') {
setTimeout(() => this.loadConversations(), 300);
}
}
},
// 连接管理方法
@@ -258,11 +299,16 @@ App({
},
// 配置缓存读写
CONFIG_CACHE_KEY: 'app_dynamic_config',
CONFIG_CACHE_KEY_PREFIX: 'app_dynamic_config_',
getConfigCacheKey() {
const cid = getClubId(this) || CLUB_ID;
return this.CONFIG_CACHE_KEY_PREFIX + cid;
},
readConfigFromStorage() {
try {
const data = wx.getStorageSync(this.CONFIG_CACHE_KEY);
const data = wx.getStorageSync(this.getConfigCacheKey());
if (data && typeof data === 'object') {
return data;
}
@@ -273,7 +319,7 @@ App({
saveConfigToStorage(config) {
try {
if (config && typeof config === 'object') {
wx.setStorageSync(this.CONFIG_CACHE_KEY, config);
wx.setStorageSync(this.getConfigCacheKey(), config);
}
} catch (e) {}
},
@@ -284,7 +330,7 @@ App({
wx.request({
url: this.globalData.apiBaseUrl + '/peizhi/qdpzhq',
method: 'POST',
header: { 'content-type': 'application/json' },
header: buildClubHeaders({ 'content-type': 'application/json' }),
success: (res) => {
if (res.statusCode === 200 && res.data && res.data.code === 0 && res.data.data) {
resolve(res.data.data);
@@ -307,7 +353,7 @@ App({
wx.request({
url: this.globalData.apiBaseUrl + '/peizhi/qdpzhq',
method: 'POST',
header: { 'content-type': 'application/json' },
header: buildClubHeaders({ 'content-type': 'application/json' }),
success: (res) => {
if (res.statusCode === 200 && res.data && res.data.code === 0) {
resolve(res.data.data);
@@ -350,6 +396,19 @@ App({
enterpriseId: config.kefu.enterpriseId || ''
};
}
try {
applyMiniappAssetsFromConfig(this, config);
} catch (e) {
console.warn('miniapp assets apply failed', e);
}
if (this.emitEvent) {
this.emitEvent('configApplied', {
ossImageUrl: this.globalData.ossImageUrl,
morentouxiang: this.globalData.morentouxiang,
});
}
},
// 仅在有效 appkey 时初始化
@@ -373,9 +432,10 @@ App({
modules: ['im', 'pubsub']
});
wx.GoEasy = GoEasy;
this.globalData.chatEnabled = true;
console.log('GoEasy 初始化成功');
if (this.startImWhenReady && wx.getStorageSync('uid')) {
setTimeout(() => this.startImWhenReady(), 100);
if (this.ensureConnection && wx.getStorageSync('uid')) {
setTimeout(() => this.ensureConnection(), 100);
}
} catch (error) {
console.error('GoEasy 初始化失败:', error);
@@ -385,10 +445,12 @@ App({
initCurrentUser() {
const uid = wx.getStorageSync('uid');
if (uid) {
const def = getDefaultAvatarUrl(this);
const avatar = resolveAvatarFromStorage(this) || def;
this.globalData.currentUser = {
id: uid,
name: '用户' + uid.substring(0, 6),
avatar: this.globalData.ossImageUrl + this.globalData.morentouxiang
name: wx.getStorageSync('nicheng') || ('用户' + uid.substring(0, 6)),
avatar: avatar || def,
};
}
},