Parcourir la source

提交diam~

release/210823_需求对对碰
王饶冀 il y a 3 ans
Parent
révision
5f6e39488d

+ 1
- 0
components/tabbar/tabbar.js Voir le fichier

@@ -48,6 +48,7 @@ Component({
*/
methods: {
tabChange(e) {
wx.closeSocket();
if (e.detail.item.text == "发布需求" || e.detail.item.text == "消息") {
if (!app.globalData.customerId) {
app.goLogin();

+ 23
- 3
pages/msgModule/index.js Voir le fichier

@@ -21,6 +21,10 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad() {
},
onShow() {
const businessCommunicationCustomer = wx.getStorageSync('businessCommunicationCustomer') || null;
if (businessCommunicationCustomer) {
this.setData({
@@ -29,8 +33,6 @@ Page({
}
// 初始化websocket
this.initWebSocket();
},
onShow() {
// 初始化数据
this.initData();
},
@@ -59,7 +61,22 @@ Page({
wx.onSocketMessage(function (res) {
// 接收到的消息{date,message,type} type类型为 1 是对方的消息 为 0 是自己的消息
console.log(res,'消息页----收到新消息')
_this.initData();
// _this.initData();
let _data = JSON.parse(res.data);
_data.chatRecord = JSON.parse(_data.chatRecord);
let msgData = _this.data.msgData;
msgData.forEach(el=>{
// 如果当前消息的 customerId = 发送人的ID
if(el.businessCommunicationCustomerVO.customerId == _data.chatRecord.sender){
el.lastContent = _data.chatRecord.content;
el.lastContentDate = $util.formatTime(new Date(_data.chatRecord.sendTime));
el.lastContentDate = el.lastContentDate.replaceAll('/', '-');
}
el.size + 1;
})
_this.setData({
msgData
})
})

// 监听连接关闭
@@ -151,4 +168,7 @@ Page({
this.getListData();
}
},
onHide(){
wx.closeSocket();
},
})

+ 1
- 0
pages/msgModule/index.wxml Voir le fichier

@@ -18,6 +18,7 @@
<view class="msg-li-item" wx:for="{{msgData}}" wx:key="index" bindtap="goToChat" data-item="{{ item }}">
<view class="chatheads-view fl">
<image class='other-head-img' src='{{item.businessCommunicationCustomerVO.chatHeads }}'></image>
<view class="view-info" wx:if="{{ item.size > 0 }}">{{ item.size > 99 ? '99+' : item.size }}</view>
</view>
<view class="msg-content fl">
<view class="msg-nickName fl yichu">{{ item.businessCommunicationCustomerVO.nickName }}</view>

+ 16
- 0
pages/msgModule/index.wxss Voir le fichier

@@ -77,6 +77,7 @@
margin: 0 20rpx;
border-radius: 50%;
margin-top: 7rpx;
position: relative;
}
.msg-li-item .chatheads-view .other-head-img{
width: 100%;
@@ -102,4 +103,19 @@
}
.msg-li-item .msg-content .msg-last-content {
max-width: calc(100% - 270rpx);
}

.msg-li-item .chatheads-view .view-info {
position: absolute;
right: -8rpx;
top: -8rpx;
background: red;
color: #fff;
font-size: 12px;
border-radius: 50%;
box-sizing: border-box;
min-width: 30rpx;
height: 30rpx;
line-height: 30rpx;
text-align: center;
}

+ 1
- 1
pages/msgModule/wechat2/wechat2.js Voir le fichier

@@ -264,7 +264,7 @@ Page({
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
wx.closeSocket();
},

/**

Chargement…
Annuler
Enregistrer