lipenghui hace 2 meses
padre
commit
39a898cdd0
Se han modificado 1 ficheros con 26 adiciones y 11 borrados
  1. 26 11
      src/views/pms/dingding.vue

+ 26 - 11
src/views/pms/dingding.vue

@@ -1,4 +1,9 @@
 
+<template>
+  <div class="loading">跳转处理中...</div>
+  <a ref="myLink" :href="href" v-show="false">跳转app</a>
+</template>
+
 <script setup lang="ts">
 import { onMounted } from 'vue'
 import { useRouter, useRoute } from 'vue-router'
@@ -12,8 +17,7 @@ const isMobileDevice = (): boolean => {
   // return /mobile|android|iphone|ipad/i.test(ua) &&
   //   !/(windows|macintosh|linux)/i.test
   const userAgentInfo = navigator.userAgent;
-  alert(userAgentInfo)
-  const mobileAgents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
+  const mobileAgents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod","OpenHarmony"];
 
   const mobileFlag = mobileAgents.some((mobileAgent) => {
     return userAgentInfo.indexOf(mobileAgent) > 0;
@@ -31,17 +35,32 @@ const businessRoutes: Record<string, string> = {
   'generateMaintenance' : ''
 }
 
+const href = ref('')
+const myLink = ref(null);
+
+const clickA = () =>{
+  alert("click")
+  alert(href.value)
+  myLink.value.click();
+}
+
 onMounted(() => {
   const { type = '', id = '' } = route.query
   const isValidType = Object.keys(businessRoutes).includes(type as string)
-
   if (isMobileDevice()) {
     // 移动端跳转deepoil协议
-    alert("app")
-    window.location.href = `deepoil://${type}/${id}`
+    // try{
+    //   const typelower = type.toLowerCase();
+    //   window.location.href = `<a>deepoil://${typelower}/${id}</a>`
+    // }catch (error) {
+    //   alert(error.message)
+    // }
+    href.value = 'deepoil://'+type+'/'+id
+    nextTick(()=>{
+      setTimeout(clickA,1000)
+    })
   } else if (isValidType) {
     // PC端路由跳转
-    alert('pc')
     if (type === 'generateInspect') {
       push({ name:'InspectOrderWrite', params:{id} })
     }else if(type === 'failureReport') {
@@ -63,15 +82,11 @@ onMounted(() => {
     }
   } else {
     // 默认跳转
-    alert('login')
     push({ name:'Login' })
   }
 })
-</script>
 
-<template>
-  <div class="loading">跳转处理中...</div>
-</template>
+</script>
 
 <style scoped>
 .loading {