刘翔宇-旅管家 4 years ago
parent eb2b749835
commit 616632011a

@ -1,6 +1,7 @@
<template> <template>
<div class="login-container"> <div class="login-container">
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left"> <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on"
label-position="left">
<div class="title-container"> <div class="title-container">
<h3 class="title">巡查养护管理系统登录</h3> <h3 class="title">巡查养护管理系统登录</h3>
@ -10,224 +11,221 @@
<span class="svg-container"> <span class="svg-container">
<svg-icon icon-class="user" /> <svg-icon icon-class="user" />
</span> </span>
<el-input <el-input ref="username" v-model="loginForm.username" placeholder="请输入账号" name="username" type="text"
ref="username" tabindex="1" auto-complete="on" />
v-model="loginForm.username"
placeholder="请输入账号"
name="username"
type="text"
tabindex="1"
auto-complete="on"
/>
</el-form-item> </el-form-item>
<el-form-item prop="password"> <el-form-item prop="password">
<span class="svg-container"> <span class="svg-container">
<svg-icon icon-class="password" /> <svg-icon icon-class="password" />
</span> </span>
<el-input <el-input :key="passwordType" ref="password" v-model="loginForm.password" :type="passwordType"
:key="passwordType" placeholder="请输入密码" name="password" tabindex="2" auto-complete="on" @keyup.enter.native="handleLogin" />
ref="password" <!-- <span class="show-pwd" @click="showPwd">
v-model="loginForm.password"
:type="passwordType"
placeholder="请输入密码"
name="password"
tabindex="2"
auto-complete="on"
@keyup.enter.native="handleLogin"
/>
<span class="show-pwd" @click="showPwd">
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" /> <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
</span> </span> -->
</el-form-item> </el-form-item>
<el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="handleLogin">登录</el-button> <el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;"
@click.native.prevent="handleLogin">登录</el-button>
</el-form> </el-form>
</div> </div>
</template> </template>
<script> <script>
import { validUsername } from '@/utils/validate' import {
validUsername
export default { } from '@/utils/validate'
name: 'Login',
data() { export default {
const validateUsername = (rule, value, callback) => { name: 'Login',
if (false) { data() {
callback(new Error('请正确输入登录名')) const validateUsername = (rule, value, callback) => {
} else { if (false) {
callback() callback(new Error('请正确输入登录名'))
} else {
callback()
}
} }
} const validatePassword = (rule, value, callback) => {
const validatePassword = (rule, value, callback) => { if (false) {
if (false) { callback(new Error('请正确输入密码'))
callback(new Error('请正确输入密码')) } else {
} else { callback()
callback() }
} }
} return {
return { loginForm: {
loginForm: { username: '',
username: '', password: ''
password: '' },
}, loginRules: {
loginRules: { username: [{
username: [{ required: true, trigger: 'blur', validator: validateUsername }], required: true,
password: [{ required: true, trigger: 'blur', validator: validatePassword }] trigger: 'blur',
}, validator: validateUsername
loading: false, }],
passwordType: 'password', password: [{
redirect: undefined required: true,
} trigger: 'blur',
}, validator: validatePassword
watch: { }]
$route: { },
handler: function(route) { loading: false,
this.redirect = route.query && route.query.redirect passwordType: 'password',
}, redirect: undefined
immediate: true
}
},
methods: {
showPwd() {
if (this.passwordType === 'password') {
this.passwordType = ''
} else {
this.passwordType = 'password'
} }
this.$nextTick(() => {
this.$refs.password.focus()
})
}, },
handleLogin() { watch: {
this.$refs.loginForm.validate(valid => { $route: {
if (valid) { handler: function(route) {
this.loading = true this.redirect = route.query && route.query.redirect
this.$store.dispatch('user/login', this.loginForm).then(() => { },
console.log(this.redirect) immediate: true
this.$router.push({ path: this.redirect || '/' }) }
this.loading = false },
}).catch(() => { methods: {
this.loading = false showPwd() {
}) if (this.passwordType === 'password') {
this.passwordType = ''
} else { } else {
console.log('error submit!!') this.passwordType = 'password'
return false
} }
}) this.$nextTick(() => {
this.$refs.password.focus()
})
},
handleLogin() {
this.$refs.loginForm.validate(valid => {
if (valid) {
this.loading = true
this.$store.dispatch('user/login', this.loginForm).then(() => {
console.log(this.redirect)
this.$router.push({
path: this.redirect || '/'
})
this.loading = false
}).catch(() => {
this.loading = false
})
} else {
console.log('error submit!!')
return false
}
})
}
} }
} }
}
</script> </script>
<style lang="scss"> <style lang="scss">
/* 修复input 背景不协调 和光标变色 */ /* 修复input 背景不协调 和光标变色 */
/* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */ /* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
$bg:#283443; $bg:#283443;
$light_gray:#fff; $light_gray:#fff;
$cursor: #fff; $cursor: #fff;
@supports (-webkit-mask: none) and (not (cater-color: $cursor)) { @supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
.login-container .el-input input { .login-container .el-input input {
color: $cursor; color: $cursor;
}
} }
}
/* reset element-ui css */
.login-container {
.el-input {
display: inline-block;
height: 47px;
width: 85%;
input {
background: transparent;
border: 0px;
-webkit-appearance: none;
border-radius: 0px;
padding: 12px 5px 12px 15px;
color: $light_gray;
height: 47px;
caret-color: $cursor;
&:-webkit-autofill { /* reset element-ui css */
box-shadow: 0 0 0px 1000px $bg inset !important; .login-container {
-webkit-text-fill-color: $cursor !important; .el-input {
display: inline-block;
height: 47px;
width: 85%;
input {
background: transparent;
border: 0px;
-webkit-appearance: none;
border-radius: 0px;
padding: 12px 5px 12px 15px;
color: $light_gray;
height: 47px;
caret-color: $cursor;
&:-webkit-autofill {
box-shadow: 0 0 0px 1000px $bg inset !important;
-webkit-text-fill-color: $cursor !important;
}
} }
} }
}
.el-form-item { .el-form-item {
border: 1px solid rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.1);
background: rgba(0, 0, 0, 0.1); background: rgba(0, 0, 0, 0.1);
border-radius: 5px; border-radius: 5px;
color: #454545; color: #454545;
}
} }
}
</style> </style>
<style lang="scss" scoped> <style lang="scss" scoped>
$bg:#2d3a4b; $bg:#2d3a4b;
$dark_gray:#889aa4; $dark_gray:#889aa4;
$light_gray:#eee; $light_gray:#eee;
.login-container { .login-container {
min-height: 100%; min-height: 100%;
width: 100%; width: 100%;
background-color: $bg; background-color: $bg;
overflow: hidden;
.login-form {
position: relative;
width: 520px;
max-width: 100%;
padding: 160px 35px 0;
margin: 0 auto;
overflow: hidden; overflow: hidden;
}
.tips { .login-form {
font-size: 14px; position: relative;
color: #fff; width: 520px;
margin-bottom: 10px; max-width: 100%;
padding: 160px 35px 0;
margin: 0 auto;
overflow: hidden;
}
.tips {
font-size: 14px;
color: #fff;
margin-bottom: 10px;
span { span {
&:first-of-type { &:first-of-type {
margin-right: 16px; margin-right: 16px;
}
} }
} }
}
.svg-container { .svg-container {
padding: 6px 5px 6px 15px; padding: 6px 5px 6px 15px;
color: $dark_gray; color: $dark_gray;
vertical-align: middle; vertical-align: middle;
width: 30px; width: 30px;
display: inline-block; display: inline-block;
} }
.title-container { .title-container {
position: relative; position: relative;
.title { .title {
font-size: 26px; font-size: 26px;
color: $light_gray; color: $light_gray;
margin: 0px auto 40px auto; margin: 0px auto 40px auto;
text-align: center; text-align: center;
font-weight: bold; font-weight: bold;
}
} }
}
.show-pwd { .show-pwd {
position: absolute; position: absolute;
right: 10px; right: 10px;
top: 7px; top: 7px;
font-size: 16px; font-size: 16px;
color: $dark_gray; color: $dark_gray;
cursor: pointer; cursor: pointer;
user-select: none; user-select: none;
}
} }
}
</style> </style>

@ -46,7 +46,8 @@ module.exports = {
//before: require('./mock/mock-server.js') //before: require('./mock/mock-server.js')
proxy: { proxy: {
[process.env.VUE_APP_BASE_API]: { [process.env.VUE_APP_BASE_API]: {
target: 'http://118.31.104.155:9003/', //target: 'http://192.168.60.100:9001/',
target: 'http://patrol.115.langye.net/',
changeOrigin: true, //配置跨域 changeOrigin: true, //配置跨域
pathRewrite: { pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: '' ['^' + process.env.VUE_APP_BASE_API]: ''

Loading…
Cancel
Save