fix(chat): 订单详情进群统一走 connectToGroupChat,groupId=订单号,修复历史消息与身份

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-06-28 07:23:55 +08:00
parent eaf05663ee
commit 848c2f6486
4 changed files with 108 additions and 126 deletions

View File

@@ -1,6 +1,7 @@
// pages/fighter-order-detail/fighter-order-detail.js - 【最终版:提交前公告弹窗 + 修改图片至少保留一张】
const app = getApp()
import request from '../../utils/request.js'
import connectionManager from '../../utils/xiaoxilj.js'
const COS = require('../../utils/cos-wx-sdk-v5.min.js')
Page({
@@ -284,7 +285,7 @@ Page({
});
},
// ===== 联系老板(订单群 groupId 订单号,与商家端 sjddxq 一致 =====
// ===== 联系老板(订单群 groupId = 订单号) =====
goToChatWithBoss() {
const uid = wx.getStorageSync('uid')
if (!uid) {
@@ -298,37 +299,15 @@ Page({
return
}
const targetUserId = 'Ds' + uid
const connected = wx.goEasy && wx.goEasy.getConnectionStatus && wx.goEasy.getConnectionStatus() === 'connected'
const currentUserId = wx.goEasy?.im?.userId
if (!connected || currentUserId !== targetUserId) {
if (app.ensureConnection) app.ensureConnection()
wx.showToast({ title: '连接中,请稍后再试', icon: 'none' })
return
}
const orderIdStr = String(orderId)
const groupName = (this.data.jibenShuju.nicheng || '订单') + '的订单群'
const isCross = this.data.jibenShuju.fadanpingtai || 0
wx.goEasy.im.subscribeGroup({
groupIds: [orderIdStr],
onSuccess: () => {
const param = {
groupId: orderIdStr,
orderId: orderIdStr,
groupName,
groupAvatar: '',
isCross,
}
wx.navigateTo({
url: '/pages/group-chat/group-chat?data=' + encodeURIComponent(JSON.stringify(param)),
})
},
onFailed: (err) => {
console.error('订阅群组失败', err)
wx.showToast({ title: '连接群聊失败', icon: 'none' })
},
connectionManager.connectToGroupChat({
identityType: 'dashou',
userId: 'Ds' + uid,
orderId: orderId,
groupName: (this.data.jibenShuju.nicheng || '订单') + '的订单群',
isCross: this.data.jibenShuju.fadanpingtai || 0,
}).catch((err) => {
console.error('跳转群聊失败', err)
wx.showToast({ title: '跳转聊天失败', icon: 'none' })
})
},