collage-details.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. hosterUid: wx.getStorageSync('uid'),
  39. colonelName: '',
  40. rewardMoney: '',
  41. goBackHome: false,
  42. dataLoading: true
  43. },
  44. //显示分享页
  45. openShare: function () {
  46. if (this.data.read) {
  47. const productId = this.data.productId;
  48. const id = this.data.orderId;
  49. const groupId = this.data.groupId;
  50. wx.navigateTo({
  51. url: `/pages/groupPage/grade-details/grade-details?productId=${productId}&id=${id}&groupId=${groupId}&share=true`
  52. })
  53. } else {
  54. this.shareDialog = this.selectComponent("#share-dialog");
  55. const data = {
  56. avatar: this.data.organizer.avatar,
  57. author: this.data.organizer.wechatName,
  58. iconImg: this.data.groupPurchaseInfo.bgImg,
  59. title: this.data.groupPurchaseInfo.productTitle,
  60. path: `pages/groupPage/group-details/group-details`,
  61. scene: `QR${this.data.orderId}`,
  62. groupPurchaseInfo: this.data.groupPurchaseInfo,
  63. groupType: this.data.groupOsType
  64. }
  65. this.shareDialog.share(data);
  66. }
  67. },
  68. // 下拉刷新
  69. onPullDownRefresh: function () {
  70. this.setData({
  71. surplusList: []
  72. },()=>{
  73. this.getInfo();
  74. })
  75. wx.showNavigationBarLoading() //在标题栏中显示加载
  76. //模拟加载
  77. setTimeout(function () {
  78. wx.hideNavigationBarLoading() //完成停止加载
  79. wx.stopPullDownRefresh() //停止下拉刷新
  80. }, 1500);
  81. },
  82. /**
  83. * 生命周期函数--监听页面加载
  84. */
  85. onLoad: function (options) {
  86. // if (app.globalData.isIOS) {
  87. // wx.redirectTo({
  88. // url: '../../index/index'
  89. // })
  90. // return
  91. // }
  92. if (options.read) {
  93. this.setData({
  94. read: options.read
  95. })
  96. }
  97. if(options.goBackHome == 'true'){
  98. this.setData({
  99. goBackHome: true
  100. })
  101. }
  102. // options.scene = 'QR1541862338777268';
  103. wx.setNavigationBarTitle({
  104. title: '拼团详情'
  105. })
  106. console.log(options);
  107. console.log(options.orderId);
  108. const orderId = options.orderId ? options.orderId : options.scene.replace('QR', '');
  109. // if (options.orderId) {
  110. // return false;
  111. // }
  112. console.log(orderId)
  113. this.setData({
  114. orderId
  115. },()=>{
  116. this.getInfo()
  117. })
  118. },
  119. getInfo: function(){
  120. httpRequestApi.getMygroupInfo(this.data.orderId).success(res => {
  121. console.log(res);
  122. const groupOrder = res.data.data.groupPurchaseOrder;
  123. const surplusNum = groupOrder.headcount - groupOrder.joinCount;
  124. this.setData({
  125. organizerUid: groupOrder.organizer,
  126. read: groupOrder.status === 'SUCCESSED' ? true : false
  127. })
  128. for (var i = 0; i < surplusNum; i++) {
  129. this.data.surplusList.push(1);
  130. }
  131. //console.log(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified)
  132. //时间转换
  133. let timeLast = '';
  134. const stillGoing = groupOrder.closeTime - Date.parse(new Date()) <= 0 ? false : true
  135. if (stillGoing) {
  136. timeLast = util.lastHours(groupOrder.closeTime - Date.parse(new Date()));
  137. }
  138. // const timeList = util.formatTime(groupOrder.closeTime - Date.parse(new Date()));
  139. // console.log(timeList)
  140. //res.data.data.joinUserList.unshift(res.data.data.organizer);
  141. this.setData({
  142. groupPurchaseInfo: res.data.data.groupPurchaseInfo,
  143. organizer: res.data.data.organizer,
  144. surplusNum,
  145. joinUserList: res.data.data.joinUserList,
  146. surplusList: this.data.surplusList,
  147. timeLast,
  148. stillGoing,
  149. productId: groupOrder.productId,
  150. groupId: groupOrder.groupId,
  151. rewardMoney: res.data.data.groupPurchaseInfo.organizerPrice / 100,
  152. dataLoading:false,
  153. groupOsType: groupOrder.os
  154. })
  155. console.log(this.data.groupOsType)
  156. if (groupOrder.groupType === 'PROMOTION') {
  157. //this.data.joinUserList.unshift(res.data.data.organizer);
  158. this.setData({
  159. colonelName: res.data.data.organizer.wechatName
  160. })
  161. this.setData({
  162. joinUserList: this.data.joinUserList,
  163. })
  164. }
  165. })
  166. },
  167. /**
  168. * 生命周期函数--监听页面初次渲染完成
  169. */
  170. onReady: function () {
  171. this.shareDialog = this.selectComponent("#share-dialog");
  172. },
  173. /**
  174. * 用户点击右上角分享
  175. */
  176. onShareAppMessage: function (ops) {
  177. if (ops.from === 'button') {
  178. console.log(ops.target)
  179. }
  180. // const productId = this.data.productId;
  181. // const groupId = this.data.groupId;
  182. const id = this.data.orderId;
  183. return {
  184. title: '老师同学都在玩的配音show,你还在等什么?',
  185. path: `pages/groupPage/group-details/group-details?share=true&shareId=${id}`,
  186. imageUrl: `https://efunbox.lingjiao.cn/reader/resource/share/group_${this.data.productId}.jpg`,
  187. success: function (res) {
  188. // 转发成功
  189. console.log("转发成功:" + JSON.stringify(res));
  190. var shareTickets = res.shareTickets;
  191. // if (shareTickets.length == 0) {
  192. // return false;
  193. // }
  194. // //可以获取群组信息
  195. // wx.getShareInfo({
  196. // shareTicket: shareTickets[0],
  197. // success: function (res) {
  198. // console.log(res)
  199. // }
  200. // })
  201. },
  202. fail: function (res) {
  203. // 转发失败
  204. console.log("转发失败:" + JSON.stringify(res));
  205. }
  206. }
  207. }
  208. })