|
@@ -30,9 +30,6 @@ Page({
|
|
|
organizer: '',
|
|
|
hide: true,
|
|
|
isIPX: app.globalData.isIPX,
|
|
|
- bookList: [],
|
|
|
- sendGroupFlag: true,
|
|
|
- selectFlag: [],
|
|
|
flag: true,
|
|
|
colonelName: '',
|
|
|
article: '',
|
|
@@ -61,7 +58,10 @@ Page({
|
|
|
// damnDialogLine2:'',
|
|
|
damnDialogShow: false,
|
|
|
knowFlag: true,
|
|
|
- menuFlag: false
|
|
|
+ menuFlag: false,
|
|
|
+ ifGroupSuccessed: false,
|
|
|
+ groupOSType:'IOS',
|
|
|
+ hideBottomBtn: true
|
|
|
},
|
|
|
//tab切换
|
|
|
//tab切换
|
|
@@ -87,52 +87,8 @@ Page({
|
|
|
//登录页信息
|
|
|
this.onLoad(this.data.onLoadOption);
|
|
|
},
|
|
|
- // 审核一定要通过啊
|
|
|
- //发起团购
|
|
|
- sendGroup: function () {
|
|
|
- this.setData({
|
|
|
- sendGroupFlag: !this.data.sendGroupFlag
|
|
|
- })
|
|
|
- },
|
|
|
- //选中团购课程
|
|
|
- selectImg: function ({
|
|
|
- currentTarget
|
|
|
- }) {
|
|
|
- const ind = currentTarget.dataset.ind;
|
|
|
- //判断单选
|
|
|
- this.data.selectFlag.forEach((item, index) => {
|
|
|
- if (index == ind) {
|
|
|
- this.data.selectFlag[ind] = !this.data.selectFlag[ind];
|
|
|
- } else {
|
|
|
- this.data.selectFlag[index] = true;
|
|
|
- }
|
|
|
- })
|
|
|
- this.setData({
|
|
|
- selectFlag: this.data.selectFlag
|
|
|
- })
|
|
|
- },
|
|
|
- //点击确定
|
|
|
- sure: function () {
|
|
|
- this.data.selectFlag.forEach((item, index) => {
|
|
|
- if (!item) {
|
|
|
- const productId = this.data.bookList[index].id;
|
|
|
- const title = this.data.bookList[index].title
|
|
|
- this.setData({
|
|
|
- sendGroupFlag: !this.data.sendGroupFlag
|
|
|
- })
|
|
|
- wx.navigateTo({
|
|
|
- url: `/pages/groupPage/grade-details/grade-details?productId=${productId}&title=${title}`
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- },
|
|
|
//参团
|
|
|
jionGroup: function (e) {
|
|
|
- // if (app.globalData.isIOS) {
|
|
|
- // this.showAlert();
|
|
|
- // return;
|
|
|
- // }
|
|
|
console.log(this.data.haveTapJoin)
|
|
|
if (this.data.haveTapJoin) {
|
|
|
return false
|
|
@@ -147,24 +103,6 @@ Page({
|
|
|
httpRequestApi.JoinGroupPurchas(orderId, formId).success((res) => {
|
|
|
console.log('参加团购', res);
|
|
|
if (res.data.message) {
|
|
|
- // if (res.data.code === 801) {
|
|
|
- // this.setData({
|
|
|
- // isModalShow: true,
|
|
|
- // modalType: 'text'
|
|
|
- // })
|
|
|
- // } else {
|
|
|
- // wx.showModal({
|
|
|
- // title: '提示',
|
|
|
- // content: res.data.message,
|
|
|
- // success(res) {
|
|
|
- // if (res.confirm) {
|
|
|
- // console.log('用户点击确定')
|
|
|
- // } else if (res.cancel) {
|
|
|
- // console.log('用户点击取消')
|
|
|
- // }
|
|
|
- // }
|
|
|
- // })
|
|
|
- // }
|
|
|
switch (res.data.code) {
|
|
|
case 801:
|
|
|
this.setData({
|
|
@@ -175,27 +113,20 @@ Page({
|
|
|
break;
|
|
|
case 802:
|
|
|
this.setData({
|
|
|
- // damnDialogLine1:'您已拥有本课程使用权',
|
|
|
- // damnDialogLine2:'快去朗读吧',
|
|
|
damnDialogShow: true,
|
|
|
haveTapJoin: false
|
|
|
})
|
|
|
break;
|
|
|
case 806:
|
|
|
- console.log(this.data.haveTapJoin)
|
|
|
+ console.log(this.data.haveTapJoin)
|
|
|
wx.pageScrollTo({
|
|
|
scrollTop: 0,
|
|
|
duration: 17
|
|
|
})
|
|
|
this.setData({
|
|
|
- // isModalShow: true,
|
|
|
- // modalType: 'text'
|
|
|
alertFlag: true,
|
|
|
haveTapJoin: false
|
|
|
})
|
|
|
- // wx.navigateTo({
|
|
|
- // url:'/pages/groupPage/my-group/my-group'
|
|
|
- // })
|
|
|
break;
|
|
|
default:
|
|
|
wx.showModal({
|
|
@@ -218,13 +149,10 @@ Page({
|
|
|
}
|
|
|
//掉起支付
|
|
|
if (res.data.data.groupPurchaseOrder.os === 'IOS') {
|
|
|
- this.jionSuccess(res.data.data.groupPurchaseOrder.id, 'join');
|
|
|
+ this.getGroupInfo(res.data.data.groupPurchaseOrder.id);
|
|
|
} else {
|
|
|
- this.prePayMap(res.data.data.prePayMap, 'join');
|
|
|
+ this.prePayMap(res.data.data.prePayMap);
|
|
|
}
|
|
|
-
|
|
|
- }).fail((error) => {
|
|
|
-
|
|
|
})
|
|
|
},
|
|
|
showAlert: function () {
|
|
@@ -233,13 +161,8 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
//支付
|
|
|
- prePayMap: function (prePayMap, type) {
|
|
|
+ prePayMap: function (prePayMap) {
|
|
|
console.log(prePayMap)
|
|
|
-
|
|
|
- // const that = this;
|
|
|
- this.setData({
|
|
|
- joinGroupType: type
|
|
|
- })
|
|
|
wx.requestPayment({
|
|
|
'appId': prePayMap.appId,
|
|
|
'timeStamp': prePayMap.timeStamp,
|
|
@@ -248,31 +171,10 @@ Page({
|
|
|
'signType': 'MD5',
|
|
|
'paySign': prePayMap.sign,
|
|
|
'success': res => {
|
|
|
- console.log('支付成功')
|
|
|
this.setData({
|
|
|
isModalShow: true,
|
|
|
haveTapJoin: false
|
|
|
})
|
|
|
- // const type1 = type;
|
|
|
- // wx.showModal({
|
|
|
- // title: '提示',
|
|
|
- // content: '支付成功',
|
|
|
- // success(res) {
|
|
|
- // //获取拼团信息
|
|
|
- // console.log(that.data.orderId)
|
|
|
- // wx.showLoading({
|
|
|
- // title: '支付查询中...',
|
|
|
- // mask: true
|
|
|
- // })
|
|
|
- // setTimeout(() => {
|
|
|
- // wx.hideLoading();
|
|
|
- // console.log(that.data.orderId)
|
|
|
- // that.jionSuccess(that.data.orderId, type1);
|
|
|
- // // that.groupSuccess(orderId, detailId);
|
|
|
- // }, 800)
|
|
|
- // }
|
|
|
- // })
|
|
|
-
|
|
|
},
|
|
|
'fail': res => {
|
|
|
console.log('支付失败', res)
|
|
@@ -283,170 +185,50 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
//拼团详情
|
|
|
- jionSuccess: function (orderId, type) {
|
|
|
+ getGroupInfo: function (orderId) {
|
|
|
httpRequestApi.getMygroupInfo(orderId).success(res => {
|
|
|
- this.data.surplusList = [];
|
|
|
- // 通过分享进入的用户,如果已经参加过本次团购,则跳转进入邀请好友的页面
|
|
|
- console.log(res)
|
|
|
- // if (this.data.goBackHome) {
|
|
|
- const joinUser = res.data.data.joinUserList;
|
|
|
- const groupId = res.data.data.groupPurchaseOrder.id;
|
|
|
- const myUid = wx.getStorageSync('uid');
|
|
|
- this.setData({
|
|
|
- haveTapJoin: false
|
|
|
- })
|
|
|
- if (myUid === res.data.data.organizer.uid) {
|
|
|
- wx.redirectTo({
|
|
|
- url: `../collage-details/collage-details?orderId=${groupId}&goBackHome=${this.data.goBackHome}`
|
|
|
- })
|
|
|
- return;
|
|
|
- }
|
|
|
- joinUser.forEach(item => {
|
|
|
- if (item.uid === myUid) {
|
|
|
- wx.redirectTo({
|
|
|
- url: `../collage-details/collage-details?orderId=${groupId}&goBackHome=${this.data.goBackHome}`
|
|
|
- })
|
|
|
- return;
|
|
|
- }
|
|
|
- })
|
|
|
- // }
|
|
|
-
|
|
|
- console.log('拼团详情', res);
|
|
|
const groupOrder = res.data.data.groupPurchaseOrder;
|
|
|
const surplusNum = groupOrder.headcount - groupOrder.joinCount;
|
|
|
- if (this.data.article === '') {
|
|
|
- this.getBooksInfo(res.data.data.groupPurchaseOrder.productId)
|
|
|
- }
|
|
|
this.setData({
|
|
|
- organizer: groupOrder.organizer,
|
|
|
- productId: res.data.data.groupPurchaseOrder.productId
|
|
|
+ organizerUid: groupOrder.organizer,
|
|
|
+ ifGroupSuccessed: groupOrder.status === 'SUCCESSED' ? true : false
|
|
|
})
|
|
|
for (var i = 0; i < surplusNum; i++) {
|
|
|
this.data.surplusList.push(1);
|
|
|
}
|
|
|
- if (type === 'join') {
|
|
|
- // this.data.surplusList.pop();
|
|
|
- if (groupOrder.status === 'SUCCESSED') {
|
|
|
- this.showSuccess(groupOrder.organizer, groupOrder.organizerPrice)
|
|
|
- } else {
|
|
|
- this.goToDetail(groupOrder.id)
|
|
|
- }
|
|
|
- } else if (type === 'create') {
|
|
|
- this.showSuccess(groupOrder.organizer, groupOrder.organizerPrice)
|
|
|
- this.setData({
|
|
|
- orderId: groupOrder.id
|
|
|
- })
|
|
|
- } else {
|
|
|
- // for (var i = 0; i < surplusNum; i++) {
|
|
|
- // this.data.surplusList.push(1);
|
|
|
- // }
|
|
|
- }
|
|
|
- let timeList = [];
|
|
|
- // || groupOrder.status ==='SUCCESSED'
|
|
|
+ // 剩余时间 如果团购已结束则不显示
|
|
|
+ let timeLast = '';
|
|
|
const stillGoing = groupOrder.closeTime - Date.parse(new Date()) <= 0 ? false : true
|
|
|
if (stillGoing) {
|
|
|
- timeList = util.lastHoursInGroup(groupOrder.closeTime - Date.parse(new Date()));
|
|
|
- console.log(timeList)
|
|
|
- }
|
|
|
- // 分享进来的并且团购失效 就跳转到详情页面
|
|
|
- // if(this.data.goBackHome && (surplusNum ===0 || !stillGoing) ){
|
|
|
- // console.log(' productID>>>>>>>>>>>>>>>>'+ res.data.data.groupPurchaseOrder.productId)
|
|
|
- // wx.navigateTo({
|
|
|
- // url: `/pages/groupPage/grade-details/grade-details?productId=${res.data.data.groupPurchaseOrder.productId}`
|
|
|
- // })
|
|
|
- // }
|
|
|
- // const groupStatus = false;
|
|
|
- if (groupOrder.status === 'SUCCESSED') {
|
|
|
- this.data.groupStatus = true
|
|
|
+ timeLast = util.lastHours(groupOrder.closeTime - Date.parse(new Date()));
|
|
|
}
|
|
|
this.setData({
|
|
|
+ groupPurchaseInfo: res.data.data.groupPurchaseInfo,
|
|
|
+ organizer: res.data.data.organizer,
|
|
|
surplusNum,
|
|
|
joinUserList: res.data.data.joinUserList,
|
|
|
surplusList: this.data.surplusList,
|
|
|
- timeList,
|
|
|
+ timeLast,
|
|
|
stillGoing,
|
|
|
- groupStatus: this.data.groupStatus,
|
|
|
+ productId: groupOrder.productId,
|
|
|
+ groupId: groupOrder.groupId,
|
|
|
+ rewardMoney: res.data.data.groupPurchaseInfo.organizerPrice / 100,
|
|
|
dataLoading: false,
|
|
|
- groupOSType: groupOrder.os,
|
|
|
+ groupOsType: groupOrder.os,
|
|
|
isLoading: false
|
|
|
- }, () => {
|
|
|
- if (groupOrder.os === 'ANDROID' && app.globalData.isIOS) {
|
|
|
- wx.redirectTo({
|
|
|
- url: `/pages/groupPage/grade-details/grade-details?productId=${res.data.data.groupPurchaseOrder.productId}&goBackHome=1`
|
|
|
- })
|
|
|
- }
|
|
|
})
|
|
|
-
|
|
|
+ if (this.data.article === '') {
|
|
|
+ this.getBooksInfo(res.data.data.groupPurchaseOrder.productId)
|
|
|
+ }
|
|
|
if (groupOrder.groupType === 'PROMOTION') {
|
|
|
- //this.data.joinUserList.unshift(res.data.data.organizer);
|
|
|
- this.setData({
|
|
|
- colonelName: res.data.data.organizer.wechatName
|
|
|
- })
|
|
|
- //this.data.surplusList.pop();
|
|
|
this.setData({
|
|
|
- joinUserList: this.data.joinUserList,
|
|
|
- //surplusList: this.data.surplusList,
|
|
|
- surplusNum: this.data.surplusNum
|
|
|
+ colonelName: res.data.data.organizer.wechatName,
|
|
|
+ promotion: true
|
|
|
+ // joinUserList: this.data.joinUserList
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
- }).fail(error => {
|
|
|
- console.log('错误', error)
|
|
|
})
|
|
|
- },
|
|
|
- // 弹成功信息框
|
|
|
- showSuccess: function (organizerUid, price) {
|
|
|
- if (wx.getStorageSync('uid') == organizerUid) {
|
|
|
- this.setData({
|
|
|
- typeOf: 'success',
|
|
|
- titles: '恭喜 !',
|
|
|
- headTextOne: '您发起的团购拼团成功',
|
|
|
- headTextTwo: '领袖体质魅力无穷!',
|
|
|
- content: [{
|
|
|
- text: " 您可以继续发起新的团购,",
|
|
|
- color: "#F97800"
|
|
|
- },
|
|
|
- {
|
|
|
- text: " 不再需要支付本课程费用",
|
|
|
- color: "#F97800"
|
|
|
- },
|
|
|
- {
|
|
|
- text: `拼团成功,您将得到奖学金`,
|
|
|
- color: "#F97800"
|
|
|
- }
|
|
|
- ],
|
|
|
- btnContent: '再接再厉 赚奖学金'
|
|
|
- }, () => {
|
|
|
- this.popup.close()
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.setData({
|
|
|
- typeOf: 'success',
|
|
|
- titles: '拼团成功 ! ',
|
|
|
- headTextOne: '您参与的团购拼团成功',
|
|
|
- headTextTwo: '感谢团长的分享',
|
|
|
- content: [{
|
|
|
- text: " 您也可以发起新的团购",
|
|
|
- color: "#F97800"
|
|
|
- },
|
|
|
- {
|
|
|
- text: "作为新的发起人",
|
|
|
- color: "#F97800"
|
|
|
- },
|
|
|
- {
|
|
|
- text: " 您无需在支付本课程费用 ",
|
|
|
- color: "#F97800"
|
|
|
- },
|
|
|
- {
|
|
|
- text: `拼团成功,您将得到奖学金`,
|
|
|
- color: "#F97800"
|
|
|
- }
|
|
|
- ],
|
|
|
- btnContent: '我也试试 赚奖学金'
|
|
|
- }, () => {
|
|
|
- this.popup.close()
|
|
|
- })
|
|
|
- }
|
|
|
+
|
|
|
},
|
|
|
// 去详情页面
|
|
|
goToDetail: function (detailId) {
|
|
@@ -509,14 +291,14 @@ Page({
|
|
|
this.setData({
|
|
|
orderId
|
|
|
})
|
|
|
- this.jionSuccess(orderId);
|
|
|
+ this.getGroupInfo(orderId);
|
|
|
} else {
|
|
|
// 从分享页面进入的
|
|
|
const orderId = options.productId ? options.productId : options.scene ? options.scene.replace('QR', '') : options.shareId;
|
|
|
this.setData({
|
|
|
orderId
|
|
|
})
|
|
|
- this.jionSuccess(orderId);
|
|
|
+ this.getGroupInfo(orderId);
|
|
|
}
|
|
|
if (options.scene || options.shareId) {
|
|
|
this.setData({
|
|
@@ -531,7 +313,25 @@ Page({
|
|
|
})
|
|
|
return;
|
|
|
});
|
|
|
-
|
|
|
+ },
|
|
|
+ // 页面滚动
|
|
|
+ pageScroll: function(e){
|
|
|
+ console.log(e.target.offsetTop)
|
|
|
+ if(e.target.offsetTop < 600){
|
|
|
+ this.setData({
|
|
|
+ hideBottomBtn: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if(e.target.offsetTop > 600){
|
|
|
+ this.setData({
|
|
|
+ hideBottomBtn: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // if(e.target.offsetTop > 600){
|
|
|
+ // this.setData({
|
|
|
+ // btnClass: 'middle-btn'
|
|
|
+ // })
|
|
|
+ // }
|
|
|
},
|
|
|
// 鉴权
|
|
|
areYouSuperSecond: function (productId) {
|
|
@@ -550,7 +350,7 @@ Page({
|
|
|
this.setData({
|
|
|
surplusList: []
|
|
|
}, () => {
|
|
|
- this.jionSuccess(this.data.orderId);
|
|
|
+ this.getGroupInfo(this.data.orderId);
|
|
|
})
|
|
|
wx.showNavigationBarLoading() //在标题栏中显示加载
|
|
|
//模拟加载
|
|
@@ -591,19 +391,19 @@ Page({
|
|
|
}).fail((error) => {
|
|
|
|
|
|
})
|
|
|
- //全部课本
|
|
|
- httpRequestApi.getAllBooks(1, 10).success((res) => {
|
|
|
- console.log('全部课', res.data.data.list)
|
|
|
- res.data.data.list.forEach(element => {
|
|
|
- this.data.selectFlag.push(true);
|
|
|
- });
|
|
|
- this.setData({
|
|
|
- bookList: res.data.data.list,
|
|
|
- selectFlag: this.data.selectFlag
|
|
|
- })
|
|
|
- }).fail((error) => {
|
|
|
- console.log('错误', error)
|
|
|
- })
|
|
|
+ // //全部课本
|
|
|
+ // httpRequestApi.getAllBooks(1, 10).success((res) => {
|
|
|
+ // console.log('全部课', res.data.data.list)
|
|
|
+ // res.data.data.list.forEach(element => {
|
|
|
+ // this.data.selectFlag.push(true);
|
|
|
+ // });
|
|
|
+ // this.setData({
|
|
|
+ // bookList: res.data.data.list,
|
|
|
+ // selectFlag: this.data.selectFlag
|
|
|
+ // })
|
|
|
+ // }).fail((error) => {
|
|
|
+ // console.log('错误', error)
|
|
|
+ // })
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
@@ -619,7 +419,7 @@ Page({
|
|
|
isModalShow: false
|
|
|
})
|
|
|
if (this.data.modalType === 'image') {
|
|
|
- this.jionSuccess(this.data.orderId, this.data.joinGroupType);
|
|
|
+ this.goToDetail();
|
|
|
}
|
|
|
|
|
|
},
|
|
@@ -628,7 +428,7 @@ Page({
|
|
|
isModalShow: false
|
|
|
})
|
|
|
if (this.data.modalType === 'image') {
|
|
|
- this.jionSuccess(this.data.orderId, this.data.joinGroupType);
|
|
|
+ this.goToDetail();
|
|
|
}
|
|
|
},
|
|
|
})
|