collage-details.js 3.5 KB

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