Browse Source

设置动态图标和标题

李文 3 years ago
parent
commit
67948adffa
1 changed files with 22 additions and 1 deletions
  1. 22 1
      src/views/main/main.vue

+ 22 - 1
src/views/main/main.vue

@@ -64,7 +64,8 @@ export default {
       mainContent: 'aui-content__wrapper',
       auiWrapper: '',
       isMainMenuHaveChild: true,
-      menuDataAll: []
+      menuDataAll: [],
+      areaCode: ''
     }
   },
   components: {
@@ -87,6 +88,7 @@ export default {
       this.getUserInfo(),
       this.getPermissions()
     ]).then(() => {
+      this.getTitleLogo()
       this.loading = false
     })
     this.loading = false
@@ -261,8 +263,12 @@ export default {
         if (res.code !== 0) {
           return this.$message.error(res.msg)
         }
+        console.log(res)
         this.$store.state.user.name = res.userInfo.displayName
         this.$store.state.user.organizations = res.userInfo.organizations[0].organizationName
+        if (res.userInfo.extendField && res.userInfo.extendField.regionCode) {
+          this.areaCode = res.userInfo.extendField.regionCode
+        }
       }).catch(() => {})
     },
     // 获取权限
@@ -274,6 +280,21 @@ export default {
         this.$store.dispatch('permission', res.buttonList)
         window.SITE_CONFIG['permissions'] = res.buttonList
       }).catch(() => {})
+    },
+    getTitleLogo () {
+      if (!this.areaCode) {
+        return
+      }
+      this.$http.get('http://10.110.34.19:30600/sysbase/area/admin/getCityAreaByCode?areaCode=' + this.areaCode).then(({ data: res }) => {
+        if (res.code !== '0') {
+          return this.$message.error(res.msg)
+        }
+        res.result.areaTitle && (document.title = res.result.areaTitle)
+        if (res.result.areaLogo) {
+          // window.$('link[rel="shortcut icon"]').attr('href', res.result.areaLogo)
+          window.$('.navbar-logo img').attr('src', res.result.areaLogo)
+        }
+      }).catch(() => {})
     }
   }
 }