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