修改登录注册

This commit is contained in:
熊丽君
2021-08-10 08:39:03 +08:00
parent c2939eeb11
commit 7a48bed10c
3 changed files with 33 additions and 18 deletions

View File

@ -1,4 +1,4 @@
import { login, logout, getInfo } from '@/api/login'; import { login, register, logout, getInfo } from '@/api/login';
import { getToken, setToken, removeToken } from '@/utils/auth'; import { getToken, setToken, removeToken } from '@/utils/auth';
const user = { const user = {

View File

@ -162,7 +162,9 @@ export default {
this.getCity(true, data); this.getCity(true, data);
} }
} }
getLabelSetting({ companyId: data.companyId || 1 }).then(({ data }) => { // data.companyId || 1;
getLabelSetting({ companyId: data ? data.companyId : 1 }).then(
({ data }) => {
this.labelList = data; this.labelList = data;
this.arr = data.map(item => this.arr = data.map(item =>
item.labelList item.labelList
@ -171,7 +173,8 @@ export default {
: '' : ''
: undefined : undefined
); );
}); }
);
}); });
}, },
// 地级市切换 // 地级市切换

View File

@ -135,11 +135,13 @@
:class="mode ? '' : 'flex-end'" :class="mode ? '' : 'flex-end'"
style="padding:0 0 15px" style="padding:0 0 15px"
> >
<el-checkbox v-if="mode">记住密码</el-checkbox> <el-checkbox v-if="mode" v-model="loginForm.rememberMe"
<el-button type="text" @click="mode = false" v-if="mode" >记住密码</el-checkbox
>
<el-button type="text" @click="changeMethod(false)" v-if="mode"
>验证码登录</el-button >验证码登录</el-button
> >
<el-button type="text" @click="mode = true" v-else <el-button type="text" @click="changeMethod(true)" v-else
>密码登录</el-button >密码登录</el-button
> >
</div> </div>
@ -152,7 +154,7 @@
>登录</el-button >登录</el-button
> >
</el-form> </el-form>
<el-checkbox style="padding:15px 0 0" <el-checkbox style="padding:15px 0 0" v-model="loginForm.flag"
>我已阅读并同意<el-button type="text" >我已阅读并同意<el-button type="text"
>用户协议</el-button >用户协议</el-button
></el-checkbox ></el-checkbox
@ -185,9 +187,11 @@ export default {
count: '', // 初始化次数 count: '', // 初始化次数
timer: null, timer: null,
loginForm: { loginForm: {
username: '19855383805', // 19855383805
password: '123456', username: '',
rememberMe: false password: '',
rememberMe: false,
flag: false
}, },
loginRules: { loginRules: {
username: [ username: [
@ -211,6 +215,10 @@ export default {
this.getCookie(); this.getCookie();
}, },
methods: { methods: {
changeMethod(flag) {
this.mode = flag;
this.loginForm.password = '';
},
getCookie() { getCookie() {
const username = Cookies.get('username'); const username = Cookies.get('username');
const password = Cookies.get('password'); const password = Cookies.get('password');
@ -245,6 +253,8 @@ export default {
}); });
}, },
handleLogin() { handleLogin() {
if (!this.loginForm.flag)
return this.msgError('请您阅读并同意《用户协议》');
this.$refs.loginForm.validate(valid => { this.$refs.loginForm.validate(valid => {
if (valid) { if (valid) {
this.loading = true; this.loading = true;
@ -272,6 +282,7 @@ export default {
this.loading = false; this.loading = false;
}); });
} else { } else {
// 验证码登录
this.$store this.$store
.dispatch('Register', this.loginForm) .dispatch('Register', this.loginForm)
.then(() => { .then(() => {
@ -437,6 +448,7 @@ $loginForm: 383px;
padding: 0 5px; padding: 0 5px;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center;
} }
} }
} }