|
@@ -3694,6 +3694,8 @@
|
|
|
|
|
|
|
|
// 给消息添加唯一ID
|
|
// 给消息添加唯一ID
|
|
|
message.uniqueId = ++this.messageIdCounter;
|
|
message.uniqueId = ++this.messageIdCounter;
|
|
|
|
|
+ let msgdata = JSON.parse(message.data);
|
|
|
|
|
+ message.msgId = msgdata.msgId;
|
|
|
this.talklist.push(message);
|
|
this.talklist.push(message);
|
|
|
|
|
|
|
|
// 当消息超过限制时,批量删除旧消息
|
|
// 当消息超过限制时,批量删除旧消息
|
|
@@ -3904,7 +3906,10 @@
|
|
|
status: true
|
|
status: true
|
|
|
};
|
|
};
|
|
|
} else if (socketMessage.cmd == 'deleteMsg') {
|
|
} else if (socketMessage.cmd == 'deleteMsg') {
|
|
|
-
|
|
|
|
|
|
|
+ const index = this.talklist.findIndex(item => item.msgId == socketMessage.msg);
|
|
|
|
|
+ if (index !== -1) {
|
|
|
|
|
+ this.talklist.splice(index, 1);
|
|
|
|
|
+ }
|
|
|
}else if (socketMessage.cmd == 'LotteryDetail') {
|
|
}else if (socketMessage.cmd == 'LotteryDetail') {
|
|
|
try {
|
|
try {
|
|
|
this.prizeInfo = Array.isArray(JSON.parse(socketMessage.data || '[]')) ? JSON.parse(
|
|
this.prizeInfo = Array.isArray(JSON.parse(socketMessage.data || '[]')) ? JSON.parse(
|
|
@@ -3984,34 +3989,32 @@
|
|
|
};
|
|
};
|
|
|
// 发送socket消息
|
|
// 发送socket消息
|
|
|
try {
|
|
try {
|
|
|
- if (this.myselfFlag) {
|
|
|
|
|
- this.addToTalkList(data);
|
|
|
|
|
- } else {
|
|
|
|
|
- this.socket.send({
|
|
|
|
|
- data: JSON.stringify(data),
|
|
|
|
|
- success: () => {
|
|
|
|
|
- this.value = '';
|
|
|
|
|
- // 发送成功后强制滚动到底部,无论当前滚动位置如何
|
|
|
|
|
- this.forceScrollToBottomOnSend();
|
|
|
|
|
- },
|
|
|
|
|
- fail: (err) => {
|
|
|
|
|
- console.error('消息发送失败:', err);
|
|
|
|
|
- if (retries > 0) {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: `发送失败,正在重试(${retries}次)`,
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- });
|
|
|
|
|
- setTimeout(() => this.sendMsg(retries - 1), 500);
|
|
|
|
|
- } else {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '发送失败,请稍后再试',
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- });
|
|
|
|
|
- this.value = text; // 恢复输入框内容
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ this.socket.send({
|
|
|
|
|
+ data: JSON.stringify(data),
|
|
|
|
|
+ success: () => {
|
|
|
|
|
+ this.value = '';
|
|
|
|
|
+ // 发送成功后强制滚动到底部,无论当前滚动位置如何
|
|
|
|
|
+ this.forceScrollToBottomOnSend();
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: (err) => {
|
|
|
|
|
+ console.error('消息发送失败:', err);
|
|
|
|
|
+ if (retries > 0) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: `发送失败,正在重试(${retries}次)`,
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ });
|
|
|
|
|
+ setTimeout(() => this.sendMsg(retries - 1), 500);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '发送失败,请稍后再试',
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ });
|
|
|
|
|
+ this.value = text; // 恢复输入框内容
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
console.error('发送消息异常:', err);
|
|
console.error('发送消息异常:', err);
|