11wqe1 3 mesiacov pred
rodič
commit
2d0d9db3ba
2 zmenil súbory, kde vykonal 26 pridanie a 26 odobranie
  1. 24 20
      src/mixins/mixin.js
  2. 2 6
      src/views/login/loginPage.vue

+ 24 - 20
src/mixins/mixin.js

@@ -3,10 +3,13 @@ import { mapGetters } from 'vuex';
 export const myMixin = {
   computed: {
     ...mapGetters(['userinfo']),
+    roleUser(){
+      return Object.keys(this.userinfo).length != 0 ? this.userinfo : this.userJson
+    }
   },
   data() {
     return {
-        // userJson: this.userinfo,
+        userJson: {},
         prefixL: window.location.href.includes("/liyuan") ? "liyuan_" : "admin_"
     };
   },
@@ -39,22 +42,23 @@ export const myMixin = {
         return "Other Browser";
       }
     },
-    async addOp3(userTime, loadTime, object, status) {
-      
-      // try {
-      //   if(!this.userinfo || !this.userinfo.accountNumber){
-          
-      //       let res = await this.$ajax.get(this.$store.state.api + "selectUser", {
-      //         userid: this.$route.query.userid
-      //       });
+    async addOp3(userTime, loadTime, object, status,account) {
+      try {
+        if(!this.roleUser || !this.roleUser.accountNumber){
+            let res = await this.$ajax.get('https://pbl.cocorobo.cn/api/pbl/selectUser', {
+              userid: account
+            });
 
-      //       this.userinfo = res.data[0][0]
-      //   }
-      // } catch (e) {
-      //   console.log(e);
-      //   return this.addOp3(userTime, loadTime, object, status);
-      // }
+            this.userJson = res.data[0][0]
+            console.log('this.userJson',this.userJson);
+        }
+      } catch (e) {
+        console.log(e);
+        return this.addOp3(userTime, loadTime, object, status);
+      }
 
+      console.log('777',this.roleUser);
+      
 
       let _time = new Date()
         .toLocaleString("zh-CN", { hour12: false, timeZone: "Asia/Shanghai" })
@@ -62,11 +66,11 @@ export const myMixin = {
       let browser = this.detectBrowser();
 
       let params = {
-        userid: this.userinfo.userid,
-        username: this.userinfo.username,
-        accountNumber: this.userinfo.accountNumber,
-        org: this.userinfo.orgName,
-        school: this.userinfo.schoolName,
+        userid: this.roleUser.userid,
+        username: this.roleUser.username,
+        accountNumber: this.roleUser.accountNumber,
+        org: this.roleUser.orgName,
+        school: this.roleUser.schoolName,
         browser: browser,
         userTime: userTime == "1" ? _time : userTime, // 使用时间 1次的就1 其次传秒
         loadTime: loadTime, //load的时间没有就“”

+ 2 - 6
src/views/login/loginPage.vue

@@ -286,9 +286,9 @@ export default {
 						console.log("userjson", userjson);
 						if (_data.active === 1) {
 							window.localStorage["identity"] = JSON.stringify(_data.identity);
-							this.addOp3('1', "", { type:this.prefixL + "login" }, "success")
 							this.$message.success("登录成功");
 							await this.login();
+							this.addOp3('1', "", { type:this.prefixL + "login" }, "success",_data.userid)
 							if (
 								userjson.data[0][0].type == 1 &&
 								userjson.data[0][0].role == 1 &&
@@ -299,7 +299,6 @@ export default {
 								this.$router.push({ path: this.redirect || "/" });
 							}
 						} else {
-							this.addOp3('1', "", { type:this.prefixL + "login" }, '登录失败')
 							this.$message.error("登录失败");
 						}
 						this.loading = false;
@@ -310,7 +309,6 @@ export default {
 						} else {
 							this.$message.error("登录失败");
 						}
-						this.addOp3('1', "", { type:this.prefixL + "login" }, e)
 						this.loading = false;
 					});
 			} else if (this.loginType == "bind") {
@@ -562,9 +560,9 @@ export default {
 					console.log("userjson", userjson);
 					if (_data.active === 1) {
 						window.localStorage["identity"] = JSON.stringify(_data.identity);
-						this.addOp3('1', "", { type:this.prefixL + "login" }, "success")
 						this.$message.success("登录成功");
 						await this.login();
+						this.addOp3('1', "", { type:this.prefixL + "login" }, "success",_data.userid)
 						if (
 							userjson.data[0][0].type == 1 &&
 							userjson.data[0][0].role == 1 &&
@@ -575,8 +573,6 @@ export default {
 							this.$router.push({ path: this.redirect || "/" });
 						}
 					} else {
-						this.addOp3('1', "", { type:this.prefixL + "login" }, '登录失败')
-
 						this.$message.error("登录失败");
 					}