Kaynağa Gözat

处理聊天相关逻辑!

release/210823_需求对对碰
王饶冀 3 yıl önce
ebeveyn
işleme
e68991c08f

+ 12
- 12
pages/msgModule/wechat2/wechat2.js Dosyayı Görüntüle

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

+ 1
- 1
pages/msgModule/wechat2/wechat2.wxml Dosyayı Görüntüle

@@ -139,7 +139,7 @@
<view wx:else class="product-item-view" bindtap="goDetails" data-value="{{ item.transactionId }}">
<view class="content-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>
</block>

Loading…
İptal
Kaydet