collage-details.js 4.5 KB

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