1.修改支付重复点击

huipay-h5
杨杰 1 year ago
parent 7669d96f0e
commit 4924fe1086
  1. 3
      App.vue
  2. 5
      Utils/Request.js
  3. 69
      pages/index/index.vue

@ -23,7 +23,8 @@
// url: 'https://hsgcs.dctpay.com/user', // url: 'https://hsgcs.dctpay.com/user',
// graurl:'https://gratia-pay.dctpay.com/crest', // graurl:'https://gratia-pay.dctpay.com/crest',
// imgUrl: 'https://hsgcs.dctpay.com/filesystem/', // imgUrl: 'https://hsgcs.dctpay.com/filesystem/',
// imageWxImg: 'https://hsgcs.dctpay.com/filesystem/wxApplets/', // imageWxImg: 'https://hsgcs.dctpay.com/filesystem/wxApplets/',
isClick: true, //
}, },
onLaunch: function() { onLaunch: function() {

@ -39,9 +39,10 @@ function request(method, url, data) {
}) })
} }
}, },
fail(err) { fail(err) {
app.globalData.isClick = true;
uni.showToast({ uni.showToast({
title: '请求失败', title: '请求失败,查看网络是否正常',
icon: 'none', icon: 'none',
duration: 1500, duration: 1500,
}) })

@ -464,7 +464,7 @@
if (item >= this.storediscountCondition) { if (item >= this.storediscountCondition) {
storetype = this.storediscountType; storetype = this.storediscountType;
storeprice = this.storediscountPrice; storeprice = this.storediscountPrice;
} }
// else { // else {
// storetype = this.storediscountType; // storetype = this.storediscountType;
// storeprice = this.storediscountPrice; // storeprice = this.storediscountPrice;
@ -672,13 +672,16 @@
// if (userAgent.match(/Alipay/i) == "alipay") { // if (userAgent.match(/Alipay/i) == "alipay") {
// this.createJSAPIOrder('ALIPAY'); // this.createJSAPIOrder('ALIPAY');
// } else if (userAgent.match(/MicroMessenger/i) == "micromessenger") { // } else if (userAgent.match(/MicroMessenger/i) == "micromessenger") {
this.createJSAPIOrder(); if (app.globalData.isClick) {
this.createJSAPIOrder();
app.globalData.isClick = false;
}
// } // }
}, },
// //
createJSAPIOrder(item) { createJSAPIOrder(item) {
uni.showLoading({ uni.showLoading({
title:'请求中' title: '请求中'
}) })
// "WECHAT ALIPAY UQRCODEPAY", // "WECHAT ALIPAY UQRCODEPAY",
let phone = ''; let phone = '';
@ -694,11 +697,12 @@
"userDiscountId": this.memDiscountId, "userDiscountId": this.memDiscountId,
"userPhone": phone "userPhone": phone
} }
createJSAPIOrder(datas).then(res => { createJSAPIOrder(datas).then(res => {
uni.hideLoading(); uni.hideLoading();
if (res.return_code == '000000') { if (res.return_code == '000000') {
this.jsapiPay(res.return_data.outTradeNo); this.jsapiPay(res.return_data.outTradeNo);
} else { } else {
app.globalData.isClick = true;
uni.showToast({ uni.showToast({
title: res.return_msg, title: res.return_msg,
duration: 2000, duration: 2000,
@ -708,11 +712,15 @@
}) })
}, },
// //
jsapiPay(item) { jsapiPay(item) {
uni.showLoading({
title: '请求中'
})
let datas = { let datas = {
outTradeNo: item outTradeNo: item
} }
jsapiPay(datas).then(res => { jsapiPay(datas).then(res => {
uni.hideLoading();
if (res.return_code == '000000') { if (res.return_code == '000000') {
if (res.return_data.payParam && app.globalData.platformType == 'WECHAT') { if (res.return_data.payParam && app.globalData.platformType == 'WECHAT') {
this.wechatpayRequest(res.return_data); this.wechatpayRequest(res.return_data);
@ -732,7 +740,8 @@
icon: 'none', icon: 'none',
duration: 2000 duration: 2000
}) })
} else { } else {
app.globalData.isClick = true;
uni.showToast({ uni.showToast({
title: res.return_msg, title: res.return_msg,
duration: 2000, duration: 2000,
@ -847,11 +856,12 @@
}, },
// //
wechatpayRequest: function(self) { wechatpayRequest: function(self) {
let that = this;
uni.showLoading({ uni.showLoading({
title: '支付中...' title: '支付中...'
}) })
if (self.platformType == 1) { if (self.platformType == 1 || self.platformType == 5) {
jweixin.config({ jweixin.config({
debug: false, // ,apialertpclogpc debug: false, // ,apialertpclogpc
appId: self.payParam.acc_resp_fields.app_id, // appId: self.payParam.acc_resp_fields.app_id, //
@ -864,8 +874,12 @@
jweixin.ready(function() { jweixin.ready(function() {
jweixin.checkJsApi({ jweixin.checkJsApi({
jsApiList: ['chooseWXPay'], // JSJS2, jsApiList: ['chooseWXPay'], // JSJS2,
success: function(res) {}, success: function(res) {
fail: function(res) {} app.globalData.isClick = true;
},
fail: function(res) {
app.globalData.isClick = true;
}
}); });
jweixin.chooseWXPay({ jweixin.chooseWXPay({
appId: self.payParam.acc_resp_fields.app_id, appId: self.payParam.acc_resp_fields.app_id,
@ -883,11 +897,16 @@
title: '支付成功' title: '支付成功'
}) })
}, },
cancel: function(r) {}, cancel: function(r) {
fail: function(res) {} app.globalData.isClick = true;
},
fail: function(res) {
app.globalData.isClick = true;
}
}); });
}); });
jweixin.error(function(res) { jweixin.error(function(res) {
app.globalData.isClick = true;
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '支付失败了', title: '支付失败了',
@ -924,11 +943,16 @@
title: '支付成功' title: '支付成功'
}) })
}, },
cancel: function(r) {}, cancel: function(r) {
fail: function(res) {} app.globalData.isClick = true;
},
fail: function(res) {
app.globalData.isClick = true;
}
}); });
}); });
jweixin.error(function(res) { jweixin.error(function(res) {
app.globalData.isClick = true;
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '支付失败了', title: '支付失败了',
@ -941,7 +965,8 @@
alipayRequest(item) { alipayRequest(item) {
alipayApi.tradePay({ alipayApi.tradePay({
tradeNO: item tradeNO: item
}, function(res) { }, function(res) {
app.globalData.isClick = true;
// alert(JSON.stringify(res)); // alert(JSON.stringify(res));
// //
}); });

Loading…
Cancel
Save