main.vue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <div class="main">
  3. <router-view />
  4. <div class="footer"></div>
  5. </div>
  6. <van-tabbar v-model="tabType" v-if="routerName != '/main/processDtl'">
  7. <van-tabbar-item icon="home-o" to="/main/message">{{$t('common.message')}}</van-tabbar-item>
  8. <van-tabbar-item icon="search" to="/main/working"
  9. >{{$t('common.workbench')}}</van-tabbar-item
  10. >
  11. <van-tabbar-item
  12. icon="friends-o"
  13. :to="tenantId == 'smt' ? '/main/xiamenList' : '/main/equipment'"
  14. >{{$t('common.things')}}</van-tabbar-item
  15. >
  16. <van-tabbar-item icon="setting-o" to="/main/home">{{$t('common.mine')}}</van-tabbar-item>
  17. </van-tabbar>
  18. </template>
  19. <script setup>
  20. import { ref, getCurrentInstance, watch } from 'vue'
  21. import { getUserInfo } from '@/utils/auth'
  22. import { useRouter } from 'vue-router'
  23. import { lang } from '@/lang/cn'
  24. import * as dd from 'dingtalk-jsapi'
  25. import '@/assets/icon/iconfont.css'
  26. import 'vant/lib/index.css'
  27. import axios from 'axios'
  28. import { uploadDdRightBtn } from '@/utils/ddAdapter'
  29. const tenantId = getUserInfo().tenantId
  30. const proxy = getCurrentInstance().proxy
  31. const tabType = ref('home')
  32. //判断是否为开发环境.如果是开发环境,则同步前后台中文配置表
  33. // const isDev = process.env.NODE_ENV === 'development'
  34. // if (isDev) {
  35. // let networkLang = window.localStorage.getItem('lang')
  36. // if (networkLang || networkLang != JSON.stringify(lang)) {
  37. // try {
  38. // networkLang = JSON.parse(networkLang)
  39. // networkLang.app.cn = lang
  40. // proxy
  41. // .post('/open/multilingual/setJson', {
  42. // configValue: JSON.stringify(networkLang),
  43. // })
  44. // .then((res) => {})
  45. // } catch (error) {}
  46. // }
  47. // }
  48. const corpId = window.localStorage.getItem('corpId')
  49. let routerName = ref(null)
  50. //监听路由变化
  51. const router = useRouter()
  52. //获取当前path
  53. routerName.value = router.currentRoute.value.path
  54. watch(router.currentRoute, (to, from) => {
  55. routerName.value = to.path
  56. console.log('routerName', routerName.value)
  57. //滚动条回到顶部
  58. document.documentElement.scrollTop = 0
  59. if (!corpId) return
  60. dd.biz.navigation.setTitle({
  61. title: router.currentRoute.value.name,
  62. onSuccess: function (result) {},
  63. onFail: function (err) {},
  64. })
  65. //设置右侧按钮
  66. proxy.uploadDdRightBtn(function () {}, ' ')
  67. //获取元素的绑定事件
  68. setTimeout(() => {
  69. if (!corpId) {
  70. return
  71. }
  72. let el = document.getElementsByClassName('van-nav-bar__content')[0]
  73. if (el) {
  74. //删除el元素
  75. el.parentNode.removeChild(el)
  76. }
  77. }, 10)
  78. })
  79. </script>
  80. <style lang="scss">
  81. .main {
  82. position: fixed;
  83. top: 0;
  84. left: 0;
  85. right: 0;
  86. bottom: 50px;
  87. overflow-y: auto;
  88. }
  89. </style>