业务交流通
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. },
  25. onShow(){
  26. // this.getMsgData();
  27. this.initData();
  28. },
  29. closeTopShow() {
  30. this.setData({
  31. topShow: false
  32. })
  33. },
  34. // 聊一聊
  35. goToChat(e) {
  36. let item = e.currentTarget.dataset.item;
  37. wx.navigateTo({
  38. url: "/pages/msgModule/wechat2/wechat2",
  39. success: function (res) {
  40. // 通过eventChannel向被打开页面传送数据
  41. res.eventChannel.emit('customerid', { customerid: item.businessCommunicationCustomerVO.customerId, chatHeads: item.businessCommunicationCustomerVO.chatHeads })
  42. }
  43. })
  44. },
  45. initData(){
  46. this.setData({
  47. pageLoading: true,
  48. page:1,
  49. size: 10,
  50. msgData: [],
  51. })
  52. this.getMsgData();
  53. },
  54. getMsgData() {
  55. let { page, size } = this.data;
  56. $request.get('/businessCommunicationDemand/getChatRecordTable.action', { page, size }).then(res => {
  57. let tempListData = this.data.msgData;
  58. if (res.status == 0) {
  59. let datas = res.data;
  60. // 先push数据
  61. tempListData.push(...datas.chatRecordTable);
  62. tempListData.forEach(el => {
  63. el.lastContentDate = $util.formatTime(new Date(el.lastContentDate));
  64. el.lastContentDate = el.lastContentDate.replaceAll('/', '-');
  65. if (typeof el.type == 'string') {
  66. el.type = el.type.split(',');
  67. }
  68. })
  69. // 设置总数
  70. this.setData({
  71. msgData: tempListData,
  72. total: datas.total,
  73. })
  74. // 如果数据大于了返回的总数
  75. if (tempListData.length >= this.data.total) {
  76. // 停止累加数据
  77. this.setData({
  78. onRefresh: false,
  79. itemLoading: false,
  80. })
  81. } else {
  82. this.setData({
  83. onRefresh: true,
  84. itemLoading: false,
  85. page: page + 1
  86. })
  87. }
  88. console.log('-------------消息 beg-------------------')
  89. console.log(this.data.msgData);
  90. console.log('-------------消息 end-------------------')
  91. }
  92. this.setData({
  93. pageLoading: false,
  94. })
  95. }).catch(error => {
  96. console.log(error, 'error appletLogin')
  97. })
  98. },
  99. /**
  100. * 页面上拉触底事件的处理函数
  101. */
  102. onReachBottom: function () {
  103. if (this.data.onRefresh) {
  104. this.setData({
  105. itemLoading: true
  106. })
  107. this.getListData();
  108. }
  109. },
  110. })