| | |
| | | <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"> |
| | |
| | | <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> |
| | |
| | | initNetwork, |
| | | saveRegInfo, |
| | | getRegInfo, |
| | | isOnNet, |
| | | } from "./api"; |
| | | |
| | | export default { |
| | | async created() {}, |
| | | mounted() { |
| | | this.getInitInfo(); |
| | | let message = "网络正常"; |
| | | |
| | | 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: { |
| | |
| | | } |
| | | 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++; |
| | |
| | | |
| | | .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; |
| | |
| | | } |
| | | |
| | | .next { |
| | | margin: 10px auto; |
| | | cursor: pointer; |
| | | width: 260px; |
| | | height: 40px; |