Forráskód Böngészése

获取用户信息&&登录时间实时 修改

suxinf 4 éve%!(EXTRA string=óta)
szülő
commit
eda299a443
3 módosított fájl, 121 hozzáadás és 66 törlés
  1. 11 3
      src/App.vue
  2. 109 62
      src/components/LoginInfo.vue
  3. 1 1
      src/views/account/AccountManage.vue

+ 11 - 3
src/App.vue

@@ -4,7 +4,9 @@
     <Navigation :navTitle1='navTitle1' :navTitle2='navTitle2'></Navigation>
     <div class="app_content">
       <div class="router">
-        <LoginInfo></LoginInfo>
+        <LoginInfo
+        :userAccount='userAccount'
+        ></LoginInfo>
         <Routerbanner
           @change_nav="changeNav"
           :isManufacturer="isManufacturer"
@@ -37,6 +39,7 @@ export default {
       navTitle1: ' > 数据管理',
       navTitle2: '',
       isManufacturer: 'distributor', // distributor 经销商 manufacturer 厂商
+      userAccount: ''
     }
   },
   methods: {
@@ -57,7 +60,6 @@ export default {
       let token = query.token || '';
       console.log('token:', token);
       if(!token) {
-        // alert('token值为空');
         return
       }
       this.$http({
@@ -70,7 +72,13 @@ export default {
         console.log(res);
         if(res.status === 200){
           if(res.data.code === 200) {
-            console.log(res.data, '200');
+            let userInfo = res.data.data;
+            if (userInfo.role === '1') {
+              this.isManufacturer = 'manufacturer';
+            } else {
+              this.isManufacturer = 'distributor';
+            }
+            this.userAccount = userInfo.userAccount;
           }else {
             let message = res.data.message;
             console.log('message', message);

+ 109 - 62
src/components/LoginInfo.vue

@@ -1,78 +1,125 @@
 <template>
   <div class="login_info">
-      <div class="user_info">
-          <div class="user_icon">
-              <img src="../img/user.png" alt="icon">
-          </div>
-          <div class="user_name">
-              <p>欢迎您,</p>
-              <p>dlrmkt</p>
-          </div>
+    <div class="user_info">
+      <div class="user_icon">
+        <img src="../img/user.png" alt="icon" />
       </div>
-      <div class="time_info">
-          <div class="clock_icon">
-              <img src="../img/clock.png" alt="icon">
-          </div>
-          <div class="login_time">
-              <p>登录时间</p>
-              <p>2021-3-31(星期三)</p>
-          </div>
+      <div class="user_name">
+        <p>欢迎您,</p>
+        <p>{{ userAccount }}</p>
       </div>
+    </div>
+    <div class="time_info">
+      <div class="clock_icon">
+        <img src="../img/clock.png" alt="icon" />
+      </div>
+      <div class="login_time">
+        <p>登录时间</p>
+        <p>{{ time }}</p>
+      </div>
+    </div>
   </div>
 </template>
 
 <script>
-export default {};
+export default {
+  props: {
+    userAccount: {
+      type: String,
+      default: "",
+    },
+  },
+  data() {
+    return {
+      time: "",
+    };
+  },
+  methods: {
+    getTime: function () {
+      let d = new Date();
+      let year = d.getFullYear();
+      let month = d.getMonth() + 1;
+      let day = d.getDate();
+      let week = d.getDay();
+      switch (week) {
+        case 1:
+          week = "星期一";
+          break;
+        case 2:
+          week = "星期二";
+          break;
+        case 3:
+          week = "星期三";
+          break;
+        case 4:
+          week = "星期四";
+          break;
+        case 5:
+          week = "星期五";
+          break;
+        case 6:
+          week = "星期六";
+          break;
+        default:
+          week = "星期天";
+      }
+      this.time = year + "-" + month + "-" + day + "(" + week + ")";
+    },
+  },
+  mounted() {
+    this.getTime();
+  },
+};
 </script>
 
 <style scoped lang="less">
 .login_info {
-    // background: rgb(212, 212, 212);
-    width: 100%;
-    .user_info{
-        height: 48px;
-        border-bottom: 1px solid #eee;
-        display: flex;
-        .user_icon{
-            margin: 8px 0 0 10px;
-            width: 30px;
-            height: 30px;
-            img{
-                // width: 30px;
-                // height: 30px;
-                width: 24px;
-                height: 24px;
-            }
-        }
-        .user_name{
-            width: 100px;
-            height: 40px;
-            margin: 4px 0 0 5px;
-            p{
-                line-height: 20px;
-                height: 20px;
-            }
-        }
+  // background: rgb(212, 212, 212);
+  width: 100%;
+  .user_info {
+    height: 48px;
+    border-bottom: 1px solid #eee;
+    display: flex;
+    .user_icon {
+      margin: 8px 0 0 10px;
+      width: 30px;
+      height: 30px;
+      img {
+        // width: 30px;
+        // height: 30px;
+        width: 24px;
+        height: 24px;
+      }
+    }
+    .user_name {
+      width: 100px;
+      height: 40px;
+      margin: 4px 0 0 5px;
+      p {
+        line-height: 20px;
+        height: 20px;
+      }
+    }
+  }
+  .time_info {
+    height: 50px;
+    display: flex;
+    .clock_icon {
+      margin: 8px 0 0 10px;
+      width: 24px;
+      height: 24px;
+      img {
+        width: 24px;
+        height: 24px;
+      }
     }
-    .time_info{
-        height: 50px;
-        display: flex;
-        .clock_icon{
-            margin: 8px 0 0 10px;
-            width: 24px;
-            height: 24px;
-            img{
-                width: 24px;
-                height: 24px;
-            }
-        }
-        .login_time{
-            margin: 4px 0 0 5px;
-            p{
-                line-height: 20px;
-                height: 20px;
-            }
-        }
+    .login_time {
+      margin: 4px 0 0 5px;
+      p {
+        line-height: 20px;
+        height: 20px;
+      }
     }
+  }
 }
 </style>

+ 1 - 1
src/views/account/AccountManage.vue

@@ -90,7 +90,7 @@ export default {
       //this.addDataList(account, fansNum, flag, editData);
       let data = {
         id: editData["id"],
-        authentication: flag === "是" ? "1" : "0",
+        authorizationName : flag === "是" ? true : false,
         fansCount: fansNum,
         accountCode: account
       };