collage-details.js 4.5 KB

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