collage-details.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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: " 您的魅力不是吹的",
  29. color: "#000"
  30. },
  31. {
  32. text: "在限定时间内成功拼团,您将得到奖学金。",
  33. color: "#FF4600"
  34. }
  35. ],
  36. read: false,
  37. organizerUid: '',
  38. colonelName: '',
  39. rewardMoney:'',
  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/group-details/group-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 (app.globalData.isIOS) {
  69. // wx.redirectTo({
  70. // url: '../../index/index'
  71. // })
  72. // return
  73. // }
  74. if (options.read) {
  75. this.setData({
  76. read: options.read
  77. })
  78. }
  79. // options.scene = 'QR1541862338777268';
  80. wx.setNavigationBarTitle({
  81. title: '拼团详情'
  82. })
  83. console.log(options);
  84. console.log(options.orderId);
  85. const orderId = options.orderId ? options.orderId : options.scene.replace('QR', '');
  86. // if (options.orderId) {
  87. // return false;
  88. // }
  89. console.log(orderId)
  90. this.setData({
  91. orderId
  92. })
  93. httpRequestApi.getMygroupInfo(orderId).success(res => {
  94. console.log(res);
  95. const groupOrder = res.data.data.groupPurchaseOrder;
  96. const surplusNum = groupOrder.headcount - groupOrder.joinCount;
  97. this.setData({
  98. organizerUid: groupOrder.organizer,
  99. })
  100. for (var i = 0; i < surplusNum; i++) {
  101. this.data.surplusList.push(1);
  102. }
  103. //console.log(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified)
  104. //时间转换
  105. let timeList = [];
  106. const stillGoing = groupOrder.closeTime - Date.parse(new Date()) <= 0 ? false : true
  107. if(stillGoing){
  108. timeList = util.formatTime(groupOrder.closeTime - Date.parse(new Date()));
  109. }
  110. // const timeList = util.formatTime(groupOrder.closeTime - Date.parse(new Date()));
  111. // console.log(timeList)
  112. //res.data.data.joinUserList.unshift(res.data.data.organizer);
  113. this.setData({
  114. groupPurchaseInfo: res.data.data.groupPurchaseInfo,
  115. organizer: res.data.data.organizer,
  116. surplusNum,
  117. joinUserList: res.data.data.joinUserList,
  118. surplusList: this.data.surplusList,
  119. timeList,
  120. stillGoing,
  121. productId: groupOrder.productId,
  122. groupId: groupOrder.groupId,
  123. rewardMoney: res.data.data.groupPurchaseInfo.organizerPrice / 100
  124. })
  125. if (groupOrder.groupType === 'PROMOTION') {
  126. //this.data.joinUserList.unshift(res.data.data.organizer);
  127. this.setData({
  128. colonelName: res.data.data.organizer.wechatName
  129. })
  130. this.setData({
  131. joinUserList: this.data.joinUserList,
  132. })
  133. }
  134. }).fail(error => {
  135. console.log('错误', error)
  136. })
  137. },
  138. /**
  139. * 生命周期函数--监听页面初次渲染完成
  140. */
  141. onReady: function () {
  142. this.shareDialog = this.selectComponent("#share-dialog");
  143. },
  144. /**
  145. * 用户点击右上角分享
  146. */
  147. onShareAppMessage: function (ops) {
  148. if (ops.from === 'button') {
  149. console.log(ops.target)
  150. }
  151. // const productId = this.data.productId;
  152. // const groupId = this.data.groupId;
  153. const id = this.data.orderId;
  154. return {
  155. title: '老师同学都在玩的配音show,你还在等什么?',
  156. path: `pages/groupPage/group-details/group-details?share=true&shareId=${id}`,
  157. imageUrl: '../../../static/share/group_icon.jpg',
  158. success: function (res) {
  159. // 转发成功
  160. console.log("转发成功:" + JSON.stringify(res));
  161. var shareTickets = res.shareTickets;
  162. // if (shareTickets.length == 0) {
  163. // return false;
  164. // }
  165. // //可以获取群组信息
  166. // wx.getShareInfo({
  167. // shareTicket: shareTickets[0],
  168. // success: function (res) {
  169. // console.log(res)
  170. // }
  171. // })
  172. },
  173. fail: function (res) {
  174. // 转发失败
  175. console.log("转发失败:" + JSON.stringify(res));
  176. }
  177. }
  178. }
  179. })