make-money.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. // pages/groupPage/make-money/make-money.js
  2. import httpRequestApi from '../../../utils/APIClient';
  3. import util from '../../../utils/util';
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. organizer: {},
  10. groupPurchaseInfo: {},
  11. joinUserList: [],
  12. surplusList: [],
  13. timeList: [],
  14. productId: '',
  15. orderId: '',
  16. groupId: '',
  17. organizerUid: ''
  18. },
  19. //显示分享页
  20. share: function () {
  21. this.shareDialog = this.selectComponent("#share-dialog");
  22. const data = {
  23. avatar: this.data.organizer.avatar,
  24. author: this.data.organizer.wechatName,
  25. iconImg: this.data.groupPurchaseInfo.bgImg,
  26. title: this.data.groupPurchaseInfo.productTitle,
  27. path: `pages/groupPage/collage-details/collage-details`,
  28. scene: `QR${this.data.orderId}`,
  29. groupPurchaseInfo: this.data.groupPurchaseInfo
  30. }
  31. this.shareDialog.share(data);
  32. },
  33. /**
  34. * 生命周期函数--监听页面加载
  35. */
  36. onLoad: function (options) {
  37. wx.setNavigationBarTitle({
  38. title: '邀请赚取奖学金'
  39. })
  40. console.log(options.id);
  41. if(!options.id) {
  42. return false;
  43. }
  44. const orderId = options.id;
  45. const productId = options.productId;
  46. const groupId = options.groupId;
  47. this.setData({
  48. orderId,
  49. productId,
  50. groupId
  51. })
  52. httpRequestApi.getMygroupInfo(orderId).success( res => {
  53. console.log('支付详情', res.data.data);
  54. const groupOrder = res.data.data.groupPurchaseOrder;
  55. const surplusNum = groupOrder.headcount - groupOrder.joinCount;
  56. this.setData({
  57. organizerUid: groupOrder.organizer,
  58. })
  59. for(var i = 0; i < surplusNum; i++) {
  60. this.data.surplusList.push(1);
  61. }
  62. //时间转换
  63. const timeList = util.formatTime(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified);
  64. this.setData({
  65. groupPurchaseInfo: res.data.data.groupPurchaseInfo,
  66. organizer: res.data.data.organizer,
  67. surplusNum,
  68. joinUserList: res.data.data.joinUserList,
  69. surplusList: this.data.surplusList,
  70. timeList,
  71. productId: res.data.data.groupPurchaseOrder.productId,
  72. groupId: res.data.data.groupPurchaseOrder.groupId
  73. })
  74. if(groupOrder.groupType === 'PROMOTION'){
  75. this.data.joinUserList.unshift(res.data.data.organizer);
  76. //this.data.surplusList.pop();
  77. this.setData({
  78. joinUserList: this.data.joinUserList,
  79. //surplusList: this.data.surplusList,
  80. //surplusNum: this.data.surplusNum
  81. })
  82. }
  83. }).fail( error => {
  84. console.log('错误', error)
  85. })
  86. },
  87. /**
  88. * 生命周期函数--监听页面初次渲染完成
  89. */
  90. onReady: function () {
  91. },
  92. /**
  93. * 生命周期函数--监听页面显示
  94. */
  95. onShow: function () {;
  96. },
  97. /**
  98. * 生命周期函数--监听页面隐藏
  99. */
  100. onHide: function () {
  101. },
  102. /**
  103. * 生命周期函数--监听页面卸载
  104. */
  105. onUnload: function () {
  106. },
  107. /**
  108. * 页面相关事件处理函数--监听用户下拉动作
  109. */
  110. onPullDownRefresh: function () {
  111. },
  112. /**
  113. * 页面上拉触底事件的处理函数
  114. */
  115. onReachBottom: function () {
  116. },
  117. /**
  118. * 用户点击右上角分享
  119. */
  120. onShareAppMessage: function () {
  121. if (ops.from === 'button') {
  122. console.log(ops.target)
  123. }
  124. const productId = this.data.productId;
  125. const groupId = this.data.groupId;
  126. const id = this.data.orderId;
  127. return {
  128. title: '小学课文朗读',
  129. path: `pages/groupPage/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`,
  130. imageUrl: '../../../static/groupImg/shareBg.png',
  131. success: function (res) {
  132. // 转发成功
  133. console.log("转发成功:" + JSON.stringify(res));
  134. var shareTickets = res.shareTickets;
  135. // if (shareTickets.length == 0) {
  136. // return false;
  137. // }
  138. // //可以获取群组信息
  139. // wx.getShareInfo({
  140. // shareTicket: shareTickets[0],
  141. // success: function (res) {
  142. // console.log(res)
  143. // }
  144. // })
  145. },
  146. fail: function (res) {
  147. // 转发失败
  148. console.log("转发失败:" + JSON.stringify(res));
  149. }
  150. }
  151. }
  152. })