collage-details.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. },
  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 (app.globalData.isIOS) {
  64. wx.redirectTo({
  65. url: '../../index/index'
  66. })
  67. return
  68. }
  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);
  79. console.log(options.orderId);
  80. const orderId = options.orderId ? options.orderId : options.scene.replace('QR', '');
  81. if (options.orderId) {
  82. return false;
  83. }
  84. console.log(orderId)
  85. this.setData({
  86. orderId
  87. })
  88. httpRequestApi.getMygroupInfo(orderId).success(res => {
  89. console.log(res);
  90. const groupOrder = res.data.data.groupPurchaseOrder;
  91. const surplusNum = groupOrder.headcount - groupOrder.joinCount;
  92. this.setData({
  93. organizerUid: groupOrder.organizer,
  94. })
  95. for (var i = 0; i < surplusNum; i++) {
  96. this.data.surplusList.push(1);
  97. }
  98. //console.log(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified)
  99. //时间转换
  100. const timeList = util.formatTime(groupOrder.closeTime - Date.parse(new Date()));
  101. console.log(timeList)
  102. //res.data.data.joinUserList.unshift(res.data.data.organizer);
  103. this.setData({
  104. groupPurchaseInfo: res.data.data.groupPurchaseInfo,
  105. organizer: res.data.data.organizer,
  106. surplusNum,
  107. joinUserList: res.data.data.joinUserList,
  108. surplusList: this.data.surplusList,
  109. timeList,
  110. productId: groupOrder.productId,
  111. groupId: groupOrder.groupId
  112. })
  113. if (groupOrder.groupType === 'PROMOTION') {
  114. //this.data.joinUserList.unshift(res.data.data.organizer);
  115. this.setData({
  116. colonelName: res.data.data.organizer.wechatName
  117. })
  118. this.setData({
  119. joinUserList: this.data.joinUserList,
  120. })
  121. }
  122. }).fail(error => {
  123. console.log('错误', error)
  124. })
  125. },
  126. /**
  127. * 生命周期函数--监听页面初次渲染完成
  128. */
  129. onReady: function () {
  130. this.shareDialog = this.selectComponent("#share-dialog");
  131. },
  132. /**
  133. * 生命周期函数--监听页面显示
  134. */
  135. onShow: function () {
  136. },
  137. /**
  138. * 生命周期函数--监听页面隐藏
  139. */
  140. onHide: function () {
  141. },
  142. /**
  143. * 生命周期函数--监听页面卸载
  144. */
  145. onUnload: function () {
  146. },
  147. /**
  148. * 页面相关事件处理函数--监听用户下拉动作
  149. */
  150. onPullDownRefresh: function () {
  151. },
  152. /**
  153. * 页面上拉触底事件的处理函数
  154. */
  155. onReachBottom: function () {
  156. },
  157. /**
  158. * 用户点击右上角分享
  159. */
  160. onShareAppMessage: function (ops) {
  161. if (ops.from === 'button') {
  162. console.log(ops.target)
  163. }
  164. const productId = this.data.productId;
  165. const groupId = this.data.groupId;
  166. const id = this.data.orderId;
  167. return {
  168. title: '老师同学都在玩的配音show,你还在等什么?',
  169. path: `pages/groupPage/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`,
  170. imageUrl: '../../../static/share/group_icon.jpg',
  171. success: function (res) {
  172. // 转发成功
  173. console.log("转发成功:" + JSON.stringify(res));
  174. var shareTickets = res.shareTickets;
  175. // if (shareTickets.length == 0) {
  176. // return false;
  177. // }
  178. // //可以获取群组信息
  179. // wx.getShareInfo({
  180. // shareTicket: shareTickets[0],
  181. // success: function (res) {
  182. // console.log(res)
  183. // }
  184. // })
  185. },
  186. fail: function (res) {
  187. // 转发失败
  188. console.log("转发失败:" + JSON.stringify(res));
  189. }
  190. }
  191. }
  192. })