my-group.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. // pages/groupPage/my-group/my-group.js
  2. import httpRequestApi from '../../../utils/APIClient';
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. myGroupList: [],
  9. typeOf:'',
  10. title: '',
  11. headTextOne: '',
  12. headTextTwo: '',
  13. content: [],
  14. productId: '',
  15. orderId: '',
  16. groupId: ''
  17. },
  18. //跳转到团购详情页
  19. collageDetails: function ({currentTarget}) {
  20. const orderId = currentTarget.dataset.orderid;
  21. const num = currentTarget.dataset.num;
  22. console.log(num)
  23. if(!num) {
  24. wx.navigateTo({
  25. url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
  26. })
  27. }
  28. },
  29. /**
  30. * 生命周期函数--监听页面加载
  31. */
  32. onLoad: function (option) {
  33. console.log(option.title);
  34. if (option.title) {
  35. wx.setNavigationBarTitle({
  36. title: option.title//页面标题为路由参数
  37. });
  38. this.setData({
  39. title: option.title
  40. });
  41. }
  42. httpRequestApi.getMygroup().success((res) => {
  43. if(!res.data.data.list){
  44. return
  45. }
  46. console.log('我的团', res.data.data.list)
  47. this.setData({
  48. myGroupList: res.data.data.list
  49. })
  50. res.data.data.list.forEach(element => {
  51. console.log(element.status)
  52. if(element.status == 'successed') {
  53. this.setData({
  54. productId: element.productId,
  55. orderId: element.id,
  56. groupId: element.groupId
  57. })
  58. if(wx.getStorageSync(uid) == element.organizer) {
  59. this.setData({
  60. typeOf: 'success',
  61. title: '恭喜 !',
  62. headTextOne: '您发起的团购拼团成功',
  63. content: [
  64. {
  65. text: "领袖体质魅力无穷!",
  66. color: "#000"
  67. },
  68. {
  69. text: " 您可以继续发起新的团购,",
  70. color: "#000"
  71. },
  72. {
  73. text: " 不再需要支付本课程费用,拼团成功,",
  74. color: "#FF9B00"
  75. },
  76. {
  77. text: " 您将得到xxx元奖励。",
  78. color: "#FF0000"
  79. }
  80. ],
  81. })
  82. }else {
  83. this.setData({
  84. typeOf: 'success',
  85. title: '拼团成功 ! ',
  86. headTextOne: '您参与的团购拼团成功',
  87. headTextTwo: '订单号:12344',
  88. content: [
  89. {
  90. text: "感谢团长的分享",
  91. color: "#000"
  92. },
  93. {
  94. text: " 您也可以发起新的团购分享给需要的朋友们,",
  95. color: "#000"
  96. },
  97. {
  98. text: "作为新的发起人,您无需在支付本课程费用;",
  99. color: "#FF0000"
  100. },
  101. {
  102. text: "团购成功,您将得到xxx元奖励。",
  103. color: "#FF0000"
  104. }
  105. ],
  106. })
  107. }
  108. }
  109. });
  110. }).fail( error => {
  111. console.log('错误', error)
  112. })
  113. },
  114. //再次发起团
  115. group: function () {
  116. // wx.showModal({
  117. // title: '提示',
  118. // content: '再次发起团',
  119. // success (res) {
  120. // if (res.confirm) {
  121. // console.log('用户点击确定')
  122. // } else if (res.cancel) {
  123. // console.log('用户点击取消')
  124. // }
  125. // }
  126. // })
  127. const productId = this.data.productId;
  128. const groupId = this.data.groupId;
  129. const id = this.data.orderId;
  130. wx.navigateTo({
  131. url: `/pages/groupPage/make-money/make-money?productId=${productId}&id=${id}&groupId=${groupId}`
  132. })
  133. },
  134. /**
  135. * 生命周期函数--监听页面初次渲染完成
  136. */
  137. onReady: function () {
  138. },
  139. /**
  140. * 生命周期函数--监听页面显示
  141. */
  142. onShow: function () {
  143. },
  144. /**
  145. * 生命周期函数--监听页面隐藏
  146. */
  147. onHide: function () {
  148. },
  149. /**
  150. * 生命周期函数--监听页面卸载
  151. */
  152. onUnload: function () {
  153. },
  154. /**
  155. * 页面相关事件处理函数--监听用户下拉动作
  156. */
  157. onPullDownRefresh: function () {
  158. },
  159. /**
  160. * 页面上拉触底事件的处理函数
  161. */
  162. onReachBottom: function () {
  163. },
  164. /**
  165. * 用户点击右上角分享
  166. */
  167. onShareAppMessage: function () {
  168. }
  169. })