my-group.js 7.2 KB

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