From ba5f0a22558ce40300fa1668d98ea74ad56fd1e3 Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期二, 26 四月 2022 20:23:32 +0800 Subject: [PATCH] 初始化页面添加信息刷新 --- src/pages/index/App.vue | 151 +++++++++++++++++++++++-------------------------- 1 files changed, 71 insertions(+), 80 deletions(-) diff --git a/src/pages/index/App.vue b/src/pages/index/App.vue index 44594c8..f97c0f2 100644 --- a/src/pages/index/App.vue +++ b/src/pages/index/App.vue @@ -9,13 +9,7 @@ <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> </el-carousel-item> @@ -42,141 +36,138 @@ </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 { getInitInfo, savePassword, initNetwork, saveRegInfo, getRegInfo, isOnNet } from "./api" export default { created() { window.addEventListener("keydown", (event) => { if (event.keyCode === 9) { - console.log("tabfalse13"); - event.preventDefault(); + console.log("tabfalse13") + event.preventDefault() } - }); + }) }, mounted() { - this.getInitInfo(); - let message = "缃戠粶姝e父"; + this.getInitInfo() + let message = "缃戠粶姝e父" function onLine(callback) { - var img = new Image(); + 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); - }; + 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 = ""; + let message = "" if (flag) { - this.isNet = true; - message = "宸叉湁缃戠粶"; + this.isNet = true + message = "宸叉湁缃戠粶" } else { //缃戠粶鏂綉鏁堟灉鍥惧嚭鏉ュ悗锛屽皢姝ゅ湴鏀逛负璺宠浆璺緞鍒版晥鏋滃浘涓� - message = "鏈厤缃綉缁�"; + message = "鏃犳硶杩炴帴浜掕仈缃�" this.$notify({ - message: message, - }); + message: message + }) } - }); + }) }, data() { return { active: 0, formData: {}, isWhite: true, - isNet: false, - }; + isNet: false + } }, components: { formAccount, formNet, - formInfo, + formInfo }, methods: { preForm() { if (this.active == 0) { - return; + return } - this.active--; - this.$refs["carousel"].prev(); + this.active-- + this.$refs["carousel"].prev() }, async nextForm() { if (this.active == 2) { - const data = this.$refs[`form${this.active}`].getFormData(); - await saveRegInfo(data); - location.assign("/view/login/"); - return; + const data = this.$refs[`form${this.active}`].getFormData() + await saveRegInfo(data) + location.assign("/view/login/") + return } if (this.active == 0) { - const data = this.$refs[`form${this.active}`].getFormData(); + const data = this.$refs[`form${this.active}`].getFormData() if (!data) { - return false; + return false } - const res1 = await savePassword(data); - console.log(data); - this.active++; - this.$refs["carousel"].next(); + 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(); + const data = this.$refs[`form${this.active}`].getFormData() + initNetwork(data) + this.active++ + this.$refs["carousel"].next() } + + this.getInitInfo() }, nextFormNot() { - this.active++; - this.$refs["carousel"].next(); + this.getInitInfo() + + this.active++ + this.$refs["carousel"].next() }, async getInitInfo() { const res = await getInitInfo().catch((err) => { - this.isWhite = false; - }); + this.isWhite = false + }) - console.log(res); + console.log(res) if (res.data && res.data.initPwd && !res.data.initRegInfo) { - const res1 = await getRegInfo(); - this.active = 1; - console.log(res1); + const res1 = await getRegInfo() + this.active = 1 + console.log(res1) setTimeout(() => { - this.$refs["carousel"].setActiveItem(1); - }, 0); + this.$refs["carousel"].setActiveItem(1) + }, 0) } if (res.data && res.data.initPwd && res.data.initRegInfo) { - location.assign("/view/login/"); - return; + location.assign("/view/login/") + return } - this.isWhite = false; - }, + this.isWhite = false + } }, destroyed() { window.removeEventListener("keydown", (event) => { - console.log(event.value); - event.preventDefault(); - }); - }, -}; + console.log(event.value) + event.preventDefault() + }) + } +} </script> <style lang="scss" scoped> @@ -331,4 +322,4 @@ height: 100%; background-color: #fff; } -</style> \ No newline at end of file +</style> -- Gitblit v1.8.0