Bläddra i källkod

fix:登录跳转控制台路径更改

刘恒 2 år sedan
förälder
incheckning
e3b0fee63b
1 ändrade filer med 47 tillägg och 49 borttagningar
  1. 47 49
      src/views/Login.vue

+ 47 - 49
src/views/Login.vue

@@ -159,18 +159,18 @@ import { login } from "@/api/user";
 import CryptoJS from "crypto-js";
 // import { getSysList } from "../http/moudules/sys";
 
-import { sendWebsocket,closeWebsocket  } from '@/utils/websocket.js'
+import { sendWebsocket, closeWebsocket } from "@/utils/websocket.js";
 import {
   getUserIP,
   getUserLocation,
-  getAddressLocation
+  getAddressLocation,
 } from "@/utils/ipAndAddress.js";
 export default {
   name: "Login",
   inject: ["reload"],
   components: {
     ThemePicker,
-    LangSelector
+    LangSelector,
   },
   data() {
     return {
@@ -182,12 +182,12 @@ export default {
         account: "",
         password: "",
         captcha: "",
-        src: ""
+        src: "",
       },
       fieldRules: {
         account: [{ required: true, message: "请输入账号", trigger: "blur" }],
         password: [{ required: true, message: "请输入密码", trigger: "blur" }],
-        captcha: [{ required: true, message: "请输入验证码", trigger: "blur" }]
+        captcha: [{ required: true, message: "请输入验证码", trigger: "blur" }],
       },
       checked: true,
       toggleQrCode: false,
@@ -197,7 +197,7 @@ export default {
       optionList: [],
       sysId: null,
       systemType: "1", //系统类型
-      addressInfo: {} //当前登录信息
+      addressInfo: {}, //当前登录信息
     };
   },
   created() {
@@ -213,7 +213,7 @@ export default {
   },
   methods: {
     getSysList() {
-      this.$api.sys.sysDictList().then(res => {
+      this.$api.sys.sysDictList().then((res) => {
         if (res.code === 200) {
           this.optionList = [...res.data];
           this.sysId = res.data && res.data.length > 0 && res.data[0].id;
@@ -222,7 +222,7 @@ export default {
     },
     enterEvent() {
       if (this.$route.name === "登录") {
-        document.onkeydown = e => {
+        document.onkeydown = (e) => {
           const url = e.target.baseURI.match(/login/);
           if (e.keyCode == 13 && url.includes("login")) {
             this.login();
@@ -231,7 +231,6 @@ export default {
       }
     },
     login(formName) {
-      
       // let token = CryptoJS.AES.encrypt(
       //   "2856c49f-7b34-4e83-b3c8-2c37dba7cb3b",
       //   "token"
@@ -239,7 +238,7 @@ export default {
       // console.log(token);
       // window.location.href =
       //   "http://localhost:8080/#/form/agreement?token=" + token;
-      this.$refs[formName].validate(valid => {
+      this.$refs[formName].validate((valid) => {
         if (valid) {
           this.loading = true;
           let userInfo = {
@@ -247,7 +246,7 @@ export default {
             password: this.loginForm.password,
             captcha: this.loginForm.captcha.toLowerCase(),
             captchaId: this.loginForm.captchaId,
-            sysId: this.sysId
+            sysId: this.sysId,
             // systemType: this.systemType
           };
 
@@ -275,12 +274,12 @@ export default {
 
           this.$api.login
             .login2(userInfo)
-            .then(res => {
+            .then((res) => {
               if (res.code != 200) {
                 this.$message({
                   message: res.msg,
                   type: "error",
-                  duration: 2000
+                  duration: 2000,
                 });
                 if (res.code == 500 && res.msg == "验证码不正确") {
                   this.refreshCaptcha();
@@ -290,7 +289,7 @@ export default {
                   //是否保存密码
                   Cookies.set("accountInfo", {
                     account: this.loginForm.account,
-                    password: this.loginForm.password
+                    password: this.loginForm.password,
                   });
                 } else {
                   Cookies.remove("accountInfo");
@@ -302,36 +301,35 @@ export default {
                   ).toString();
 
                   window.location.href =
-                    process.env.CONSOLE_BASE_URL +
-                    "/#/agreement/index?token=" +
-                    token;
+                    process.env.CONSOLE_BASE_URL + "/#/index?token=" + token;
                   // alert(res.data);
                 } else {
                   this.getUser();
                   Cookies.set("token", res.data); // 放置token到Cookie
                   // this.submitLocation();
                   this.getDictItems();
-                  setTimeout(()=>{
-                    let userId=sessionStorage.getItem("user")
-                    let data={
-                    ...this.addressInfo,
-                    userId,
-                    systemType:this.systemType
-                  }
-                  sendWebsocket(`${process.env.SOCKET_Url}/pcWebsocket/${userId}`,data)
-                  // sendWebsocket(`/pcWebsocket/${userId}`,data)
-                  },1000)
-                  
-
+                  setTimeout(() => {
+                    let userId = sessionStorage.getItem("user");
+                    let data = {
+                      ...this.addressInfo,
+                      userId,
+                      systemType: this.systemType,
+                    };
+                    sendWebsocket(
+                      `${process.env.SOCKET_Url}/pcWebsocket/${userId}`,
+                      data
+                    );
+                    // sendWebsocket(`/pcWebsocket/${userId}`,data)
+                  }, 1000);
                 }
               }
               this.loading = false;
             })
-            .catch(res => {
+            .catch((res) => {
               this.$message({
                 message: res.message,
                 type: "error",
-                duration: 2000
+                duration: 2000,
               });
             });
         } else {
@@ -343,13 +341,13 @@ export default {
     submitLocation() {
       let location = {
         systemType: this.systemType,
-        ...this.addressInfo
+        ...this.addressInfo,
       };
-      this.$api.login.uploadLocationInfo(location).then(res => {
+      this.$api.login.uploadLocationInfo(location).then((res) => {
         if (res.code !== 200) {
           this.$message({
             message: res.msg,
-            type: "error"
+            type: "error",
           });
         }
       });
@@ -358,11 +356,11 @@ export default {
     getDictItems() {
       //--数据字典--
       // 性别
-      this.$api.dict.findByLableName("sex").then(response => {
+      this.$api.dict.findByLableName("sex").then((response) => {
         localStorage.setItem("sexOptions", JSON.stringify(response.data)); // 保存用户到本地会话
       });
       // 状态
-      this.$api.dict.findByLableName("user_status").then(response => {
+      this.$api.dict.findByLableName("user_status").then((response) => {
         localStorage.setItem(
           "user_statusoptions",
           JSON.stringify(response.data)
@@ -371,7 +369,7 @@ export default {
     },
     // 用户信息
     getUser() {
-      this.$api.user.getLoginUser().then(response => {
+      this.$api.user.getLoginUser().then((response) => {
         if (response.code == 200) {
           //头像地址拼接
           if (
@@ -394,7 +392,7 @@ export default {
           this.$message.error(response.msg);
         }
       });
-      this.$api.role.findAll().then(res => {
+      this.$api.role.findAll().then((res) => {
         localStorage.setItem("find_all", JSON.stringify(res.data));
       });
     },
@@ -412,7 +410,7 @@ export default {
       this.$refs.loginForm.resetFields();
     },
     // 切换主题
-    onThemeChange: function(themeColor) {
+    onThemeChange: function (themeColor) {
       this.$store.commit("setThemeColor", themeColor);
     },
     switchLogin() {
@@ -429,14 +427,14 @@ export default {
       let url = process.env.BASE_URL + "/scanQrCode?uuid=" + uuid;
       this.$nextTick(() => {
         this.creatQrCode(url);
-        this.$api.login.getQRCode(uuid).then(res => {
+        this.$api.login.getQRCode(uuid).then((res) => {
           this.uuid = res.data.uuid;
           this.startPolling();
         });
       });
     },
     checkScanStatus() {
-      this.$api.login.QrCodeStatusQuery(this.uuid).then(res => {
+      this.$api.login.QrCodeStatusQuery(this.uuid).then((res) => {
         if (res.data.statusCode == 20000) {
           this.tipVisibility = true;
           this.loadingCode = true;
@@ -477,10 +475,10 @@ export default {
           height: 200,
           colorDark: "#000000",
           colorLight: "#ffffff",
-          correctLevel: QRCode.CorrectLevel.H
+          correctLevel: QRCode.CorrectLevel.H,
         });
       }
-    }
+    },
   },
 
   beforeDestroy() {
@@ -490,22 +488,22 @@ export default {
   mounted() {
     this.refreshCaptcha();
     /**获取当前登录的ip地址 */
-    getUserIP(ip => {
-      getAddressLocation(ip, info => {
-        console.log(info,22222222222);
+    getUserIP((ip) => {
+      getAddressLocation(ip, (info) => {
+        console.log(info, 22222222222);
         this.addressInfo = info;
       });
     });
   },
   computed: {
     ...mapState({
-      themeColor: state => state.app.themeColor
-    })
+      themeColor: (state) => state.app.themeColor,
+    }),
   },
   //销毁函数
   destroyed() {
     document.onkeydown = null;
-  }
+  },
 };
 </script>