myInvite.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. let list = res.page.list.map(v => {
  91. v.inputtime = v.inputtime.slice(0, 10);
  92. return v;
  93. })
  94. this.setData({
  95. list: list || [],
  96. page: {
  97. total: res.page.totalCount,
  98. currPage: res.page.currPage,
  99. totalPage: res.page.totalPage
  100. }
  101. })
  102. }
  103. }, err => {}, complete => {
  104. setTimeout(() => {
  105. wx.hideLoading()
  106. }, 500)
  107. })
  108. },
  109. getDetail() {
  110. App._get('myInvitation/myInvitationStatistics', {
  111. id: this.data.user.id,
  112. myInvitationType: this.data.currentTab
  113. }, res => {
  114. if (res.code === 0) {
  115. this.setData({
  116. detail: res.data
  117. })
  118. }
  119. }, err => {}, complete => {})
  120. },
  121. bindPickerChange(e) {
  122. console.log('picker发送选择改变,携带值为', e.detail.value)
  123. this.setData({
  124. currentTab: e.detail.value
  125. })
  126. this.setData({
  127. queryParams: {
  128. page: 1,
  129. limit: 10
  130. }
  131. })
  132. this.getList()
  133. this.getDetail()
  134. },
  135. /**
  136. * 生命周期函数--监听页面隐藏
  137. */
  138. onHide() {
  139. },
  140. /**
  141. * 生命周期函数--监听页面卸载
  142. */
  143. onUnload() {
  144. },
  145. /**
  146. * 页面相关事件处理函数--监听用户下拉动作
  147. */
  148. onPullDownRefresh() {
  149. },
  150. /**
  151. * 页面上拉触底事件的处理函数
  152. */
  153. onReachBottom() {
  154. this.setData({
  155. queryParams: {
  156. page: ++this.data.queryParams,
  157. limit: 10
  158. }
  159. })
  160. this.getList()
  161. this.getDetail()
  162. },
  163. /**
  164. * 用户点击右上角分享
  165. */
  166. onShareAppMessage() {
  167. }
  168. })