Browse Source

优化头部logo

林旭祥 2 months ago
parent
commit
38a26db595
1 changed files with 23 additions and 2 deletions
  1. 23 2
      src/components/Header/index.vue

+ 23 - 2
src/components/Header/index.vue

@@ -39,7 +39,6 @@ const emit = defineEmits(['confirmExit', 'setMusic']);
 const router = useRouter();
 const route = useRoute();
 const dic: any = dataDictionary;
-const myInfo: any = localStorage.getItem('userInfo');
 
 //父值
 const props = defineProps({
@@ -135,6 +134,26 @@ const getMusic = async () => {
   music.value.show = true;
 };
 
+//获取个人信息
+const getUserInfo = () => {
+  //用户信息
+  const myInfo: any = localStorage.getItem('userInfo');
+  if (myInfo) {
+    userInfo.value = JSON.parse(myInfo);
+  } else {
+    let params = {};
+    proxy?.$http.common.getUserInfo(params).then((res: any) => {
+      //保存信息
+      if (res.data.length) {
+        let myData = res.data[0];
+        userInfo.value = myData;
+        let info: any = JSON.stringify(myData);
+        localStorage.setItem("userInfo", info);
+      }
+    });
+  }
+};
+
 onBeforeMount(() => {
   setDate();
   parameter.value = route.query;
@@ -160,7 +179,7 @@ onBeforeMount(() => {
     getMusic();
   }
   //用户信息
-  userInfo.value = JSON.parse(myInfo);
+  getUserInfo();
 });
 </script>
 <style lang="scss" scoped>
@@ -300,11 +319,13 @@ $waiPadding: 6.51rem;
     background-repeat: no-repeat;
     background-size: 100% auto;
     background-image: url('@/assets/images/common/music.png');
+
     ::v-deep(.el-select__wrapper) {
       width: 0;
       height: 0;
       padding: 0 0 0 0;
       min-height: 20px;
+
       .el-select__suffix {
         display: none;
       }