dingding.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. let { type = '', id = '', userId='', deptId='',createTime='',orderStatus='',orderName='',userName='' } = 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+'&orderName='+orderName+'&userName='+userName;
  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. authUtil.setTenantId(1)
  64. const res = await LoginApi.simpleLogin(userId)
  65. if (!res) {
  66. return
  67. }
  68. authUtil.setToken(res)
  69. // PC端路由跳转
  70. if (type === 'generateInspect') {
  71. push({ name:'InspectOrderWrite', params:{id} })
  72. }else if(type === 'failureReport') {
  73. push({
  74. name: 'BpmProcessInstanceDetail',
  75. query: {
  76. id: id
  77. }
  78. })
  79. } else if (type === 'generateMaintain') {
  80. push({ name: 'MaintainEdit', params: {id } })
  81. } else if (type === 'maintainOut') {
  82. push({
  83. name: 'BpmProcessInstanceDetail',
  84. query: {
  85. id: id
  86. }
  87. })
  88. } else if(type === 'generateOperation'){
  89. // push({
  90. // name: 'FillOrderInfo',
  91. // params: { deptId,userId,createTime,id,orderStatus }
  92. // })
  93. id = deptId+','+userId+','+createTime+','+id+','+orderStatus
  94. push({ name: 'FillOrderInfo',params:{id}})
  95. } else if (type === 'generateMaintenance') {
  96. push({
  97. name: 'IotMainWorkOrderBom',
  98. params: { id }
  99. })
  100. }
  101. } else {
  102. // 默认跳转
  103. push({ name:'Login' })
  104. }
  105. })
  106. </script>
  107. <style scoped>
  108. .loading {
  109. text-align: center;
  110. padding-top: 100px;
  111. font-size: 16px;
  112. color: #666;
  113. }
  114. .wxtip {
  115. background: rgba(0, 0, 0, 0.8);
  116. text-align: center;
  117. position: fixed;
  118. left: 0;
  119. top: 0;
  120. width: 100%;
  121. height: 100%;
  122. z-index: 998;
  123. display: block;
  124. }
  125. .wxtip-icon {
  126. width: 100%;
  127. height: 100%;
  128. background: url(@/assets/imgs/bgzz.png) center center no-repeat;
  129. background-size: cover; /* 新增样式,使背景图片覆盖整个元素 */
  130. display: block;
  131. position: absolute;
  132. }
  133. .wxtip-txt {
  134. margin-top: 107px;
  135. color: #fff;
  136. font-size: 16px;
  137. line-height: 1.5;
  138. }
  139. </style>