my-group.js 4.9 KB

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