collage-details.js 5.5 KB

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