Pārlūkot izejas kodu

首页联调,个人中心赋值

wh 2 gadi atpakaļ
vecāks
revīzija
a934be5f37
4 mainītis faili ar 59 papildinājumiem un 11 dzēšanām
  1. 32 0
      src/App.vue
  2. 10 7
      src/views/home.vue
  3. 10 1
      src/views/rentBill.vue
  4. 7 3
      src/views/userInfo.vue

+ 32 - 0
src/App.vue

@@ -14,16 +14,48 @@ export default {
     }
   },
   created(){
+    console.log(this.getUrlKey('username'))
     if(localStorage.getItem('token')){
       this.getUserInfo();
+    }else{
+       let username = this.getUrlKey("username");
+       let pwd = this.getUrlKey("pwd");
+       this.login(username,pwd)
     }
   },
   methods:{
+     getUrlKey(name){
+      return (
+        decodeURIComponent(
+          (new RegExp("[?|&]" + name + "=" + "([^&;]+?)(&|#|;|$)").exec(location.href) || [, ""])[1].replace(/\+/g, "%20")) || null);
+    },
+    login(username,pwd){
+      this.loading = true;
+      Api.loginByPwd({
+        username:username,
+        password:pwd,
+      }).then((res) => {
+        this.loading = false
+        if (res.code == 0) {
+          this.$toast.clear();
+          window.localStorage.setItem("token", res.data.token);
+          this.$store.state.password=this.pwd;
+          this.getUserInfo();
+        } else {
+          this.$notify({ type: "danger", message: res.msg });
+        }
+      });
+    },
      getUserInfo() {
       Api.getUserInfo().then((res) => {
         if (res.code == 0) {
           this.$store.state.username=res.data.username;
           this.$store.state.userMobile=res.data.mobile;
+            if(res.data.roleCodes.length==0){ //admin
+              localStorage.setItem('role','admin')
+            }else{
+              localStorage.setItem('role',res.data.roleCodes[0])
+            }
         } else {
           this.$notify({ type: "danger", message: res.msg });
         }

+ 10 - 7
src/views/home.vue

@@ -28,7 +28,7 @@
       </van-row>
     </div>
     <!-- 维修工没有此块功能 -->
-    <template v-if="role != 3">
+    <template v-if="role == 'admin'">
       <div class="info_function">
         <div
           class="function_item"
@@ -44,6 +44,7 @@
       </div>
     </template>
     <div class="info_list">
+      <template v-if="role==''">
       <!-- 实时巡检begin -->
       <van-row align="center" justify="space-between" class="sub_title">
         <van-col class="title">实时巡检</van-col>
@@ -74,7 +75,8 @@
         </van-row>
       </van-row>
       <!-- 实时巡检end -->
-
+      </template>
+      <template v-if="role=='admin'">
       <!-- 工单待办begin -->
       <van-row align="center" justify="space-between" class="sub_title">
         <van-col class="title">工单待办</van-col>
@@ -108,7 +110,7 @@
 
       <!-- 设备异常begin -->
       <van-row align="center" justify="space-between" class="sub_title">
-        <van-col class="title">工单待办</van-col>
+        <van-col class="title">设备异常</van-col>
         <van-col class="function_btn">
           <van-col>立即处理</van-col>
           <van-image
@@ -170,9 +172,9 @@
 </van-row>
       </div>
       <!-- 欠费待收end -->
+       </template>
     </div>
   </div>
-
   <!-- 底部tabbar -->
   <van-tabbar
     v-model="activeTabBar"
@@ -229,17 +231,17 @@ export default {
         {
           src: require("@/assets/repair-online.svg"),
           label: "线上报修",
-          role: [1, 2, 4],
+          role: ['admin', 2, 4],
         },
         {
           src: require("@/assets/check-review.svg"),
           label: "巡检记录",
-          role: [1, 2],
+          role: ['admin', 2],
         },
         {
           src: require("@/assets/reduce-record.svg"),
           label: "扣缴记录",
-          role: [1, 4],
+          role: ['admin', 4],
         },
       ],
       checkList: [
@@ -280,6 +282,7 @@ export default {
   },
   created() {
     this.getHomeData();
+    this.role=localStorage.getItem('role')
   },
   methods: {
     getHomeData() {

+ 10 - 1
src/views/rentBill.vue

@@ -31,7 +31,13 @@
         />
       </div>
     </div>
-    <div class="drop_down">
+    <div class="drop_down" style="display:flex">
+      <!-- <van-date-picker
+        v-model="currentDate"
+        title="选择日期"
+        :min-date="minDate"
+        :max-date="maxDate"
+      /> -->
       <van-dropdown-menu active-color="#1989fa">
         <van-dropdown-item
           v-model="rentStatus"
@@ -108,6 +114,9 @@ export default {
   },
   data() {
     return {
+      minDate: new Date(2020, 0, 1),
+      maxDate: new Date(2025, 5, 1),
+      currentDate:'',
       loading: false,
       name: "电商园四期-B座",
       rentStatus: "",

+ 7 - 3
src/views/userInfo.vue

@@ -84,8 +84,8 @@ export default {
       title: "",
       loading: false,
       dataForm: {
-        username: "张浩",
-        tel: 158304802928,
+        username: "",
+        tel:'',
         password: "123456",
         newpassword: "",
         confirmpassword: "",
@@ -95,6 +95,8 @@ export default {
   created() {
     this.title = this.$route.query.title;
     this.source = this.$route.query.source;
+    this.dataForm.username=this.$store.state.username;
+    this.dataForm.tel=this.$store.state.userMobile;
     this.dataForm.password = this.plusXing(this.dataForm.password, 0, 0, "*");
   },
   methods: {
@@ -123,7 +125,9 @@ export default {
         this.$router.push("/");
       }, 2000);
     },
-    loginOut() {},
+    loginOut() {
+      localStorage.clear();
+    },
     backPath() {
       this.$router.back();
     },