collage-details.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. debugger;
  60. wx.setNavigationBarTitle({
  61. title: '拼团详情'
  62. })
  63. console.log(options.orderId);
  64. if(!options.orderId) {
  65. return false;
  66. }
  67. const orderId = options.orderId ? options.orderId : options.scene.replace('QR', '');
  68. this.setData({
  69. orderId
  70. })
  71. httpRequestApi.getMygroupInfo(orderId).success( res => {
  72. console.log('支付详情', res.data.data);
  73. const surplusNum = res.data.data.groupPurchaseOrder.headcount - res.data.data.groupPurchaseOrder.joinCount;
  74. for(var i = 0; i < surplusNum; i++) {
  75. this.data.surplusList.push(1);
  76. }
  77. //console.log(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified)
  78. //时间转换
  79. const timeList = util.formatTime(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified);
  80. this.setData({
  81. groupPurchaseInfo: res.data.data.groupPurchaseInfo,
  82. organizer: res.data.data.organizer,
  83. surplusNum,
  84. joinUserList: res.data.data.joinUserList,
  85. surplusList: this.data.surplusList,
  86. timeList,
  87. productId: res.data.data.groupPurchaseOrder.productId,
  88. groupId: res.data.data.groupPurchaseOrder.groupId
  89. })
  90. }).fail( error => {
  91. console.log('错误', error)
  92. })
  93. },
  94. /**
  95. * 生命周期函数--监听页面初次渲染完成
  96. */
  97. onReady: function () {
  98. this.shareDialog = this.selectComponent("#share-dialog");
  99. },
  100. /**
  101. * 生命周期函数--监听页面显示
  102. */
  103. onShow: function () {
  104. },
  105. /**
  106. * 生命周期函数--监听页面隐藏
  107. */
  108. onHide: function () {
  109. },
  110. /**
  111. * 生命周期函数--监听页面卸载
  112. */
  113. onUnload: function () {
  114. },
  115. /**
  116. * 页面相关事件处理函数--监听用户下拉动作
  117. */
  118. onPullDownRefresh: function () {
  119. },
  120. /**
  121. * 页面上拉触底事件的处理函数
  122. */
  123. onReachBottom: function () {
  124. },
  125. /**
  126. * 用户点击右上角分享
  127. */
  128. onShareAppMessage: function (ops) {
  129. if (ops.from === 'button') {
  130. console.log(ops.target)
  131. }
  132. const productId = this.data.productId;
  133. const groupId = this.data.groupId;
  134. const id = this.data.orderId;
  135. return {
  136. title: '小学课文朗读',
  137. path: `pages/groupPage/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`,
  138. imageUrl: '../../../static/groupImg/shareBg.png',
  139. success: function (res) {
  140. // 转发成功
  141. console.log("转发成功:" + JSON.stringify(res));
  142. var shareTickets = res.shareTickets;
  143. // if (shareTickets.length == 0) {
  144. // return false;
  145. // }
  146. // //可以获取群组信息
  147. // wx.getShareInfo({
  148. // shareTicket: shareTickets[0],
  149. // success: function (res) {
  150. // console.log(res)
  151. // }
  152. // })
  153. },
  154. fail: function (res) {
  155. // 转发失败
  156. console.log("转发失败:" + JSON.stringify(res));
  157. }
  158. }
  159. }
  160. })