一:微信小程序中的微信支付
1:你要先在微信公众平台里微信支付那里去关联你的商户号,然后去申请接入微信支付,需要提交所需的资料,需要管理员操作。
2:前提准备好后开发中
postMoney() { // 点击确认充值
console.log("点击了");
let that = this
console.log(that.payChannelid);
if(that.payChannelid == 0){
uni.showToast({
title: '请选择支付方式',
icon: 'none'
});
}else if(that.payChannelid == 4){
wx.showLoading({
title: '加载中',
})
// 获取订单
requestApi(prefix + "/order/createRechargeOrder", {
amount: that.chargcount, 充值金额
tenantId: that.tenantId, 租客id
resourceId: that.resourceId 房间id
}, "post").then(res => {
if (res.success == true) {
that.order = res.data
//保存订单
requestApi(prefix + "/pay/findPrepaymentOrder", {
rechargeOrderId: that.order, 订单id
resourceId: that.resourceId 房间id
}, "post").then(res => {
if (res.success == true) {
requestApi(prefix + "/pay/rechargeWxPay",{
rechargeOrderId: that.order,
resourceId: that.resourceId
},"post").then(res=>{
if(res.success == true){
wx.hideLoading(); //关闭loading
console.log(res.data.body);
res.data.body = JSON.parse(res.data.body)
console.log(res.data.body);
wx.requestPayment({ // 这一步是调起微信支付
"appId": res.data.body.appId,
"timeStamp": res.data.body.timeStamp,
"nonceStr": res.data.body.nonceStr,
"package": res.data.body.package,
"signType": res.data.body.signType,
"paySign": res.data.body.paySign,
"success": function(res) {
wx.hideLoading(); //关闭loading
uni.showToast({
title: '充值成功',
icon: 'none'
});
},
"fail": function(res) {
wx.hideLoading(); //关闭loading
uni.showToast({
title: '支付失败',
icon: 'none'
});
},
// "complete": function(res) {
// wx.hideLoading(); //关闭loading
// uni.showToast({
// title: '取消支付',
// icon: 'none'
// });
// }
})
}
})
}
})
}
})
}else if(that.payChannelid == 3){ //支付宝充值
uni.showToast({
title: '目前只支持微信支付',
icon: 'none'
});
}
},