From d91c8da48ca76f43999220971bc540227790c1e4 Mon Sep 17 00:00:00 2001 From: ZZJ <zzjdsg2300@163.com> Date: 星期一, 13 十二月 2021 17:50:43 +0800 Subject: [PATCH] 改 --- src/pages/index/App.vue | 127 +++++++++++++++++++++++++++++------------- 1 files changed, 87 insertions(+), 40 deletions(-) diff --git a/src/pages/index/App.vue b/src/pages/index/App.vue index f161ffc..4751673 100644 --- a/src/pages/index/App.vue +++ b/src/pages/index/App.vue @@ -1,5 +1,6 @@ <template> <div class="init" v-if="!isWhite"> + <img class="img-test" onerror="console.log('缃戠粶鏁呴殰')" /> <div class="content"> <div class="title">娆㈣繋娉ㄥ唽Smart AI 浜哄伐鏅鸿兘鎿嶄綔绯荤粺</div> <el-steps :active="active" finish-status="success" :align-center="true"> @@ -30,7 +31,10 @@ <div class="control"> <div class="pre" @click="preForm">涓婁竴姝�</div> <div class="next" @click="nextForm" v-if="active == 0">涓嬩竴姝�</div> - <div class="next" @click="nextForm" v-if="active == 1">璺宠繃</div> + <div class="next" @click="nextFormNot" v-if="active == 1">璺宠繃</div> + <div class="next" @click="nextForm" v-if="active == 1 && !isNet"> + 涓嬩竴姝� + </div> <div class="next" @click="nextForm" v-if="active == 2">瀹屾垚</div> </div> </div> @@ -48,17 +52,49 @@ initNetwork, saveRegInfo, getRegInfo, + isOnNet, } from "./api"; export default { + async created() {}, 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, + }); + }); }, data() { return { active: 0, formData: {}, isWhite: true, + isNet: false, }; }, components: { @@ -89,61 +125,74 @@ } 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(); } }, + nextFormNot() { + this.active++; + this.$refs["carousel"].next(); + }, systemLogin() { - this.nullRule = this.rules + this.nullRule = this.rules; this.$nextTick(() => { - this.$refs['ruleForm'].validate(valid => { + 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() + text: "Loading", + spinner: "el-icon-loading", + background: "rgba(0, 0, 0, 0.7)", + }); + this.testLogin(); } else { - this.nullRule = {} + this.nullRule = {}; } - }) - this.nullRule = {} - }) + }); + this.nullRule = {}; + }); }, async testLogin() { // location.assign("/view/desktop/") tologin({ username: this.user.loginName, password: this.user.password }) - .then(json => { + .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() + 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() + .catch((err) => { + this.loading.close(); this.$notify({ - title: '鎻愮ず', - type: 'error', - message: err.msg - }) - this.$refs.pwd.focus() - }) + title: "鎻愮ず", + type: "error", + message: err.msg, + }); + this.$refs.pwd.focus(); + }); }, async getLoginUserData() { - let res = await getLoginUserData() + let res = await getLoginUserData(); if (res.success) { - sessionStorage.setItem('userInfo', JSON.stringify(res.data)) - this.$notify.success("鐧诲綍鎴愬姛锛�") + sessionStorage.setItem("userInfo", JSON.stringify(res.data)); + this.$notify.success("鐧诲綍鎴愬姛锛�"); // 鑾峰彇鏉冮檺 - await this.getMenuList() - location.assign("/view/desktop/") - return res.data + await this.getMenuList(); + location.assign("/view/desktop/"); + return res.data; } else { - this.$notify.error("鐧诲綍澶辫触锛�") + this.$notify.error("鐧诲綍澶辫触锛�"); } this.active++; @@ -277,15 +326,12 @@ .control { position: fixed; - display: flex; - justify-content: center; - align-items: center; - bottom: 258px; + top: 770px; left: 0; right: 0; line-height: 40px; .pre { - margin-right: 20px; + margin: 10px auto; cursor: pointer; width: 260px; height: 40px; @@ -296,6 +342,7 @@ } .next { + margin: 10px auto; cursor: pointer; width: 260px; height: 40px; -- Gitblit v1.8.0