统一排行榜对齐星雀UI,页面资源后台配置实时刷新

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-06-27 01:26:11 +08:00
parent 1ab2e2080a
commit 21112173f2
292 changed files with 64010 additions and 81 deletions

View File

@@ -3,6 +3,11 @@ const app = getApp();
import { formatDate } from '../static/lib/utils';
import request from './request.js';
import { getFreshImUser } from './im-user.js';
import { sendGoEasyImage } from './chatImageSend.js';
function isCrossPlatformOrder(isCross) {
return isCross === 1 || isCross === true || String(isCross) === '1';
}
function sendGroupMessage(options) {
const { msgData, onSuccess, onSendStart } = options;
@@ -20,8 +25,7 @@ function sendGroupMessage(options) {
const localMsg = buildLocalMessage(msgData);
if (onSendStart) onSendStart(localMsg);
// 只有 isCross 明确为 0 才走前端 SDK其余一律走后端
if (isCross === 0) {
if (!isCrossPlatformOrder(isCross)) {
sendViaSDK(localMsg, currentUser, groupId, onSuccess, orderId, isCross, groupName, groupAvatar);
return;
}
@@ -32,7 +36,7 @@ function buildLocalMessage(data) {
const { type, text, filePath, orderPayload, currentUser, groupId } = data;
const now = Date.now();
const base = {
messageId: `${type}-${now}`,
messageId: `local-${type}-${now}`,
timestamp: now,
senderId: currentUser.id,
groupId: groupId,
@@ -45,7 +49,7 @@ function buildLocalMessage(data) {
};
if (type === 'text') return { ...base, type: 'text', payload: { text } };
if (type === 'image') return { ...base, type: 'image', payload: { url: filePath } };
if (type === 'image') return { ...base, type: 'image', payload: { url: filePath }, imageUrl: filePath };
if (type === 'order') return { ...base, type: 'order', payload: orderPayload };
return base;
}
@@ -66,6 +70,7 @@ function sendViaSDK(localMsg, currentUser, groupId, onSuccess, orderId, isCross,
dashouAvatar: groupMeta.dashouAvatar,
partnerAvatar: groupMeta.partnerAvatar,
orderDesc: groupMeta.orderDesc,
orderZhuangtai: groupMeta.orderZhuangtai,
};
const to = {
@@ -74,18 +79,35 @@ function sendViaSDK(localMsg, currentUser, groupId, onSuccess, orderId, isCross,
data: toData
};
if (localMsg.type === 'image') {
sendGoEasyImage({
file: localMsg.payload.url,
to,
onSuccess: (res) => {
const serverMsg = res && res.content;
if (serverMsg && onSuccess) {
onSuccess(localMsg.messageId, 'success', serverMsg);
} else if (onSuccess) {
onSuccess(localMsg.messageId, 'success');
}
},
onFailed: () => { if (onSuccess) onSuccess(localMsg.messageId, 'failed'); }
});
return;
}
let message;
if (localMsg.type === 'text') {
message = wx.goEasy.im.createTextMessage({ text: localMsg.payload.text, to });
} else if (localMsg.type === 'image') {
message = wx.goEasy.im.createImageMessage({ file: localMsg.payload.url, to });
} else if (localMsg.type === 'order') {
message = wx.goEasy.im.createCustomMessage({ type: 'order', payload: localMsg.payload, to });
}
wx.goEasy.im.sendMessage({
message,
onSuccess: () => { if (onSuccess) onSuccess(localMsg.messageId, 'success'); },
onSuccess: (res) => {
if (onSuccess) onSuccess(localMsg.messageId, 'success', res && res.content);
},
onFailed: () => { if (onSuccess) onSuccess(localMsg.messageId, 'failed'); }
});
}
@@ -93,18 +115,17 @@ function sendViaSDK(localMsg, currentUser, groupId, onSuccess, orderId, isCross,
function sendViaBackend(localMsg, currentUser, groupId, orderId, onSuccess) {
const apiUrl = '/dingdan/kptxxfs';
// 🔥 实时获取当前身份,不再依赖外部传入的 currentUser.id
const uid = wx.getStorageSync('uid');
const role = app.globalData.currentRole || 'normal';
const prefixMap = { normal: 'Boss', dashou: 'Ds', shangjia: 'Sj', guanshi: 'Gs', zuzhang: 'Zz' };
const identityType = role === 'dashou' ? 'dashou' : (role === 'shangjia' ? 'shangjia' : 'boss');
const prefixMap = { normal: 'Boss', dashou: 'Ds', shangjia: 'Sj', guanshi: 'Gs', zuzhang: 'Zz' };
const prefix = prefixMap[role] || 'Boss';
const senderId = prefix + uid;
const freshUser = getFreshImUser(app, role, uid);
const params = {
orderId: orderId,
groupId: groupId,
identityType: identityType, // 告诉后端当前是什么身份
identityType: identityType,
senderId: senderId,
senderName: freshUser.name || currentUser.name || ('用户' + uid),
senderAvatar: freshUser.avatar || currentUser.avatar || (app.globalData.ossImageUrl + app.globalData.morentouxiang),
@@ -135,7 +156,6 @@ function sendViaBackend(localMsg, currentUser, groupId, orderId, onSuccess) {
return;
}
// 图片消息
if (localMsg.type === 'image') {
const token = wx.getStorageSync('token');
const formData = {
@@ -169,4 +189,4 @@ function sendViaBackend(localMsg, currentUser, groupId, orderId, onSuccess) {
}
}
module.exports = { sendGroupMessage };
module.exports = { sendGroupMessage };