index.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. const app = getApp()
  2. Page({
  3. data: {
  4. logo: "",
  5. user: {},
  6. searchInfo: {},
  7. list: [],
  8. total: 0,
  9. page: 0,
  10. skip: 0,
  11. limit: 5,
  12. },
  13. toPath(e) {
  14. let data = e.detail;
  15. let url = `/${data.route}`;
  16. if (data.type == '0') wx.navigateTo({ url })
  17. else if (data.type == '1') wx.redirectTo({ url })
  18. else if (data.type == '2') wx.relaunch({ url })
  19. else if (data.type == '3') wx.switchTab({ url })
  20. },
  21. // 查询
  22. async toSearch(e) {
  23. const that = this;
  24. that.setData({ 'searchInfo.name': e.detail.value })
  25. that.clearPage();
  26. that.search()
  27. },
  28. // 查看详情
  29. toView(e) {
  30. const that = this;
  31. if (that.data.user._id) {
  32. const item = e.currentTarget.dataset.item
  33. wx.navigateTo({ url: '/pagesTeam/apply/index?id=' + item._id })
  34. } else {
  35. wx.navigateTo({ url: '/pagesCommon/login/index' })
  36. }
  37. },
  38. /**
  39. * 生命周期函数--监听页面加载
  40. */
  41. async onLoad(options) {
  42. const that = this;
  43. wx.showLoading({ title: '加载中', mask: true })
  44. await that.searchConfig()
  45. await that.searchOther()
  46. await that.clearPage();
  47. await that.search()
  48. wx.hideLoading()
  49. },
  50. async searchConfig() {
  51. const that = this;
  52. wx.getStorage({
  53. key: 'config',
  54. async success(res) {
  55. // logo
  56. if (res.data && res.data.logo_url && res.data.logo_url.length > 0) {
  57. let logo = res.data.logo_url[0].url
  58. that.setData({ logo })
  59. }
  60. },
  61. fail(err) {
  62. console.log(err);
  63. }
  64. })
  65. wx.getStorage({
  66. key: 'token',
  67. async success(res) {
  68. that.setData({ user: res.data })
  69. },
  70. fail(err) {
  71. console.log(err);
  72. }
  73. })
  74. },
  75. // 查询通知
  76. async search() {
  77. const that = this;
  78. let info = { skip: that.data.skip, limit: that.data.limit, status: '1' };
  79. let res = await app.$api('team', 'GET', { ...info, ...that.data.searchInfo })
  80. if (res.errcode == '0') {
  81. let list = [...that.data.list, ...res.data]
  82. // for (const val of list) {
  83. // val.tel = val.phone.substr(0,3) + "****" + val.phone.substr(7)
  84. // }
  85. that.setData({ list })
  86. that.setData({ total: res.total })
  87. }
  88. },
  89. // 分页-触底
  90. toLower() {
  91. const that = this;
  92. let list = that.data.list;
  93. let limit = that.data.limit;
  94. if (that.data.total > list.length) {
  95. wx.showLoading({ title: '加载中', mask: true })
  96. let page = that.data.page + 1;
  97. that.setData({ page })
  98. let skip = page * limit
  99. that.setData({ skip })
  100. that.search()
  101. wx.hideLoading()
  102. } else {
  103. wx.showToast({ title: `到底了没数据了`, icon: 'none' });
  104. }
  105. },
  106. // 分页-滚动
  107. toScroll() {
  108. // console.log('滚动');
  109. },
  110. // 字典
  111. getDict(value, model) {
  112. const that = this;
  113. if (model == 'status') {
  114. if (value) {
  115. let data = that.data.statusList.find(i => i.value == value)
  116. if (data) return data.label
  117. else return '暂无'
  118. }
  119. }
  120. },
  121. // 查询其他信息
  122. async searchOther() {
  123. const that = this;
  124. },
  125. // 清空列表
  126. clearPage() {
  127. const that = this;
  128. that.setData({ list: [] })
  129. that.setData({ skip: 0 })
  130. that.setData({ limit: 5 })
  131. that.setData({ total: 0 })
  132. },
  133. /**
  134. * 生命周期函数--监听页面初次渲染完成
  135. */
  136. onReady() {
  137. },
  138. /**
  139. * 生命周期函数--监听页面显示
  140. */
  141. onShow() {
  142. },
  143. /**
  144. * 生命周期函数--监听页面隐藏
  145. */
  146. onHide() {
  147. },
  148. /**
  149. * 生命周期函数--监听页面卸载
  150. */
  151. onUnload() {
  152. },
  153. /**
  154. * 页面相关事件处理函数--监听用户下拉动作
  155. */
  156. onPullDownRefresh() {
  157. },
  158. /**
  159. * 页面上拉触底事件的处理函数
  160. */
  161. onReachBottom() {
  162. },
  163. /**
  164. * 用户点击右上角分享
  165. */
  166. onShareAppMessage() {
  167. }
  168. })