Ver código fonte

提交代码~

release/210823_需求对对碰
王饶冀 3 anos atrás
pai
commit
801a4a5bdc
1 arquivos alterados com 33 adições e 78 exclusões
  1. 33
    78
      pages/msgModule/wechat2/wechat2.js

+ 33
- 78
pages/msgModule/wechat2/wechat2.js Ver arquivo

@@ -114,15 +114,19 @@ Page({

// 接收服务器的消息事件
wx.onSocketMessage(function (res) {

// 接收到的消息{date,message,type} type类型为 1 是对方的消息 为 0 是自己的消息

var list = [];
let list = [];
list = _this.data.newsList;
var _data = JSON.parse(res.data);

list.push(_data);
console.log(list)
let _data = JSON.parse(res.data);
_data.chatRecord = JSON.parse(_data.chatRecord);
let msgData = {};
if(_data.chatRecord.sender != _this.data.receiveMemberId){
msgData.type = 1;
}else{
msgData.type = 0;
}
msgData.message = _data.chatRecord.content;
list.push(msgData);
_this.setData({
newsList: list
})
@@ -170,56 +174,6 @@ Page({
}).catch(err => {
console.log(err)
})
// var params = {
// receiveMemberId,
// sendMemberId,
// pageNo,
// pageSize: 5,
// }
// api.get("/zxxt/chat/msg/list", params, (res) => {
// if (res.code == 'success') {
// // var historyList = res.data.data
// var historyList = [...res.data.data, ...this.data.historyList]
// if (historyList && historyList.length > 0) {
// historyList.forEach(item => {
// if (item.send_member_id == sendMemberId) {
// item.type = 0
// } else {
// item.type = 1
// }
// });
// this.setData({
// historyList
// })
// console.log(this.data.historyList, '历史记录数据')
// } else {
// // 判断是否是第一次进入查看历史记录:是(不显示弹框,不是则显示弹框)
// if (this.data.pageNo > 1) {
// wx.showToast({
// title: "没有更多历史记录了",
// icon: 'none',
// duration: 2000
// })
// }
// }
// } else {
// if (res.message) {
// wx.showToast({
// title: res.message,
// icon: 'none',
// duration: 2000
// })
// }
// }
// }, (res) => {
// if (res.message) {
// wx.showToast({
// title: res.message,
// icon: 'none',
// duration: 2000
// })
// }
// })
},

// 滚动到底部
@@ -315,28 +269,29 @@ Page({
send: function () {
var _this = this;
if (_this.data.input) {
wx.sendSocketMessage({
data: _this.data.input,
success: (res) => {
let { sendMemberId ,receiveMemberId ,businessCommunicationDemandId} = _this.data;
let params = {
sender: receiveMemberId, // 发件人Id
addressee: sendMemberId, // 收件人Id
transactionId: businessCommunicationDemandId, // 产品ID
content: _this.data.input
};
$request.post('/businessCommunicationDemand/addChatRecord.action',params).then(res => {
console.log(`------------聊一聊保存记录-----------------`)
console.log(res);
console.log(`------------聊一聊保存记录-----------------`)
}).catch(err => {
console.log(err)
})
},
fail: (err) => {
console.log('sendSocketMessage', '失败')
}
let { sendMemberId ,receiveMemberId ,businessCommunicationDemandId} = _this.data;
let params = {
sender: receiveMemberId, // 发件人Id
addressee: sendMemberId, // 收件人Id
transactionId: businessCommunicationDemandId, // 产品ID
content: _this.data.input
};
$request.post('/businessCommunicationDemand/addChatRecord.action',params).then(res => {
console.log(`------------聊一聊保存记录-----------------`)
console.log(res);
console.log(`------------聊一聊保存记录-----------------`)
}).catch(err => {
console.log(err)
})
// wx.sendSocketMessage({
// data: _this.data.input,
// success: (res) => {
// },
// fail: (err) => {
// console.log('sendSocketMessage', '失败')
// }
// })
var list = [];
list = this.data.newsList;
var temp = { 'message': _this.data.input, 'date': utils.formatTime(new Date()), type: 0 };

Carregando…
Cancelar
Salvar