|
|
@@ -1,130 +1,153 @@
|
|
|
<template>
|
|
|
<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"
|
|
|
+ class="login-form"
|
|
|
+ auto-complete="on"
|
|
|
+ label-position="left"
|
|
|
+ >
|
|
|
<div class="title-container">
|
|
|
<h3 class="title">湖南智企云开放平台</h3>
|
|
|
</div>
|
|
|
|
|
|
<el-form-item prop="username">
|
|
|
- <span class="svg-container">
|
|
|
- <svg-icon icon-class="user" />
|
|
|
- </span>
|
|
|
+ <span class="svg-container el-icon-user-solid"></span>
|
|
|
+
|
|
|
<el-input
|
|
|
ref="username"
|
|
|
v-model="loginForm.username"
|
|
|
- placeholder="Username"
|
|
|
+ placeholder="请输入手机号/邮箱"
|
|
|
name="username"
|
|
|
type="text"
|
|
|
- tabindex="1"
|
|
|
auto-complete="on"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item prop="password">
|
|
|
- <span class="svg-container">
|
|
|
- <svg-icon icon-class="password" />
|
|
|
- </span>
|
|
|
+ <span class="svg-container el-icon-lock"></span>
|
|
|
<el-input
|
|
|
:key="passwordType"
|
|
|
ref="password"
|
|
|
v-model="loginForm.password"
|
|
|
:type="passwordType"
|
|
|
- placeholder="Password"
|
|
|
+ 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>
|
|
|
</el-form-item>
|
|
|
|
|
|
- <el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="handleLogin">立即登录</el-button>
|
|
|
+ <el-form-item prop="password">
|
|
|
+ <span class="svg-container el-icon-warning"></span>
|
|
|
|
|
|
+ <el-input
|
|
|
+ ref="captcha"
|
|
|
+ v-model="loginForm.captcha"
|
|
|
+ placeholder="请输入验证码"
|
|
|
+ name="captcha"
|
|
|
+ type="text"
|
|
|
+ />
|
|
|
+ <img
|
|
|
+ :src="captcha"
|
|
|
+ class="show-pwd"
|
|
|
+ style="height: 38px"
|
|
|
+ @click="refreshCaptcha"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-button
|
|
|
+ :loading="loading"
|
|
|
+ type="primary"
|
|
|
+ style="width: 100%; margin-bottom: 30px"
|
|
|
+ @click.native.prevent="handleLogin"
|
|
|
+ >立即登录</el-button
|
|
|
+ >
|
|
|
</el-form>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { validUsername } from '@/utils/validate'
|
|
|
+import { getCaptcha } from "@/api/oauth";
|
|
|
|
|
|
export default {
|
|
|
- name: 'Login',
|
|
|
+ name: "Login",
|
|
|
data() {
|
|
|
- const validateUsername = (rule, value, callback) => {
|
|
|
- if (!validUsername(value)) {
|
|
|
- callback(new Error('Please enter the correct user name'))
|
|
|
- } else {
|
|
|
- callback()
|
|
|
- }
|
|
|
- }
|
|
|
- const validatePassword = (rule, value, callback) => {
|
|
|
- if (value.length < 6) {
|
|
|
- callback(new Error('The password can not be less than 6 digits'))
|
|
|
- } else {
|
|
|
- callback()
|
|
|
- }
|
|
|
- }
|
|
|
return {
|
|
|
loginForm: {
|
|
|
- username: 'admin',
|
|
|
- password: '111111'
|
|
|
- },
|
|
|
- loginRules: {
|
|
|
- username: [{ required: true, trigger: 'blur', validator: validateUsername }],
|
|
|
- password: [{ required: true, trigger: 'blur', validator: validatePassword }]
|
|
|
+ username: "",
|
|
|
+ password: "",
|
|
|
+ captcha: "",
|
|
|
},
|
|
|
loading: false,
|
|
|
- passwordType: 'password',
|
|
|
- redirect: undefined
|
|
|
- }
|
|
|
+ passwordType: "password",
|
|
|
+ redirect: undefined,
|
|
|
+ token: "",
|
|
|
+ captcha: "",
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.refreshCaptcha();
|
|
|
},
|
|
|
watch: {
|
|
|
$route: {
|
|
|
- handler: function(route) {
|
|
|
- this.redirect = route.query && route.query.redirect
|
|
|
+ handler: function (route) {
|
|
|
+ this.redirect = route.query && route.query.redirect;
|
|
|
},
|
|
|
- immediate: true
|
|
|
- }
|
|
|
+ immediate: true,
|
|
|
+ },
|
|
|
},
|
|
|
methods: {
|
|
|
+ refreshCaptcha() {
|
|
|
+ let _this = this;
|
|
|
+ getCaptcha().then((v) => {
|
|
|
+ console.log(v);
|
|
|
+ this.token = v.token;
|
|
|
+ this.captcha = v.captcha;
|
|
|
+ });
|
|
|
+ },
|
|
|
showPwd() {
|
|
|
- if (this.passwordType === 'password') {
|
|
|
- this.passwordType = ''
|
|
|
+ if (this.passwordType === "password") {
|
|
|
+ this.passwordType = "";
|
|
|
} else {
|
|
|
- this.passwordType = 'password'
|
|
|
+ this.passwordType = "password";
|
|
|
}
|
|
|
this.$nextTick(() => {
|
|
|
- this.$refs.password.focus()
|
|
|
- })
|
|
|
+ this.$refs.password.focus();
|
|
|
+ });
|
|
|
},
|
|
|
handleLogin() {
|
|
|
- this.$refs.loginForm.validate(valid => {
|
|
|
+ this.$refs.loginForm.validate((valid) => {
|
|
|
if (valid) {
|
|
|
- this.loading = true
|
|
|
- this.$store.dispatch('user/login', this.loginForm).then(() => {
|
|
|
- this.$router.push({ path: this.redirect || '/' })
|
|
|
- this.loading = false
|
|
|
- }).catch(() => {
|
|
|
- this.loading = false
|
|
|
- })
|
|
|
+ this.loading = true;
|
|
|
+ this.$store
|
|
|
+ .dispatch("user/login", { ...this.loginForm, token: this.token })
|
|
|
+ .then(() => {
|
|
|
+ this.$router.push({ path: this.redirect || "/" });
|
|
|
+ this.loading = false;
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
} else {
|
|
|
- console.log('error submit!!')
|
|
|
- return false
|
|
|
+ console.log("error submit!!");
|
|
|
+ return false;
|
|
|
}
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
|
+$bg: #283443;
|
|
|
|
|
|
-$bg:#283443;
|
|
|
-
|
|
|
-$light_gray:#fff;
|
|
|
+$light_gray: #fff;
|
|
|
$cursor: #fff;
|
|
|
|
|
|
@supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
|
|
|
@@ -167,9 +190,9 @@ $cursor: #fff;
|
|
|
</style>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-$bg:#2d3a4b;
|
|
|
-$dark_gray:#889aa4;
|
|
|
-$light_gray:#eee;
|
|
|
+$bg: #2d3a4b;
|
|
|
+$dark_gray: #889aa4;
|
|
|
+$light_gray: #eee;
|
|
|
|
|
|
.login-container {
|
|
|
min-height: 100%;
|