diff --git a/src/api/index.js b/src/api/index.js index 4ad0e9b..0b1871f 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -12,6 +12,7 @@ export default { logins: `${host}users/users/user/login`, //登录 verification: `${host}users/users/user/captcha`,// 验证码图片 logoDetail: `${host}occupationlab/sys/logo/detail`, //查看系统设置信息 + isClient: `${host}users/users/user/isClient`, //实验台 curriculumDetail: `${host}nakadai/nakadai/curriculum/curriculumDetail`, // 课程详情 diff --git a/src/assets/img/dev/sup1.png b/src/assets/img/dev/sup1.png index 069cba2..3c39a8f 100644 Binary files a/src/assets/img/dev/sup1.png and b/src/assets/img/dev/sup1.png differ diff --git a/src/assets/img/login/female.png b/src/assets/img/login/female.png new file mode 100644 index 0000000..f376ab3 Binary files /dev/null and b/src/assets/img/login/female.png differ diff --git a/src/assets/img/login/male.png b/src/assets/img/login/male.png new file mode 100644 index 0000000..ca0ca29 Binary files /dev/null and b/src/assets/img/login/male.png differ diff --git a/src/pages/account/login/index.vue b/src/pages/account/login/index.vue index 3cbb8b5..b9ec107 100644 --- a/src/pages/account/login/index.vue +++ b/src/pages/account/login/index.vue @@ -68,6 +68,18 @@ 确 定 + + + @@ -77,6 +89,7 @@ import vFooter from "@/layouts/footer"; import { mapActions } from "vuex"; import util from "@/libs/util"; import Setting from "@/setting"; +import axios from "axios" export default { data: function() { @@ -110,7 +123,10 @@ export default { phoneCode: "", phoneDisabled: false, phoneTimer: null, - phoneBtnText: "发送验证码" + phoneBtnText: "发送验证码", + selectVisible: false, + selectedRole: '', + token: '' }; }, components: { @@ -128,36 +144,69 @@ export default { }, methods: { ...mapActions("user", [ - "login" + "setInfo" ]), getVerImg() { // 获取验证码图片 this.form.random = Math.floor(Math.random() * 999999999); this.verificationIMG = this.api.verification + "?random=" + `${this.form.random}`; }, typeClick(tab) { // 切换标签 - console.log(tab) this.form.distinguish = tab.id this.form.account = ""; this.$refs.form.clearValidate(); this.loginRules.account[0].message = tab.id === "1" ? "请输入账号" : "请输入手机号/邮箱"; }, + // 处理登录成功 + setLogin() { + util.local.set(Setting.tokenKey, this.token, Setting.tokenExpires) + util.successMsg('登录成功') + const redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : "/station" + this.$router.replace(redirect) + }, submitFormLogin() { // 提交登录 this.$refs.form.validate(valid => { if (valid) { this.form.distinguish = Number(this.form.distinguish); - this.login(this.form).then(() => { - let redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : "/station"; - this.$router.replace(redirect); + this.$post(this.api.logins, this.form).then((res) => { + if (res.status == 200) { + this.token = res.data.token + console.log(11, res) + // 查询是否是客户,如果是客户,则弹出选择端的页面去选择跳转到哪个端 + axios.get(this.api.isClient, { + headers: { + token: res.data.token + } + }).then(res => { + // 如果是客户 + if (res.data.customer) { + this.selectVisible = true + } else { + this.setLogin() + } + }).catch(res => {}) + } else { + util.errorMsg(res.message) + } }).catch(res => { if (res && res.status == 30001) { this.phoneVisible = true; } this.getVerImg(); - this.form.code = ""; - }); + this.form.code = '' + }) } }); }, + // 选择端 + selectRole(val) { + this.selectedRole = val + if (val === 1) { + this.setLogin() + } else { + location.href = `${location.origin}/admin/#/redirect?auth=${window.btoa(this.token)}` + // location.href = 'http://192.168.31.125:8081/#/redirect?auth=' + btoa(this.token) + } + }, phoneCountdown() { let count = 60; if (!this.phoneTimer) { @@ -373,4 +422,37 @@ export default { text-align: center; color: #666; } +.port { + display: flex; + justify-content: center; + padding: 60px 0; + li { + text-align: center; + cursor: pointer; + &:first-child { + margin-right: 86px; + } + &:hover img { + opacity: .9; + } + &.active span { + background-color: #9278ff; + } + } + img { + width: 122px; + margin-bottom: 20px; + } + p { + width: 88px; + margin: 0 auto; + line-height: 21px; + color: #fff; + background-color: #e8e3ff; + border-radius: 4px; + } +} +/deep/.select-dia { + margin-top: calc((100vh - 383px) / 2) !important; +} \ No newline at end of file diff --git a/src/setting.js b/src/setting.js index 6173fdf..64685db 100644 --- a/src/setting.js +++ b/src/setting.js @@ -38,10 +38,10 @@ if (isHh) { } else if (isDev) { // 本地 // host = "http://www.occupationlab.com:9000/";//线上 - // host = "http://39.108.250.202:9000/"; // 中台测试服 + host = "http://39.108.250.202:9000/"; // 中台测试服 systemPath = `http://192.168.31.125:8093` // host = "http://192.168.31.137:9000/"; // 赓 - host = "http://192.168.31.151:9000/"; // 榕 + // host = "http://192.168.31.151:9000/"; // 榕 title = "职站"; } else { console.log("其它版本");