From 10727876994cffcd1fc74af114223740fc8825b6 Mon Sep 17 00:00:00 2001
From: ZZJ <zzjdsg2300@163.com>
Date: 星期一, 13 十二月 2021 10:44:23 +0800
Subject: [PATCH] Merge branch 'bhomebus' of http://192.168.5.5:10010/r/web/vue-smart-ai into bhomebus

---
 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 9e13cdd..f161ffc 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