index.js 4.5 KB

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