| total: 0, | total: 0, | ||||
| // 是否加载数据,true加载,false不加载 | // 是否加载数据,true加载,false不加载 | ||||
| onRefresh: true, | onRefresh: true, | ||||
| slideButtons: [{ | |||||
| type: 'warn', | |||||
| text: '删除', | |||||
| extClass: 'delete', | |||||
| }], | |||||
| }, | }, | ||||
| /** | /** | ||||
| * 生命周期函数--监听页面加载 | * 生命周期函数--监听页面加载 | ||||
| }) | }) | ||||
| } | } | ||||
| // 如果全局的 websocket 是连接的,需要关闭连接 调用自身的 | // 如果全局的 websocket 是连接的,需要关闭连接 调用自身的 | ||||
| if(app.globalData.isOnSocketOpen){ | |||||
| if (app.globalData.isOnSocketOpen) { | |||||
| wx.closeSocket(); | wx.closeSocket(); | ||||
| } | } | ||||
| // 初始化websocket | // 初始化websocket | ||||
| el.lastContentDate = el.lastContentDate.replaceAll('/', '-'); | el.lastContentDate = el.lastContentDate.replaceAll('/', '-'); | ||||
| el.size += 1; | el.size += 1; | ||||
| } | } | ||||
| if(el.customer){ | |||||
| if(el.customer.paidByMonth){ | |||||
| if (el.customer) { | |||||
| if (el.customer.paidByMonth) { | |||||
| el.businessCommunicationCustomerVO.nickName = el.customer.nickName | el.businessCommunicationCustomerVO.nickName = el.customer.nickName | ||||
| } | } | ||||
| } | } | ||||
| if (typeof el.type == 'string') { | if (typeof el.type == 'string') { | ||||
| el.type = el.type.split(','); | el.type = el.type.split(','); | ||||
| } | } | ||||
| if(el.customer){ | |||||
| if (el.customer) { | |||||
| // console.log(el.customer.paidByMonth,el.customer.nickName) | // console.log(el.customer.paidByMonth,el.customer.nickName) | ||||
| if(el.customer.paidByMonth){ | |||||
| if (el.customer.paidByMonth) { | |||||
| el.businessCommunicationCustomerVO.nickName = el.customer.nickName | el.businessCommunicationCustomerVO.nickName = el.customer.nickName | ||||
| } | } | ||||
| } | } | ||||
| }) | }) | ||||
| }, | }, | ||||
| // 左滑删除 | |||||
| slideButtonTap(e) { | |||||
| console.log(`执行了删除`) | |||||
| let item = e.currentTarget.dataset.item; | |||||
| let customerId = item.businessCommunicationCustomerVO.customerId; | |||||
| let lastChatRecordCode = item.lastChatRecordCode; | |||||
| $request.post('/businessCommunicationDemand/delChatRecordTable/' + customerId + '/' + lastChatRecordCode + '.action').then(res => { | |||||
| // console.log() | |||||
| if (res.status == 0) { | |||||
| let msgData = this.data.msgData; | |||||
| msgData.forEach((el, inx) => { | |||||
| if (el.businessCommunicationCustomerVO.customerId == customerId) { | |||||
| msgData.splice(inx, 1); | |||||
| } | |||||
| }) | |||||
| this.setData({ | |||||
| msgData: msgData | |||||
| }) | |||||
| } | |||||
| }).catch(err => { | |||||
| console.log(err); | |||||
| }) | |||||
| }, | |||||
| /** | /** | ||||
| * 页面上拉触底事件的处理函数 | * 页面上拉触底事件的处理函数 | ||||
| */ | */ | ||||
| onHide: function () { | onHide: function () { | ||||
| wx.closeSocket(); | wx.closeSocket(); | ||||
| // 检测到全局的 websocket 是连接的 关闭 | // 检测到全局的 websocket 是连接的 关闭 | ||||
| if(app.globalData.isOnSocketOpen){ | |||||
| if (app.globalData.isOnSocketOpen) { | |||||
| app.globalData.isOnSocketOpen = false; | app.globalData.isOnSocketOpen = false; | ||||
| } | } | ||||
| }, | }, | ||||
| onUnload: function () { | onUnload: function () { | ||||
| wx.closeSocket(); | wx.closeSocket(); | ||||
| // 检测到全局的 websocket 是连接的 关闭 | // 检测到全局的 websocket 是连接的 关闭 | ||||
| if(app.globalData.isOnSocketOpen){ | |||||
| if (app.globalData.isOnSocketOpen) { | |||||
| app.globalData.isOnSocketOpen = false; | app.globalData.isOnSocketOpen = false; | ||||
| } | } | ||||
| }, | }, |
| { | { | ||||
| "component": true, | "component": true, | ||||
| "usingComponents": {} | |||||
| "usingComponents": { | |||||
| "mp-slideview": "/miniprogram_npm/weui-miniprogram/slideview/slideview", | |||||
| "mp-cells": "/miniprogram_npm/weui-miniprogram/cells/cells", | |||||
| "mp-cell": "/miniprogram_npm/weui-miniprogram/cell/cell" | |||||
| } | |||||
| } | } |
| <view class="top-view" wx:if="{{ topShow }}"> | <view class="top-view" wx:if="{{ topShow }}"> | ||||
| <image class="msg-top-img fl" src="/images/home/msg-top-icon.png" /> | <image class="msg-top-img fl" src="/images/home/msg-top-icon.png" /> | ||||
| <view class="msg-text fl">关注公众号可随时接收离线消息~</view> | <view class="msg-text fl">关注公众号可随时接收离线消息~</view> | ||||
| <van-button color="#5e73e5" round class="msg-btn-go fl" size="small" bindtap="followApplets">前往关注</van-button> | |||||
| <van-button color="#5e73e5" round class="msg-btn-go fl" size="small" bindtap="followApplets"> | |||||
| 前往关注 | |||||
| </van-button> | |||||
| <image class="msg-colse-img fl" src="/images/home/close.png" bind:tap="closeTopShow" /> | <image class="msg-colse-img fl" src="/images/home/close.png" bind:tap="closeTopShow" /> | ||||
| </view> | </view> | ||||
| <view class="msg-box-view {{ topShow ? 'topShow' : '' }} not-msg-data" wx:if="{{ msgData.length < 1 }}"> | <view class="msg-box-view {{ topShow ? 'topShow' : '' }} not-msg-data" wx:if="{{ msgData.length < 1 }}"> | ||||
| <image class="not-msg-data-img " src="/images/home/not-msg-data.png"/> | |||||
| <image class="not-msg-data-img " src="/images/home/not-msg-data.png" /> | |||||
| <view class="not-data-msg-info">暂无消息记录</view> | <view class="not-data-msg-info">暂无消息记录</view> | ||||
| </view> | </view> | ||||
| <view wx:else class="msg-box-view {{ topShow ? 'topShow' : '' }}"> | <view wx:else class="msg-box-view {{ topShow ? 'topShow' : '' }}"> | ||||
| <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> | |||||
| <mp-slideview buttons="{{slideButtons}}" bindbuttontap="slideButtonTap" wx:for="{{msgData}}" data-item="{{ item }}" wx:key="index"> | |||||
| <view class="msg-li-item {{ index == 0 ? 'msg-li-item-first':'' }} {{ index == msgData.length - 1 ? 'msg-li-item-last':'' }}" 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> | |||||
| <view class="msg-last-content fl yichu" wx:if="{{ item.messageType == 2 }}"> | |||||
| [图片] | |||||
| </view> | |||||
| <view class="msg-last-content fl yichu" wx:else> | |||||
| {{ item.lastContent }} | |||||
| </view> | |||||
| <view class="msg-last-content-date fr yichu"> | |||||
| {{ item.lastContentDate }} | |||||
| </view> | |||||
| </view> | |||||
| </view> | </view> | ||||
| <view class="msg-content fl"> | |||||
| <view class="msg-nickName fl yichu">{{ item.businessCommunicationCustomerVO.nickName }}</view> | |||||
| <view class="msg-last-content fl yichu" wx:if="{{ item.messageType == 2 }}">[图片]</view> | |||||
| <view class="msg-last-content fl yichu" wx:else>{{ item.lastContent }}</view> | |||||
| <view class="msg-last-content-date fr yichu">{{ item.lastContentDate }}</view> | |||||
| </view> | |||||
| </view> | |||||
| </mp-slideview> | |||||
| </view> | </view> | ||||
| </view> | </view> | ||||
| <tabBar currentIndex="{{currentIndex}}"></tabBar> | <tabBar currentIndex="{{currentIndex}}"></tabBar> |
| .msg-li-item { | .msg-li-item { | ||||
| height: 140rpx; | height: 140rpx; | ||||
| border-bottom: 1rpx solid #d9dde5; | |||||
| box-sizing: border-box; | box-sizing: border-box; | ||||
| /* padding: 26rpx 0; */ | |||||
| padding-top: 20rpx; | padding-top: 20rpx; | ||||
| border-top: 1rpx solid #d9dde5; | |||||
| } | |||||
| .msg-li-item-first{ | |||||
| border-top: 0; | |||||
| } | |||||
| .msg-li-item-last { | |||||
| border-bottom: 1rpx solid #d9dde5; | |||||
| } | } | ||||
| .msg-li-item .chatheads-view{ | .msg-li-item .chatheads-view{ |
| connectemoji: $faces.getfaces(), | connectemoji: $faces.getfaces(), | ||||
| }) | }) | ||||
| // 如果全局的 websocket 是连接的,需要关闭连接 调用自身的 | // 如果全局的 websocket 是连接的,需要关闭连接 调用自身的 | ||||
| if(app.globalData.isOnSocketOpen){ | |||||
| if (app.globalData.isOnSocketOpen) { | |||||
| wx.closeSocket(); | wx.closeSocket(); | ||||
| } | } | ||||
| // 获取内存中的数据 | // 获取内存中的数据 | ||||
| // 滚动到底部 | // 滚动到底部 | ||||
| scrollBottom: function () { | scrollBottom: function () { | ||||
| var { newsList } = this.data | |||||
| var scrollid = `scrollid${newsList.length - 1}`; | |||||
| if (newsList.length == 0) { | |||||
| scrollid = "scrollid0" | |||||
| } | |||||
| console.log(`触发了吗?`) | |||||
| // wx.createSelectorQuery().select('#sendmessage').boundingClientRect(rect => { | |||||
| // console.log(rect.height); | |||||
| // console.log(`触发了吗2?`) | |||||
| // wx.pageScrollTo({ | |||||
| // scrollTop:rect.height | |||||
| // }) | |||||
| // }).exec() | |||||
| // var { newsList } = this.data | |||||
| // var scrollid = `scrollid${newsList.length - 1}`; | |||||
| // if (newsList.length == 0) { | |||||
| // scrollid = "scrollid0" | |||||
| // } | |||||
| this.setData({ | this.setData({ | ||||
| scrollid | |||||
| scrollid:"sendmessage" | |||||
| }) | }) | ||||
| }, | }, | ||||
| if (!this.data.isSendImg) { | if (!this.data.isSendImg) { | ||||
| wx.closeSocket(); | wx.closeSocket(); | ||||
| // 检测到全局的 websocket 是连接的 关闭 | // 检测到全局的 websocket 是连接的 关闭 | ||||
| if(app.globalData.isOnSocketOpen){ | |||||
| if (app.globalData.isOnSocketOpen) { | |||||
| app.globalData.isOnSocketOpen = false; | app.globalData.isOnSocketOpen = false; | ||||
| } | } | ||||
| } | } | ||||
| if (!this.data.isSendImg) { | if (!this.data.isSendImg) { | ||||
| wx.closeSocket(); | wx.closeSocket(); | ||||
| // 检测到全局的 websocket 是连接的 关闭 | // 检测到全局的 websocket 是连接的 关闭 | ||||
| if(app.globalData.isOnSocketOpen){ | |||||
| if (app.globalData.isOnSocketOpen) { | |||||
| app.globalData.isOnSocketOpen = false; | app.globalData.isOnSocketOpen = false; | ||||
| } | } | ||||
| } | } |
| </view> | </view> | ||||
| </view> | </view> | ||||
| </block> | </block> | ||||
| <view id="sendmessage"></view> | |||||
| </scroll-view> | </scroll-view> | ||||
| </view> | </view> | ||||
| </view> | </view> | ||||
| <view class="sendmessage"> | <view class="sendmessage"> |