Files
HnyhuaXCX/pages/pay/index.js

103 lines
2.4 KiB
JavaScript

var app = getApp()
var that=null
var sopenFrame=null
var areas = null;
Page( {
data: {
loadingHidden:false,
ResultId:0
},
onReady: function(e) {
},
onLoad: function(options) {
that = this
if(options.id){
that.setData({
ResultId:options.id
})
}
that.rdata()
},rdata: function() {
wx.login({
success: function (resc) {
if (resc.code) {
var code=resc.code;
wx.request({
url: app.globalData.apiurl + "/xapiajax.ashx",
data: {
action:"getpaydata",
id:that.data.ResultId,
code:code
},
method:"POST",
dataType:"json",
header: {
"content-type": "application/x-www-form-urlencoded" // 默认值
},
success (res) {
that.setData({
loadingHidden:true
})
if(res.data.status==1){
wx.requestPayment({
timeStamp: res.data.timeStamp,
nonceStr: res.data.noncestr,
package: res.data.package,
signType: res.data.signType,
paySign: res.data.paySign,
success (res0) {
wx.showToast({
title: "支付成功",
icon: "none",
duration: 3000
})
},
fail (res0) {
wx.request({
url: app.globalData.apiurl + "/xapiajax.ashx",
data: {
action:"CancelOrderPay",
id:that.data.ResultId
},
method:"POST",
dataType:"json",
header: {
"content-type": "application/x-www-form-urlencoded" // 默认值
},
success (res) {
},
fail (res0) {
}
})
/* wx.showToast({
title: JSON.stringify(res0),
icon: "none",
duration: 3000
})*/
}
})
}else{
wx.showToast({
title: res.data.msg,
icon: "none",
duration: 3000
})
}
}
})
}
}
})
},launchAppError: function() {
}
})