1.优化充值问题

yj-dev
杨杰 4 years ago
parent 616d25db44
commit 3be3f813fb
  1. 79
      pages/user/deposit/deposit.vue

@ -78,6 +78,7 @@
addOrder,
orderToPay
} from "../../../Utils/Api.js";
var jweixin = require('jweixin-module');
export default {
data() {
return {
@ -87,6 +88,9 @@
user: "",
};
},
onLoad() {
this.user = app.globalData.userInfo
},
methods: {
select(amount) {
@ -126,11 +130,9 @@
}]
}
addOrder(goods).then(res => {
uni.hideLoading();
if (res.return_code == '000000') {
///
uni.showLoading({
title: '支付中...'
})
let params = {
"orderId": res.return_data.id,
"openId": app.globalData.openId,
@ -138,6 +140,10 @@
}
orderToPay(params).then(res => {
if (res.return_code == '000000') {
// #ifdef MP
uni.showLoading({
title: '支付中...'
})
uni.requestPayment({
"appId": res.return_data.appId,
"nonceStr": res.return_data.nonceStr,
@ -159,23 +165,80 @@
console.log('fail:' + JSON.stringify(err));
}
});
}else{
// #endif
//
// #ifdef H5
//
this.payRequest(res);
// #endif
} else {
uni.showToast({
title:'支付失败'
title: '支付失败'
})
}
})
} else {
uni.showToast({
title: res.return_msg
});
}
})
}
},
onLoad() {
this.user = app.globalData.userInfo
payRequest: function(self) {
uni.showLoading({
title: '支付中...'
})
jweixin.config({
// debug: true, // ,apialertpclogpc
appId: self.return_data.appId, //
timestamp: self.return_data.timeStamp, //
nonceStr: self.return_data.nonceStr, //
signature: self.return_data.sign, // 1
jsApiList: ['chooseWXPay'] // 使JSJS2
});
uni.hideLoading();
jweixin.ready(function() {
jweixin.checkJsApi({
jsApiList: ['chooseWXPay'], // JSJS2,
success: function(res) {},
fail: function(res) {}
});
jweixin.chooseWXPay({
appId: self.return_data.appId,
timestamp: self.return_data
.timeStamp, // jssdk使timestamp使timeStampS
nonceStr: self.return_data.nonceStr, // 32
package: self.return_data
.package, // prepay_idprepay_id=***
signType: 'MD5', // 'SHA1'使'MD5'
paySign: self.return_data.sign, //
success: function(res) {
//
uni.showToast({
title: '支付成功'
})
uni.reLaunch({
url: '../success/success?id=' + that.couponId
});
},
cancel: function(r) {},
fail: function(res) {}
});
});
jweixin.error(function(res) {
uni.showToast({
icon: 'none',
title: '支付失败了',
duration: 4000
});
});
},
},
}
</script>

Loading…
Cancel
Save