|
|
|
|
@ -13,14 +13,14 @@
|
|
|
|
|
<div class="title-container">
|
|
|
|
|
<h3 class="title">欢迎登录</h3>
|
|
|
|
|
<div class="title-change">
|
|
|
|
|
<span @click="changeLogin=false" :class="{color:!changeLogin}">账号登录</span>
|
|
|
|
|
<span @click="changeLogin=true" :class="{color:changeLogin}">短信登录</span>
|
|
|
|
|
<span @click="changeLoginType" :class="{color:!changeLogin}">账号登录</span>
|
|
|
|
|
<span @click="changeLoginType" :class="{color:changeLogin}">短信登录</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<template v-if="!changeLogin">
|
|
|
|
|
<el-form-item prop="username">
|
|
|
|
|
<el-input ref="username" v-model="loginForm.username" placeholder="手机号/邮箱" name="username" type="text"
|
|
|
|
|
<el-input ref="username" v-model="loginForm.username" placeholder="用户名" name="username" type="text"
|
|
|
|
|
tabindex="1" auto-complete="on" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item prop="password">
|
|
|
|
|
@ -32,22 +32,26 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<el-form-item prop="username">
|
|
|
|
|
<el-input ref="username" v-model="loginForm.username" placeholder="手机号" name="username" type="text"
|
|
|
|
|
tabindex="1" auto-complete="on" />
|
|
|
|
|
<el-form-item prop="mobile">
|
|
|
|
|
<el-input ref="mobile" v-model="loginForm.mobile" placeholder="手机号" name="mobile" type="text" tabindex="1"
|
|
|
|
|
auto-complete="on" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item prop="code" class="send_item">
|
|
|
|
|
<el-input ref="code" v-model="loginForm.code" placeholder="验证码" name="code" type="text" tabindex="1"
|
|
|
|
|
auto-complete="on">
|
|
|
|
|
</el-input>
|
|
|
|
|
<span class="senndCode">发送验证码</span>
|
|
|
|
|
<span :class="hasSend?'hasCode':'senndCode'" @click="sendMsg">{{hasSend?'已发送':'发送验证码'}}
|
|
|
|
|
<span v-if="hasSend">({{count}}s)</span>
|
|
|
|
|
</span>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-button :loading="loading" type="primary" class="loginBtn"
|
|
|
|
|
@click.native.prevent="handleLogin">登录</el-button>
|
|
|
|
|
<el-button v-if="!changeLogin" :loading="loading" type="primary" class="loginBtn"
|
|
|
|
|
@click.native.prevent="handleLogin">登录</el-button>
|
|
|
|
|
<el-button v-else :loading="loading" type="primary" class="loginBtn"
|
|
|
|
|
@click.native.prevent="handleMsgLogin">登录</el-button>
|
|
|
|
|
</el-form>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
@ -60,7 +64,13 @@
|
|
|
|
|
import {
|
|
|
|
|
validUsername
|
|
|
|
|
} from '@/utils/validate'
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
getMsg,
|
|
|
|
|
loginMsg
|
|
|
|
|
} from "@/api/user.js"
|
|
|
|
|
import {
|
|
|
|
|
setToken
|
|
|
|
|
} from '@/utils/auth'
|
|
|
|
|
const defaultSettings = require('../../../src/settings.js')
|
|
|
|
|
export default {
|
|
|
|
|
name: 'Login',
|
|
|
|
|
@ -82,6 +92,9 @@
|
|
|
|
|
return {
|
|
|
|
|
title: "",
|
|
|
|
|
changeLogin: false,
|
|
|
|
|
hasSend: false,
|
|
|
|
|
count: 60,
|
|
|
|
|
sendTimer: null,
|
|
|
|
|
loginForm: {
|
|
|
|
|
username: '',
|
|
|
|
|
password: ''
|
|
|
|
|
@ -105,12 +118,12 @@
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
$route: {
|
|
|
|
|
handler: function(route) {
|
|
|
|
|
if(route.query && route.query.redirect==='/'){
|
|
|
|
|
this.redirect = '/dashboard'
|
|
|
|
|
}else{
|
|
|
|
|
this.redirect = route.query && route.query.redirect
|
|
|
|
|
}
|
|
|
|
|
handler: function(route) {
|
|
|
|
|
if (route.query && route.query.redirect === '/') {
|
|
|
|
|
this.redirect = '/dashboard'
|
|
|
|
|
} else {
|
|
|
|
|
this.redirect = route.query && route.query.redirect
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
immediate: true
|
|
|
|
|
@ -132,8 +145,66 @@
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.$refs.password.focus()
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
changeLoginType(){
|
|
|
|
|
this.changeLogin = !this.changeLogin
|
|
|
|
|
},
|
|
|
|
|
// 发短信
|
|
|
|
|
sendMsg() {
|
|
|
|
|
if(this.hasSend){
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (this.base.isNull(this.loginForm.mobile)) {
|
|
|
|
|
this.$Message.warning('请输入手机号')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (!this.base.isPhone(this.loginForm.mobile)) {
|
|
|
|
|
this.$Message.warning('请输入正确的手机号')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
getMsg({
|
|
|
|
|
mobile: this.loginForm.mobile
|
|
|
|
|
}).then(res => {
|
|
|
|
|
this.$Message.success('发送成功')
|
|
|
|
|
// 短信发送后 60s
|
|
|
|
|
this.hasSend = true
|
|
|
|
|
this.sendTimer = setInterval(() => {
|
|
|
|
|
if (this.count > 1) {
|
|
|
|
|
this.count--;
|
|
|
|
|
} else {
|
|
|
|
|
clearInterval(this.sendTimer);
|
|
|
|
|
this.hasSend = false;
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 短信登录
|
|
|
|
|
handleMsgLogin(){
|
|
|
|
|
if (this.base.isNull(this.loginForm.mobile)) {
|
|
|
|
|
this.$Message.warning('请输入手机号')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (this.base.isNull(this.loginForm.code)) {
|
|
|
|
|
this.$Message.warning('请输入验证码')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.loading = true
|
|
|
|
|
loginMsg({
|
|
|
|
|
mobile:this.loginForm.mobile,
|
|
|
|
|
code:this.loginForm.code
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
setToken(res.access_token)
|
|
|
|
|
this.$router.push({
|
|
|
|
|
path: this.redirect || '/dashboard'
|
|
|
|
|
})
|
|
|
|
|
this.loading = false
|
|
|
|
|
}).catch(res=>{
|
|
|
|
|
this.loading = false
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
//处理登录
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//处理账号登录
|
|
|
|
|
handleLogin() {
|
|
|
|
|
this.$refs.loginForm.validate(valid => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
@ -152,7 +223,8 @@
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 处理短信登录
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
@ -222,17 +294,19 @@
|
|
|
|
|
background: url("../../assets/login_bg.png") no-repeat;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
background-size: 100% 100%;
|
|
|
|
|
position: relative;
|
|
|
|
|
.login-footer{
|
|
|
|
|
text-align: center;
|
|
|
|
|
position: absolute;
|
|
|
|
|
bottom:20px;
|
|
|
|
|
left:0;
|
|
|
|
|
width:100%;
|
|
|
|
|
color:#274999;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
|
|
.login-footer {
|
|
|
|
|
text-align: center;
|
|
|
|
|
position: absolute;
|
|
|
|
|
bottom: 20px;
|
|
|
|
|
left: 0;
|
|
|
|
|
width: 100%;
|
|
|
|
|
color: #274999;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.login-logo {
|
|
|
|
|
// width: 20vw;
|
|
|
|
|
width: 383px;
|
|
|
|
|
@ -316,6 +390,18 @@
|
|
|
|
|
height: 47px;
|
|
|
|
|
line-height: 47px;
|
|
|
|
|
border-radius: 0 5px 5px 0;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
.hasCode{
|
|
|
|
|
background-color: #ddd;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
width: 30%;
|
|
|
|
|
text-align: center;
|
|
|
|
|
color: #000;
|
|
|
|
|
height: 47px;
|
|
|
|
|
line-height: 47px;
|
|
|
|
|
border-radius: 0 5px 5px 0;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -354,12 +440,13 @@
|
|
|
|
|
user-select: none;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@media (max-width:492px) {
|
|
|
|
|
.login-container {
|
|
|
|
|
.login-logo{
|
|
|
|
|
width:100%;
|
|
|
|
|
.login-container {
|
|
|
|
|
.login-logo {
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.login-wrap {
|
|
|
|
|
margin-left: 0px;
|
|
|
|
|
margin-right: 0px;
|
|
|
|
|
@ -374,7 +461,7 @@
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media (min-width:493px) {
|
|
|
|
|
.login-container {
|
|
|
|
|
|