mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-11-17 08:03:49 +08:00
Live chat method updated , Alipay payment gatewat integrated
This commit is contained in:
@@ -93,10 +93,7 @@
|
||||
<p>请返回商品结算页面重新支付</p>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<div style="display:none">
|
||||
<form :action="this.h5PayUrl" method="post" ref="h5SubmitForm">
|
||||
<input type="hidden" v-model="h5payRedirectUrl">
|
||||
</form>
|
||||
<div style="display:none" ref="h5SubmitForm">
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -114,7 +111,6 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
util,
|
||||
h5payRedirectUrl:'',
|
||||
activeIndex: 0,
|
||||
paymentTimer:undefined,
|
||||
isSucess: false,
|
||||
@@ -148,28 +144,44 @@ export default {
|
||||
|
||||
},
|
||||
mounted() {
|
||||
let isWx = this.util.isWX();
|
||||
if(!isWx) {
|
||||
this.disableAlipay = false;
|
||||
}
|
||||
let stype=this.$route.query.stype;
|
||||
|
||||
this.userPayData = JSON.parse(this.$route.query.userPayData);
|
||||
this.defaultHandlePayment();
|
||||
},
|
||||
methods: {
|
||||
detectQrcodeDisplay(){
|
||||
let payType = this.util.pickPaytype();
|
||||
switch(payType) {
|
||||
case 1:
|
||||
this.disableQrcode=false;
|
||||
break;
|
||||
case 2:
|
||||
this.disableQrcode=true;
|
||||
break;
|
||||
case 3:
|
||||
//TODO raise WX jsapi pay
|
||||
break;
|
||||
}
|
||||
},
|
||||
defaultHandlePayment() {
|
||||
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("订单信息错误,请删除商品后再次购买");
|
||||
|
||||
this.detectQrcodeDisplay();
|
||||
//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.updateOrderNotification();
|
||||
break;
|
||||
case 2:
|
||||
this.disableQrcode=true;
|
||||
this.$refs["h5SubmitForm"].innerHTML = '<form action="'+this.userPayData.wxPay+'" method="post"><form>';
|
||||
break;
|
||||
case 3:
|
||||
//TODO raise WX jsapi pay
|
||||
@@ -185,13 +197,12 @@ export default {
|
||||
])
|
||||
},
|
||||
goPayH5() {
|
||||
let isMobile = this.util.isMobile();
|
||||
if(this.userPayData.wxPay && isMobile) {
|
||||
if(this.userPayData.wxPay) {
|
||||
//this.$refs["h5SubmitForm"].action="http://47.96.75.242:10086/royalcanin/royalcanin/redirectUrlWXH5";
|
||||
this.$refs["h5SubmitForm"].action=this.userPayData.wxPay;
|
||||
this.$refs["h5SubmitForm"].submit();
|
||||
//window.location.href=this.userPayData.wxPay;;
|
||||
this.disableQrcode=true;
|
||||
//this.$refs["h5SubmitForm"].action=this.userPayData.wxPay;
|
||||
this.$refs["h5SubmitForm"].children[0].submit()
|
||||
//window.location.href=this.userPayData.wxPay;
|
||||
//this.disableQrcode=true;
|
||||
} else {
|
||||
throw new Error("订单信息错误,请删除商品后再次购买");
|
||||
}
|
||||
@@ -217,21 +228,25 @@ export default {
|
||||
this.paytype = item.paytype;
|
||||
if (index == 1) {
|
||||
//支付宝
|
||||
let res = await generateOrderAlipay(this.userPayData.orderId);
|
||||
this.qrtext = '';
|
||||
let isMobile = this.util.isMobile();
|
||||
isMobile = (isMobile?2:1);
|
||||
let res = await generateOrderAlipay(this.userPayData.orderId, isMobile);
|
||||
if (res.success) {
|
||||
|
||||
this.qrtext=res.data;
|
||||
this.disableQrcode = true;
|
||||
let virtualForm = res.data;
|
||||
virtualForm = virtualForm.substr(0,virtualForm.indexOf("</form>")+7);
|
||||
this.$refs["h5SubmitForm"].innerHTML = virtualForm;
|
||||
}
|
||||
|
||||
} else {
|
||||
this.userPayData = JSON.parse(this.$route.query.userPayData);
|
||||
this.qrtext=this.userPayData.wxPay
|
||||
this.qrtext=this.userPayData.wxPay;
|
||||
this.$refs["h5SubmitForm"].innerHTML = '<form method="get" action="'+this.userPayData.wxPay+'"></form>';
|
||||
this.detectQrcodeDisplay();
|
||||
}
|
||||
},
|
||||
//支付监听
|
||||
|
||||
async payOrderWX() {
|
||||
async updateOrderNotification() {
|
||||
let res = await monitorOrderNotify(this.userPayData.orderId);
|
||||
if (res.success) {
|
||||
this.qrtext = '成功加入群的二维码';
|
||||
@@ -250,7 +265,7 @@ export default {
|
||||
} else {
|
||||
let _self = this;
|
||||
this.paymentTimer = setTimeout(function(){
|
||||
_self.payOrderWX()
|
||||
_self.updateOrderNotification()
|
||||
},5000);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user