You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

113 lines
2.3 KiB

// pages/activity/signIn/confirm/index.js
const app = getApp();
import util from '../../../../utils/util'
Page({
/**
* 页面的初始数据
*/
data: {
payInfo : {},
canClick:true
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let info = JSON.parse(decodeURIComponent(options.payInfo));
info.activity.activityStartTime = util.setTime(info.activity.activityStartTime);
info.activity.activityEndTime = util.setTime(info.activity.activityEndTime);
this.setData({
payInfo:info
})
console.log(this.data.payInfo)
},
backUpPage(){
wx.navigateBack({
delta: 1,
})
},
toPay(){
if(this.data.canClick){
this.setData({canClick : false});
app.http('POST','activity/orderPay',{id:this.data.payInfo.order.id}).then((res)=>{
console.log(res)
if(res.data.success){
//微信支付
wx.requestPayment({
timeStamp: res.data.data.timeStamp,
nonceStr: res.data.data.nonceStr,
package: res.data.data.packageValue,
signType: 'MD5',
paySign: res.data.data.paySign,
success: response=> {
this.setData({canClick: true});
wx.showToast({
title: '支付成功!',
duration: 1500
});
setTimeout(()=> {
wx.navigateTo({
url: '../paymentSuccess/index',
})
}, 1500);
},
fail: response=> {
this.setData({canClick: true});
console.log(response)
}
})
}
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})