|
|
@@ -64,10 +64,12 @@ export default {
|
|
|
payInfo: {
|
|
|
},
|
|
|
payStatus:0,
|
|
|
+ pay_code : '',
|
|
|
};
|
|
|
},
|
|
|
onLoad(option) {
|
|
|
- this.getPayDetail(option.id)
|
|
|
+ this.getPayDetail(option.id);
|
|
|
+ this.pay_code = option.id;
|
|
|
},
|
|
|
methods: {
|
|
|
getPayDetail(payId) {
|
|
|
@@ -87,7 +89,7 @@ export default {
|
|
|
"&sign=" +
|
|
|
md5Sign;
|
|
|
let postData = {
|
|
|
- code:payId,
|
|
|
+ code:payId,
|
|
|
openId: getApp().globalData.open_id,
|
|
|
};
|
|
|
uni.request({
|
|
|
@@ -126,28 +128,75 @@ export default {
|
|
|
let value = this.payInfo.total_fee - this.payInfo.reduction;
|
|
|
this.payInfo.real_fee = value;
|
|
|
}
|
|
|
- this.payInfo.payType = e.detail.value;
|
|
|
+ this.payInfo.type = e.detail.value;
|
|
|
},
|
|
|
paySubmit(){
|
|
|
if(this.payStatus){
|
|
|
this.open()
|
|
|
return
|
|
|
}
|
|
|
- uni.requestPayment({
|
|
|
- provider: 'wxpay',
|
|
|
- timeStamp: String(Date.now()),
|
|
|
- nonceStr: 'A1B2C3D4E5',
|
|
|
- package: 'prepay_id=wx20180101abcdefg',
|
|
|
- signType: 'MD5',
|
|
|
- paySign: '',
|
|
|
- success: function (res) {
|
|
|
- console.log('success:' + JSON.stringify(res));
|
|
|
- this.payStatus = 1;
|
|
|
- },
|
|
|
- fail: function (err) {
|
|
|
- console.log('fail:' + JSON.stringify(err));
|
|
|
- }
|
|
|
- });
|
|
|
+
|
|
|
+ let md5Sign = md5(
|
|
|
+ "method=" +
|
|
|
+ "user" +
|
|
|
+ "×tamp=" +
|
|
|
+ getApp().globalData.globalTimestamp +
|
|
|
+ "&secret=" +
|
|
|
+ getApp().globalData.secret
|
|
|
+ );
|
|
|
+ let url =
|
|
|
+ getApp().globalData.shareUrl +
|
|
|
+ "api/api.php" +
|
|
|
+ "?method=user&source=user&action=prepay×tamp=" +
|
|
|
+ getApp().globalData.globalTimestamp +
|
|
|
+ "&sign=" +
|
|
|
+ md5Sign;
|
|
|
+ let postData = {
|
|
|
+ code:this.pay_code,
|
|
|
+ type : this.payInfo.type,
|
|
|
+ openId: getApp().globalData.open_id,
|
|
|
+ };
|
|
|
+ uni.request({
|
|
|
+ url: url,
|
|
|
+ method: "POST",
|
|
|
+ header: {
|
|
|
+ "content-type": "application/x-www-form-urlencoded",
|
|
|
+ },
|
|
|
+ data: postData,
|
|
|
+ success: (res) => {
|
|
|
+ if (res.data.code === 200) {
|
|
|
+ let r = res.data.data;
|
|
|
+ uni.requestPayment({
|
|
|
+ provider: 'wxpay',
|
|
|
+ timeStamp: String(Date.now()),
|
|
|
+ nonceStr: r.nonce_str,
|
|
|
+ package: 'prepay_id=' + r.prepay_id,
|
|
|
+ signType: 'MD5',
|
|
|
+ paySign: r.sign,
|
|
|
+ success: function (res) {
|
|
|
+ console.log('success:' + JSON.stringify(res));
|
|
|
+ this.payStatus = 1;
|
|
|
+ },
|
|
|
+ fail: function (err) {
|
|
|
+ console.log('fail:' + JSON.stringify(err));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: res.data.msg,
|
|
|
+ icon: "none",
|
|
|
+ duration: 2500,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: () => {
|
|
|
+ console.log("连接失败");
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
//支付这里缺少签名参数 还需要后台配合调用微信那边的接口
|
|
|
//参考https://github.com/dcloudio/H5P.Server/tree/master/payment
|
|
|
|