collage-details.js 5.2 KB

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