dingding.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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 = [
  19. 'Android',
  20. 'iPhone',
  21. 'SymbianOS',
  22. 'Windows Phone',
  23. 'iPad',
  24. 'iPod',
  25. 'OpenHarmony'
  26. ]
  27. const mobileFlag = mobileAgents.some((mobileAgent) => {
  28. return userAgentInfo.indexOf(mobileAgent) > 0
  29. })
  30. return mobileFlag
  31. }
  32. // 判断是否是钉钉环境
  33. const isDingTalk = (): boolean => {
  34. const userAgent = navigator.userAgent.toLowerCase()
  35. return userAgent.includes('dingtalk')
  36. }
  37. // 业务路由映射
  38. const businessRoutes: Record<string, string> = {
  39. generateInspect: 'InspectOrderWrite',
  40. failureReport: 'BpmProcessInstanceDetail',
  41. maintainOut: 'BpmProcessInstanceDetail',
  42. generateOperation: '',
  43. generateMaintenance: '',
  44. generateMaintain: '',
  45. rdReportApproval: 'rdReportApproval'
  46. }
  47. const href = ref('')
  48. const myLink = ref(null)
  49. const clickA = () => {
  50. myLink.value.click()
  51. }
  52. onMounted(async () => {
  53. let {
  54. type = '',
  55. id = '',
  56. userId = '',
  57. deptId = '',
  58. createTime = '',
  59. orderStatus = '',
  60. orderName = '',
  61. userName = ''
  62. } = route.query
  63. console.log('route.query :>> ', route.query)
  64. const isValidType = Object.keys(businessRoutes).includes(type as string)
  65. if (isMobileDevice()) {
  66. if (type === 'generateOperation') {
  67. window.location.href =
  68. import.meta.env.VITE_BASE_URL +
  69. '/deepoil/#/?type=' +
  70. type +
  71. '&id=' +
  72. id +
  73. '&userId=' +
  74. userId +
  75. '&deptId=' +
  76. deptId +
  77. '&createTime=' +
  78. createTime +
  79. '&orderStatus=' +
  80. orderStatus +
  81. '&orderName=' +
  82. orderName +
  83. '&userName=' +
  84. userName
  85. } else {
  86. window.location.href =
  87. import.meta.env.VITE_BASE_URL +
  88. '/deepoil/#/?type=' +
  89. type +
  90. '&id=' +
  91. id +
  92. '&userId=' +
  93. userId
  94. }
  95. // 移动端跳转deepoil协议
  96. // try{
  97. // const typelower = type.toLowerCase();
  98. // window.location.href = `<a>deepoil://${typelower}/${id}</a>`
  99. // }catch (error) {
  100. // alert(error.message)
  101. // }
  102. // href.value = 'deepoil://'+type+'/'+id
  103. // nextTick(()=>{
  104. // setTimeout(clickA,1000)
  105. // })
  106. } else if (isValidType) {
  107. authUtil.setTenantId('1')
  108. const res = await LoginApi.simpleLogin(userId)
  109. if (!res) {
  110. return
  111. }
  112. authUtil.setToken(res)
  113. // PC端路由跳转
  114. if (type === 'generateInspect') {
  115. push({ name: 'InspectOrderWrite', params: { id } })
  116. } else if (type === 'failureReport') {
  117. push({
  118. name: 'BpmProcessInstanceDetail',
  119. query: {
  120. id: id
  121. }
  122. })
  123. } else if (type === 'generateMaintain') {
  124. debugger
  125. push({ name: 'MaintainEdit', params: { id } })
  126. } else if (type === 'maintainOut') {
  127. push({
  128. name: 'BpmProcessInstanceDetail',
  129. query: {
  130. id: id
  131. }
  132. })
  133. } else if (type === 'generateOperation') {
  134. // push({
  135. // name: 'FillOrderInfo',
  136. // params: { deptId,userId,createTime,id,orderStatus }
  137. // })
  138. id = deptId + ',' + userId + ',' + createTime + ',' + id + ',' + orderStatus
  139. push({ name: 'FillOrderInfo', params: { id } })
  140. } else if (type === 'generateMaintenance') {
  141. push({
  142. name: 'IotMainWorkOrderBom',
  143. params: { id }
  144. })
  145. } else if (type === 'rdDailyReport') {
  146. push({
  147. name: 'FillDailyReportForm',
  148. params: { id: id, mode: 'fill' }
  149. })
  150. } else if (type === 'rdReportApproval') {
  151. push({
  152. name: 'DailyReportApprovalForm',
  153. params: { id }
  154. })
  155. }
  156. } else {
  157. // 默认跳转
  158. push({ name: 'Login' })
  159. }
  160. })
  161. </script>
  162. <style scoped>
  163. .loading {
  164. padding-top: 100px;
  165. font-size: 16px;
  166. color: #666;
  167. text-align: center;
  168. }
  169. .wxtip {
  170. position: fixed;
  171. top: 0;
  172. left: 0;
  173. z-index: 998;
  174. display: block;
  175. width: 100%;
  176. height: 100%;
  177. text-align: center;
  178. background: rgb(0 0 0 / 80%);
  179. }
  180. .wxtip-icon {
  181. position: absolute;
  182. display: block;
  183. width: 100%;
  184. height: 100%;
  185. background: url('@/assets/imgs/bgzz.png') center center no-repeat;
  186. background-size: cover; /* 新增样式,使背景图片覆盖整个元素 */
  187. }
  188. .wxtip-txt {
  189. margin-top: 107px;
  190. font-size: 16px;
  191. line-height: 1.5;
  192. color: #fff;
  193. }
  194. </style>