2024-02-02 15:04:47 +08:00
|
|
|
<template>
|
|
|
|
|
<div>
|
2024-03-19 22:45:16 +08:00
|
|
|
<div class="proLoading-box" v-if="proLoading"></div>
|
|
|
|
|
<div v-else>
|
|
|
|
|
<div class="login-title">{{ $t('login.phoneLogin') }}</div>
|
|
|
|
|
<el-form :model="loginForm" :rules="loginRules" ref="loginForm" class="login-form">
|
|
|
|
|
<el-form-item prop="username">
|
|
|
|
|
<el-input size="small" style="margin-top: 20px; margin-bottom:10px;"
|
|
|
|
|
@keyup.enter.native="handleLogin"
|
|
|
|
|
v-model="loginForm.username"
|
|
|
|
|
:auto-complete="off"
|
|
|
|
|
placeholder="请输入您的账号">
|
2024-04-25 17:01:14 +08:00
|
|
|
<i slot="prefix" class="icon-yonghu"/>
|
2024-03-19 22:45:16 +08:00
|
|
|
</el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item prop="password">
|
2024-04-25 17:01:14 +08:00
|
|
|
<el-input size="small" style="margin-top: 20px; margin-bottom:10px;"
|
2024-03-19 22:45:16 +08:00
|
|
|
type="password"
|
|
|
|
|
@keyup.enter.native="handleLogin"
|
|
|
|
|
v-model="loginForm.password"
|
|
|
|
|
:auto-complete="off"
|
|
|
|
|
placeholder="请输入您的密码">
|
|
|
|
|
<i slot="prefix" class="icon-mima"/>
|
|
|
|
|
</el-input>
|
|
|
|
|
</el-form-item>
|
2024-04-25 17:01:14 +08:00
|
|
|
<!-- <el-form-item v-if="this.website.captchaMode" prop="code">-->
|
|
|
|
|
<!-- <el-input size="small" style="margin-top: 20px; margin-bottom:10px;"-->
|
|
|
|
|
<!-- @keyup.enter.native="handleLogin"-->
|
|
|
|
|
<!-- v-model="loginForm.code"-->
|
|
|
|
|
<!-- auto-complete="off"-->
|
|
|
|
|
<!-- placeholder="请输入图形验证码"-->
|
|
|
|
|
<!-- class="code-input">-->
|
|
|
|
|
<!-- <i slot="prefix" class="icon-yanzhengma"/>-->
|
|
|
|
|
<!-- </el-input>-->
|
|
|
|
|
<!-- <div class="login-code" >-->
|
|
|
|
|
<!-- <img :src="loginForm.image" class="login-code-img" @click="refreshCode" />-->
|
|
|
|
|
<!-- </div>-->
|
|
|
|
|
<!-- </el-form-item>-->
|
2024-03-19 22:45:16 +08:00
|
|
|
<div>
|
|
|
|
|
<el-button
|
|
|
|
|
size="small"
|
|
|
|
|
type="primary"
|
|
|
|
|
@click.native.prevent="handleLogin"
|
|
|
|
|
class="login-submit"
|
2024-04-25 17:01:14 +08:00
|
|
|
>{{ $t('login.submit') }}
|
|
|
|
|
</el-button>
|
2024-02-02 15:04:47 +08:00
|
|
|
</div>
|
2024-03-19 22:45:16 +08:00
|
|
|
</el-form>
|
|
|
|
|
</div>
|
2024-02-02 15:04:47 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2024-04-25 17:01:14 +08:00
|
|
|
import {mapGetters} from "vuex";
|
2024-02-02 15:04:47 +08:00
|
|
|
import topLang from "@/page/index/top/top-lang";
|
|
|
|
|
// import { info } from "@/api/system/tenant";
|
2024-04-25 17:01:14 +08:00
|
|
|
import {getCaptcha} from "@/api/user";
|
|
|
|
|
|
2024-04-15 18:01:50 +08:00
|
|
|
if (/(\/login\?)(.*)/ig.test(location.href)) {
|
2024-03-20 14:28:28 +08:00
|
|
|
const obj = {}
|
2024-03-20 15:22:17 +08:00
|
|
|
const query = location.href.split('?')[1].replace(/\?/, '').split('&')
|
2024-04-25 17:01:14 +08:00
|
|
|
query.forEach((item) => {
|
|
|
|
|
const a = item.split('=');
|
|
|
|
|
obj[a[0]] = a[1]
|
|
|
|
|
})
|
2024-03-20 14:28:28 +08:00
|
|
|
window.sessionStorage.setItem('query_session', JSON.stringify(obj))
|
|
|
|
|
} else {
|
|
|
|
|
window.sessionStorage.removeItem('query_session')
|
|
|
|
|
}
|
2024-02-02 15:04:47 +08:00
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: "login",
|
|
|
|
|
components: {
|
|
|
|
|
topLang,
|
|
|
|
|
},
|
2024-04-25 17:01:14 +08:00
|
|
|
data() {
|
2024-02-02 15:04:47 +08:00
|
|
|
return {
|
|
|
|
|
loginForm: {
|
|
|
|
|
//租户ID
|
|
|
|
|
tenantId: "000000",
|
|
|
|
|
//用户名
|
|
|
|
|
username: "",
|
|
|
|
|
//密码
|
|
|
|
|
password: "",
|
|
|
|
|
//账户类型
|
|
|
|
|
type: "account",
|
|
|
|
|
//验证码的值
|
|
|
|
|
code: "",
|
|
|
|
|
//验证码的索引
|
|
|
|
|
key: "",
|
|
|
|
|
//预加载白色背景
|
|
|
|
|
image: "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
|
|
|
|
|
//工作站loginTpye值为2
|
2024-04-25 17:01:14 +08:00
|
|
|
loginType: 'Type-T'
|
2024-02-02 15:04:47 +08:00
|
|
|
},
|
|
|
|
|
loginRules: {
|
|
|
|
|
username: [
|
2024-04-25 17:01:14 +08:00
|
|
|
{required: true, message: "请输入用户名", trigger: "blur"}
|
2024-02-02 15:04:47 +08:00
|
|
|
],
|
|
|
|
|
password: [
|
2024-04-25 17:01:14 +08:00
|
|
|
{required: true, message: "请输入密码", trigger: "blur"},
|
|
|
|
|
{min: 1, message: "密码长度最少为6位", trigger: "blur"}
|
2024-02-02 15:04:47 +08:00
|
|
|
]
|
|
|
|
|
},
|
2024-03-19 22:45:16 +08:00
|
|
|
passwordType: "password",
|
|
|
|
|
proLoading: false,
|
|
|
|
|
loading: null,
|
2024-04-15 18:01:50 +08:00
|
|
|
ticket: ''
|
2024-02-02 15:04:47 +08:00
|
|
|
};
|
|
|
|
|
},
|
2024-04-25 17:01:14 +08:00
|
|
|
watch: {},
|
|
|
|
|
created() {
|
2024-02-02 15:04:47 +08:00
|
|
|
// this.getTenant();
|
2024-04-25 17:01:14 +08:00
|
|
|
const {ticket} = JSON.parse(window.sessionStorage.getItem('query_session') || "{}")
|
2024-03-20 14:28:28 +08:00
|
|
|
window.sessionStorage.removeItem('query_session')
|
2024-04-15 18:01:50 +08:00
|
|
|
console.log(ticket)
|
2024-04-25 17:01:14 +08:00
|
|
|
if (ticket) {
|
2024-03-19 22:45:16 +08:00
|
|
|
this.proLoading = true
|
2024-04-15 18:01:50 +08:00
|
|
|
this.ticket = ticket
|
2024-03-20 12:08:54 +08:00
|
|
|
this.handleLogin()
|
2024-03-19 22:45:16 +08:00
|
|
|
} else {
|
2024-03-20 16:17:54 +08:00
|
|
|
console.log('刷新1')
|
2024-03-19 22:45:16 +08:00
|
|
|
this.refreshCode();
|
|
|
|
|
}
|
2024-02-02 15:04:47 +08:00
|
|
|
},
|
2024-04-25 17:01:14 +08:00
|
|
|
mounted() {
|
2024-02-02 15:04:47 +08:00
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
...mapGetters(["website", "tagWel"])
|
|
|
|
|
},
|
|
|
|
|
props: [],
|
|
|
|
|
methods: {
|
2024-04-25 17:01:14 +08:00
|
|
|
handelGoReg() {
|
|
|
|
|
this.$router.push({path: "/reg"});
|
2024-02-02 15:04:47 +08:00
|
|
|
},
|
2024-04-25 17:01:14 +08:00
|
|
|
refreshCode() {
|
2024-02-02 15:04:47 +08:00
|
|
|
getCaptcha().then(res => {
|
|
|
|
|
const data = res.data;
|
|
|
|
|
this.loginForm.key = data.key;
|
|
|
|
|
this.loginForm.image = data.image;
|
|
|
|
|
})
|
|
|
|
|
},
|
2024-04-25 17:01:14 +08:00
|
|
|
showPassword() {
|
2024-02-02 15:04:47 +08:00
|
|
|
this.passwordType === ""
|
|
|
|
|
? (this.passwordType = "password")
|
|
|
|
|
: (this.passwordType = "");
|
|
|
|
|
},
|
2024-04-25 17:01:14 +08:00
|
|
|
handleLogin() {
|
|
|
|
|
if (this.proLoading) {
|
2024-04-15 18:01:50 +08:00
|
|
|
let params = {
|
|
|
|
|
...this.loginForm,
|
|
|
|
|
username: "admin",
|
2024-04-15 19:17:17 +08:00
|
|
|
password: "111111",
|
2024-04-15 18:01:50 +08:00
|
|
|
ticket: this.ticket
|
|
|
|
|
}
|
|
|
|
|
this.ByUsernameCallback(params)
|
2024-03-19 22:45:16 +08:00
|
|
|
return
|
|
|
|
|
}
|
2024-02-02 15:04:47 +08:00
|
|
|
this.$refs.loginForm.validate(valid => {
|
|
|
|
|
if (valid) {
|
2024-03-20 12:08:54 +08:00
|
|
|
this.ByUsernameCallback()
|
2024-02-02 15:04:47 +08:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
2024-04-15 18:01:50 +08:00
|
|
|
ByUsernameCallback(params) {
|
2024-03-20 12:08:54 +08:00
|
|
|
const loading = this.$loading({
|
|
|
|
|
lock: true,
|
|
|
|
|
text: '登录中,请稍后。。。',
|
|
|
|
|
spinner: "el-icon-loading"
|
|
|
|
|
});
|
2024-04-15 18:01:50 +08:00
|
|
|
let obj = this.loginForm
|
2024-04-25 17:01:14 +08:00
|
|
|
if (params) {
|
2024-04-15 18:01:50 +08:00
|
|
|
obj = params
|
|
|
|
|
}
|
|
|
|
|
this.$store.dispatch("LoginByUsername", obj).then(() => {
|
2024-03-20 12:08:54 +08:00
|
|
|
this.$store.dispatch('jlHelpShow', false)
|
2024-04-25 17:01:14 +08:00
|
|
|
this.$router.push({path: this.tagWel.value});
|
2024-03-20 12:08:54 +08:00
|
|
|
loading.close();
|
2024-04-15 19:17:17 +08:00
|
|
|
this.proLoading = false
|
2024-03-20 12:08:54 +08:00
|
|
|
}).catch(() => {
|
2024-04-25 17:01:14 +08:00
|
|
|
if (obj.ticket) {
|
2024-04-15 19:43:51 +08:00
|
|
|
return window.location.href = process.env.VUE_APP_LOGIN_ERROR
|
|
|
|
|
}
|
2024-04-15 19:17:17 +08:00
|
|
|
this.proLoading = false
|
2024-03-20 12:08:54 +08:00
|
|
|
loading.close();
|
|
|
|
|
this.refreshCode();
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-02-02 15:04:47 +08:00
|
|
|
// getTenant () {
|
|
|
|
|
// let domain = window.location.href.split("/#/")[0];
|
|
|
|
|
// // 临时指定域名,方便测试
|
|
|
|
|
// info(domain).then(res => {
|
|
|
|
|
// const data = res.data;
|
|
|
|
|
// if (data.success && data.data.tenantId) {
|
|
|
|
|
// this.tenantMode = false;
|
|
|
|
|
// this.loginForm.tenantId = data.data.tenantId;
|
|
|
|
|
// this.$parent.$refs.login.style.backgroundImage = `url(${data.data.backgroundUrl})`;
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
@import "@/styles/login.scss";
|
2024-04-25 17:01:14 +08:00
|
|
|
|
|
|
|
|
.proLoading-box {
|
2024-03-19 22:45:16 +08:00
|
|
|
position: fixed;
|
|
|
|
|
left: 0;
|
|
|
|
|
top: 0;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
background: #FFFFFF;
|
|
|
|
|
}
|
2024-02-02 15:04:47 +08:00
|
|
|
</style>
|