Browse Source

设备类型 新增deviceType的app判断

xinfeng 6 years ago
parent
commit
557071cc0c
2 changed files with 22 additions and 11 deletions
  1. 6 6
      pages/otherpage/companyVerifyInput/index.vue
  2. 16 5
      plugins/deviceType.js

+ 6 - 6
pages/otherpage/companyVerifyInput/index.vue

@@ -167,17 +167,17 @@
             if (Number(this.dataInfo.status === 0)) {
               let appUrl = "proginn://pay?product_type=5"
               let url = '/pay?product_type=5'
-              let isApp = false //零时 需要新增一个字端判断是不是app登录
-              if (isApp) {
+              if (!this.deviceType.app) {
                 window.open(url, '_black')
               } else {
                 location.href = appUrl
               }
+            } else {
+              this.$message.success('您已提交企业认证,请耐心等待审核结果!')
+              setTimeout(() => {
+                history.back()
+              }, 1000)
             }
-            // this.$message.success('您已提交企业认证,请耐心等待审核结果!')
-            // setTimeout(() => {
-            //   history.back()
-            // }, 1000)
           } else {
             this.$message.error('提交失败')
           }

+ 16 - 5
plugins/deviceType.js

@@ -1,8 +1,3 @@
-import Vue from 'vue'
-// import DeviceType from './utils/deviceType'
-
-// Vue.use(DeviceType, { $axios, redirect, req, ...args })
-
 export default function ({req}, inject) {
   let deviceType = {}
   deviceType.ios = false
@@ -11,7 +6,10 @@ export default function ({req}, inject) {
   deviceType.ios = false
   deviceType.wx = false
   deviceType.ua = ''
+  deviceType.cookie = ''
+  deviceType.app = false
   
+  /** 通过UA判断设备类型 **/
   if (req && req.headers) {
     deviceType.ua = req && req.headers && req.headers['user-agent'] || ''
   } else if (window && window.navigator){
@@ -25,6 +23,19 @@ export default function ({req}, inject) {
     deviceType.pc = true
   }
   
+  /** 通过cookie 判断是不是APP **/
+  if (req && req.headers && req.headers.cookie) {
+    deviceType.cookie = req.headers.cookie
+  } else if (document){
+    deviceType.cookie = document.cookie
+  }
+  if (/(x_app)/i.test(deviceType.cookie)) {
+    deviceType.app = true
+  }  else {
+    deviceType.app = false
+  }
+  
+  /** 判断是不是 微信 **/
   if (/(MicroMessenger)/i.test(deviceType.ua)) {
     deviceType.wx = true
   }