From c0c034b3ef0fdf0fd9c802d5984dbd717db6817a Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期三, 06 九月 2023 17:54:55 +0800
Subject: [PATCH] 定制桌面.

---
 src/pages/index/App.vue |  178 ++++++++++++++++++++---------------------------------------
 1 files changed, 61 insertions(+), 117 deletions(-)

diff --git a/src/pages/index/App.vue b/src/pages/index/App.vue
index b4fa2eb..9a4d3bc 100644
--- a/src/pages/index/App.vue
+++ b/src/pages/index/App.vue
@@ -9,32 +9,26 @@
         <el-step title="娉ㄥ唽淇℃伅"></el-step>
       </el-steps>
 
-      <el-carousel
-        ref="carousel"
-        trigger="click"
-        :loop="false"
-        :autoplay="false"
-        :initial-index="active"
-      >
+      <el-carousel ref="carousel" trigger="click" :loop="false" :autoplay="false" :initial-index="active">
         <el-carousel-item>
-          <formAccount ref="form0"></formAccount>
+          <formAccount ref="form0" v-show="active == createUser"></formAccount>
         </el-carousel-item>
         <el-carousel-item>
-          <formNet ref="form1"></formNet>
+          <formNet ref="form1" v-show="active == configNet"></formNet>
         </el-carousel-item>
         <el-carousel-item>
-          <formInfo ref="form2"></formInfo>
+          <formInfo ref="form2" v-show="active == registerInfo"></formInfo>
         </el-carousel-item>
       </el-carousel>
 
       <div class="control">
-        <div class="pre" @click="preForm" v-if="active != 0">涓婁竴姝�</div>
-        <div class="next" @click="nextForm" v-if="active == 0">涓嬩竴姝�</div>
-        <div class="next" @click="nextFormNot" v-if="active == 1">璺宠繃</div>
-        <div class="next" @click="nextForm" v-if="active == 1 && !isNet">
+        <div class="pre" @click="preForm" v-if="active != createUser">涓婁竴姝�</div>
+        <div class="next" @click="nextForm" v-if="active == createUser || (active == configNet && !isOnline)">
           涓嬩竴姝�
         </div>
-        <div class="next" @click="nextForm" v-if="active == 2">瀹屾垚</div>
+        <div class="next" @click="nextFormNot" v-if="active == configNet">璺宠繃</div>
+
+        <div class="next" @click="nextForm" v-if="active == registerInfo">瀹屾垚</div>
       </div>
     </div>
   </div>
@@ -42,123 +36,73 @@
 </template>
 
 <script>
-import formAccount from "@/pages/index/components/formAccount";
-import formNet from "@/pages/index/components/formNet";
-import formInfo from "@/pages/index/components/formInfo";
-import {
-  getInitInfo,
-  savePassword,
-  initNetwork,
-  saveRegInfo,
-  getRegInfo,
-  isOnNet,
-} from "./api";
+import formAccount from "@/pages/index/components/formAccount"
+import formNet from "@/pages/index/components/formNet"
+import formInfo from "@/pages/index/components/formInfo"
+import { tologin, getLoginUserData, getServerName } from "./api.ts"
+import { getMenuListData } from "@/api/utils"
 
 export default {
-  mounted() {
-    this.getInitInfo();
-    let message = "缃戠粶姝e父";
-
-    function onLine(callback) {
-      var img = new Image();
-      //涓存椂鍒ゆ柇缃戠粶鏄惁閫氱晠
-      img.src = "http://apps.smartai.com/img/icon_logo.f78688b5.png";
-      img.onload = function () {
-        console.log("11111");
-        if (callback) callback(true);
-      };
-      img.onerror = function () {
-        console.log("22222");
-        if (callback) callback(false);
-      };
-    }
-
-    onLine((flag) => {
-      let message = "";
-      if (flag) {
-        this.isNet = true;
-        message = "宸叉湁缃戠粶";
-      } else {
-        //缃戠粶鏂綉鏁堟灉鍥惧嚭鏉ュ悗锛屽皢姝ゅ湴鏀逛负璺宠浆璺緞鍒版晥鏋滃浘涓�
-        message = "鏈厤缃綉缁�";
-        this.$notify({
-          message: message,
-        });
-      }
-    });
+  name: "smartai init",
+  components: {
+    formAccount,
+    formNet,
+    formInfo
   },
   data() {
     return {
       active: 0,
       formData: {},
       isWhite: true,
-      isNet: false,
-    };
+      isOnline: false,
+      createUser: 0,
+      configNet: 1,
+      registerInfo: 2
+    }
   },
-  components: {
-    formAccount,
-    formNet,
-    formInfo,
+  mounted() {
+    this.testLogin()
   },
+
   methods: {
-    preForm() {
-      if (this.active == 0) {
-        return;
-      }
-      this.active--;
-      this.$refs["carousel"].prev();
+    async testLogin() {
+      // location.assign("/view/desktop/")
+      tologin({ username: "basic", password: "basic2019" })
+        .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))
+          sessionStorage.setItem("userInfo", JSON.stringify(json.userInfo))
+
+          location.assign("/view/desktop/")
+        })
+        .catch()
     },
-    async nextForm() {
-      if (this.active == 2) {
-        const data = this.$refs[`form${this.active}`].getFormData();
-        await saveRegInfo(data);
-        location.assign("/view/login/");
-        return;
-      }
+    async getLoginUserData() {
+      let res = await getLoginUserData()
+      if (res.success) {
+        sessionStorage.setItem("userInfo", JSON.stringify(res.data))
+        // 鑾峰彇鏉冮檺
+        // await this.getMenuList()
 
-      if (this.active == 0) {
-        const data = this.$refs[`form${this.active}`].getFormData();
-        if (!data) {
-          return false;
-        }
-        const res1 = await savePassword(data);
-        console.log(data);
-        this.active++;
-        this.$refs["carousel"].next();
-      }
-
-      if (this.active == 1) {
-        const data = this.$refs[`form${this.active}`].getFormData();
-        initNetwork(data);
-        this.active++;
-        this.$refs["carousel"].next();
+        return res.data
+      } else {
       }
     },
-    nextFormNot() {
-      this.active++;
-      this.$refs["carousel"].next();
-    },
-    async getInitInfo() {
-      const res = await getInitInfo();
-
-      if (true) {
-        const res1 = await getRegInfo();
-        this.active = 1;
-        console.log(res1);
-        setTimeout(() => {
-          this.$refs["carousel"].setActiveItem(1);
-        }, 0);
+    async getMenuList() {
+      let results = await getMenuListData({})
+      if (results && results.success) {
+        /* 瀛樺偍鏉冮檺 */
+        let buttonAuthoritys = results.data
+        sessionStorage.setItem("buttonAuthoritys", "," + buttonAuthoritys + ",")
+        sessionStorage.setItem("menuInfo", JSON.stringify(results))
       }
-
-      /* if (res.data.initPwd && res.data.initRegInfo) {
-        location.assign("/login");
-        return;
-      } */
-
-      this.isWhite = false;
-    },
-  },
-};
+    }
+  }
+}
 </script>
 
 <style lang="scss" scoped>
@@ -313,4 +257,4 @@
   height: 100%;
   background-color: #fff;
 }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.8.0