make-money.js 3.9 KB

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