meeting-list.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. // pages/meeting-list/meeting-list.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. type: ''
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. let that = this;
  19. that.setData({
  20. type: options.type
  21. });
  22. util.get({
  23. url: '/api/meeting/info/list',
  24. data: {
  25. current: that.data.current,
  26. size: that.data.size
  27. },
  28. success: function (res) {
  29. wx.hideLoading();
  30. if (res.data.code != 200) {
  31. util.toast(res.data.msg);
  32. } else {
  33. that.setData({
  34. total: res.data.data.total,
  35. list: res.data.data.records
  36. });
  37. }
  38. }
  39. });
  40. },
  41. /**
  42. * 生命周期函数--监听页面初次渲染完成
  43. */
  44. onReady: function () {
  45. },
  46. /**
  47. * 生命周期函数--监听页面显示
  48. */
  49. onShow: function () {
  50. },
  51. /**
  52. * 生命周期函数--监听页面隐藏
  53. */
  54. onHide: function () {
  55. },
  56. /**
  57. * 生命周期函数--监听页面卸载
  58. */
  59. onUnload: function () {
  60. },
  61. /**
  62. * 页面相关事件处理函数--监听用户下拉动作
  63. */
  64. onPullDownRefresh: function () {
  65. let that = this;
  66. that.setData({
  67. current: 1,
  68. list: []
  69. });
  70. util.get({
  71. url: '/api/meeting/info/list',
  72. data: {
  73. current: that.data.current,
  74. size: that.data.size
  75. },
  76. success: (res) => {
  77. wx.hideLoading();
  78. wx.stopPullDownRefresh();
  79. if (res.data.code != 200) {
  80. util.toast(res.data.msg);
  81. } else {
  82. that.setData({
  83. total: res.data.data.total,
  84. list: res.data.data.records
  85. });
  86. }
  87. }
  88. });
  89. },
  90. /**
  91. * 页面上拉触底事件的处理函数
  92. */
  93. onReachBottom: function () {
  94. let that = this;
  95. let arr = that.data.list;
  96. let page = that.data.current;
  97. if (arr.length >= that.data.total) {
  98. util.toast('没有更多数据了');
  99. return;
  100. }
  101. that.setData({
  102. current: ++page
  103. });
  104. util.get({
  105. url: '/api/meeting/info/list',
  106. data: {
  107. current: that.data.current,
  108. size: that.data.size
  109. },
  110. success: (res) => {
  111. wx.hideLoading();
  112. wx.stopPullDownRefresh();
  113. console.info(res);
  114. if (res.data.code != 200) {
  115. util.toast(res.data.msg);
  116. } else {
  117. let list = res.data.data.records;
  118. that.setData({
  119. list: arr.concat(list)
  120. });
  121. }
  122. }
  123. });
  124. },
  125. /**
  126. * 用户点击右上角分享
  127. */
  128. onShareAppMessage: function () {
  129. },
  130. /**
  131. * 点击跳转到会议封面页面
  132. * @param {*} e
  133. */
  134. meetingCover: function (e) {
  135. let that = this;
  136. let item = e.currentTarget.dataset.item;
  137. if ('INSPECTION' == that.data.type) {
  138. if (item.status == 20) {
  139. util.toast('会议已结束');
  140. } else {
  141. wx.navigateTo({
  142. url: '../meeting-inspection/meeting-inspection?templetId=' + item.inspectionTemplateId + '&meetingId=' + item.id,
  143. });
  144. }
  145. } else {
  146. wx.navigateTo({
  147. url: '../meeting-cover/meeting-cover?id=' + item.id,
  148. });
  149. }
  150. },
  151. /**
  152. * 编辑会议
  153. * @param {*} e
  154. */
  155. editMeeting: function (e) {
  156. },
  157. /**
  158. * 删除会议
  159. * @param {*} e
  160. */
  161. delMeeting: function (e) {
  162. console.info(e);
  163. let that = this;
  164. util.post({
  165. url: '/api/meeting/info/deleteById',
  166. data: {
  167. id: e.target.dataset.id
  168. },
  169. header: {
  170. 'Content-Type': 'application/x-www-form-urlencoded'
  171. },
  172. success: (res) => {
  173. console.info(res);
  174. if (res.data.code != 200) {
  175. util.toast(res.data.msg);
  176. } else {
  177. util.toast(res.data.msg, 'success');
  178. that.onPullDownRefresh();
  179. }
  180. }
  181. });
  182. }
  183. })