Live chat method updated , Alipay payment gatewat integrated

This commit is contained in:
Vion 2022-02-14 17:50:30 +08:00
parent bf838eb78a
commit b636872ecd
4 changed files with 60 additions and 32 deletions

View File

@ -661,8 +661,19 @@ export const getOrderList = (user, status) => {
} }
//支付宝支付二维码 //支付宝支付二维码
export const generateOrderAlipay = (data) => { export const generateOrderAlipay = (orderNo, payType) => {
return fetch('generateOrderAlipay', data, 'POST' ) //Dictionary : 1: PC, 2: Mobile
} let url = 'generateOrderAlipayPC';
if(payType == 2) {
url = 'generateOrderAlipayPhone'
}
var data = {
orderNo:orderNo
}
return fetch(url, data)
//let ret = { "code": 1, "msg": "操作成功!", "success": true, "data": "<form name=\"punchout_form\" method=\"post\" action=\"https://openapi.alipay.com/gateway.do?charset=utf-8&method=alipay.trade.wap.pay&sign=GK1NjnOYPh%2BHTcTtuZg4YunsBNGPHiyc9BwXLx%2FG4G6Z7S8ILYy2E6VmxkGVwZEwZ1G5PA3u2eZxJN3ysyynL9uwG7L4jGQcOB6I2m1763VBi7euNiyMhimv5AYeXP4KiDtmZNDIAdyi3eKWemKTq74AfS0TTubYvKL8aqhJHTQy2GtYdXA89v53ZeFkXjoqpylwCf2j%2FJWD1nV1eO0a0PB5MFqPaZB5Eif69XkT1TNAt1eZiwIn4AO6yqMFJ41gGN5ymmLQUVcUgc5dxlGkMNgY4FUsI6mFYucQ%2BRPPmuH78YJTFU6VS5E%2BZ%2BCL%2BGLxeJs068n%2BLAPqpPqDbhveYg%3D%3D&return_url=https%3A%2F%2Fshop.royalcanin.com.cn&notify_url=https%3A%2F%2Fshop.royalcanin.com.cn%2Froyalcanin%2Froyalcanin%2Froyalcanin%2FupdateOrderAliPay&version=1.0&app_id=2021003108690157&sign_type=RSA2&timestamp=2022-02-14+15%3A08%3A05&alipay_sdk=alipay-sdk-java-dynamicVersionNo&format=json\">\n<input type=\"hidden\" name=\"biz_content\" value=\"{&quot;out_trade_no&quot;:&quot;02110014172230000&quot;,&quot;total_amount&quot;:&quot;138.0&quot;,&quot;subject&quot;:&quot;皇家宠物食品官方商城&quot;}\">\n<input type=\"submit\" value=\"立即支付\" style=\"display:none\" >\n</form>\n<script>document.forms[0].submit();</script>" };
//ret = JSON.parse(ret);
//return ret;
}

View File

