123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- // pages/release/release.js
- // 获取应用实例
- const app = getApp()
- const $request = require('../../utils/request.js');
- const $util = require('../../utils/util.js');
- Page({
- data: {
- currentIndex: 2,
- pageLoading: true,
- customerId: "",
- // 前往关注公众号
- topShow: true,
- msgData: [],
- page: 1,
- size: 10,
- total: 0,
- // 是否加载数据,true加载,false不加载
- onRefresh: true,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad() {
- this.getMsgData();
- },
- closeTopShow() {
- this.setData({
- topShow: false
- })
- },
- // 聊一聊
- goToChat(e) {
-
- let item = e.currentTarget.dataset.item;
- wx.navigateTo({
- url: "/pages/msgModule/wechat2/wechat2",
- success: function (res) {
- // 通过eventChannel向被打开页面传送数据
- res.eventChannel.emit('customerid', { customerid: item.businessCommunicationCustomerVO.customerId, chatHeads: item.businessCommunicationCustomerVO.chatHeads })
- }
- })
- },
- getMsgData() {
- let { page, size } = this.data;
- $request.get('/businessCommunicationDemand/getChatRecordTable.action', { page, size }).then(res => {
- let tempListData = this.data.msgData;
- if (res.status == 0) {
- let datas = res.data;
- // 先push数据
- tempListData.push(...datas.chatRecordTable);
- tempListData.forEach(el => {
- el.lastContentDate = $util.formatTime(new Date(el.lastContentDate));
- el.lastContentDate = el.lastContentDate.replaceAll('/', '-');
- if (typeof el.type == 'string') {
- el.type = el.type.split(',');
- }
- })
- // 设置总数
- this.setData({
- msgData: tempListData,
- total: datas.total,
- })
- // 如果数据大于了返回的总数
- if (tempListData.length >= this.data.total) {
- // 停止累加数据
- this.setData({
- onRefresh: false,
- itemLoading: false,
- })
- } else {
- this.setData({
- onRefresh: true,
- itemLoading: false,
- page: page + 1
- })
- }
- console.log('-------------消息 beg-------------------')
- console.log(this.data.msgData);
- console.log('-------------消息 end-------------------')
- }
- this.setData({
- pageLoading: false,
- })
- }).catch(error => {
- console.log(error, 'error appletLogin')
- })
-
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- if (this.data.onRefresh) {
- this.setData({
- itemLoading: true
- })
- this.getListData();
- }
- },
- })
|