my-group.js 5.0 KB

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