Payment method consolidated

This commit is contained in:
Vion
2022-01-27 16:55:00 +08:00
parent 7912abdabc
commit 300788a552
6 changed files with 104 additions and 167 deletions

View File

@@ -93,6 +93,9 @@
<p>请返回商品结算页面重新支付</p>
</div>
</el-dialog>
<div style="display:none">
<form :action="this.h5PayUrl" method="post" ref="h5SubmitForm"></form>
</div>
</div>
</template>
@@ -103,39 +106,40 @@ import vueQr from 'vue-qr'
import { generateOrderAlipay, updateOrderWX, monitorOrderNotify,repayOrde } from "../../ajax/getData";
//import { isMobile } from "@/ajax/util";
import util from "@/ajax/util";
export default {
data() {
return {
activeIndex: 0,
paymentTimer:undefined,
isSucess: false,
data() {
return {
util,
activeIndex: 0,
paymentTimer:undefined,
isSucess: false,
h5PayUrl:"",
dialogSuccess: false,
paytype: "微信",
userpaystype: [
{
paytype: "微信",
payimage: require("../../assets/pay/wx.png"),
type:'wechat'
},
dialogSuccess: false,
paytype: "微信",
userpaystype: [
{
paytype: "微信",
payimage: require("../../assets/pay/wx.png"),
type:'wechat'
},
{
paytype: "支付宝",
payimage: require("../../assets/pay/zfb.png"),
type:'alipay'
},
],
dialogFail: false,
userPayData: {},
qrtext:'',
userData:'',
disableAlipay:true,
disableQrcode:false,
};
},
{
paytype: "支付宝",
payimage: require("../../assets/pay/zfb.png"),
type:'alipay'
},
],
dialogFail: false,
userPayData: {},
qrtext:'',
userData:'',
disableAlipay:true,
disableQrcode:false,
};
},
created(){
@@ -144,65 +148,42 @@ export default {
let stype=this.$route.query.stype;
this.userPayData = JSON.parse(this.$route.query.userPayData);
this.defaultHandlePayment();
this.defaultHandlePayment();
},
methods: {
defaultHandlePayment() {
let isMobile = this.isMobile();
let isWx = this.isWX();
if(isWx && this.userPayData.wxPay && this.userPayData.wxPay.length>4) {
//Desktop, use native pay
this.disableQrcode=false;
this.qrtext=this.userPayData.wxPay;
} else if(isWx) {
let isMobile = this.util.isMobile();
let isWx = this.util.isWX();
let payType = this.util.pickPaytype();
if(!this.userPayData.wxPay || this.userPayData.wxPay.length<4)
throw new Error("订单信息错误请删除商品后再次购买");
}
if(!isWx) {
if(this.userPayData.wxPay && !isMobile) {
//Desktop, use native pay
//Dictionary : 1: scan qrcode, 2:redirect 3: raise local app
switch(payType) {
case 1:
this.disableQrcode=false;
this.qrtext=this.userPayData.wxPay;
this.payOrderWX();
this.disableQrcode=false;
} else if (this.userPayData.wxPay && isMobile) {
//Mobile, use H5 pay
break;
case 2:
this.disableQrcode=true;
} else if(!this.userPayData.wxPay || this.userPayData.wxPay.length<=4) {
throw new Error("订单信息错误,请删除商品后再次购买");
}
break;
case 3:
//TODO raise WX jsapi pay
break;
}
},
goPayH5() {
let isMobile = this.isMobile();
let isMobile = this.util.isMobile();
if(this.userPayData.wxPay && isMobile) {
window.location.href=this.userPayData.wxPay;
this.$refs["h5SubmitForm"].action=this.userPayData.wxPay;
this.$refs["h5SubmitForm"].submit();
//window.location.href=this.userPayData.wxPay;;
this.disableQrcode=true;
} else {
throw new Error("订单信息错误请删除商品后再次购买");
}
},
isMobile () {
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp = sUserAgent.match(/midp/i) == "midp";
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid = sUserAgent.match(/android/i) == "android";
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
if (!(bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM)) {
return false;
} else {
return true;
}
},
/**/
isWX(){
var ua = navigator.userAgent.toLowerCase();
return (/micromessenger/.test(ua)) ? true : false;
},
closeDialogSuccess() {
this.qrtext = '';
this.$router.push({