make-money.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. // pages/groupPage/make-money/make-money.js
  2. import httpRequestApi from '../../../utils/APIClient';
  3. import util from '../../../utils/util';
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. organizer: {},
  11. groupPurchaseInfo: {},
  12. joinUserList: [],
  13. surplusList: [],
  14. timeList: [],
  15. productId: '',
  16. orderId: '',
  17. groupId: '',
  18. organizerUid: '',
  19. orderList: {}
  20. },
  21. //显示分享页
  22. share: function () {
  23. this.shareDialog = this.selectComponent("#share-dialog");
  24. const data = {
  25. avatar: this.data.organizer.avatar,
  26. author: this.data.organizer.wechatName,
  27. iconImg: this.data.groupPurchaseInfo.bgImg,
  28. title: this.data.groupPurchaseInfo.productTitle,
  29. path: `pages/groupPage/collage-details/collage-details`,
  30. scene: `QR${this.data.orderId}`,
  31. groupPurchaseInfo: this.data.groupPurchaseInfo
  32. }
  33. this.shareDialog.share(data);
  34. },
  35. /**
  36. * 生命周期函数--监听页面加载
  37. */
  38. onLoad: function (options) {
  39. // if (app.globalData.isIOS) {
  40. // wx.redirectTo({
  41. // url: '../../index/index'
  42. // })
  43. // return
  44. // }
  45. wx.setNavigationBarTitle({
  46. title: '邀请赚取奖学金'
  47. })
  48. console.log(options.id);
  49. if(!options.id) {
  50. return false;
  51. }
  52. const orderId = options.id;
  53. const productId = options.productId;
  54. const groupId = options.groupId;
  55. this.setData({
  56. orderId,
  57. productId,
  58. groupId
  59. })
  60. httpRequestApi.getMygroupInfo(orderId).success( res => {
  61. console.log('支付详情', res.data.data);
  62. const groupOrder = res.data.data.groupPurchaseOrder;
  63. const surplusNum = groupOrder.headcount - groupOrder.joinCount;
  64. this.setData({
  65. organizerUid: groupOrder.organizer,
  66. orderList: res.data.data
  67. })
  68. for(var i = 0; i < surplusNum; i++) {
  69. this.data.surplusList.push(1);
  70. }
  71. //时间转换
  72. const timeList = util.formatTime(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified);
  73. this.setData({
  74. groupPurchaseInfo: res.data.data.groupPurchaseInfo,
  75. organizer: res.data.data.organizer,
  76. surplusNum,
  77. joinUserList: res.data.data.joinUserList,
  78. surplusList: this.data.surplusList,
  79. timeList,
  80. productId: res.data.data.groupPurchaseOrder.productId,
  81. groupId: res.data.data.groupPurchaseOrder.groupId
  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: '老师同学都在玩的配音show,你还在等什么?',
  129. path: `pages/groupPage/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`,
  130. imageUrl: '../../../static/share/group_icon.jpg',
  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. })