collage-details.js 5.1 KB

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