App.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div id="app">
  3. <div v-if="isPageLoading" class="avue-home">
  4. <div class="avue-home__main">
  5. <img class="avue-home__loading" src="/svg/loading-spin.svg" alt="loading">
  6. <div class="avue-home__title">
  7. 正在加载资源
  8. </div>
  9. <div class="avue-home__sub-title">
  10. 初次加载资源可能需要较多时间 请耐心等待
  11. </div>
  12. </div>
  13. </div>
  14. <router-view v-else />
  15. <AccountStopTip :showDialog.sync="showAccountStopTip" />
  16. </div>
  17. </template>
  18. <script>
  19. import { mapGetters } from 'vuex'
  20. import applyPortalConfigFn from '@/util/usePortalConfig'
  21. import awaitCatch from '@/util/awaitCatch'
  22. import { getPortalConfig } from '@/api/common'
  23. import AccountStopTip from '@/components/accountStopTip'
  24. export default {
  25. name: 'App',
  26. components: { AccountStopTip },
  27. data() {
  28. return {
  29. specialPath: null,
  30. isRefresh: true, // 是否初次进入页面
  31. showAccountStopTip: false // 账号截止服务提示窗
  32. }
  33. },
  34. computed: {
  35. ...mapGetters({ isPageLoading: 'isPageLoading', portalConfig: 'portalConfig' , specialPathStorage: 'specialPath', accountExpiry: 'accountExpiry' })
  36. },
  37. watch: {
  38. $route (newVal) {
  39. this.specialPath = newVal.query.s
  40. // 登录页
  41. if (newVal.path === '/login') {
  42. if (this.specialPath) {
  43. this.$store.commit('SET_SPECIAL_PATH', this.specialPath)
  44. this.getPortalConfigFn()
  45. this.isRefresh = false
  46. } else {
  47. this.$store.commit('SET_SPECIAL_PATH', 'default')
  48. if (this.isRefresh) {
  49. // 首次进入需要应用门户配置
  50. applyPortalConfigFn()
  51. this.isRefresh = false
  52. }
  53. }
  54. } else {
  55. if (this.isRefresh) {
  56. // 首次进入需要应用门户配置
  57. applyPortalConfigFn()
  58. this.isRefresh = false
  59. }
  60. }
  61. },
  62. accountExpiry (newVal) {
  63. console.log(newVal);
  64. if (newVal.remainDays <= 30) {
  65. this.showAccountStopTip = true
  66. }
  67. }
  68. },
  69. created() {
  70. this.loadMapScript()
  71. },
  72. methods: {
  73. loadMapScript() {
  74. var script = document.createElement("script");
  75. script.type = "text/javascript";
  76. script.src = "https://map.qq.com/api/gljs?v=1.exp&libraries=service&key=C4ABZ-HWE3X-5DW4J-ZO4GH-IQBWK-TXF2X";
  77. document.body.appendChild(script);
  78. },
  79. // 获取门户配置
  80. async getPortalConfigFn () {
  81. this.$store.commit('SET_IS_PAGE_LOADING', true)
  82. const [res] = await awaitCatch(getPortalConfig({ s: this.specialPath }))
  83. if (res && res.data.code === 0) {
  84. const config = ((res.data && res.data.data) && Object.keys(res.data.data).length) ? res.data.data : null
  85. if (config) {
  86. this.$store.commit('SET_PORTAL_CONFIG', {
  87. ...this.portalConfig,
  88. [this.specialPath]: config
  89. })
  90. } else {
  91. this.$store.commit('SET_SPECIAL_PATH', 'default')
  92. this.$message.warning('未获取到门户配置')
  93. }
  94. }
  95. applyPortalConfigFn()
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss">
  101. #app {
  102. width: 100%;
  103. height: 100%;
  104. overflow: hidden;
  105. }
  106. </style>