meeting-inspection-history.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // pages/meeting-inspection-history/meeting-inspection-history.js
  2. const util = require('../../utils/util.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. current: 1,
  9. size: 10,
  10. total: 0,
  11. list: []
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. let that = this;
  18. util.get({
  19. url: '/api/inspection/record/list',
  20. data: {
  21. current: that.data.current,
  22. size: that.data.size
  23. },
  24. success: function (res) {
  25. console.info(res)
  26. wx.hideLoading();
  27. if (res.data.code != 200) {
  28. util.toast(res.data.msg);
  29. } else {
  30. that.setData({
  31. total: res.data.data.total,
  32. list: res.data.data.records
  33. });
  34. }
  35. }
  36. });
  37. },
  38. /**
  39. * 生命周期函数--监听页面初次渲染完成
  40. */
  41. onReady: function () {
  42. },
  43. /**
  44. * 生命周期函数--监听页面显示
  45. */
  46. onShow: function () {
  47. },
  48. /**
  49. * 生命周期函数--监听页面隐藏
  50. */
  51. onHide: function () {
  52. },
  53. /**
  54. * 生命周期函数--监听页面卸载
  55. */
  56. onUnload: function () {
  57. },
  58. /**
  59. * 页面相关事件处理函数--监听用户下拉动作
  60. */
  61. onPullDownRefresh: function () {
  62. let that = this;
  63. that.setData({
  64. current: 1,
  65. list: []
  66. });
  67. util.get({
  68. url: '/api/inspection/record/list',
  69. data: {
  70. current: that.data.current,
  71. size: that.data.size
  72. },
  73. success: (res) => {
  74. wx.hideLoading();
  75. wx.stopPullDownRefresh();
  76. if (res.data.code != 200) {
  77. util.toast(res.data.msg);
  78. } else {
  79. that.setData({
  80. total: res.data.data.total,
  81. list: res.data.data.records
  82. });
  83. }
  84. }
  85. });
  86. },
  87. /**
  88. * 页面上拉触底事件的处理函数
  89. */
  90. onReachBottom: function () {
  91. let that = this;
  92. let arr = that.data.list;
  93. let page = that.data.current;
  94. if (arr.length >= that.data.total) {
  95. util.toast('没有更多数据了');
  96. return;
  97. }
  98. that.setData({
  99. current: ++page
  100. });
  101. util.get({
  102. url: '/api/inspection/record/list',
  103. data: {
  104. current: that.data.current,
  105. size: that.data.size
  106. },
  107. success: (res) => {
  108. wx.hideLoading();
  109. wx.stopPullDownRefresh();
  110. console.info(res);
  111. if (res.data.code != 200) {
  112. util.toast(res.data.msg);
  113. } else {
  114. let list = res.data.data.records;
  115. that.setData({
  116. list: arr.concat(list)
  117. });
  118. }
  119. }
  120. });
  121. },
  122. /**
  123. * 用户点击右上角分享
  124. */
  125. onShareAppMessage: function () {
  126. },
  127. /**
  128. * 查看详情
  129. * @param {*} e
  130. */
  131. openDetail: function (e) {
  132. wx.navigateTo({
  133. url: '../meeting-inspection-history-detail/meeting-inspection-history-detail?id='+e.currentTarget.dataset.id,
  134. });
  135. }
  136. })