diff --git a/rc-busness/ajax/util.js b/rc-busness/ajax/util.js new file mode 100644 index 00000000..30b245f5 --- /dev/null +++ b/rc-busness/ajax/util.js @@ -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 } +*/ \ No newline at end of file diff --git a/rc-busness/nuxt.config.js b/rc-busness/nuxt.config.js index 98b61444..5b889a0c 100644 --- a/rc-busness/nuxt.config.js +++ b/rc-busness/nuxt.config.js @@ -4,7 +4,7 @@ export default { // Global page headers: https://go.nuxtjs.dev/config-head head: { - title: '皇家官方商城', + title: '皇家宠物食品官方商城', htmlAttrs: { lang: 'zh-cn', diff --git a/rc-busness/pages/personal/userpay.vue b/rc-busness/pages/personal/userpay.vue index 44734200..fc92d93c 100644 --- a/rc-busness/pages/personal/userpay.vue +++ b/rc-busness/pages/personal/userpay.vue @@ -101,7 +101,9 @@ import Myheader from "~/components/header.vue"; import tabs from "@/components/tabs.vue"; import vueQr from 'vue-qr' + import { generateOrderAlipay, updateOrderWX, monitorOrderNotify,repayOrde } from "../../ajax/getData"; +//import { isMobile } from "@/ajax/util"; export default { data() { @@ -147,15 +149,28 @@ export default { methods: { defaultHandlePayment() { let isMobile = this.isMobile(); - if(this.userPayData.wxPay && !isMobile) { - this.qrtext=this.userPayData.wxPay; - this.payOrderWX(); + let isWx = this.isWX(); + if(isWx && this.userPayData.wxPay && this.userPayData.wxPay.length>4) { + //Desktop, use native pay this.disableQrcode=false; - } else if (this.userPayData.wxPay && isMobile) { - this.disableQrcode=true; - } else if(!this.userPayData.wxPay || this.userPayData.wxPay.length<=4) { + this.qrtext=this.userPayData.wxPay; + } else if(isWx) { throw new Error("订单信息错误,请删除商品后再次购买"); } + + if(!isWx) { + if(this.userPayData.wxPay && !isMobile) { + //Desktop, use native pay + this.qrtext=this.userPayData.wxPay; + this.payOrderWX(); + this.disableQrcode=false; + } else if (this.userPayData.wxPay && isMobile) { + //Mobile, use H5 pay + this.disableQrcode=true; + } else if(!this.userPayData.wxPay || this.userPayData.wxPay.length<=4) { + throw new Error("订单信息错误,请删除商品后再次购买"); + } + } }, goPayH5() { let isMobile = this.isMobile(); @@ -166,6 +181,7 @@ export default { throw new Error("订单信息错误,请删除商品后再次购买"); } }, + isMobile () { var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; @@ -182,6 +198,11 @@ export default { return true; } }, + /**/ + isWX(){ + var ua = navigator.userAgent.toLowerCase(); + return (/micromessenger/.test(ua)) ? true : false; + }, closeDialogSuccess() { this.qrtext = ''; this.$router.push({ @@ -198,12 +219,6 @@ export default { // 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) { this.activeIndex = index; this.paytype = item.paytype;