my-group.js 4.5 KB

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