collage-details.js 5.8 KB

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