my-group.js 5.6 KB

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