collage-details.js 5.1 KB

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