|
|
@@ -144,25 +144,29 @@ Page({ |
|
|
|
}) |
|
|
|
// 接收服务器的消息事件 |
|
|
|
wx.onSocketMessage(function (res) { |
|
|
|
// console.log(res, '消息发送页接受---------------------------------'); |
|
|
|
console.log(res, '消息发送页接受---------------------------------'); |
|
|
|
// 接收到的消息{date,message,type} type类型为 1 是对方的消息 为 0 是自己的消息 |
|
|
|
let list = []; |
|
|
|
list = _this.data.newsList; |
|
|
|
let historyList = _this.data.historyList; |
|
|
|
let _data = JSON.parse(res.data); |
|
|
|
console.log(_data, '_data'); |
|
|
|
if (_data.readMessageCode) { |
|
|
|
list.forEach(el=>{ |
|
|
|
el.isRead = true; |
|
|
|
}) |
|
|
|
historyList.forEach(el=>{ |
|
|
|
el.isRead = true; |
|
|
|
}) |
|
|
|
_this.setData({ |
|
|
|
newsList: list, |
|
|
|
historyList |
|
|
|
}) |
|
|
|
// list.forEach(el=>{ |
|
|
|
// el.isRead = true; |
|
|
|
// }) |
|
|
|
// historyList.forEach(el=>{ |
|
|
|
// el.isRead = true; |
|
|
|
// }) |
|
|
|
// _this.setData({ |
|
|
|
// newsList: list, |
|
|
|
// historyList |
|
|
|
// }) |
|
|
|
} else { |
|
|
|
|
|
|
|
_data.chatRecord = JSON.parse(_data.chatRecord); |
|
|
|
|
|
|
|
|
|
|
|
let msgData = {}; |
|
|
|
// type 0 自己 1 对方 |
|
|
|
if (_data.chatRecord.chatRecord.sender != _this.data.receiveMemberId) { |
|
|
@@ -176,6 +180,24 @@ Page({ |
|
|
|
if (msgData.messageType == 1) { |
|
|
|
msgData.object = _data.chatRecord.chatRecord.object; |
|
|
|
} |
|
|
|
|
|
|
|
let d = { |
|
|
|
sendno: _this.data.receiveMemberId+'', |
|
|
|
userno: _this.data.sendMemberId+'', |
|
|
|
messageModule : "010", |
|
|
|
readMessageCode: _this.data.currentGuid, |
|
|
|
}; |
|
|
|
wx.sendSocketMessage({ |
|
|
|
data: JSON.stringify(d), |
|
|
|
success: (res) => { |
|
|
|
console.log(`发送成功`) |
|
|
|
console.log(res) |
|
|
|
}, |
|
|
|
fail: (err) => { |
|
|
|
console.log('sendSocketMessage', '失败') |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
msgData.date = utils.formatTime(new Date(_data.chatRecord.chatRecord.sendTime)); |
|
|
|
msgData.date = msgData.date.replaceAll('/', '-'); |
|
|
|
list.push(msgData); |