main.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div class="main">
  3. <router-view />
  4. <div class="footer"></div>
  5. </div>
  6. <van-tabbar v-model="tabType">
  7. <van-tabbar-item icon="home-o" to="/main/message">消息</van-tabbar-item>
  8. <van-tabbar-item icon="search" to="/main/working"
  9. >工作台</van-tabbar-item
  10. >
  11. <van-tabbar-item
  12. icon="friends-o"
  13. :to="tenantId == 'xmhjc' ? '/main/xiamenList' : '/main/equipment'"
  14. >物联网</van-tabbar-item
  15. >
  16. <van-tabbar-item icon="setting-o" to="/main/home">我的</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. //监听路由变化
  50. const router = useRouter()
  51. watch(router.currentRoute, (to, from) => {
  52. //滚动条回到顶部
  53. document.documentElement.scrollTop = 0
  54. if (!corpId) return
  55. dd.biz.navigation.setTitle({
  56. title: router.currentRoute.value.name,
  57. onSuccess: function (result) {},
  58. onFail: function (err) {},
  59. })
  60. //设置右侧按钮
  61. proxy.uploadDdRightBtn(function () {}, ' ')
  62. //获取元素的绑定事件
  63. setTimeout(() => {
  64. if (!corpId) {
  65. return
  66. }
  67. let el = document.getElementsByClassName('van-nav-bar__content')[0]
  68. if (el) {
  69. //删除el元素
  70. el.parentNode.removeChild(el)
  71. }
  72. }, 10)
  73. })
  74. </script>
  75. <style lang="scss">
  76. .main {
  77. position: fixed;
  78. top: 0;
  79. left: 0;
  80. right: 0;
  81. bottom: 50px;
  82. overflow-y: auto;
  83. }
  84. </style>