123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- // pages/groupPage/my-group/my-group.js
- import httpRequestApi from '../../../utils/APIClient';
- import util from '../../../utils/util';
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- myGroupList: [],
- typeOf: '',
- title: '',
- headTextOne: '',
- headTextTwo: '',
- content: [],
- productId: '',
- orderId: '',
- groupId: '',
- closeFlags: [],
- ind: 0,
- timeList: [],
- line1: '您还没有拼过团哦',
- line2: '拼过团再来看看吧'
- },
- //跳转到团购详情页
- collageDetails: function ({
- currentTarget
- }) {
- const orderId = currentTarget.dataset.orderid;
- const productId = currentTarget.dataset.productid;
- const groupId = currentTarget.dataset.groupid;
- const uid = currentTarget.dataset.uid;
- const myUid = wx.getStorageSync('uid');
- const num = currentTarget.dataset.num;
- const ind = currentTarget.dataset.ind;
- const groupType = currentTarget.dataset.grouptype;
- if(app.globalData.isIOS ){
- if( groupType==='IOS' ){
- if( uid === myUid){
- wx.navigateTo({
- url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}&read=true`
- })
- return;
- } else {
- }
- } else {
- wx.navigateTo({
- url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}&read=true`
- })
- return;
- }
- }
-
- this.setData({
- ind
- })
- console.log(num)
- if (!num) {
- wx.navigateTo({
- url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
- })
- } else {
- if (this.data.closeFlags[ind]) {
- this.popup.close();
- this.setData({
- productId,
- orderId,
- groupId
- })
- this.dialog(uid, groupType);
- } else {
- wx.navigateTo({
- url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}&read=true`
- })
- }
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- console.log(options)
- // if (app.globalData.isIOS) {
- // wx.redirectTo({
- // url: '../../index/index'
- // })
- // return
- // }
- if (options && options.title) {
- wx.setNavigationBarTitle({
- title: options.title //页面标题为路由参数
- });
- this.setData({
- title: options.title
- });
- }
- if(options.share){
- this.setData({
- goBackHome: true
- })
- }
- this.getMyGroup();
- },
- // 获取我的拼团
- getMyGroup: function () {
- httpRequestApi.getMygroup().success((res) => {
- if (!res.data.data.list) {
- return
- }
- this.setData({
- myGroupList: [],
- myGroupList: [],
- timeList: []
- });
- console.log('我的团', res.data.data.list)
- res.data.data.list.forEach(element => {
- if (element.groupPurchaseOrder.status == 'SUCCESSED') {
- this.data.closeFlags.push(true);
- this.data.timeList.push(util.formatDate(element.groupPurchaseOrder.gmtModified, 4))
- } else {
- this.data.closeFlags.push(false);
- if (element.groupPurchaseOrder.closeTime - Date.parse(new Date()) < 0) {
- this.data.timeList.push('时间到了,')
- } else {
- this.data.timeList.push(util.lastHours(element.groupPurchaseOrder.closeTime - Date.parse(new Date())))
- }
- }
- });
- this.setData({
- closeFlags: this.data.closeFlags,
- myGroupList: res.data.data.list,
- timeList: this.data.timeList
- })
- }).fail(error => {
- console.log('错误', error)
- })
- },
- dialog: function (uid,type) {
- if (wx.getStorageSync('uid') == uid) {
- this.setData({
- typeOf: 'success',
- title: '恭喜',
- headTextOne: type === 'IOS' ? '您发起的助力团成功' : '您发起的团购拼团成功',
- headTextTwo: type === 'IOS' ? '真是魅力无穷啊' : '领袖体质魅力无穷!',
- content: [{
- text: type === 'IOS' || app.globalData.isIOS ? '快快去朗读吧' : '您可以继续发起新的团购',
- color: "#F97800"
- },
- {
- text: type === 'IOS' || app.globalData.isIOS ? '让更多人听到你美妙的读书声吧' : '不再需要支付本课程费用',
- color: "#F97800"
- },
- {
- text: type === 'IOS' || app.globalData.isIOS ? '' : '拼团成功,您将得到奖学金',
- color: "#F97800"
- }
- ],
- haveReward: type === 'IOS' ? false : true,
- btnContent: type === 'IOS' ? '我要去朗读' : '再接再厉 赚奖学金'
- })
- } else {
- this.setData({
- typeOf: 'success',
- title: '恭喜',
- headTextOne: type === 'IOS' ? '您助力的团成功啦' : '您参与的团购拼团成功',
- headTextTwo: '感谢团长的分享',
- content: [{
- text: type === 'IOS'|| app.globalData.isIOS ? '您还可以自己发团' : " 您也可以发起新的团购",
- color: "#F97800"
- },
- {
- text: type === 'IOS' || app.globalData.isIOS? '获得本课程三年使用权哦' :"作为新的发起人",
- color: "#F97800"
- },
- {
- text: type === 'IOS'|| app.globalData.isIOS ? '' : "您无需在支付本课程费用",
- color: "#F97800"
- },
- {
- text: type === 'IOS'|| app.globalData.isIOS ? '' : "拼团成功,您将得到奖学金",
- color: "#F97800"
- }
- ],
- haveReward: type === 'IOS' || app.globalData.isIOS ? false : true,
- btnContent: type === 'IOS' || app.globalData.isIOS ? '我要去朗读' : '我也试试 赚奖学金'
- })
- }
- },
- close: function () {
- const ind = this.data.ind;
- this.data.closeFlags[ind] = false;
- this.setData({
- closeFlags: this.data.closeFlags
- })
- console.log(this.data.closeFlags)
- },
- //再次发起团
- group: function () {
- const productId = this.data.productId;
- const groupId = this.data.groupId;
- const id = this.data.orderId;
- wx.navigateTo({
- url: `/pages/groupPage/grade-details/grade-details?productId=${productId}`
- })
- //开始发起团购
- // httpRequestApi.SendGroupPurchas({
- // productId,
- // groupId
- // }).success((res) => {
- // console.log('发起团购', res);
- // if (res.data.message) {
- // wx.showModal({
- // title: '提示',
- // content: res.data.message,
- // success:(res) => {
- // }
- // })
- // return false;
- // }
- // wx.navigateTo({
- // url: `/pages/groupPage/make-money/make-money?productId=${productId}&id=${res.data.data.groupPurchaseOrder.id}&groupId=${groupId}`
- // })
- // // this.getMygroup();
- // }).fail((error) => {
- // })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- this.popup = this.selectComponent("#popup");
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- onPullDownRefresh: function () {
- this.onLoad();
- wx.showNavigationBarLoading() //在标题栏中显示加载
- //模拟加载
- setTimeout(function () {
- // complete
- wx.hideNavigationBarLoading() //完成停止加载
- wx.stopPullDownRefresh() //停止下拉刷新
- }, 1500);
- }
- })
|