From 1e3e48e3deacb44e9de1097dbf8d6c42aac71835 Mon Sep 17 00:00:00 2001
From: heyujie <516346543@qq.com>
Date: 星期五, 10 十二月 2021 20:30:45 +0800
Subject: [PATCH] 对比库管理2

---
 src/pages/index/App.vue |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/src/pages/index/App.vue b/src/pages/index/App.vue
index 5fc814d..21e780b 100644
--- a/src/pages/index/App.vue
+++ b/src/pages/index/App.vue
@@ -90,11 +90,60 @@
         const res1 = await savePassword(data);
         console.log(data);
       }
-
-      if (this.active == 1) {
-        const data = this.$refs[`form${this.active}`].getFormData();
-        await initNetwork(data);
-        console.log(data);
+    },
+    systemLogin() {
+      this.nullRule = this.rules
+      this.$nextTick(() => {
+        this.$refs['ruleForm'].validate(valid => {
+          if (valid) {
+            this.loading = this.$loading({
+              lock: true,
+              text: 'Loading',
+              spinner: 'el-icon-loading',
+              background: 'rgba(0, 0, 0, 0.7)'
+            })
+            this.testLogin()
+          } else {
+            this.nullRule = {}
+          }
+        })
+        this.nullRule = {}
+      })
+    },
+    async testLogin() {
+      // location.assign("/view/desktop/")
+      tologin({ username: this.user.loginName, password: this.user.password })
+        .then(json => {
+          const loginedInfo = {
+            access_token: json.token_type + ' ' + json.access_token,
+            refresh_token: json.refresh_token
+          }
+          sessionStorage.setItem('expires_in', json.expires_in)
+          sessionStorage.setItem('loginedInfo', JSON.stringify(loginedInfo))
+          this.loading.close()
+          this.getLoginUserData()
+        })
+        .catch(err => {
+          this.loading.close()
+          this.$notify({
+            title: '鎻愮ず',
+            type: 'error',
+            message: err.msg
+          })
+          this.$refs.pwd.focus()
+        })
+    },
+    async getLoginUserData() {
+      let res = await getLoginUserData()
+      if (res.success) {
+        sessionStorage.setItem('userInfo', JSON.stringify(res.data))
+        this.$notify.success("鐧诲綍鎴愬姛锛�")
+        // 鑾峰彇鏉冮檺
+        await this.getMenuList()
+        location.assign("/view/desktop/")
+        return res.data
+      } else {
+        this.$notify.error("鐧诲綍澶辫触锛�")
       }
 
       this.active++;

--
Gitblit v1.8.0