@ -55,7 +55,7 @@ export default {
}, },
methods:{ methods:{
...mapMutations(["checkIsLogin"]), ...mapMutations(["checkIsLogin"]),
lianxi(item,index){ lianxi(item,index) {
this.checkIsLogin(); this.checkIsLogin();
let user = this.$store.state.userInfo; let user = this.$store.state.userInfo;
let curMemberId = (user?user.data.id:''); let curMemberId = (user?user.data.id:'');
@ -63,7 +63,8 @@ export default {
//this.customerServerStop = true; //this.customerServerStop = true;
/* Stop until 2022-2-10 */ /* Stop until 2022-2-10 */
var option = { var option = {
customer: {id: '', name: '', email: '', mobile: '', memberId: curMemberId} customer: {id: '', name: '', email: '', mobile: '', memberId: curMemberId, types:'14054'},
type:3
} }
dis_livchat(option); dis_livchat(option);
_hmt.push([ _hmt.push([
@ -91,7 +92,8 @@ export default {
//this.customerServerStop = true; //this.customerServerStop = true;
/* Stop until 2022-2-10*/ /* Stop until 2022-2-10*/
var option = { var option = {
customer: {id: '', name: '', email: '', mobile: '', memberId: curMemberId} customer: {id: '', name: '', email: '', mobile: '', memberId: curMemberId, types:'14053'},
type:3
} }
dis_livchat(option); dis_livchat(option);
_hmt.push([ _hmt.push([

View File

@ -15,7 +15,7 @@ export default {
script: [ script: [
//{ src: '/js/rem.js' }, //{ src: '/js/rem.js' },
// { src: '/js/flexible.js', type: 'text/javascript', charset: 'utf-8'}, // { src: '/js/flexible.js', type: 'text/javascript', charset: 'utf-8'},
{ src: 'https://ocstest.royalcanin.com.cn:8081/livechat/chatapp/customer/branch/RoyalCanin/14053/index.js' }, { src: 'https://ocstest.royalcanin.com.cn:8081/livechat/chatapp/customer/branch/RoyalCanin/14054/index.js' },
//{ src: 'https://ocs.royalcanin.com.cn:8081/livechat/chatapp/customer/branch/RoyalCanin/14053/index.js' }, //{ src: 'https://ocs.royalcanin.com.cn:8081/livechat/chatapp/customer/branch/RoyalCanin/14053/index.js' },
//{ src: 'https://ocstest.royalcanin.com.cn:8081/livechat/chatapp/customer/branch/RoyalCanin/14054/index.js' }, //{ src: 'https://ocstest.royalcanin.com.cn:8081/livechat/chatapp/customer/branch/RoyalCanin/14054/index.js' },
{ innerHTML: trackingScript, type: 'text/javascript', charset: 'utf-8'}, { innerHTML: trackingScript, type: 'text/javascript', charset: 'utf-8'},

View File

@ -93,10 +93,7 @@
<p>请返回商品结算页面重新支付</p> <p>请返回商品结算页面重新支付</p>
</div> </div>
</el-dialog> </el-dialog>
<div style="display:none"> <div style="display:none" ref="h5SubmitForm">
<form :action="this.h5PayUrl" method="post" ref="h5SubmitForm">
<input type="hidden" v-model="h5payRedirectUrl">
</form>
</div> </div>
</div> </div>
</template> </template>
@ -114,7 +111,6 @@ export default {
data() { data() {
return { return {
util, util,
h5payRedirectUrl:'',
activeIndex: 0, activeIndex: 0,
paymentTimer:undefined, paymentTimer:undefined,
isSucess: false, isSucess: false,
@ -148,28 +144,44 @@ export default {
}, },
mounted() { mounted() {
let isWx = this.util.isWX();
if(!isWx) {
this.disableAlipay = false;
}
let stype=this.$route.query.stype; let stype=this.$route.query.stype;
this.userPayData = JSON.parse(this.$route.query.userPayData); this.userPayData = JSON.parse(this.$route.query.userPayData);
this.defaultHandlePayment(); this.defaultHandlePayment();
}, },
methods: { 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() { defaultHandlePayment() {
let isMobile = this.util.isMobile(); let isMobile = this.util.isMobile();
let isWx = this.util.isWX(); let isWx = this.util.isWX();
let payType = this.util.pickPaytype(); let payType = this.util.pickPaytype();
if(!this.userPayData.wxPay || this.userPayData.wxPay.length<4) if(!this.userPayData.wxPay || this.userPayData.wxPay.length<4)
throw new Error("订单信息错误,请删除商品后再次购买"); throw new Error("订单信息错误,请删除商品后再次购买");
this.detectQrcodeDisplay();
//Dictionary : 1: scan qrcode, 2:redirect 3: raise local app //Dictionary : 1: scan qrcode, 2:redirect 3: raise local app
switch(payType) { switch(payType) {
case 1: case 1:
this.disableQrcode=false;
this.qrtext=this.userPayData.wxPay; this.qrtext=this.userPayData.wxPay;
this.payOrderWX(); this.updateOrderNotification();
break; break;
case 2: case 2:
this.disableQrcode=true; this.$refs["h5SubmitForm"].innerHTML = '<form action="'+this.userPayData.wxPay+'" method="post"><form>';
break; break;
case 3: case 3:
//TODO raise WX jsapi pay //TODO raise WX jsapi pay
@ -185,13 +197,12 @@ export default {
]) ])
}, },
goPayH5() { goPayH5() {
let isMobile = this.util.isMobile(); if(this.userPayData.wxPay) {
if(this.userPayData.wxPay && isMobile) {
//this.$refs["h5SubmitForm"].action="http://47.96.75.242:10086/royalcanin/royalcanin/redirectUrlWXH5"; //this.$refs["h5SubmitForm"].action="http://47.96.75.242:10086/royalcanin/royalcanin/redirectUrlWXH5";
this.$refs["h5SubmitForm"].action=this.userPayData.wxPay; //this.$refs["h5SubmitForm"].action=this.userPayData.wxPay;
this.$refs["h5SubmitForm"].submit(); this.$refs["h5SubmitForm"].children[0].submit()
//window.location.href=this.userPayData.wxPay;; //window.location.href=this.userPayData.wxPay;
this.disableQrcode=true; //this.disableQrcode=true;
} else { } else {
throw new Error("订单信息错误,请删除商品后再次购买"); throw new Error("订单信息错误,请删除商品后再次购买");
} }
@ -217,21 +228,25 @@ export default {
this.paytype = item.paytype; this.paytype = item.paytype;
if (index == 1) { if (index == 1) {
// //
let res = await generateOrderAlipay(this.userPayData.orderId); let isMobile = this.util.isMobile();
this.qrtext = ''; isMobile = (isMobile?2:1);
let res = await generateOrderAlipay(this.userPayData.orderId, isMobile);
if (res.success) { if (res.success) {
this.disableQrcode = true;
this.qrtext=res.data; let virtualForm = res.data;
virtualForm = virtualForm.substr(0,virtualForm.indexOf("</form>")+7);
this.$refs["h5SubmitForm"].innerHTML = virtualForm;
} }
} else { } else {
this.userPayData = JSON.parse(this.$route.query.userPayData); 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); let res = await monitorOrderNotify(this.userPayData.orderId);
if (res.success) { if (res.success) {
this.qrtext = '成功加入群的二维码'; this.qrtext = '成功加入群的二维码';
@ -250,7 +265,7 @@ export default {
} else { } else {
let _self = this; let _self = this;
this.paymentTimer = setTimeout(function(){ this.paymentTimer = setTimeout(function(){
_self.payOrderWX() _self.updateOrderNotification()
},5000); },5000);
} }