| | |
| | |
|
| | | <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>
|
| | |
| | | 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()
|
| | | }
|
| | | })
|
| | | name: "smartai init",
|
| | | components: {
|
| | | formAccount,
|
| | | formNet,
|
| | | formInfo
|
| | | },
|
| | | data() {
|
| | | return {
|
| | | active: 0,
|
| | | formData: {},
|
| | | isWhite: true,
|
| | | isOnline: false,
|
| | | createUser: 0,
|
| | | configNet: 1,
|
| | | registerInfo: 2
|
| | | }
|
| | | },
|
| | | mounted() {
|
| | | this.getInitInfo()
|
| | |
| | | //临时判断网络是否通畅
|
| | | img.src = "http://apps.smartai.com/img/icons/favicon-32x32.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
|
| | | this.isOnline = true
|
| | | message = "已有网络"
|
| | | } else {
|
| | | //网络断网效果图出来后,将此地改为跳转路径到效果图上
|
| | |
| | | }
|
| | | })
|
| | | },
|
| | | data() {
|
| | | return {
|
| | | active: 0,
|
| | | formData: {},
|
| | | isWhite: true,
|
| | | isNet: false
|
| | | }
|
| | | },
|
| | | components: {
|
| | | formAccount,
|
| | | formNet,
|
| | | formInfo
|
| | | },
|
| | |
|
| | | methods: {
|
| | | preForm() {
|
| | | if (this.active == 0) {
|
| | | if (this.active == this.createUser) {
|
| | | return
|
| | | }
|
| | | this.active--
|
| | | this.$refs["carousel"].prev()
|
| | |
|
| | | // 如果网络正常, 直接跳过
|
| | | if (this.active == this.configNet && this.isOnline) {
|
| | | this.active--
|
| | | }
|
| | |
|
| | | this.$refs["carousel"].setActiveItem(this.active)
|
| | | },
|
| | | async nextForm() {
|
| | | if (this.active == 2) {
|
| | | // 提交注册信息
|
| | | if (this.active == this.registerInfo) {
|
| | | const data = this.$refs[`form${this.active}`].getFormData()
|
| | | await saveRegInfo(data)
|
| | | location.assign("/view/login/")
|
| | | return
|
| | | }
|
| | |
|
| | | if (this.active == 0) {
|
| | | // 配置网络
|
| | | if (this.active == this.configNet) {
|
| | | const data = this.$refs[`form${this.active}`].getFormData()
|
| | | initNetwork(data)
|
| | | }
|
| | |
|
| | | // 创建用户
|
| | | if (this.active == this.createUser) {
|
| | | 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()
|
| | |
|
| | | await savePassword(data)
|
| | |
|
| | | // 如果网络正常, 直接跳到第三部
|
| | | if (this.isOnline) {
|
| | | this.active++
|
| | | }
|
| | | }
|
| | |
|
| | | if (this.active == 1) {
|
| | | const data = this.$refs[`form${this.active}`].getFormData()
|
| | | initNetwork(data)
|
| | | this.active++
|
| | | this.$refs["carousel"].next()
|
| | | }
|
| | |
|
| | | this.getInitInfo()
|
| | | this.active++
|
| | | this.$refs["carousel"].setActiveItem(this.active)
|
| | | },
|
| | | nextFormNot() {
|
| | | this.getInitInfo()
|
| | | async nextFormNot() {
|
| | | await this.getInitInfo()
|
| | |
|
| | | this.active++
|
| | | this.$refs["carousel"].next()
|
| | |
| | | this.isWhite = false
|
| | | })
|
| | |
|
| | | console.log(res)
|
| | |
|
| | | if (res.data && res.data.initPwd && !res.data.initRegInfo) {
|
| | | const res1 = await getRegInfo()
|
| | | this.active = 1
|
| | | console.log(res1)
|
| | | setTimeout(() => {
|
| | | this.$refs["carousel"].setActiveItem(1)
|
| | | }, 0)
|
| | | this.active = this.isOnline ? this.registerInfo : this.configNet
|
| | | }
|
| | |
|
| | | if (res.data && res.data.initPwd && res.data.initRegInfo) {
|
| | |
| | |
|
| | | this.isWhite = false
|
| | | }
|
| | | },
|
| | | destroyed() {
|
| | | window.removeEventListener("keydown", (event) => {
|
| | | console.log(event.value)
|
| | | event.preventDefault()
|
| | | })
|
| | | }
|
| | | }
|
| | | </script>
|