Sfoglia il codice sorgente

临时提交代码~

release/210823_需求对对碰
王饶冀 3 anni fa
parent
commit
5abba4457a
1 ha cambiato i file con 65 aggiunte e 39 eliminazioni
  1. 65
    39
      pages/msgModule/wechat2/wechat2.js

+ 65
- 39
pages/msgModule/wechat2/wechat2.js Vedi File

}) })
// 接收服务器的消息事件 // 接收服务器的消息事件
wx.onSocketMessage(function (res) { wx.onSocketMessage(function (res) {
console.log(res, '消息发送页接受---------------------------------');
// 接收到的消息{date,message,type} type类型为 1 是对方的消息 为 0 是自己的消息 // 接收到的消息{date,message,type} type类型为 1 是对方的消息 为 0 是自己的消息
let list = []; let list = [];
list = _this.data.newsList; list = _this.data.newsList;
let _data = JSON.parse(res.data); let _data = JSON.parse(res.data);
_data.chatRecord = JSON.parse(_data.chatRecord);


console.log(_data, '_data');
let msgData = {};
// type 0 自己 1 对方
if (_data.chatRecord.chatRecord.sender != _this.data.receiveMemberId) {
msgData.type = 1;
if (_data.readMessageCode) {

} else { } else {
msgData.type = 0;
}
msgData.isRead = true;
msgData.message = _data.chatRecord.chatRecord.content;
msgData.messageType = _data.chatRecord.chatRecord.messageType;
if (msgData.messageType == 1) {
msgData.object = _data.chatRecord.chatRecord.object;

_data.chatRecord = JSON.parse(_data.chatRecord);

console.log(_data, '_data');
let msgData = {};
// type 0 自己 1 对方
if (_data.chatRecord.chatRecord.sender != _this.data.receiveMemberId) {
msgData.type = 1;
} else {
msgData.type = 0;
}
msgData.isRead = true;
msgData.message = _data.chatRecord.chatRecord.content;
msgData.messageType = _data.chatRecord.chatRecord.messageType;
if (msgData.messageType == 1) {
msgData.object = _data.chatRecord.chatRecord.object;
}

let d = {
sendno: _this.data.receiveMemberId,
userno: _this.data.sendMemberId,
messageModule : "010",
readMessageCode: _data.chatRecord.chatRecord.chatRecordCode,
};
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);
_this.setData({
newsList: list
})
_this.setMsgRead('newsList', _this.data.newsList, 0)
_this.scrollBottom()
} }
msgData.date = utils.formatTime(new Date(_data.chatRecord.chatRecord.sendTime));
msgData.date = msgData.date.replaceAll('/', '-');
list.push(msgData);
_this.setData({
newsList: list
})
_this.setMsgRead('newsList', _this.data.newsList, 0)
_this.scrollBottom()

}, },
) )
// 监听连接关闭 // 监听连接关闭
send: function () { send: function () {
var _this = this; var _this = this;
if (_this.data.input) { if (_this.data.input) {
wx.sendSocketMessage({
data: _this.data.input,
success: (res) => {
console.log(`发送成功`)
console.log(res)
// let { sendMemberId, receiveMemberId, businessCommunicationDemandId } = _this.data;
// let params = {
// sender: receiveMemberId, // 发件人Id
// addressee: sendMemberId, // 收件人Id
// transactionId: businessCommunicationDemandId, // 产品ID
// content: _this.data.input
// };
},
fail: (err) => {
console.log('sendSocketMessage', '失败')
}
})
return
// wx.sendSocketMessage({
// data: _this.data.input,
// success: (res) => {
// console.log(`发送成功`)
// console.log(res)
// // let { sendMemberId, receiveMemberId, businessCommunicationDemandId } = _this.data;
// // let params = {
// // sender: receiveMemberId, // 发件人Id
// // addressee: sendMemberId, // 收件人Id
// // transactionId: businessCommunicationDemandId, // 产品ID
// // content: _this.data.input
// // };
// },
// fail: (err) => {
// console.log('sendSocketMessage', '失败')
// }
// })
// return
this.sendmsgApi(_this.data.input, 0); this.sendmsgApi(_this.data.input, 0);
} }
}, },

Loading…
Annulla
Salva