139 lines
3.3 KiB
JavaScript
139 lines
3.3 KiB
JavaScript
const Apps = getApp();
|
|
const api = require('../../config/api.js');
|
|
const util = require('../../config/util.js');
|
|
import Toast from '../../miniprogram_npm/@vant/weapp/toast/toast';
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
pareid: 0,
|
|
listdata: [],
|
|
liveclickopen: 2,
|
|
baseurl: Apps.globalData.baseimgurl,
|
|
coursename: '',
|
|
vipsmonth_id: 1
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
console.log(options);
|
|
this.setData({
|
|
pareid: options.id,
|
|
vipsmonth_id: options.vipsmonth_id
|
|
});
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
Apps.islogin();
|
|
this.getvipmonthcourse();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
},
|
|
|
|
getvipmonthcourse: function () {
|
|
const that = this;
|
|
let url = Apps.globalData.baseUrl + '/vip/getvipmonthcourselist';
|
|
var param = {
|
|
id: that.data.pareid,
|
|
};
|
|
//此处为使用封装的post请求
|
|
util.post(url, param).then((res) => {
|
|
console.log(res);
|
|
that.setData({
|
|
listdata: res.data,
|
|
coursename: res.data[0]['parentname']
|
|
});
|
|
|
|
}).catch((errMsg) => {
|
|
console.log(errMsg);
|
|
});
|
|
},
|
|
payorderclick: function (params) {
|
|
|
|
let vipsmonth = params.currentTarget.dataset.vipsmonth;
|
|
const that = this;
|
|
let url = Apps.globalData.baseUrl + '/wxpay/makerorder';
|
|
var param = {
|
|
id: params.currentTarget.id,
|
|
openid: wx.getStorageSync('wxopenid'),
|
|
paytypeid: 2, //会员卡充值
|
|
user_id: wx.getStorageSync('wxuserid') == null ? 3 : wx.getStorageSync('wxuserid'),
|
|
vipsmonth: vipsmonth
|
|
};
|
|
//此处为使用封装的post请求
|
|
util.post(url, param).then((res) => {
|
|
console.log(res);
|
|
var rest = res;
|
|
// var orders = res.data.orders;
|
|
// 调用支付接口开始
|
|
wx.requestPayment({
|
|
timeStamp: rest.timeStamp,
|
|
nonceStr: rest.nonceStr,
|
|
package: rest.package,
|
|
signType: rest.signType,
|
|
paySign: rest.paySign,
|
|
success: function (res) {
|
|
Toast('VIP充值成功');
|
|
},
|
|
fail: function (res) {
|
|
console.log(res)
|
|
},
|
|
complete: function (res) {
|
|
console.log(res)
|
|
},
|
|
})
|
|
|
|
}).catch((errMsg) => {
|
|
console.log(errMsg);
|
|
});
|
|
},
|
|
|
|
}) |