同步聊天修复到根目录pages/utils(与副本工程结构一致)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,9 +2,19 @@
|
||||
const app = getApp();
|
||||
import { formatDate } from '../static/lib/utils';
|
||||
import request from './request.js';
|
||||
import { getFreshImUser } from './im-user.js';
|
||||
|
||||
function sendGroupMessage(options) {
|
||||
const { msgData, onSuccess, onSendStart } = options;
|
||||
const role = app.globalData.currentRole || 'normal';
|
||||
const uid = wx.getStorageSync('uid');
|
||||
const freshUser = getFreshImUser(app, role, uid);
|
||||
msgData.currentUser = {
|
||||
...msgData.currentUser,
|
||||
name: freshUser.name,
|
||||
avatar: freshUser.avatar,
|
||||
};
|
||||
|
||||
const { type, currentUser, groupId, orderId, isCross, groupName, groupAvatar } = msgData;
|
||||
|
||||
const localMsg = buildLocalMessage(msgData);
|
||||
@@ -41,12 +51,22 @@ function buildLocalMessage(data) {
|
||||
}
|
||||
|
||||
function sendViaSDK(localMsg, currentUser, groupId, onSuccess, orderId, isCross, groupName, groupAvatar) {
|
||||
const groupMeta = (app.globalData.groupInfoMap && app.globalData.groupInfoMap[groupId]) || {};
|
||||
const toData = {
|
||||
name: groupName || '订单群聊',
|
||||
avatar: groupAvatar || currentUser.avatar
|
||||
name: groupName || groupMeta.name || '订单群聊',
|
||||
avatar: groupAvatar || groupMeta.avatar || currentUser.avatar,
|
||||
orderId: orderId || groupMeta.orderId,
|
||||
isCross: isCross || 0,
|
||||
dashouGoEasyId: groupMeta.dashouGoEasyId,
|
||||
partnerGoEasyId: groupMeta.partnerGoEasyId,
|
||||
dashouYonghuid: groupMeta.dashouYonghuid,
|
||||
partnerYonghuid: groupMeta.partnerYonghuid,
|
||||
dashouName: groupMeta.dashouName,
|
||||
partnerName: groupMeta.partnerName,
|
||||
dashouAvatar: groupMeta.dashouAvatar,
|
||||
partnerAvatar: groupMeta.partnerAvatar,
|
||||
orderDesc: groupMeta.orderDesc,
|
||||
};
|
||||
if (orderId) toData.orderId = orderId;
|
||||
toData.isCross = isCross || 0;
|
||||
|
||||
const to = {
|
||||
type: wx.GoEasy.IM_SCENE.GROUP,
|
||||
@@ -80,14 +100,14 @@ function sendViaBackend(localMsg, currentUser, groupId, orderId, onSuccess) {
|
||||
const identityType = role === 'dashou' ? 'dashou' : (role === 'shangjia' ? 'shangjia' : 'boss');
|
||||
const prefix = prefixMap[role] || 'Boss';
|
||||
const senderId = prefix + uid;
|
||||
|
||||
const freshUser = getFreshImUser(app, role, uid);
|
||||
const params = {
|
||||
orderId: orderId,
|
||||
groupId: groupId,
|
||||
identityType: identityType, // 告诉后端当前是什么身份
|
||||
senderId: senderId,
|
||||
senderName: currentUser.name || ('用户' + uid),
|
||||
senderAvatar: currentUser.avatar || (app.globalData.ossImageUrl + app.globalData.morentouxiang),
|
||||
senderName: freshUser.name || currentUser.name || ('用户' + uid),
|
||||
senderAvatar: freshUser.avatar || currentUser.avatar || (app.globalData.ossImageUrl + app.globalData.morentouxiang),
|
||||
messageType: localMsg.type,
|
||||
messageId: localMsg.messageId,
|
||||
timestamp: localMsg.timestamp
|
||||
|
||||
Reference in New Issue
Block a user