业务交流通
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // pages/release/release.js
  2. // 获取应用实例
  3. const app = getApp()
  4. const $request = require('../../utils/request.js');
  5. const $util = require('../../utils/util.js');
  6. Page({
  7. data: {
  8. currentIndex: 2,
  9. pageLoading: true,
  10. customerId: "",
  11. // 前往关注公众号
  12. topShow: true,
  13. msgData: [],
  14. page: 1,
  15. size: 10,
  16. total: 0,
  17. // 是否加载数据,true加载,false不加载
  18. onRefresh: true,
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad() {
  24. this.getMsgData();
  25. },
  26. closeTopShow() {
  27. this.setData({
  28. topShow: false
  29. })
  30. },
  31. // 聊一聊
  32. goToChat(e) {
  33. let item = e.currentTarget.dataset.item;
  34. wx.navigateTo({
  35. url: "/pages/msgModule/wechat2/wechat2",
  36. success: function (res) {
  37. // 通过eventChannel向被打开页面传送数据
  38. res.eventChannel.emit('customerid', { customerid: item.businessCommunicationCustomerVO.customerId, chatHeads: item.businessCommunicationCustomerVO.chatHeads })
  39. }
  40. })
  41. },
  42. getMsgData() {
  43. let { page, size } = this.data;
  44. $request.get('/businessCommunicationDemand/getChatRecordTable.action', { page, size }).then(res => {
  45. let tempListData = this.data.msgData;
  46. if (res.status == 0) {
  47. let datas = res.data;
  48. // 先push数据
  49. tempListData.push(...datas.chatRecordTable);
  50. tempListData.forEach(el => {
  51. el.lastContentDate = $util.formatTime(new Date(el.lastContentDate));
  52. el.lastContentDate = el.lastContentDate.replaceAll('/', '-');
  53. if (typeof el.type == 'string') {
  54. el.type = el.type.split(',');
  55. }
  56. })
  57. // 设置总数
  58. this.setData({
  59. msgData: tempListData,
  60. total: datas.total,
  61. })
  62. // 如果数据大于了返回的总数
  63. if (tempListData.length >= this.data.total) {
  64. // 停止累加数据
  65. this.setData({
  66. onRefresh: false,
  67. itemLoading: false,
  68. })
  69. } else {
  70. this.setData({
  71. onRefresh: true,
  72. itemLoading: false,
  73. page: page + 1
  74. })
  75. }
  76. console.log('-------------消息 beg-------------------')
  77. console.log(this.data.msgData);
  78. console.log('-------------消息 end-------------------')
  79. }
  80. this.setData({
  81. pageLoading: false,
  82. })
  83. }).catch(error => {
  84. console.log(error, 'error appletLogin')
  85. })
  86. },
  87. /**
  88. * 页面上拉触底事件的处理函数
  89. */
  90. onReachBottom: function () {
  91. if (this.data.onRefresh) {
  92. this.setData({
  93. itemLoading: true
  94. })
  95. this.getListData();
  96. }
  97. },
  98. })