Selaa lähdekoodia

处理聊天相关逻辑!

release/210823_需求对对碰
王饶冀 3 vuotta sitten
vanhempi
commit
e68991c08f
2 muutettua tiedostoa jossa 13 lisäystä ja 13 poistoa
  1. 12
    12
      pages/msgModule/wechat2/wechat2.js
  2. 1
    1
      pages/msgModule/wechat2/wechat2.wxml

+ 12
- 12
pages/msgModule/wechat2/wechat2.js Näytä tiedosto

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); _data.chatRecord = JSON.parse(_data.chatRecord);
let msgData = {}; let msgData = {};
// type 0 自己 1 对方 // type 0 自己 1 对方
if (_data.chatRecord.sender != _this.data.receiveMemberId) { if (_data.chatRecord.sender != _this.data.receiveMemberId) {
} }
msgData.isRead = true; msgData.isRead = true;
msgData.message = _data.chatRecord.content; msgData.message = _data.chatRecord.content;
msgData.messageType = _data.chatRecord.messageType
msgData.messageType = _data.chatRecord.messageType;
if (msgData.messageType == 1) {
msgData.object = _data.chatRecord.object;
}
msgData.date = utils.formatTime(new Date(_data.chatRecord.sendTime));
msgData.date = msgData.date.replaceAll('/', '-');
list.push(msgData); list.push(msgData);
_this.setData({ _this.setData({
newsList: list newsList: list
_this.scrollBottom() _this.scrollBottom()
console.log('--------------对方给你发消息拉 beg -------------') console.log('--------------对方给你发消息拉 beg -------------')
console.log(_data); console.log(_data);
console.log(_this.data.newsList)
console.log('--------------对方给你发消息拉 end -------------') console.log('--------------对方给你发消息拉 end -------------')
}, },
) )
let tempArr = []; let tempArr = [];
for (let index = historyList.length - 1; index >= 0; index--) { for (let index = historyList.length - 1; index >= 0; index--) {
const element = historyList[index]; const element = historyList[index];
if (element.messageType == 1) {
if (element.messageType == 1 && tempArr.length < 1) {
tempArr.push(element); tempArr.push(element);
if (element.transactionId == businessCommunicationDemandId) {
break;
} else {
this.sendmsgApi("", 1);
}
} }
} }
// 说明没有一条是messageType == 1 的 // 说明没有一条是messageType == 1 的
if (tempArr.length < 1) { if (tempArr.length < 1) {
this.sendmsgApi("", 1); this.sendmsgApi("", 1);
}else{
if(tempArr[0].transactionId != businessCommunicationDemandId){
this.sendmsgApi("", 1);
}
} }
} else { } else {
this.sendmsgApi("", 1); this.sendmsgApi("", 1);
messageType: msgType, messageType: msgType,
}; };
$request.post('/businessCommunicationDemand/addChatRecord.action', params).then(res => { $request.post('/businessCommunicationDemand/addChatRecord.action', params).then(res => {
console.log(`------------聊一聊保存记录-----------------`)
console.log(res);
// 是由需求点击的聊一聊 保存完信息后需要再发送一条 // 是由需求点击的聊一聊 保存完信息后需要再发送一条
if (msgType == 1) { if (msgType == 1) {
this.sendmsgApi("你好,我对这个需求很有兴趣,可以聊聊吗?", 0); this.sendmsgApi("你好,我对这个需求很有兴趣,可以聊聊吗?", 0);
} }
console.log(`------------聊一聊保存记录-----------------`)
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
}) })

+ 1
- 1
pages/msgModule/wechat2/wechat2.wxml Näytä tiedosto

<view wx:else class="product-item-view" bindtap="goDetails" data-value="{{ item.transactionId }}"> <view wx:else class="product-item-view" bindtap="goDetails" data-value="{{ item.transactionId }}">
<view class="content-view"> <view class="content-view">
<view class="product-info-item">{{ item.info }}</view> <view class="product-info-item">{{ item.info }}</view>
<view class="product-send-time">{{ item.date }} 由你发起沟通</view>
<view class="product-send-time">{{ item.date }} 由{{ receiveMemberId != item.sender ? '对方':'' }}发起沟通</view>
</view> </view>
</view> </view>
</block> </block>

Loading…
Peruuta
Tallenna