app-ldm.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <div class="layout" v-if="isMounted">
  3. <div class="header"></div>
  4. <div class="content">
  5. <nuxt />
  6. </div>
  7. <div class="footer"></div>
  8. <ldm-login></ldm-login>
  9. </div>
  10. </template>
  11. <script>
  12. import { mapGetters } from 'vuex'
  13. export default {
  14. computed: {
  15. ...mapGetters([
  16. 'userInfo',
  17. 'accessToken',
  18. 'authUserId',
  19. 'appId',
  20. 'accountType',
  21. 'routePrefix',
  22. ]),
  23. },
  24. head() {
  25. return {
  26. title: '德国WELLCOMET LDM® 官方查询系统',
  27. link: [{ rel: 'icon', type: 'image/x-icon', href: '/ldm.ico' }],
  28. }
  29. },
  30. data() {
  31. return {
  32. isMounted: false,
  33. }
  34. },
  35. mounted() {
  36. this.responseWidth()
  37. this.initPageData()
  38. },
  39. beforeDestroy() {
  40. window.removeEventListener('resize', () => {})
  41. this.refreshCacheData()
  42. },
  43. methods: {
  44. // 初始化数据页面公共数据
  45. initPageData() {
  46. // this.$store.commit('app/SET_PAGE_THEME', 'app')
  47. // 获取用户信息
  48. let userInfo = this.$getStorage(this.routePrefix, 'userInfo')
  49. if (userInfo && userInfo.authUserId === this.authUserId) {
  50. this.$store.commit('user/SET_USER_INFO', userInfo)
  51. }
  52. this.isMounted = true
  53. },
  54. // 退出登录
  55. logout() {
  56. this.$store.dispatch('user/logout')
  57. this.$removeStorage(this.routePrefix, 'userInfo')
  58. this.backHome()
  59. },
  60. // 回到首页
  61. backHome() {
  62. if (this.$route.path === this.routePrefix) return
  63. this.$router.replace(this.routePrefix)
  64. },
  65. // 响应页面宽度变化
  66. responseWidth() {
  67. this.$store.commit('app/SET_SCREEN', window.innerWidth)
  68. window.addEventListener('resize', (e) => {
  69. this.$store.commit('app/SET_SCREEN', e.target.innerWidth)
  70. })
  71. },
  72. // 数据初始化刷新浏览器
  73. refreshCacheData() {
  74. this.$removeStorage(this.routePrefix, 'club_list_data')
  75. },
  76. },
  77. }
  78. </script>
  79. <style scoped lang="scss"></style>