Kaynağa Gözat

调取设置接口、将医院名称等存储在store中

liyanyan 1 hafta önce
ebeveyn
işleme
a26cb29c15
4 değiştirilmiş dosya ile 21 ekleme ve 19 silme
  1. 0 4
      src/api/user.js
  2. 14 0
      src/layout/index.vue
  3. 7 0
      src/store/modules/app.js
  4. 0 15
      src/utils/index.js

+ 0 - 4
src/api/user.js

@@ -37,7 +37,3 @@ export function logout() {
     method: 'post',
   });
 }
-
-export function getSetting() {
-  return axios.get('/get_setting');
-}

+ 14 - 0
src/layout/index.vue

@@ -52,6 +52,19 @@ export default {
     handleClickOutside() {
       this.$store.dispatch('app/closeSideBar', { withoutAnimation: false });
     },
+    getSystemSetting() {
+      this.$axios.get('/get_setting').then(res => {
+        if(res.code == 200) {
+          const { web_name, background_img, logo, menu_logo } = res.data
+          this.$store.dispatch('app/setSystemSetting', {
+            background_img: background_img.content,
+            logo: logo.content,
+            menu_logo: menu_logo.content,
+            web_name: web_name.content
+          });
+        }
+      })     
+    }
   },
   mounted() {
     // 目标元素
@@ -69,6 +82,7 @@ export default {
 
     // 开始观察
     this.observer.observe(targetElement);
+    this.getSystemSetting();
     // document.getElementById('mainContainer').style.width = `calc(100% - (${document.getElementById('sidebarContainer')}px))`
     // document.getElementById('mainContainer').style.width = `${document.getElementsByClassName('app-wrapper')[0].offsetWidth - document.getElementsByClassName('sidebar-container')[0].offsetWidth}px`
   },

+ 7 - 0
src/store/modules/app.js

@@ -6,6 +6,7 @@ const state = {
     withoutAnimation: false,
   },
   device: 'desktop',
+  systemSetting: {},
 };
 
 const mutations = {
@@ -26,6 +27,9 @@ const mutations = {
   TOGGLE_DEVICE: (state, device) => {
     state.device = device;
   },
+  SYSTEM_SETTING: (state, systemSetting) => {
+    state.systemSetting = systemSetting;
+  },
 };
 
 const actions = {
@@ -38,6 +42,9 @@ const actions = {
   toggleDevice({ commit }, device) {
     commit('TOGGLE_DEVICE', device);
   },
+  setSystemSetting({ commit }, systemSetting) {
+    commit('SYSTEM_SETTING', systemSetting);
+  },
 };
 
 export default {

+ 0 - 15
src/utils/index.js

@@ -3,7 +3,6 @@
  */
 
 import moment from 'moment'
-import { getSetting } from '@/api/user'
 
 // 获取某年某月的天数
 export function getDaysInMonth(year, month) {
@@ -127,18 +126,4 @@ export function param2Obj(url) {
     }
   });
   return obj;
-}
-
-
-export async function getSystemSetting() {
-  try {
-    const result = await getSetting()
-    if(result.code == 200) {
-      return result.data || {}
-    } else {
-      return {}
-    }
-  } catch (error) {
-    return {}
-  }
 }