dingding.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <div v-if="isMobileDevice&&!isDingTalk()" class="loading">跳转处理中...</div>
  3. <!-- <a ref="myLink" :href="href" v-show="false">跳转app</a>-->
  4. <!-- <div v-if="isMobileDevice()&&isDingTalk()" class="wxtip" id="JweixinTip">-->
  5. <!-- <span class="wxtip-icon"></span>-->
  6. <!-- </div>-->
  7. </template>
  8. <script setup lang="ts">
  9. import { onMounted } from 'vue'
  10. import { useRouter, useRoute } from 'vue-router'
  11. import * as LoginApi from "@/api/login";
  12. import * as authUtil from "@/utils/auth";
  13. const { push } = useRouter()
  14. const route = useRoute()
  15. // 设备检测
  16. const isMobileDevice = (): boolean => {
  17. const userAgentInfo = navigator.userAgent;
  18. const mobileAgents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod","OpenHarmony"];
  19. const mobileFlag = mobileAgents.some((mobileAgent) => {
  20. return userAgentInfo.indexOf(mobileAgent) > 0;
  21. });
  22. return mobileFlag;
  23. }
  24. // 判断是否是钉钉环境
  25. const isDingTalk = (): boolean => {
  26. const userAgent = navigator.userAgent.toLowerCase();
  27. return userAgent.includes('dingtalk');
  28. }
  29. // 业务路由映射
  30. const businessRoutes: Record<string, string> = {
  31. 'generateInspect': 'InspectOrderWrite',
  32. 'failureReport': 'BpmProcessInstanceDetail',
  33. 'maintainOut': 'BpmProcessInstanceDetail',
  34. 'generateOperation' :'',
  35. 'generateMaintenance' : ''
  36. }
  37. const href = ref('')
  38. const myLink = ref(null);
  39. const clickA = () =>{
  40. myLink.value.click();
  41. }
  42. onMounted(async () => {
  43. const { type = '', id = '', userId='', deptId='',createTime='',orderStatus='' } = route.query
  44. const isValidType = Object.keys(businessRoutes).includes(type as string)
  45. if (isMobileDevice()) {
  46. if (type==='generateOperation') {
  47. window.location.href = 'https://iot.deepoil.cc/deepoil/#/?type=' + type+'&id='+id+'&userId='+userId+'&deptId='+deptId+'&createTime='+createTime+'&orderStatus='+orderStatus;
  48. }else {
  49. window.location.href = 'https://iot.deepoil.cc/deepoil/#/?type=' + type+'&id='+id+'&userId='+userId;
  50. }
  51. // 移动端跳转deepoil协议
  52. // try{
  53. // const typelower = type.toLowerCase();
  54. // window.location.href = `<a>deepoil://${typelower}/${id}</a>`
  55. // }catch (error) {
  56. // alert(error.message)
  57. // }
  58. // href.value = 'deepoil://'+type+'/'+id
  59. // nextTick(()=>{
  60. // setTimeout(clickA,1000)
  61. // })
  62. } else if (isValidType) {
  63. const res = await LoginApi.simpleLogin(userId)
  64. if (!res) {
  65. return
  66. }
  67. authUtil.setToken(res)
  68. // PC端路由跳转
  69. if (type === 'generateInspect') {
  70. push({ name:'InspectOrderWrite', params:{id} })
  71. }else if(type === 'failureReport') {
  72. push({
  73. name: 'BpmProcessInstanceDetail',
  74. query: {
  75. id: id
  76. }
  77. })
  78. } else if (type === 'generateMaintain') {
  79. push({ name: 'MaintainEdit', params: {id } })
  80. } else if (type === 'maintainOut') {
  81. push({
  82. name: 'BpmProcessInstanceDetail',
  83. query: {
  84. id: id
  85. }
  86. })
  87. }else if(type === 'generateOperation'){
  88. push({
  89. name: 'FillOrderInfo',
  90. params: { deptId,userId,createTime,id,orderStatus }
  91. })
  92. }
  93. } else {
  94. // 默认跳转
  95. push({ name:'Login' })
  96. }
  97. })
  98. </script>
  99. <style scoped>
  100. .loading {
  101. text-align: center;
  102. padding-top: 100px;
  103. font-size: 16px;
  104. color: #666;
  105. }
  106. .wxtip {
  107. background: rgba(0, 0, 0, 0.8);
  108. text-align: center;
  109. position: fixed;
  110. left: 0;
  111. top: 0;
  112. width: 100%;
  113. height: 100%;
  114. z-index: 998;
  115. display: block;
  116. }
  117. .wxtip-icon {
  118. width: 100%;
  119. height: 100%;
  120. background: url(@/assets/imgs/bgzz.png) center center no-repeat;
  121. background-size: cover; /* 新增样式,使背景图片覆盖整个元素 */
  122. display: block;
  123. position: absolute;
  124. }
  125. .wxtip-txt {
  126. margin-top: 107px;
  127. color: #fff;
  128. font-size: 16px;
  129. line-height: 1.5;
  130. }
  131. </style>