123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- // pages/grade-details/grade-details.js
- import httpRequestApi from '../../../utils/APIClient';
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- productId: '',
- payList: [],
- titleIcon: '',
- title: '',
- bookInfo: '',
- lessonList: [],
- content: [{
- text: "转发给自己的朋友们,分享好课,",
- color: "#000"
- },
- {
- text: " 追随您一起学习进步。您的魅力不是吹的!",
- color: "#000"
- },
- {
- text: `在限定时间内成功拼团,您将得到xx元的奖励金哦。`,
- color: "#FF4600"
- }
- ],
- share: false
- },
- //获取团购信息并掉起支付
- pay: function ({
- currentTarget
- }) {
- const productId = this.data.productId;
- const groupId = currentTarget.dataset.id;
- //开始发起团购
- httpRequestApi.SendGroupPurchas({
- productId,
- groupId
- }).success((res) => {
- console.log('发起团购', res);
- // wx.navigateTo({
- // url: `/pages/groupPage/collage-details/collage-details`
- // })
- if (res.data.message) {
- wx.showModal({
- title: '提示',
- content: res.data.message,
- success(res) {
- if (res.confirm) {
- console.log('用户点击确定')
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- return false;
- }
- this.data.content[2].text = res.data.data.groupPurchaseOrder.organizerPrice === 0 ? '' : `在限定时间内内成功拼团,您将得到${res.data.data.groupPurchaseOrder.organizerPrice}元的奖励金哦。`
- this.setData({
- content: this.data.content
- })
- // 如果已经拥有当前课程,则无需支付,直接进入拼团成功页面
- if (res.data.data.groupPurchaseOrder.group === 'PROMOTION') {
- wx.showModal({
- title: '重新发起团购',
- content: '您会获得奖励哦',
- success(res) {
- console.log(res)
- that.popup.close();
- if (res.data.data.groupPurchaseOrder.headCount !== 1) {
- setTimeout(() => {
- wx.navigateTo({
- url: `/pages/groupPage/make-money/make-money?productId=${productId}&id=${res.data.data.groupPurchaseOrder.id}&groupId=${groupId}`
- })
- wx.setNavigationBarTitle({
- title: '拼团详情'
- })
- }, 3000)
- }
- }
- })
- } else {
- //掉起支付
- this.prePayMap(res.data.data.prePayMap, res.data.data.groupPurchaseOrder.id, res.data.data.groupPurchaseOrder.headCount);
- }
- }).fail((error) => {
- })
- },
- //支付
- prePayMap: function (prePayMap, orderId, num) {
- console.log(prePayMap)
- const that = this;
- //console.log(new Date().getTime())
- wx.requestPayment({
- 'appId': prePayMap.appId,
- 'timeStamp': prePayMap.timeStamp,
- 'nonceStr': prePayMap.nonceStr,
- 'package': prePayMap.package,
- 'signType': 'MD5',
- 'paySign': prePayMap.sign,
- 'success': function (res) {
- console.log('支付成功')
- wx.showModal({
- title: '提示',
- content: '支付成功',
- success(res) {
- console.log(res)
- that.popup.close();
- if (num !== 1) {
- setTimeout(() => {
- wx.navigateTo({
- url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
- })
- wx.setNavigationBarTitle({
- title: '拼团详情'
- })
- }, 3000)
- }
- }
- })
- },
- 'fail': function (res) {
- console.log('支付失败', res)
- }
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- console.log(options)
- if(options.share){
- this.setData({
- share: options.share
- })
- }
- // wx.setNavigationBarTitle({
- // title: options.title
- // })
- const productId = options.productId;
- if (productId) {
- this.setData({
- productId
- })
- }
- //课本详情
- httpRequestApi.getBookDetail(wx.getStorageSync('uid'), productId).success((res) => {
- console.log('课本详情', res.data.data);
- const bookInfo = res.data.data.product;
- const lessonList = res.data.data.lessonList;
- wx.setNavigationBarTitle({
- title: bookInfo.title
- })
- this.setData({
- titleIcon: bookInfo.bgImg,
- title: bookInfo.title,
- bookInfo: bookInfo.description
- })
- const lessonTemp = [];
- lessonList.forEach(item => {
- const temp = {};
- temp.id = item.id;
- temp.title = item.title;
- temp.readNum = item.readCount;
- lessonTemp.push(temp);
- });
- this.setData({
- lessonList: lessonTemp
- });
- }).fail((error) => {
- })
- //支付详情
- httpRequestApi.getGroupPurchaseInfo(productId).success((res) => {
- console.log('支付详情', res.data.data);
- this.setData({
- payList: res.data.data
- })
- }).fail((error) => {
- })
- },
- goToClass: function (e) {
- let id = e.currentTarget.dataset.id;
- let title = e.currentTarget.dataset.title;
- wx.navigateTo({
- url: `../../main/class/class?id=${id}&title=${title}`
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- //获取弹窗组件
- this.popup = this.selectComponent("#popup");
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|