invitationDetails.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. // pages/invitationDetails/invitationDetails.js
  2. import {
  3. get,
  4. } from '../../utils/http';
  5. import {
  6. trackUserEvent
  7. } from '../../utils/util'
  8. const app = getApp()
  9. /**
  10. * 数据上报-邀请者枚举类型
  11. */
  12. const XEnum_Inviter_Type = 7
  13. Page({
  14. /**
  15. * 页面的初始数据
  16. */
  17. data: {
  18. call_team: [
  19. ],
  20. steps: [],
  21. active: -1,
  22. show: false,
  23. activity_time: '',
  24. page: 1,
  25. limit: 10,
  26. loading: false,
  27. finished: false,
  28. total:0,//已邀请的人数
  29. experienceList:['【舒敏修复】华熙生物智慧舒敏修复','【祛黄提亮】华熙智慧水光肌提亮祛黄','【无创水光】华熙生物真皮层补水','【清痘消炎】痘痘清理痘肌消炎','【紧致嫩肤】华熙智慧紧致提拉嫩肤'],//免费体验列表
  30. },
  31. /**
  32. * 生命周期函数--监听页面加载
  33. */
  34. onLoad() {
  35. this.getInvite()
  36. this.scrollToLower()
  37. // "shareAppMessage"表示“发送给朋友”按钮,"shareTimeline"表示“分享到朋友圈”按钮
  38. wx.showShareMenu({
  39. menus: ['shareAppMessage', 'shareTimeline'],
  40. // 需要显示的转发按钮名称列表.合法值包含 "shareAppMessage"、"shareTimeline"
  41. success(res) {
  42. console.log(res);
  43. },
  44. fail(e) {
  45. console.log(e);
  46. }
  47. });
  48. },
  49. onOpenShow() {
  50. this.setData({
  51. show: true
  52. });
  53. },
  54. onClose() {
  55. this.setData({
  56. show: false
  57. })
  58. },
  59. onShareFriends () {
  60. trackUserEvent(XEnum_Inviter_Type)
  61. },
  62. onMoments() {
  63. wx.navigateTo({
  64. url: `/pages/invitationDetails/poster/poster`,
  65. })
  66. },
  67. /**
  68. * 邀请活动主页
  69. * /api/invite
  70. */
  71. getInvite() {
  72. get('/api/invite', {}, (res) => {
  73. console.log(res);
  74. this.setData({
  75. activity_time: res.data.activity_time
  76. })
  77. let array = []
  78. res.data.progress_list.forEach((item, index) => {
  79. let obj = {}
  80. let init = {
  81. // value_1: '(价值',
  82. // value_2: ')',
  83. greyText_1: '成功解锁',
  84. greyText_2: `,可获得${item.product_name}一次`
  85. }
  86. obj["text"] = item.product_name
  87. // obj["price"] = `¥${item.price}`
  88. obj["redText"] = `${item.require_num.require_num}人`
  89. obj["status"] = item.status
  90. let obj_info = {
  91. ...obj,
  92. ...init
  93. }
  94. array.push(obj_info)
  95. if (item.status == 1) {
  96. this.setData({
  97. active: index
  98. })
  99. }
  100. })
  101. getApp().invite_id = res.data.qrcode_content
  102. this.setData({
  103. steps: array,
  104. })
  105. })
  106. },
  107. /**
  108. * 获取已邀请的列表
  109. * /api/invite/list
  110. */
  111. scrollToLower() {
  112. if (!this.data.finished && !this.data.loading) {
  113. this.setData({
  114. loading: true
  115. })
  116. setTimeout(() => {
  117. get('/api/invite/list', {
  118. page: this.data.page,
  119. limit: this.data.limit
  120. }, (res) => {
  121. this.setData({
  122. loading: false,
  123. total:res.data.total,
  124. page: this.data.page + 1
  125. })
  126. let arr = []
  127. arr = [...res.data.list, ...this.data.call_team]
  128. console.log(arr,'arrarr');
  129. this.setData({
  130. call_team:arr
  131. })
  132. if (res.data.list.length < 10) {
  133. this.setData({
  134. finished: true
  135. })
  136. }
  137. })
  138. }, 1000)
  139. }
  140. },
  141. onShareAppMessage() {
  142. return {
  143. title: '朋友送你的0元修丽可B5补水还未领取,点击去领取~', // 分享出的卡片标题
  144. path: `pages/invitees/invitees?invite_id=${app.globalData.userInfo.uid}`, // 他人通过卡片进入小程序的路径,可以在后面拼接URL的形式带参数
  145. imageUrl: 'https://we-spa.oss-cn-shenzhen.aliyuncs.com/wxapp/20220811/%E4%BA%8C%E5%9B%BE/%E5%9B%BE%E7%89%87/%E7%BC%96%E7%BB%84%203%402x.png',
  146. };
  147. },
  148. onShareTimeline() {
  149. return {
  150. title: '送你一份修丽可无创水光项目,一起变美丽吧',
  151. path: `pages/invitees/invitees?invite_id=${app.globalData.userInfo.uid}`,
  152. imageUrl: 'https://we-spa.oss-cn-shenzhen.aliyuncs.com/wxapp/20220413/%E9%82%80%E8%AF%B7%E8%80%85%E5%88%86%E4%BA%AB%E6%9C%8B%E5%8F%8B%E5%9C%88%E6%B5%B7%E6%8A%A5%402x%20%282%29.png',
  153. };
  154. },
  155. /**
  156. * 生命周期函数--监听页面初次渲染完成
  157. */
  158. onReady() {
  159. },
  160. /**
  161. * 生命周期函数--监听页面显示
  162. */
  163. onShow() {
  164. },
  165. /**
  166. * 生命周期函数--监听页面隐藏
  167. */
  168. onHide() {
  169. },
  170. /**
  171. * 生命周期函数--监听页面卸载
  172. */
  173. onUnload() {
  174. },
  175. /**
  176. * 页面相关事件处理函数--监听用户下拉动作
  177. */
  178. onPullDownRefresh() {
  179. },
  180. /**
  181. * 页面上拉触底事件的处理函数
  182. */
  183. onReachBottom() {
  184. },
  185. closeShow() {
  186. this.setData({
  187. show: false
  188. })
  189. }
  190. })