瀏覽代碼

1 消息列表页新增左滑删除

release/210823_需求对对碰
王饶冀 3 年之前
父節點
當前提交
32bcafc259

+ 35
- 7
pages/msgModule/index.js 查看文件

@@ -16,6 +16,11 @@ Page({
total: 0,
// 是否加载数据,true加载,false不加载
onRefresh: true,
slideButtons: [{
type: 'warn',
text: '删除',
extClass: 'delete',
}],
},
/**
* 生命周期函数--监听页面加载
@@ -33,7 +38,7 @@ Page({
})
}
// 如果全局的 websocket 是连接的,需要关闭连接 调用自身的
if(app.globalData.isOnSocketOpen){
if (app.globalData.isOnSocketOpen) {
wx.closeSocket();
}
// 初始化websocket
@@ -78,8 +83,8 @@ Page({
el.lastContentDate = el.lastContentDate.replaceAll('/', '-');
el.size += 1;
}
if(el.customer){
if(el.customer.paidByMonth){
if (el.customer) {
if (el.customer.paidByMonth) {
el.businessCommunicationCustomerVO.nickName = el.customer.nickName
}
}
@@ -136,9 +141,9 @@ Page({
if (typeof el.type == 'string') {
el.type = el.type.split(',');
}
if(el.customer){
if (el.customer) {
// console.log(el.customer.paidByMonth,el.customer.nickName)
if(el.customer.paidByMonth){
if (el.customer.paidByMonth) {
el.businessCommunicationCustomerVO.nickName = el.customer.nickName
}
}
@@ -174,6 +179,29 @@ Page({
})

},
// 左滑删除
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);
})
},
/**
* 页面上拉触底事件的处理函数
*/
@@ -200,7 +228,7 @@ Page({
onHide: function () {
wx.closeSocket();
// 检测到全局的 websocket 是连接的 关闭
if(app.globalData.isOnSocketOpen){
if (app.globalData.isOnSocketOpen) {
app.globalData.isOnSocketOpen = false;
}
},
@@ -211,7 +239,7 @@ Page({
onUnload: function () {
wx.closeSocket();
// 检测到全局的 websocket 是连接的 关闭
if(app.globalData.isOnSocketOpen){
if (app.globalData.isOnSocketOpen) {
app.globalData.isOnSocketOpen = false;
}
},

+ 5
- 1
pages/msgModule/index.json 查看文件

@@ -1,4 +1,8 @@
{
"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"
}
}

+ 27
- 13
pages/msgModule/index.wxml 查看文件

@@ -7,26 +7,40 @@
<view class="top-view" wx:if="{{ topShow }}">
<image class="msg-top-img fl" src="/images/home/msg-top-icon.png" />
<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" />
</view>
<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>
<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 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>
<tabBar currentIndex="{{currentIndex}}"></tabBar>

+ 9
- 2
pages/msgModule/index.wxss 查看文件

@@ -65,10 +65,17 @@

.msg-li-item {
height: 140rpx;
border-bottom: 1rpx solid #d9dde5;
box-sizing: border-box;
/* padding: 26rpx 0; */
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{

+ 18
- 9
pages/msgModule/wechat2/wechat2.js 查看文件

@@ -92,7 +92,7 @@ Page({
connectemoji: $faces.getfaces(),
})
// 如果全局的 websocket 是连接的,需要关闭连接 调用自身的
if(app.globalData.isOnSocketOpen){
if (app.globalData.isOnSocketOpen) {
wx.closeSocket();
}
// 获取内存中的数据
@@ -233,13 +233,22 @@ Page({

// 滚动到底部
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({
scrollid
scrollid:"sendmessage"
})
},

@@ -303,7 +312,7 @@ Page({
if (!this.data.isSendImg) {
wx.closeSocket();
// 检测到全局的 websocket 是连接的 关闭
if(app.globalData.isOnSocketOpen){
if (app.globalData.isOnSocketOpen) {
app.globalData.isOnSocketOpen = false;
}
}
@@ -317,7 +326,7 @@ Page({
if (!this.data.isSendImg) {
wx.closeSocket();
// 检测到全局的 websocket 是连接的 关闭
if(app.globalData.isOnSocketOpen){
if (app.globalData.isOnSocketOpen) {
app.globalData.isOnSocketOpen = false;
}
}

+ 2
- 0
pages/msgModule/wechat2/wechat2.wxml 查看文件

@@ -143,7 +143,9 @@
</view>
</view>
</block>
<view id="sendmessage"></view>
</scroll-view>

</view>
</view>
<view class="sendmessage">

Loading…
取消
儲存