collage-details.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. console.log(this.shareDialog)
  45. this.shareDialog.share();
  46. },
  47. /**
  48. * 生命周期函数--监听页面加载
  49. */
  50. onLoad: function (options) {
  51. wx.setNavigationBarTitle({
  52. title: '拼团详情'
  53. })
  54. console.log(options.orderId);
  55. if(!options.orderId) {
  56. return false;
  57. }
  58. const orderId = options.orderId;
  59. this.setData({
  60. orderId
  61. })
  62. httpRequestApi.getMygroupInfo(orderId).success( res => {
  63. console.log('支付详情', res.data.data);
  64. const surplusNum = res.data.data.groupPurchaseOrder.headcount - res.data.data.groupPurchaseOrder.joinCount;
  65. for(var i = 0; i < surplusNum; i++) {
  66. this.data.surplusList.push(1);
  67. }
  68. //console.log(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified)
  69. //时间转换
  70. const timeList = util.formatTime(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified);
  71. this.setData({
  72. surplusNum,
  73. joinUserList: res.data.data.joinUserList,
  74. surplusList: this.data.surplusList,
  75. timeList,
  76. productId: res.data.data.groupPurchaseOrder.productId,
  77. groupId: res.data.data.groupPurchaseOrder.groupId
  78. })
  79. }).fail( error => {
  80. console.log('错误', error)
  81. })
  82. },
  83. /**
  84. * 生命周期函数--监听页面初次渲染完成
  85. */
  86. onReady: function () {
  87. this.shareDialog = this.selectComponent("#share-dialog");
  88. },
  89. /**
  90. * 生命周期函数--监听页面显示
  91. */
  92. onShow: function () {
  93. },
  94. /**
  95. * 生命周期函数--监听页面隐藏
  96. */
  97. onHide: function () {
  98. },
  99. /**
  100. * 生命周期函数--监听页面卸载
  101. */
  102. onUnload: function () {
  103. },
  104. /**
  105. * 页面相关事件处理函数--监听用户下拉动作
  106. */
  107. onPullDownRefresh: function () {
  108. },
  109. /**
  110. * 页面上拉触底事件的处理函数
  111. */
  112. onReachBottom: function () {
  113. },
  114. /**
  115. * 用户点击右上角分享
  116. */
  117. onShareAppMessage: function (ops) {
  118. if (ops.from === 'button') {
  119. console.log(ops.target)
  120. }
  121. const productId = this.data.productId;
  122. const groupId = this.data.groupId;
  123. const id = this.data.orderId;
  124. return {
  125. title: '小学课文朗读',
  126. path: `pages/groupPage/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`,
  127. imageUrl: '../../../static/groupImg/shareBg.png',
  128. success: function (res) {
  129. // 转发成功
  130. console.log("转发成功:" + JSON.stringify(res));
  131. var shareTickets = res.shareTickets;
  132. // if (shareTickets.length == 0) {
  133. // return false;
  134. // }
  135. // //可以获取群组信息
  136. // wx.getShareInfo({
  137. // shareTicket: shareTickets[0],
  138. // success: function (res) {
  139. // console.log(res)
  140. // }
  141. // })
  142. },
  143. fail: function (res) {
  144. // 转发失败
  145. console.log("转发失败:" + JSON.stringify(res));
  146. }
  147. }
  148. }
  149. })