|
|
@@ -251,7 +251,7 @@ export default {
|
|
|
// 如果没有传入房间号,使用默认值或生成一个
|
|
|
this.room = 'default_room';
|
|
|
}
|
|
|
- console.log('---------- this.room: ', this.room);
|
|
|
+ // console.log('---------- this.room: ', this.room);
|
|
|
|
|
|
// 加载聊天记录
|
|
|
this.loadChatHistory();
|
|
|
@@ -281,12 +281,11 @@ export default {
|
|
|
},
|
|
|
onUnload() {
|
|
|
// 页面卸载时关闭WebSocket连接
|
|
|
- this.isManualDisconnect = true; // 标记为主动断开
|
|
|
this.disconnectWebSocket();
|
|
|
},
|
|
|
onHide() {
|
|
|
// 页面隐藏时可以选择性地关闭连接(根据业务需求)
|
|
|
- this.disconnectWebSocket()
|
|
|
+ this.disconnectWebSocket();
|
|
|
},
|
|
|
onShow() {
|
|
|
// 页面显示时重新连接(如果之前断开了)
|
|
|
@@ -421,7 +420,9 @@ export default {
|
|
|
// 只有在非主动断开的情况下才尝试重连
|
|
|
if (!this.isManualDisconnect && this.reconnectCount < this.maxReconnectCount) {
|
|
|
setTimeout(() => {
|
|
|
- this.reconnectWebSocket();
|
|
|
+ if (!this.isManualDisconnect) {
|
|
|
+ this.reconnectWebSocket();
|
|
|
+ }
|
|
|
}, 3000);
|
|
|
}
|
|
|
|
|
|
@@ -669,7 +670,7 @@ export default {
|
|
|
console.error('协议长度超限:', protocol.length);
|
|
|
return false;
|
|
|
}
|
|
|
- console.log('protocal -- ', protocol, protocol.length)
|
|
|
+ // console.log('protocal -- ', protocol, protocol.length)
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
@@ -703,7 +704,7 @@ export default {
|
|
|
|
|
|
// 处理 WebSocket 消息
|
|
|
handleWebSocketMessage(data) {
|
|
|
- console.log('---------- data: ', data);
|
|
|
+ // console.log('---------- data: ', data);
|
|
|
try {
|
|
|
// 尝试解析JSON,如果失败则认为是纯文本消息
|
|
|
let messageData;
|
|
|
@@ -731,7 +732,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
const messageType = messageData.messageType || "text";
|
|
|
- console.log('messageType -- ', messageType);
|
|
|
+ // console.log('messageType -- ', messageType);
|
|
|
|
|
|
// 创建消息对象
|
|
|
const newMessage = {
|
|
|
@@ -749,7 +750,7 @@ export default {
|
|
|
newMessage.goodsInfo = this.parseGoodsMessage(newMessage.message);
|
|
|
}
|
|
|
|
|
|
- console.log('收到 ---------- newMessage: ', newMessage);
|
|
|
+ // console.log('收到 ---------- newMessage: ', newMessage);
|
|
|
// 添加到消息列表
|
|
|
this.messageList.push(newMessage);
|
|
|
|
|
|
@@ -821,12 +822,12 @@ export default {
|
|
|
};
|
|
|
|
|
|
const json = JSON.stringify(messageData);
|
|
|
- console.log('send ---------- json: ', json);
|
|
|
+ // console.log('send ---------- json: ', json);
|
|
|
// 发送到WebSocket服务器
|
|
|
this.socket.send({
|
|
|
data: json,
|
|
|
success: () => {
|
|
|
- console.log('消息发送成功');
|
|
|
+ // console.log('消息发送成功');
|
|
|
},
|
|
|
fail: (error) => {
|
|
|
console.error('消息发送失败:', error);
|
|
|
@@ -886,7 +887,7 @@ export default {
|
|
|
},
|
|
|
// 输入框聚焦事件
|
|
|
onInputFocus() {
|
|
|
- console.log('输入框聚焦');
|
|
|
+ // console.log('输入框聚焦');
|
|
|
// 微信小程序中,聚焦时延迟滚动到底部
|
|
|
setTimeout(() => {
|
|
|
this.scrollToBottom();
|
|
|
@@ -898,7 +899,7 @@ export default {
|
|
|
|
|
|
// 输入框失焦事件
|
|
|
onInputBlur() {
|
|
|
- console.log('输入框失焦');
|
|
|
+ // console.log('输入框失焦');
|
|
|
this.isInputFocused = false
|
|
|
// this.inputFocus = false
|
|
|
},
|
|
|
@@ -998,7 +999,7 @@ export default {
|
|
|
this.socket.send({
|
|
|
data: json,
|
|
|
success: () => {
|
|
|
- console.log("商品消息发送成功");
|
|
|
+ // console.log("商品消息发送成功");
|
|
|
},
|
|
|
fail: (error) => {
|
|
|
console.error("商品消息发送失败:", error);
|
|
|
@@ -1017,12 +1018,12 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
createQrotedPrice(message) {
|
|
|
- console.log("createPrice", message)
|
|
|
+ // console.log("createPrice", message)
|
|
|
createQuotedPrice({
|
|
|
key: message.goodsInfo.key,
|
|
|
price: message.quotedPrice,
|
|
|
}).then(res => {
|
|
|
- console.log("createQuotedPrice", res)
|
|
|
+ // console.log("createQuotedPrice", res)
|
|
|
if (res.code == 1) {
|
|
|
this.$msg("报价成功")
|
|
|
message.goodsInfo.goodsPriceType = 2;
|