collage-details.js 3.9 KB

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