|
@@ -64,24 +64,7 @@
|
|
|
</el-form-item>
|
|
|
</el-tooltip>
|
|
|
|
|
|
- <!-- <el-form-item v-if="captchaEnabled" prop="code ">
|
|
|
- <el-col :span="16">
|
|
|
- <el-input
|
|
|
- v-model="loginForm.code "
|
|
|
- placeholder="验证码"
|
|
|
- style="width:63%"
|
|
|
- @keyup.enter.native="handleLogin"
|
|
|
- >
|
|
|
- <svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" />
|
|
|
- </el-input>
|
|
|
- <div class="login-code">
|
|
|
- <img :src="codeUrl" class="login-code-img" @click="getCode">
|
|
|
- </div>
|
|
|
- </el-col>
|
|
|
- </el-form-item>
|
|
|
- <el-checkbox v-model="loginForm.rememberMe" style="margin-left: 20px;">记住密码</el-checkbox> -->
|
|
|
-
|
|
|
- <el-form-item prop="code">
|
|
|
+ <!-- <el-form-item prop="code">
|
|
|
<el-input
|
|
|
v-model="loginForm.code"
|
|
|
class="code"
|
|
@@ -96,15 +79,41 @@
|
|
|
alt="验证码"
|
|
|
@click="changeCode"
|
|
|
>
|
|
|
+ </el-form-item> -->
|
|
|
+
|
|
|
+ <!-- 验证码 -->
|
|
|
+ <el-form-item>
|
|
|
+ <el-row :gutter="24">
|
|
|
+ <el-col :span="16" :offset="0">
|
|
|
+ <el-input
|
|
|
+ v-model="loginForm.code"
|
|
|
+ placeholder="请输入验证码"
|
|
|
+ />
|
|
|
+ <!-- 引入图标 -->
|
|
|
+ <!-- <el-input
|
|
|
+ v-model="loginForm.code"
|
|
|
+ prefix-icon="el-icon-info"
|
|
|
+ style="margin-left: 5px; fill: currentColor"
|
|
|
+ /> -->
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="8" :offset="0">
|
|
|
+ <vue-image @getIdentifyCode="getIdentifyCodes" />
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
</el-form-item>
|
|
|
- <el-checkbox v-model="loginForm.rememberMe" style="margin-left: 8px;">记住密码</el-checkbox>
|
|
|
+
|
|
|
+ <!-- 记住密码 -->
|
|
|
+ <el-checkbox
|
|
|
+ v-model="loginForm.rememberMe"
|
|
|
+ style="margin-left: 8px"
|
|
|
+ >记住密码</el-checkbox>
|
|
|
|
|
|
<!-- 按钮 -->
|
|
|
<el-button
|
|
|
:loading="loading"
|
|
|
type="info"
|
|
|
icon="el-icon el-icon-delete"
|
|
|
-
|
|
|
style="width: 30%; margin-bottom: 20px; margin-left: 20px"
|
|
|
@click="resetLoginForm"
|
|
|
>
|
|
@@ -115,7 +124,7 @@
|
|
|
:loading="loading"
|
|
|
type="warning"
|
|
|
icon="el-icon el-icon-circle-plus"
|
|
|
- style="width:35%;margin-bottom: 20px; margin-left: 20px"
|
|
|
+ style="width: 35%; margin-bottom: 20px; margin-left: 20px"
|
|
|
@click="registerForm($refs['loginForm'])"
|
|
|
>
|
|
|
注册
|
|
@@ -130,7 +139,6 @@
|
|
|
>
|
|
|
{{ $t("login.logIn") }}
|
|
|
</el-button>
|
|
|
-
|
|
|
</el-form>
|
|
|
|
|
|
<el-dialog :title="$t('login.thirdparty')" :visible.sync="showDialog">
|
|
@@ -148,13 +156,13 @@
|
|
|
import { validUsername } from '@/utils/validate'
|
|
|
import LangSelect from '@/components/LangSelect'
|
|
|
import SocialSign from './components/SocialSignin'
|
|
|
-import Cookies from 'js-cookie'
|
|
|
+import VueImage from './components/vueImageVerify.vue'
|
|
|
// import LoginFunc from '@/function-namespace/auth/LoginFunc'
|
|
|
|
|
|
export default {
|
|
|
name: 'Login',
|
|
|
// eslint-disable-next-line vue/no-unused-components
|
|
|
- components: { LangSelect, SocialSign },
|
|
|
+ components: { LangSelect, SocialSign, VueImage },
|
|
|
data() {
|
|
|
const validateUsername = (rule, value, callback) => {
|
|
|
if (value.length < 6) {
|
|
@@ -221,25 +229,16 @@ export default {
|
|
|
// window.removeEventListener('storage', this.afterQRScan)
|
|
|
},
|
|
|
methods: {
|
|
|
- // getCode() {
|
|
|
- // getCodeImg().then(res => {
|
|
|
- // this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
|
|
|
- // if (this.captchaEnabled) {
|
|
|
- // this.codeUrl = 'data:image/gif;base64,' + res.img
|
|
|
- // this.loginForm.uuid = res.uuid
|
|
|
- // }
|
|
|
- // })
|
|
|
- // },
|
|
|
- // getCookie() {
|
|
|
- // const username = Cookies.get('username')
|
|
|
- // const password = Cookies.get('password')
|
|
|
- // const rememberMe = Cookies.get('rememberMe')
|
|
|
- // this.loginForm = {
|
|
|
- // username: username === undefined ? this.loginForm.username : username,
|
|
|
- // // password: password === undefined ? this.loginForm.password : decrypt(password),
|
|
|
- // rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
|
|
|
- // }
|
|
|
- // },
|
|
|
+ getIdentifyCodes(value) {
|
|
|
+ console.log('------', value)
|
|
|
+ // 判断验证码输入是否有误 和输入的文本框
|
|
|
+ // if (this.verify.toLowerCase() != value.toLowerCase()) {
|
|
|
+ // Toast.fail('验证码有误')
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ this.valiatecode = value.toLowerCase()
|
|
|
+ },
|
|
|
+
|
|
|
checkCapslock(e) {
|
|
|
const { key } = e
|
|
|
this.capsTooltip = key && key.length === 1 && key >= 'A' && key <= 'Z'
|
|
@@ -255,25 +254,32 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
handleLogin() {
|
|
|
- this.$refs.loginForm.validate((valid) => {
|
|
|
+ // 验证码判断
|
|
|
+ // eslint-disable-next-line eqeqeq
|
|
|
+ if (this.valiatecode.toLowerCase() != this.loginForm.code.toLowerCase()) {
|
|
|
+ console.log(this.valiatecode, this.loginForm.code)
|
|
|
+ this.$notify({
|
|
|
+ title: 'warning',
|
|
|
+ message: '验证码错误',
|
|
|
+ type: 'warning',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 登陆判断
|
|
|
+ this.$refs.loginForm.validate(valid => {
|
|
|
if (valid) {
|
|
|
this.loading = true
|
|
|
- if (this.loginForm.rememberMe) {
|
|
|
- Cookies.set('username', this.loginForm.username, { expires: 30 })
|
|
|
- // Cookies.set('password', encrypt(this.loginForm.password), { expires: 30 })
|
|
|
- Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 })
|
|
|
- } else {
|
|
|
- Cookies.remove('username')
|
|
|
- Cookies.remove('password')
|
|
|
- Cookies.remove('rememberMe')
|
|
|
- }
|
|
|
- this.$store
|
|
|
- .dispatch('user/login', this.loginForm)
|
|
|
+ this.$notify({
|
|
|
+ title: 'Success',
|
|
|
+ message: '登录成功',
|
|
|
+ type: 'success',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+
|
|
|
+ this.$store.dispatch('user/login', this.loginForm)
|
|
|
.then(() => {
|
|
|
- this.$router.push({
|
|
|
- path: this.redirect || '/',
|
|
|
- query: this.otherQuery
|
|
|
- })
|
|
|
+ this.$router.push({ path: this.redirect || '/', query: this.otherQuery })
|
|
|
this.loading = false
|
|
|
})
|
|
|
.catch(() => {
|
|
@@ -285,6 +291,31 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
+ handleLogin_second() {
|
|
|
+ this.$refs.loginForm.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ this.loading = true
|
|
|
+ this.$store.dispatch('user/login', this.loginForm)
|
|
|
+ .then(() => {
|
|
|
+ this.$router.push({ path: this.redirect || '/', query: this.otherQuery })
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ resetLoginForm() {
|
|
|
+ // vue中刷新页面
|
|
|
+ this.$router.go(0)
|
|
|
+ // windows强制刷新:window.location.reload()
|
|
|
+ },
|
|
|
getOtherQuery(query) {
|
|
|
return Object.keys(query).reduce((acc, cur) => {
|
|
|
if (cur !== 'redirect') {
|
|
@@ -313,7 +344,6 @@ export default {
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
@@ -368,7 +398,7 @@ $bg: #2d3a4b;
|
|
|
$dark_gray: #889aa4;
|
|
|
$light_gray: #eee;
|
|
|
|
|
|
-.el-button--info{
|
|
|
+.el-button--info {
|
|
|
background: #1890ff;
|
|
|
}
|
|
|
|
|
@@ -382,7 +412,7 @@ $light_gray: #eee;
|
|
|
margin-top: 5px;
|
|
|
margin-left: 10px;
|
|
|
height: 30px;
|
|
|
- width:"60%",
|
|
|
+ width: "60%";
|
|
|
}
|
|
|
.login-form {
|
|
|
position: relative;
|
|
@@ -444,29 +474,29 @@ $light_gray: #eee;
|
|
|
}
|
|
|
|
|
|
.login-code {
|
|
|
- width: 33%;
|
|
|
- height: 38px;
|
|
|
- float: right;
|
|
|
- img {
|
|
|
- cursor: pointer;
|
|
|
- vertical-align: middle;
|
|
|
+ width: 33%;
|
|
|
+ height: 38px;
|
|
|
+ float: right;
|
|
|
+ img {
|
|
|
+ cursor: pointer;
|
|
|
+ vertical-align: middle;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .el-login-footer {
|
|
|
+ height: 40px;
|
|
|
+ line-height: 40px;
|
|
|
+ position: fixed;
|
|
|
+ bottom: 0;
|
|
|
+ width: 100%;
|
|
|
+ text-align: center;
|
|
|
+ color: #fff;
|
|
|
+ font-family: Arial;
|
|
|
+ font-size: 12px;
|
|
|
+ letter-spacing: 1px;
|
|
|
+ }
|
|
|
+ .login-code-img {
|
|
|
+ height: 38px;
|
|
|
}
|
|
|
-}
|
|
|
-.el-login-footer {
|
|
|
- height: 40px;
|
|
|
- line-height: 40px;
|
|
|
- position: fixed;
|
|
|
- bottom: 0;
|
|
|
- width: 100%;
|
|
|
- text-align: center;
|
|
|
- color: #fff;
|
|
|
- font-family: Arial;
|
|
|
- font-size: 12px;
|
|
|
- letter-spacing: 1px;
|
|
|
-}
|
|
|
-.login-code-img {
|
|
|
- height: 38px;
|
|
|
-}
|
|
|
|
|
|
.thirdparty-button {
|
|
|
position: absolute;
|