collage-details.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. // pages/groupPage/collage-details/collage-details.js
  2. import httpRequestApi from '../../../utils/APIClient';
  3. import util from '../../../utils/util';
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. hideFlag: true,
  10. surplusNum: '',
  11. joinUserList: [],
  12. surplusList: [],
  13. timeList: [],
  14. productId: '',
  15. orderId: '',
  16. groupId: ''
  17. },
  18. //分享好友触发事件
  19. eventListener: function () {
  20. //console.log(1);
  21. content: [
  22. {
  23. text: "领袖体质魅力无穷!",
  24. color: "#000"
  25. },
  26. {
  27. text: "您可以继续发起新的团购,",
  28. color: "#000"
  29. },
  30. {
  31. text: "不再需要支付本课程费用,拼团成功,",
  32. color: "#FF9B00"
  33. },
  34. {
  35. text: "您将得到xxx元奖励。",
  36. color: "#FF0000"
  37. },
  38. ]
  39. },
  40. //规则页显示和隐藏
  41. hide: function () {
  42. this.setData({
  43. hideFlag: !this.data.hideFlag
  44. })
  45. },
  46. //显示分享页
  47. share: function () {
  48. this.shareDialog.share();
  49. },
  50. /**
  51. * 生命周期函数--监听页面加载
  52. */
  53. onLoad: function (options) {
  54. wx.setNavigationBarTitle({
  55. title: '拼团详情'
  56. })
  57. console.log(options.orderId);
  58. if(!options.orderId) {
  59. return false;
  60. }
  61. const orderId = options.orderId;
  62. this.setData({
  63. orderId
  64. })
  65. httpRequestApi.getMygroupInfo(orderId).success( res => {
  66. console.log('支付详情', res.data.data);
  67. const surplusNum = res.data.data.groupPurchaseOrder.headcount - res.data.data.groupPurchaseOrder.joinCount;
  68. for(var i = 0; i < surplusNum; i++) {
  69. this.data.surplusList.push(1);
  70. }
  71. //console.log(res.data.data.groupPurchaseOrder.closeTimed - res.data.data.groupPurchaseOrder.gmtCreated)
  72. //时间转换
  73. const timeList = util.formatTime(res.data.data.groupPurchaseOrder.closeTimed - res.data.data.groupPurchaseOrder.gmtCreated);
  74. this.setData({
  75. surplusNum,
  76. joinUserList: res.data.data.joinUserList,
  77. surplusList: this.data.surplusList,
  78. timeList,
  79. productId: res.data.data.groupPurchaseOrder.productId,
  80. groupId: res.data.data.groupPurchaseOrder.groupId
  81. })
  82. }).fail( error => {
  83. console.log('错误', error)
  84. })
  85. },
  86. /**
  87. * 生命周期函数--监听页面初次渲染完成
  88. */
  89. onReady: function () {
  90. this.shareDialog = this.selectComponent("#share-dialog");
  91. },
  92. /**
  93. * 生命周期函数--监听页面显示
  94. */
  95. onShow: function () {
  96. },
  97. /**
  98. * 生命周期函数--监听页面隐藏
  99. */
  100. onHide: function () {
  101. },
  102. /**
  103. * 生命周期函数--监听页面卸载
  104. */
  105. onUnload: function () {
  106. },
  107. /**
  108. * 页面相关事件处理函数--监听用户下拉动作
  109. */
  110. onPullDownRefresh: function () {
  111. },
  112. /**
  113. * 页面上拉触底事件的处理函数
  114. */
  115. onReachBottom: function () {
  116. },
  117. /**
  118. * 用户点击右上角分享
  119. */
  120. onShareAppMessage: function (ops) {
  121. if (ops.from === 'button') {
  122. console.log(ops.target)
  123. }
  124. const productId = this.data.productId;
  125. const groupId = this.data.groupId;
  126. const id = this.data.orderId;
  127. return {
  128. title: '小学课文朗读',
  129. path: `pages/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`,
  130. imageUrl: '../../../static/groupImg/shareBg.png',
  131. success: function (res) {
  132. // 转发成功
  133. console.log("转发成功:" + JSON.stringify(res));
  134. var shareTickets = res.shareTickets;
  135. // if (shareTickets.length == 0) {
  136. // return false;
  137. // }
  138. // //可以获取群组信息
  139. // wx.getShareInfo({
  140. // shareTicket: shareTickets[0],
  141. // success: function (res) {
  142. // console.log(res)
  143. // }
  144. // })
  145. },
  146. fail: function (res) {
  147. // 转发失败
  148. console.log("转发失败:" + JSON.stringify(res));
  149. }
  150. }
  151. }
  152. })