help.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // pages/user/help.js
  2. import api from '../../utils/api'
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. tabIndex: 1,
  9. result: {
  10. list: []
  11. },
  12. params: {
  13. page: 1,
  14. offset: 10
  15. },
  16. showList: [],
  17. rotateList: [],
  18. qrCode: ''
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. this.getList()
  25. // this.getContactInfo()
  26. },
  27. /**
  28. * 生命周期函数--监听页面初次渲染完成
  29. */
  30. onReady: function () {
  31. },
  32. /**
  33. * 生命周期函数--监听页面显示
  34. */
  35. onShow: function () {
  36. },
  37. /**
  38. * 生命周期函数--监听页面隐藏
  39. */
  40. onHide: function () {
  41. },
  42. /**
  43. * 生命周期函数--监听页面卸载
  44. */
  45. onUnload: function () {
  46. },
  47. /**
  48. * 页面相关事件处理函数--监听用户下拉动作
  49. */
  50. onPullDownRefresh: function () {
  51. let { tabIndex, result, params } = this.data
  52. // 重置数据和参数
  53. result[tabIndex] = {
  54. list: []
  55. }
  56. params[tabIndex].page = 1
  57. this.setData({
  58. result,
  59. params
  60. })
  61. // 请求新数据
  62. this.getList()
  63. wx.stopPullDownRefresh()
  64. },
  65. /**
  66. * 页面上拉触底事件的处理函数
  67. */
  68. onReachBottom: function () {
  69. this.getList()
  70. },
  71. slideHelp: function (e) {
  72. let { showList, rotateList } = this.data
  73. let index = +e.currentTarget.dataset.index
  74. showList[index] = !showList[index]
  75. rotateList[index] = showList[index]
  76. this.setData({
  77. showList,
  78. rotateList
  79. })
  80. setTimeout(() => {
  81. rotateList[index] = false
  82. this.setData({
  83. rotateList
  84. })
  85. }, 500)
  86. },
  87. getList: function () {
  88. let { params, result } = this.data
  89. if (result.count <= (params.page - 1) * params.offset) {
  90. return false
  91. }
  92. api.getHelpList(params).then(res => {
  93. params.page++
  94. res.data.list = [
  95. ...result.list,
  96. ...res.data.list
  97. ]
  98. result = res.data
  99. this.setData({
  100. params,
  101. result
  102. })
  103. })
  104. },
  105. tabChange: function (e) {
  106. let index = +e.currentTarget.dataset.index
  107. this.setData({
  108. tabIndex: index
  109. })
  110. if (!index && !this.data.result.list.length) {
  111. this.getList()
  112. }
  113. },
  114. getContactInfo: function (e) {
  115. if (!this.data.qrCode) {
  116. api.getWithdrawTips().then(res => {
  117. if (res.code === 200) {
  118. this.setData({
  119. qrCode: res.data.image
  120. })
  121. }
  122. })
  123. }
  124. },
  125. copyQQ: function (e) {
  126. wx.setClipboardData({
  127. data: e.currentTarget.dataset.qq,
  128. success: function () {
  129. wx.showToast({
  130. title: 'QQ已复制'
  131. })
  132. }
  133. })
  134. },
  135. onShareAppMessage: function () {
  136. let { shareinfo, state, mem_id } = app.globalData.userInfo
  137. return {
  138. path: `/pages/share/share?state=${state}&mem_id=${mem_id}`
  139. }
  140. }
  141. })