业务交流通
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. getMsgData() {
  32. let { page, size } = this.data;
  33. $request.get('/businessCommunicationDemand/getChatRecordTable.action', { page, size }).then(res => {
  34. console.log(res);
  35. let tempListData = this.data.msgData;
  36. if (res.status == 0) {
  37. let datas = res.data;
  38. console.log(datas, 'datas')
  39. // 先push数据
  40. tempListData.push(...datas.chatRecordTable);
  41. tempListData.forEach(el => {
  42. el.createdOn = $util.formatTime(new Date(el.createdOn), true);
  43. if (typeof el.type == 'string') {
  44. el.type = el.type.split(',');
  45. }
  46. })
  47. // 设置总数
  48. this.setData({
  49. msgData: tempListData,
  50. total: datas.total,
  51. })
  52. // 如果数据大于了返回的总数
  53. if (tempListData.length >= this.data.total) {
  54. // 停止累加数据
  55. this.setData({
  56. onRefresh: false,
  57. itemLoading: false,
  58. })
  59. } else {
  60. this.setData({
  61. onRefresh: true,
  62. itemLoading: false,
  63. page: page + 1
  64. })
  65. }
  66. console.log('-------------消息 beg-------------------')
  67. console.log(this.data.msgData);
  68. console.log('-------------消息 end-------------------')
  69. }
  70. this.setData({
  71. pageLoading: false,
  72. })
  73. }).catch(error => {
  74. console.log(error, 'error appletLogin')
  75. })
  76. },
  77. /**
  78. * 页面上拉触底事件的处理函数
  79. */
  80. onReachBottom: function () {
  81. if (this.data.onRefresh) {
  82. this.setData({
  83. itemLoading: true
  84. })
  85. this.getListData();
  86. }
  87. },
  88. })