|
@@ -1,33 +1,72 @@
|
|
|
<template>
|
|
|
<div :style="bg" class="login-container">
|
|
|
- <div class="code">
|
|
|
+ <!-- <div class="code">
|
|
|
<span>微信扫一扫登录</span>
|
|
|
<img :src="code" class="code-img">
|
|
|
- </div>
|
|
|
+ </div> -->
|
|
|
+ <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" label-position="left">
|
|
|
+ <h3 class="title">手机号码登录</h3>
|
|
|
+ <p class="tips">手机号码登录,未注册将自动创建智能白板账号</p>
|
|
|
+ <el-form-item prop="username">
|
|
|
+ <el-input v-model="loginForm.username" name="username" type="text" placeholder="手机号" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="code">
|
|
|
+ <el-input
|
|
|
+ v-model="loginForm.code"
|
|
|
+ name="code"
|
|
|
+ type="text"
|
|
|
+ placeholder="验证码"
|
|
|
+ @keyup.enter.native="handleLogin" />
|
|
|
+ <el-button :disabled="flag" type="primary" @click.native.prevent="handleCode">{{ msg }}</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button :loading="loading" type="primary" style="width:100%;" @click.native.prevent="handleLogin">
|
|
|
+ 登录
|
|
|
+ </el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { mapGetters } from 'vuex'
|
|
|
+// import { mapGetters } from 'vuex'
|
|
|
import { setToken } from '@/utils/auth'
|
|
|
+import { isvalidUsername } from '@/utils/validate'
|
|
|
|
|
|
export default {
|
|
|
name: 'Login',
|
|
|
data() {
|
|
|
+ const validateUsername = (rule, value, callback) => {
|
|
|
+ if (!isvalidUsername(value)) {
|
|
|
+ callback(new Error('请输入正确的手机号'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
return {
|
|
|
+ loginForm: {
|
|
|
+ username: '',
|
|
|
+ code: ''
|
|
|
+ },
|
|
|
+ loginRules: {
|
|
|
+ username: [{ required: true, trigger: 'blur', validator: validateUsername }]
|
|
|
+ },
|
|
|
loading: false,
|
|
|
- pwdType: 'password',
|
|
|
redirect: undefined,
|
|
|
+ flag: false,
|
|
|
+ time: 10,
|
|
|
+ msg: '获取验证码',
|
|
|
bg: {
|
|
|
backgroundImage: 'url(' + require('@/assets/bg.jpg') + ')'
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- computed: {
|
|
|
- ...mapGetters([
|
|
|
- 'code'
|
|
|
- ])
|
|
|
- },
|
|
|
+ // 获取二维码暂时注释改为手机号登录 需要的话可以打开
|
|
|
+ // computed: {
|
|
|
+ // ...mapGetters([
|
|
|
+ // 'code'
|
|
|
+ // ])
|
|
|
+ // },
|
|
|
watch: {
|
|
|
$route: {
|
|
|
handler: function(route) {
|
|
@@ -36,24 +75,78 @@ export default {
|
|
|
immediate: true
|
|
|
}
|
|
|
},
|
|
|
- created() {
|
|
|
- this.getLogincode()
|
|
|
- },
|
|
|
methods: {
|
|
|
- getLogincode() {
|
|
|
- this.$store.dispatch('LoginCode').then(() => {
|
|
|
- this.queryLogin()
|
|
|
+ // 获取二维码暂时注释改为手机号登录 需要的话可以打开
|
|
|
+ // getLogincode() {
|
|
|
+ // this.$store.dispatch('LoginCode').then(() => {
|
|
|
+ // this.queryLogin()
|
|
|
+ // })
|
|
|
+ // },
|
|
|
+ // queryLogin() {
|
|
|
+ // setTimeout(() => {
|
|
|
+ // this.$store.dispatch('loginSuccess').then(res => { // 拉取用户信息
|
|
|
+ // setToken(res.data.id)
|
|
|
+ // this.$router.push({ path: this.redirect || '/' })
|
|
|
+ // }).catch(() => {
|
|
|
+ // this.queryLogin()
|
|
|
+ // })
|
|
|
+ // }, 5000)
|
|
|
+ // },
|
|
|
+ // showPwd() {
|
|
|
+ // if (this.pwdType === 'password') {
|
|
|
+ // this.pwdType = ''
|
|
|
+ // } else {
|
|
|
+ // this.pwdType = 'password'
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ handleCode() {
|
|
|
+ this.$refs.loginForm.validate(valid => {
|
|
|
+ if (valid && (!this.flag)) {
|
|
|
+ this.$store.dispatch('sendMag', this.loginForm).then(() => {
|
|
|
+ this.countDown()
|
|
|
+ }).catch(() => {
|
|
|
+
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
- queryLogin() {
|
|
|
+ handleLogin() {
|
|
|
+ if (!this.loginForm.code) {
|
|
|
+ alert('输入验证码')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ this.$refs.loginForm.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ this.loading = true
|
|
|
+ this.$store.dispatch('loginByPhone', this.loginForm).then((res) => {
|
|
|
+ this.loading = false
|
|
|
+ setToken(res.data.id)
|
|
|
+ this.$router.push({ path: this.redirect || '/' })
|
|
|
+ }).catch(() => {
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ countDown() {
|
|
|
setTimeout(() => {
|
|
|
- this.$store.dispatch('loginSuccess').then(res => { // 拉取用户信息
|
|
|
- setToken(res.data.id)
|
|
|
- this.$router.push({ path: this.redirect || '/' })
|
|
|
- }).catch(() => {
|
|
|
- this.queryLogin()
|
|
|
- })
|
|
|
- }, 5000)
|
|
|
+ this.time--
|
|
|
+ if (this.time > 0) {
|
|
|
+ this.flag = true
|
|
|
+ this.msg = `${this.time}秒后重新发送`
|
|
|
+ this.countDown()
|
|
|
+ } else {
|
|
|
+ this.flag = false
|
|
|
+ this.msg = `获取验证码`
|
|
|
+ this.time = 10
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -78,7 +171,6 @@ $light_gray:#eee;
|
|
|
color: $light_gray;
|
|
|
height: 47px;
|
|
|
&:-webkit-autofill {
|
|
|
- -webkit-box-shadow: 0 0 0px 1000px $bg inset !important;
|
|
|
-webkit-text-fill-color: #fff !important;
|
|
|
}
|
|
|
}
|
|
@@ -88,6 +180,9 @@ $light_gray:#eee;
|
|
|
background: rgba(0, 0, 0, 0.1);
|
|
|
border-radius: 5px;
|
|
|
color: #454545;
|
|
|
+ .el-form-item__content {
|
|
|
+ display: flex;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -114,12 +209,6 @@ $light_gray:#eee;
|
|
|
.tips {
|
|
|
font-size: 14px;
|
|
|
color: #fff;
|
|
|
- margin-bottom: 10px;
|
|
|
- span {
|
|
|
- &:first-of-type {
|
|
|
- margin-right: 16px;
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
.svg-container {
|
|
|
padding: 6px 5px 6px 15px;
|
|
@@ -132,8 +221,6 @@ $light_gray:#eee;
|
|
|
font-size: 26px;
|
|
|
font-weight: 400;
|
|
|
color: $light_gray;
|
|
|
- margin: 0px auto 40px auto;
|
|
|
- text-align: center;
|
|
|
font-weight: bold;
|
|
|
}
|
|
|
.show-pwd {
|
|
@@ -145,23 +232,23 @@ $light_gray:#eee;
|
|
|
cursor: pointer;
|
|
|
user-select: none;
|
|
|
}
|
|
|
- .code {
|
|
|
- position: absolute;
|
|
|
- right: 222px;
|
|
|
- top: 50%;
|
|
|
- margin-top: -171px;
|
|
|
- width: 320px;
|
|
|
- height: 342px;
|
|
|
- background: rgba(255,255,255,1);
|
|
|
- border-radius: 5px;
|
|
|
- text-align: center;
|
|
|
- padding-top: 20px;
|
|
|
- box-sizing: border-box;
|
|
|
- .code-img {
|
|
|
- width:218px;
|
|
|
- height: 218px;
|
|
|
- margin: 20px 0;
|
|
|
- }
|
|
|
- }
|
|
|
+ // .code {
|
|
|
+ // position: absolute;
|
|
|
+ // right: 222px;
|
|
|
+ // top: 50%;
|
|
|
+ // margin-top: -171px;
|
|
|
+ // width: 320px;
|
|
|
+ // height: 342px;
|
|
|
+ // background: rgba(255,255,255,1);
|
|
|
+ // border-radius: 5px;
|
|
|
+ // text-align: center;
|
|
|
+ // padding-top: 20px;
|
|
|
+ // box-sizing: border-box;
|
|
|
+ // .code-img {
|
|
|
+ // width:218px;
|
|
|
+ // height: 218px;
|
|
|
+ // margin: 20px 0;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}
|
|
|
</style>
|