myInvite.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. // pages/my/myInvite/myInvite.js
  2. const App = getApp()
  3. const util = require('../../../utils/util')
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. array: [{
  10. label: '全部',
  11. i: '0'
  12. },
  13. {
  14. label: '今天',
  15. i: '1'
  16. },
  17. {
  18. label: '本周',
  19. i: '2'
  20. },
  21. {
  22. label: '本月',
  23. i: '3'
  24. },
  25. {
  26. label: '今年',
  27. i: '4'
  28. }
  29. ],
  30. currentTab: 0,
  31. queryParams: {
  32. page: 1,
  33. limit: 10
  34. },
  35. list: [],
  36. page: {
  37. total: null,
  38. currPage: null,
  39. totalPage: null,
  40. },
  41. detail: {},
  42. headerHeight: 0,
  43. user: wx.getStorageSync('USER'),
  44. nodata: util.nodata(),
  45. },
  46. /**
  47. * 生命周期函数--监听页面加载
  48. */
  49. onLoad(options) {
  50. this.getList()
  51. this.getDetail()
  52. },
  53. /**
  54. * 生命周期函数--监听页面初次渲染完成
  55. */
  56. onReady() {
  57. const query = wx.createSelectorQuery()
  58. query.select('#header').boundingClientRect()
  59. query.exec((res) => {
  60. console.log(res, 11111)
  61. this.setData({
  62. headerHeight: res[0].height
  63. })
  64. })
  65. },
  66. /**
  67. * 生命周期函数--监听页面显示
  68. */
  69. onShow() {
  70. },
  71. getList() {
  72. if (this.data.queryParams.page > 1) {
  73. if (this.data.page.currPage == this.data.page.totalPage) {
  74. wx.showToast({
  75. icon: 'none',
  76. title: '没有更多哦~',
  77. })
  78. return false
  79. }
  80. }
  81. wx.showLoading({
  82. title: '努力加载中...',
  83. })
  84. App._get('myInvitation/myInvitationPage', {
  85. ...this.data.queryParams,
  86. id: this.data.user.id,
  87. myInvitationType: this.data.currentTab
  88. }, res => {
  89. if (res.code === 0) {
  90. this.setData({
  91. list: res.page.list,
  92. page: {
  93. total: res.page.totalCount,
  94. currPage: res.page.currPage,
  95. totalPage: res.page.totalPage
  96. }
  97. })
  98. }
  99. }, err => {}, complete => {
  100. setTimeout(() => {
  101. wx.hideLoading()
  102. }, 500)
  103. })
  104. },
  105. getDetail() {
  106. App._get('myInvitation/myInvitationStatistics', {
  107. id: this.data.user.id,
  108. myInvitationType: this.data.currentTab
  109. }, res => {
  110. if (res.code === 0) {
  111. this.setData({
  112. detail: res.data
  113. })
  114. }
  115. }, err => {}, complete => {})
  116. },
  117. bindPickerChange(e) {
  118. console.log('picker发送选择改变,携带值为', e.detail.value)
  119. this.setData({
  120. currentTab: e.detail.value
  121. })
  122. this.setData({
  123. queryParams: {
  124. page: 1,
  125. limit: 10
  126. }
  127. })
  128. this.getList()
  129. this.getDetail()
  130. },
  131. /**
  132. * 生命周期函数--监听页面隐藏
  133. */
  134. onHide() {
  135. },
  136. /**
  137. * 生命周期函数--监听页面卸载
  138. */
  139. onUnload() {
  140. },
  141. /**
  142. * 页面相关事件处理函数--监听用户下拉动作
  143. */
  144. onPullDownRefresh() {
  145. },
  146. /**
  147. * 页面上拉触底事件的处理函数
  148. */
  149. onReachBottom() {
  150. this.setData({
  151. queryParams: {
  152. page: ++this.data.queryParams,
  153. limit: 10
  154. }
  155. })
  156. this.getList()
  157. this.getDetail()
  158. },
  159. /**
  160. * 用户点击右上角分享
  161. */
  162. onShareAppMessage() {
  163. }
  164. })