return | return | ||||
} | } | ||||
console.log(`点击了聊一聊`) | console.log(`点击了聊一聊`) | ||||
let customerid = e.currentTarget.dataset.customerid; | |||||
let item = e.currentTarget.dataset.item; | |||||
wx.navigateTo({ | wx.navigateTo({ | ||||
url:"/pages/msgModule/wechat2/wechat2", | url:"/pages/msgModule/wechat2/wechat2", | ||||
success: function (res) { | success: function (res) { | ||||
// 通过eventChannel向被打开页面传送数据 | // 通过eventChannel向被打开页面传送数据 | ||||
res.eventChannel.emit('customerid', { customerid }) | |||||
res.eventChannel.emit('customerid', { customerid:item.customerId,businessCommunicationDemandId:item.businessCommunicationDemandId }) | |||||
} | } | ||||
}) | }) | ||||
}, | }, |
<image class="collect-img" src="/images/home/not-collect.png" wx:else /> | <image class="collect-img" src="/images/home/not-collect.png" wx:else /> | ||||
收藏 | 收藏 | ||||
</view> | </view> | ||||
<view class="fr list-foot-text-chat" wx:if="{{ pageStatus != 'myRelease' && isOther }}" bindtap="goToChat" data-customerid="{{ item.customerId }}"> | |||||
<view class="fr list-foot-text-chat" wx:if="{{ pageStatus != 'myRelease' && isOther }}" bindtap="goToChat" data-item="{{ item }}"> | |||||
<image class="chat-img" src="/images/home/chat-icon.png" /> | <image class="chat-img" src="/images/home/chat-icon.png" /> | ||||
聊一聊 | 聊一聊 | ||||
</view> | </view> |
}, | }, | ||||
sendAvatar: 'http://wx.qlogo.cn/mmopen/ajNVdqHZLLAIliaZvz5B1ibTzTehYzXdfBZ9hXTL7yuhuCUQGyzbuHeYS2yr8rO5PkbUBbHuWb5h9SibpRQkj3GTw/0', | sendAvatar: 'http://wx.qlogo.cn/mmopen/ajNVdqHZLLAIliaZvz5B1ibTzTehYzXdfBZ9hXTL7yuhuCUQGyzbuHeYS2yr8rO5PkbUBbHuWb5h9SibpRQkj3GTw/0', | ||||
newsList: [ | newsList: [ | ||||
{ | |||||
date: "2020.10.19", | |||||
message: '哈喽,好久不见', | |||||
type: 0 | |||||
}, | |||||
{ | |||||
date: "2020.10.20", | |||||
message: '是呀,好久不见', | |||||
type: 1 | |||||
}, | |||||
{ | |||||
date: "2020.10.20", | |||||
message: '是呀,好久不见', | |||||
type: 1 | |||||
}, | |||||
{ | |||||
date: "2020.10.20", | |||||
message: 'sad加撒恐龙当家撒了框架到拉喀什就科利达杀伤力肯定会萨克雷号地块了撒接口连接达萨罗凯撒将到拉萨就来的就是sad就卡了😘', | |||||
type: 1 | |||||
}, | |||||
{ | |||||
date: "2020.10.19", | |||||
message: '自行车金坷垃上架了靠的就是卡旅行者沉默现在你沙雕萨比许昌办是撒娇登记卡数据库大数据库写注册表你现在从现在是阿斯顿撒多😄', | |||||
type: 0 | |||||
}, | |||||
// { | |||||
// date: "2020.10.19", | |||||
// message: '哈喽,好久不见', | |||||
// type: 0 | |||||
// }, | |||||
// { | |||||
// date: "2020.10.20", | |||||
// message: '是呀,好久不见', | |||||
// type: 1 | |||||
// }, | |||||
],//消息列表 | ],//消息列表 | ||||
historyList: [], | historyList: [], | ||||
input: null, | input: null, | ||||
triggered: true, | triggered: true, | ||||
// 历史记录当前页 | // 历史记录当前页 | ||||
pageNo: 1, | pageNo: 1, | ||||
// 当前产品ID | |||||
businessCommunicationDemandId:null, | |||||
}, | }, | ||||
/** | /** | ||||
eventChannel.on('customerid', data => { | eventChannel.on('customerid', data => { | ||||
this.setData({ | this.setData({ | ||||
sendMemberId: data.customerid, | sendMemberId: data.customerid, | ||||
businessCommunicationDemandId:data.businessCommunicationDemandId, | |||||
}) | }) | ||||
// 获取历史记录 | // 获取历史记录 | ||||
this.getHistory() | this.getHistory() | ||||
var historyList = [...res.data.chatRecordList, ...this.data.historyList] | var historyList = [...res.data.chatRecordList, ...this.data.historyList] | ||||
if (historyList && historyList.length > 0) { | if (historyList && historyList.length > 0) { | ||||
historyList.forEach(item => { | historyList.forEach(item => { | ||||
if (item.send_member_id == sendMemberId) { | |||||
if (item.sender != sendMemberId) { | |||||
item.type = 0 | item.type = 0 | ||||
} else { | } else { | ||||
item.type = 1 | item.type = 1 | ||||
} | } | ||||
item.date = utils.formatTime(new Date(item.sendTime)) | |||||
}); | }); | ||||
this.setData({ | this.setData({ | ||||
historyList | historyList | ||||
wx.sendSocketMessage({ | wx.sendSocketMessage({ | ||||
data: _this.data.input, | data: _this.data.input, | ||||
success: (res) => { | success: (res) => { | ||||
console.log(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) => { | fail: (err) => { | ||||
console.log('sendSocketMessage', '失败') | console.log('sendSocketMessage', '失败') | ||||
input = input + connectemoji[e.currentTarget.dataset.index]; | input = input + connectemoji[e.currentTarget.dataset.index]; | ||||
} else { | } else { | ||||
input = connectemoji[e.currentTarget.dataset.index] | input = connectemoji[e.currentTarget.dataset.index] | ||||
} | |||||
} | |||||
console.log(input, '输入框额值') | console.log(input, '输入框额值') | ||||
this.setData({ | this.setData({ | ||||
input | input |
<!-- pages/wechat2/wechat2.wxml --> | <!-- pages/wechat2/wechat2.wxml --> | ||||
<view class="chat-header"> | |||||
<view class="header-image-box"> | |||||
<image class="header-image" src="{{receivebaseInfo.avatar}}"></image> | |||||
</view> | |||||
<view> | |||||
<view class="chat-name">{{receivebaseInfo.nickname}}</view> | |||||
<view class="chat-company"> | |||||
{{receivebaseInfo.company_name}} - {{receivebaseInfo.department_name}} | |||||
</view> | |||||
</view> | |||||
</view> | |||||
<view class='news'> | <view class='news'> | ||||
<view class="historycon"> | <view class="historycon"> | ||||
<scroll-view scroll-y="true" scroll-into-view="{{scrollid}}" scroll-with-animation="{{true}}" style="height:{{scrollHeight}}" class="history" refresher-enabled="true" bindrefresherrefresh="refresh" refresher-triggered="{{triggered}}"> | <scroll-view scroll-y="true" scroll-into-view="{{scrollid}}" scroll-with-animation="{{true}}" style="height:{{scrollHeight}}" class="history" refresher-enabled="true" bindrefresherrefresh="refresh" refresher-triggered="{{triggered}}"> | ||||
<text class='chat-time' style="display:none;">{{item.date}}</text> | <text class='chat-time' style="display:none;">{{item.date}}</text> | ||||
</view> | </view> | ||||
<view class='other-record'> | <view class='other-record'> | ||||
<image class='other-head-img' src='{{receivebaseInfo.avatar}}'></image> | |||||
<image class='other-head-img' src='{{item.addresseeHeadPortrait}}'></image> | |||||
<view class='other-record-content-triangle'></view> | <view class='other-record-content-triangle'></view> | ||||
<view class='other-record-content'>{{item.content_msg}}</view> | |||||
<view class='other-record-content'>{{item.content}}</view> | |||||
</view> | </view> | ||||
</view> | </view> | ||||
<!-- 此处为结尾 --> | <!-- 此处为结尾 --> | ||||
<text class='chat-time' style="display:none;">{{item.date}}</text> | <text class='chat-time' style="display:none;">{{item.date}}</text> | ||||
</view> | </view> | ||||
<view class='own-record'> | <view class='own-record'> | ||||
<view class='own-record-content'>{{item.content_msg}}</view> | |||||
<view class='own-record-content'>{{item.content}}</view> | |||||
<view class='own-record-content-triangle'></view> | <view class='own-record-content-triangle'></view> | ||||
<image class='own-head-img' src='{{sendAvatar}}'></image> | |||||
<image class='own-head-img' src='{{item.senderHeadPortrait}}'></image> | |||||
</view> | </view> | ||||
</view> | </view> | ||||
<!-- own结尾 --> | <!-- own结尾 --> |
background-color: #f3f3f4; | background-color: #f3f3f4; | ||||
} | } | ||||
/* 新增样式 */ | |||||
.chat-header { | |||||
display: flex; | |||||
align-items: center; | |||||
justify-content: flex-start; | |||||
height: 88px; | |||||
padding: 0 12px; | |||||
background-color: #fff; | |||||
border-radius: 0px 0px 10px 10px; | |||||
} | |||||
.header-image-box { | |||||
width: 64px; | |||||
height: 64px; | |||||
border-radius: 50%; | |||||
margin-right: 12px; | |||||
} | |||||
.header-image { | |||||
width: 100%; | |||||
height: 100%; | |||||
border-radius: 50%; | |||||
} | |||||
.chat-name { | |||||
color: #333; | |||||
font-size: 16px; | |||||
font-weight: 700; | |||||
} | |||||
.chat-company { | |||||
font-size: 14px; | |||||
color: rgba(81, 81, 81, 100); | |||||
} | |||||
.tab { | .tab { | ||||
padding: 20rpx 20rpx 40rpx 50rpx; | padding: 20rpx 20rpx 40rpx 50rpx; |