Преглед изворни кода

EHR-绩效:中间跳转页逻辑跳转,区分PC、移动端。

001295 пре 1 година
родитељ
комит
f8a7cbf164
1 измењених фајлова са 43 додато и 12 уклоњено
  1. 43 12
      src/views/ehrentrance.vue

+ 43 - 12
src/views/ehrentrance.vue

@@ -22,19 +22,50 @@ export default {
     jump() {
       let query = this.$route.query;
       console.log('query',query);
-      let str = query.path + window.location.search;
-      console.log('str',str);
-      ehrLogin(query.code).then(res => {
-        console.log('res',res);
-        if (res.code === 200) {
-          let token = res.token;
-          setToken(token);
-          this.$store.commit('SET_TOKEN', token)
-          this.$store.dispatch("GetInfo").then(
-            this.$router.push({ path: str})
-          )
+      //判断PC、移动端
+      let r = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
+      if (r) {
+        console.log("移动端");
+        let url = window.location.href;
+        console.log('url',url,this.$route,'this.$route');
+        let arr = url.split('/ehrentrance?');
+        console.log('arr[0]',arr[0]);
+        let resUrl = "";
+        //移动端判断环境
+        if(arr[0].includes('dev') || arr[0].includes('test') || arr[0].includes('localhost')){
+          resUrl = "https://sy.derom.com/test-drp-mobile/#/pages/public-entrance?path=" + query.mobilePath + window.location.search;
+        }else{
+          resUrl = "https://sy.derom.com/drp-mobile/#/pages/public-entrance?path=" + query.mobilePath + window.location.search;
         }
-      })
+        console.log('resUrl',resUrl);
+        location.replace(resUrl);
+      } else {
+        console.log("PC端");
+        let str = query.pcPath + window.location.search;
+        console.log('str',str);
+        ehrLogin(query.code).then(res => {
+          console.log('res',res);
+          if (res.code === 200) {
+            let token = res.token;
+            setToken(token);
+            this.$store.commit('SET_TOKEN', token)
+            this.$store.dispatch("GetInfo").then(
+              this.$router.push({ path: str})
+            )
+          }
+        })
+      }
+      // ehrLogin(query.code).then(res => {
+      //   console.log('res',res);
+      //   if (res.code === 200) {
+      //     let token = res.token;
+      //     setToken(token);
+      //     this.$store.commit('SET_TOKEN', token)
+      //     this.$store.dispatch("GetInfo").then(
+      //       this.$router.push({ path: str})
+      //     )
+      //   }
+      // })
       console.log('执行完成');
     },
   }