my-group.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. // pages/groupPage/my-group/my-group.js
  2. import httpRequestApi from '../../../utils/APIClient';
  3. import util from '../../../utils/util';
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. myGroupList: [],
  11. typeOf: '',
  12. title: '',
  13. headTextOne: '',
  14. headTextTwo: '',
  15. content: [],
  16. productId: '',
  17. orderId: '',
  18. groupId: '',
  19. closeFlags: [],
  20. ind: 0,
  21. timeList: [],
  22. line1: '您还没有拼过团哦',
  23. line2: '拼过团再来看看吧'
  24. },
  25. //跳转到团购详情页
  26. collageDetails: function ({
  27. currentTarget
  28. }) {
  29. const orderId = currentTarget.dataset.orderid;
  30. wx.navigateTo({
  31. url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}&read=true`
  32. })
  33. // const productId = currentTarget.dataset.productid;
  34. // const groupId = currentTarget.dataset.groupid;
  35. // const uid = currentTarget.dataset.uid;
  36. // const myUid = wx.getStorageSync('uid');
  37. // const num = currentTarget.dataset.num;
  38. // const ind = currentTarget.dataset.ind;
  39. // const groupType = currentTarget.dataset.grouptype;
  40. // if(app.globalData.isIOS ){
  41. // if( groupType==='IOS' ){
  42. // if( uid === myUid){
  43. // wx.navigateTo({
  44. // url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}&read=true`
  45. // })
  46. // return;
  47. // } else {
  48. // }
  49. // } else {
  50. // wx.navigateTo({
  51. // url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}&read=true`
  52. // })
  53. // return;
  54. // }
  55. // }
  56. // this.setData({
  57. // ind
  58. // })
  59. // console.log(num)
  60. // if (!num) {
  61. // wx.navigateTo({
  62. // url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
  63. // })
  64. // } else {
  65. // if (this.data.closeFlags[ind]) {
  66. // this.popup.close();
  67. // this.setData({
  68. // productId,
  69. // orderId,
  70. // groupId
  71. // })
  72. // this.dialog(uid, groupType);
  73. // } else {
  74. // wx.navigateTo({
  75. // url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}&read=true`
  76. // })
  77. // }
  78. // }
  79. },
  80. /**
  81. * 生命周期函数--监听页面加载
  82. */
  83. onLoad: function (options) {
  84. console.log(options)
  85. // if (app.globalData.isIOS) {
  86. // wx.redirectTo({
  87. // url: '../../index/index'
  88. // })
  89. // return
  90. // }
  91. if (options && options.title) {
  92. wx.setNavigationBarTitle({
  93. title: options.title //页面标题为路由参数
  94. });
  95. this.setData({
  96. title: options.title
  97. });
  98. }
  99. if(options.share){
  100. this.setData({
  101. goBackHome: true
  102. })
  103. }
  104. this.getMyGroup();
  105. },
  106. // 获取我的拼团
  107. getMyGroup: function () {
  108. httpRequestApi.getMygroup().success((res) => {
  109. if (!res.data.data.list) {
  110. return
  111. }
  112. this.setData({
  113. myGroupList: [],
  114. myGroupList: [],
  115. timeList: []
  116. });
  117. console.log('我的团', res.data.data.list)
  118. res.data.data.list.forEach(element => {
  119. if (element.groupPurchaseOrder.status == 'SUCCESSED') {
  120. this.data.closeFlags.push(true);
  121. this.data.timeList.push(util.formatDate(element.groupPurchaseOrder.gmtModified, 4))
  122. } else {
  123. this.data.closeFlags.push(false);
  124. if (element.groupPurchaseOrder.closeTime - Date.parse(new Date()) < 0) {
  125. this.data.timeList.push('时间到了,')
  126. } else {
  127. this.data.timeList.push(util.lastHours(element.groupPurchaseOrder.closeTime - Date.parse(new Date())))
  128. }
  129. }
  130. });
  131. this.setData({
  132. closeFlags: this.data.closeFlags,
  133. myGroupList: res.data.data.list,
  134. timeList: this.data.timeList
  135. })
  136. }).fail(error => {
  137. console.log('错误', error)
  138. })
  139. },
  140. dialog: function (uid,type) {
  141. if (wx.getStorageSync('uid') == uid) {
  142. this.setData({
  143. typeOf: 'success',
  144. title: '恭喜',
  145. headTextOne: type === 'IOS' ? '您发起的助力团成功' : '您发起的团购拼团成功',
  146. headTextTwo: type === 'IOS' ? '真是魅力无穷啊' : '领袖体质魅力无穷!',
  147. content: [{
  148. text: type === 'IOS' || app.globalData.isIOS ? '快快去朗读吧' : '您可以继续发起新的团购',
  149. color: "#F97800"
  150. },
  151. {
  152. text: type === 'IOS' || app.globalData.isIOS ? '让更多人听到你美妙的读书声吧' : '不再需要支付本课程费用',
  153. color: "#F97800"
  154. },
  155. {
  156. text: type === 'IOS' || app.globalData.isIOS ? '' : '拼团成功,您将得到奖学金',
  157. color: "#F97800"
  158. }
  159. ],
  160. haveReward: type === 'IOS' ? false : true,
  161. btnContent: type === 'IOS' ? '我要去朗读' : '再接再厉 赚奖学金'
  162. })
  163. } else {
  164. this.setData({
  165. typeOf: 'success',
  166. title: '恭喜',
  167. headTextOne: type === 'IOS' ? '您助力的团成功啦' : '您参与的团购拼团成功',
  168. headTextTwo: '感谢团长的分享',
  169. content: [{
  170. text: type === 'IOS'|| app.globalData.isIOS ? '您还可以自己发团' : " 您也可以发起新的团购",
  171. color: "#F97800"
  172. },
  173. {
  174. text: type === 'IOS' || app.globalData.isIOS? '获得本课程三年使用权哦' :"作为新的发起人",
  175. color: "#F97800"
  176. },
  177. {
  178. text: type === 'IOS'|| app.globalData.isIOS ? '' : "您无需在支付本课程费用",
  179. color: "#F97800"
  180. },
  181. {
  182. text: type === 'IOS'|| app.globalData.isIOS ? '' : "拼团成功,您将得到奖学金",
  183. color: "#F97800"
  184. }
  185. ],
  186. haveReward: type === 'IOS' || app.globalData.isIOS ? false : true,
  187. btnContent: type === 'IOS' || app.globalData.isIOS ? '我要去朗读' : '我也试试 赚奖学金'
  188. })
  189. }
  190. },
  191. close: function () {
  192. const ind = this.data.ind;
  193. this.data.closeFlags[ind] = false;
  194. this.setData({
  195. closeFlags: this.data.closeFlags
  196. })
  197. console.log(this.data.closeFlags)
  198. },
  199. //再次发起团
  200. group: function () {
  201. const productId = this.data.productId;
  202. const groupId = this.data.groupId;
  203. const id = this.data.orderId;
  204. wx.navigateTo({
  205. url: `/pages/groupPage/grade-details/grade-details?productId=${productId}`
  206. })
  207. //开始发起团购
  208. // httpRequestApi.SendGroupPurchas({
  209. // productId,
  210. // groupId
  211. // }).success((res) => {
  212. // console.log('发起团购', res);
  213. // if (res.data.message) {
  214. // wx.showModal({
  215. // title: '提示',
  216. // content: res.data.message,
  217. // success:(res) => {
  218. // }
  219. // })
  220. // return false;
  221. // }
  222. // wx.navigateTo({
  223. // url: `/pages/groupPage/make-money/make-money?productId=${productId}&id=${res.data.data.groupPurchaseOrder.id}&groupId=${groupId}`
  224. // })
  225. // // this.getMygroup();
  226. // }).fail((error) => {
  227. // })
  228. },
  229. /**
  230. * 生命周期函数--监听页面初次渲染完成
  231. */
  232. onReady: function () {
  233. this.popup = this.selectComponent("#popup");
  234. },
  235. /**
  236. * 用户点击右上角分享
  237. */
  238. onShareAppMessage: function () {
  239. },
  240. onPullDownRefresh: function () {
  241. this.onLoad();
  242. wx.showNavigationBarLoading() //在标题栏中显示加载
  243. //模拟加载
  244. setTimeout(function () {
  245. // complete
  246. wx.hideNavigationBarLoading() //完成停止加载
  247. wx.stopPullDownRefresh() //停止下拉刷新
  248. }, 1500);
  249. }
  250. })