!120 2022-1-27 Leung

Merge pull request !120 from Admin/sit-Leung
This commit is contained in:
Admin 2022-01-27 03:25:24 +00:00 committed by Gitee
commit aeec63e7a3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 92 additions and 13 deletions

64
rc-busness/ajax/util.js Normal file
View File

@ -0,0 +1,64 @@
/*
export const 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;
}
}
*/
export default {
isMobile :false
}
/*
export default {
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;
}
}
}
*/
/*
function 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;
}
}
export { isMobile }
*/

View File

@ -4,7 +4,7 @@ export default {
// Global page headers: https://go.nuxtjs.dev/config-head // Global page headers: https://go.nuxtjs.dev/config-head
head: { head: {
title: '皇家官方商城', title: '皇家宠物食品官方商城',
htmlAttrs: { htmlAttrs: {
lang: 'zh-cn', lang: 'zh-cn',

View File

@ -101,7 +101,9 @@ import Myheader from "~/components/header.vue";
import tabs from "@/components/tabs.vue"; import tabs from "@/components/tabs.vue";
import vueQr from 'vue-qr' import vueQr from 'vue-qr'
import { generateOrderAlipay, updateOrderWX, monitorOrderNotify,repayOrde } from "../../ajax/getData"; import { generateOrderAlipay, updateOrderWX, monitorOrderNotify,repayOrde } from "../../ajax/getData";
//import { isMobile } from "@/ajax/util";
export default { export default {
data() { data() {
@ -147,15 +149,28 @@ export default {
methods: { methods: {
defaultHandlePayment() { defaultHandlePayment() {
let isMobile = this.isMobile(); 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) {
throw new Error("订单信息错误,请删除商品后再次购买");
}
if(!isWx) {
if(this.userPayData.wxPay && !isMobile) { if(this.userPayData.wxPay && !isMobile) {
//Desktop, use native pay
this.qrtext=this.userPayData.wxPay; this.qrtext=this.userPayData.wxPay;
this.payOrderWX(); this.payOrderWX();
this.disableQrcode=false; this.disableQrcode=false;
} else if (this.userPayData.wxPay && isMobile) { } else if (this.userPayData.wxPay && isMobile) {
//Mobile, use H5 pay
this.disableQrcode=true; this.disableQrcode=true;
} else if(!this.userPayData.wxPay || this.userPayData.wxPay.length<=4) { } else if(!this.userPayData.wxPay || this.userPayData.wxPay.length<=4) {
throw new Error("订单信息错误,请删除商品后再次购买"); throw new Error("订单信息错误,请删除商品后再次购买");
} }
}
}, },
goPayH5() { goPayH5() {
let isMobile = this.isMobile(); let isMobile = this.isMobile();
@ -166,6 +181,7 @@ export default {
throw new Error("订单信息错误,请删除商品后再次购买"); throw new Error("订单信息错误,请删除商品后再次购买");
} }
}, },
isMobile () { isMobile () {
var sUserAgent = navigator.userAgent.toLowerCase(); var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
@ -182,6 +198,11 @@ export default {
return true; return true;
} }
}, },
/**/
isWX(){
var ua = navigator.userAgent.toLowerCase();
return (/micromessenger/.test(ua)) ? true : false;
},
closeDialogSuccess() { closeDialogSuccess() {
this.qrtext = ''; this.qrtext = '';
this.$router.push({ this.$router.push({
@ -198,12 +219,6 @@ export default {
// path: "/personal/useraddress", // path: "/personal/useraddress",
// }); // });
}, },
async selectGoods(item, index) {
this.activeIndex = index;
this.paytype = item.paytype;
if (index == 1) {
//
let res = await generateOrderAlipay(this.userPayData.orderId);
async selectGoods(item, index) { async selectGoods(item, index) {
this.activeIndex = index; this.activeIndex = index;
this.paytype = item.paytype; this.paytype = item.paytype;