myService.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. // pages/my/myService/myService.js
  2. const App = getApp();
  3. const util = require("../../utils/util");
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. tabs: [
  10. {
  11. i: 0,
  12. title: "全部",
  13. },
  14. {
  15. i: 1,
  16. title: "待处理",
  17. },
  18. {
  19. i: 2,
  20. title: "处理中",
  21. },
  22. {
  23. i: 3,
  24. title: "已拒绝",
  25. },
  26. {
  27. i: 4,
  28. title: "已完成",
  29. },
  30. ],
  31. currentTab: 0,
  32. status: 0,
  33. list: [],
  34. queryParams: {
  35. page: 1,
  36. limit: 10,
  37. },
  38. total: 0,
  39. totalPage: 0,
  40. currPage: 0,
  41. nodata: util.nodata(),
  42. },
  43. /**
  44. * 生命周期函数--监听页面加载
  45. */
  46. onLoad(options) {
  47. if (options && options.status) {
  48. this.setData({
  49. status: options.status,
  50. currentTab: options.status
  51. })
  52. }
  53. },
  54. /**
  55. * 生命周期函数--监听页面初次渲染完成
  56. */
  57. onReady() {},
  58. /**
  59. * 生命周期函数--监听页面显示
  60. */
  61. onShow() {
  62. this.init();
  63. },
  64. tabChange(e) {
  65. console.log(e);
  66. if (e.currentTarget.dataset.index == this.data.currentTab) {
  67. return;
  68. }
  69. this.setData({
  70. currentTab: e.currentTarget.dataset.index,
  71. status: e.currentTarget.dataset.index,
  72. total: 0,
  73. totalPage: 0,
  74. currPage: 0,
  75. });
  76. this.init();
  77. },
  78. init() {
  79. this.setData({
  80. list: [],
  81. queryParams: {
  82. page: 1,
  83. limit: 10,
  84. },
  85. });
  86. this.getList();
  87. },
  88. // 获取列表数据
  89. getList() {
  90. if (this.data.queryParams.page > 1) {
  91. if (this.data.total > 0 && this.data.currPage == this.data.totalPage) {
  92. wx.showToast({
  93. title: "没有更多了~",
  94. icon: "none",
  95. });
  96. return false;
  97. }
  98. }
  99. wx.showLoading({
  100. title: "努力加载中...",
  101. });
  102. App._get(
  103. "expert_workbench/myServicePage",
  104. {
  105. ...this.data.queryParams,
  106. status: this.data.status,
  107. memberId: util.getUserId(),
  108. },
  109. (res) => {
  110. if (res.code === 0) {
  111. this.setData({
  112. list: [...this.data.list, ...res.page.list],
  113. total: res.page.totalCount,
  114. totalPage: res.page.totalPage,
  115. currPage: res.page.currPage,
  116. });
  117. wx.hideLoading();
  118. }
  119. },
  120. (err) => {
  121. wx.showToast({
  122. icon: 'error',
  123. title: '服务端异常',
  124. })
  125. },
  126. (complete) => {}
  127. );
  128. },
  129. toServiceDetail(e) {
  130. wx.navigateTo({
  131. url:
  132. "/workbench/service/service?meetId=" + e.currentTarget.dataset.meetid,
  133. });
  134. },
  135. /**
  136. * 生命周期函数--监听页面隐藏
  137. */
  138. onHide() {},
  139. /**
  140. * 生命周期函数--监听页面卸载
  141. */
  142. onUnload() {},
  143. /**
  144. * 页面相关事件处理函数--监听用户下拉动作
  145. */
  146. onPullDownRefresh() {},
  147. /**
  148. * 页面上拉触底事件的处理函数
  149. */
  150. onReachBottom() {
  151. this.setData({
  152. queryParams: {
  153. page: ++this.data.queryParams.page,
  154. limit: 10,
  155. },
  156. });
  157. this.getList();
  158. },
  159. /**
  160. * 用户点击右上角分享
  161. */
  162. onShareAppMessage() {},
  163. });