app-ldm.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. async 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. const res = await this.$http.api.checkTokenResult()
  52. this.$store.commit('user/SET_USER_INFO', res.data)
  53. }
  54. this.isMounted = true
  55. },
  56. // 退出登录
  57. logout() {
  58. this.$store.dispatch('user/logout')
  59. this.$removeStorage(this.routePrefix, 'userInfo')
  60. this.backHome()
  61. },
  62. // 回到首页
  63. backHome() {
  64. if (this.$route.path === this.routePrefix) return
  65. this.$router.replace(this.routePrefix)
  66. },
  67. // 响应页面宽度变化
  68. responseWidth() {
  69. this.$store.commit('app/SET_SCREEN', window.innerWidth)
  70. window.addEventListener('resize', (e) => {
  71. this.$store.commit('app/SET_SCREEN', e.target.innerWidth)
  72. })
  73. },
  74. // 数据初始化刷新浏览器
  75. refreshCacheData() {
  76. this.$removeStorage(this.routePrefix, 'club_list_data')
  77. },
  78. },
  79. }
  80. </script>
  81. <style scoped lang="scss"></style>