my-group.js 6.1 KB

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