登录修改

chengdu
4 years ago
parent 895522b265
commit 606d743053
  1. 117
      src/components/page/Login.vue
  2. 14
      src/styles/common.scss

@ -12,8 +12,49 @@
<div class="back" v-show="isReg" @click="toReg(false)"> <div class="back" v-show="isReg" @click="toReg(false)">
<i class="el-icon-back"></i> <i class="el-icon-back"></i>
</div> </div>
<div v-if="!isReg"> <div v-if="!isReg" class="ms-login">
<h2>密码登录</h2> <el-tabs v-model="activeName">
<el-tab-pane label="账号登录" name="0">
<el-form :model="loginForm" :rules="loginRules" ref="loginForm" style="margin-top: 20px">
<el-form-item label="用户名" prop="username">
<el-input v-model="loginForm.username" placeholder="请输入账号"></el-input>
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input
type="password"
placeholder="请输入密码"
v-model="loginForm.password"
@keyup.enter.native="getSchool('loginForm')"
>
</el-input>
</el-form-item>
<el-button class="submit" type="primary" @click="getSchool('loginForm')">登录</el-button>
</el-form>
</el-tab-pane>
<el-tab-pane label="手机号/邮箱登录" name="1">
<el-form :model="phoneParam" :rules="phoneRules" ref="phoneParam" style="margin-top: 20px">
<el-form-item label="手机号/邮箱" prop="userphone">
<el-input v-model="phoneParam.userphone" placeholder="请输入手机号/邮箱"></el-input>
</el-form-item>
<el-form-item label="密码" prop="phonePassword">
<el-input
type="password"
placeholder="请输入密码"
v-model="phoneParam.phonePassword"
@keyup.enter.native="getSchool('phoneParam')"
>
</el-input>
</el-form-item>
<el-button class="submit" type="primary" @click="getSchool('phoneParam')">登录</el-button>
</el-form>
</el-tab-pane>
</el-tabs>
<div class="links flex-between">
<el-button type="text" class="ques" @click="toReg(true)">前往注册</el-button>
<el-button type="text" class="forget" @click="forget">忘记密码</el-button>
</div>
<!-- <h2>密码登录</h2>
<el-form :model="loginForm" :rules="loginRules" ref="login" label-width="0px"> <el-form :model="loginForm" :rules="loginRules" ref="login" label-width="0px">
<el-form-item prop="username"> <el-form-item prop="username">
<p class="label">用户名</p> <p class="label">用户名</p>
@ -34,18 +75,7 @@
<el-button type="text" class="ques" @click="toReg(true)">前往注册</el-button> <el-button type="text" class="ques" @click="toReg(true)">前往注册</el-button>
<el-button type="text" class="forget" @click="forget">忘记密码</el-button> <el-button type="text" class="forget" @click="forget">忘记密码</el-button>
</div> </div>
<!-- <p class="login-tips">其他登陆方式</p> </el-form> -->
<div class="thirdParty">
<div class="item">
<img src="../../assets/img/icon_wechat.png" alt="">
微信扫码登录
</div>
<div class="item">
<img src="../../assets/img/icon_qq.png" alt="">
QQ一键登录
</div>
</div> -->
</el-form>
</div> </div>
<register v-else :isReg.sync="isReg" @updateInfo="updateInfo"></register> <register v-else :isReg.sync="isReg" @updateInfo="updateInfo"></register>
</div> </div>
@ -59,7 +89,8 @@
</div> </div>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="cancleRoleDia"> </el-button> <el-button @click="cancleRoleDia"> </el-button>
<el-button type="primary" @click="roleSure"> </el-button> <el-button v-if="activeName == '0'" type="primary" @click="roleSure('loginForm')"> </el-button>
<el-button v-else type="primary" @click="roleSure('phoneParam')"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
@ -115,6 +146,7 @@ import register from './RegisterForm';
export default { export default {
data: function() { data: function() {
return { return {
activeName: '0',
isReg: false, isReg: false,
loginForm: { loginForm: {
username: '15794146134', username: '15794146134',
@ -124,6 +156,14 @@ export default {
username: [{ required: true, message: '请输入用户名', trigger: 'blur' }], username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
password: [{ required: true, message: '请输入密码', trigger: 'blur' }], password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
}, },
phoneParam: {
userphone: '',
phonePassword: ''
},
phoneRules: {
userphone: [{ required: true, message: '请输入手机号/邮箱', trigger: 'blur' }],
phonePassword: [{ required: true, message: '请输入密码', trigger: 'blur' }],
},
roleDialog: false, roleDialog: false,
userId: '', userId: '',
schoolId: '', schoolId: '',
@ -159,13 +199,14 @@ export default {
}) })
}, },
methods: { methods: {
getSchool() { getSchool(form) {
this.$refs.login.validate(valid => { this.$refs[form].validate(valid => {
if (valid) { if (valid) {
let data = { let data = {
account: this.loginForm.username, account: this.activeName == '0' ? this.loginForm.username : this.phoneParam.userphone,
password: this.loginForm.password, password: this.activeName == '0' ? this.loginForm.password : this.phoneParam.phonePassword,
schoolId: 2105 schoolId: 2105,
source: this.activeName
}; };
this.$get(this.api.loginSchool, data) this.$get(this.api.loginSchool, data)
.then(res => { .then(res => {
@ -182,7 +223,7 @@ export default {
this.studentId = this.schoolList[0].studentId this.studentId = this.schoolList[0].studentId
// this.getRole() // this.getRole()
this.roleId = 4 this.roleId = 4
this.submitForm() this.submitForm(form)
}else{ }else{
this.$message.error('账号不存在') this.$message.error('账号不存在')
} }
@ -197,7 +238,7 @@ export default {
} }
}); });
}, },
getRole() { getRole(form) {
// this.userId = this.schoolList.find((n,k) => { // this.userId = this.schoolList.find((n,k) => {
// return n.schoolId == this.schoolId // return n.schoolId == this.schoolId
// }).userId // }).userId
@ -230,7 +271,7 @@ export default {
this.roleDialog = true this.roleDialog = true
}else{ }else{
this.roleId = this.roleList[0].roleId this.roleId = this.roleList[0].roleId
this.submitForm() this.submitForm(form)
} }
}) })
.catch(res => {}); .catch(res => {});
@ -239,15 +280,15 @@ export default {
this.loginForm.username = data.username this.loginForm.username = data.username
this.loginForm.password = data.password this.loginForm.password = data.password
}, },
roleSure(){ roleSure(form){
if(this.roleId){ if(this.roleId){
this.submitForm() this.submitForm(form)
}else{ }else{
this.$message.error('请选择角色!'); this.$message.error('请选择角色!');
} }
}, },
submitForm() { submitForm(form) {
this.$refs.login.validate(valid => { this.$refs[form].validate(valid => {
if (valid) { if (valid) {
let data = { let data = {
roleId: this.roleId, roleId: this.roleId,
@ -485,17 +526,6 @@ export default {
border-radius: 23px; border-radius: 23px;
border: 0; border: 0;
} }
.links{
margin: 20px 0 20px;
}
.ques{
color: #105cb2;
font-size: 14px;
}
.forget{
color: #ffa94e;
font-size: 14px;
}
.login-tips{ .login-tips{
margin-bottom: 20px; margin-bottom: 20px;
font-size: 16px; font-size: 16px;
@ -529,4 +559,15 @@ export default {
color: #9076FF; color: #9076FF;
} }
} }
.links{
margin: 20px 0 20px;
}
.ques{
color: #105cb2;
font-size: 14px;
}
.forget{
color: #ffa94e;
font-size: 14px;
}
</style> </style>

@ -195,7 +195,7 @@
opacity: 0; opacity: 0;
} }
.ms-login .el-tabs__item{ .ms-login .el-tabs__item{
padding: 0 90px; padding: 0 40px;
color: #999; color: #999;
} }
.ms-login .el-tabs__item:hover{ .ms-login .el-tabs__item:hover{
@ -214,12 +214,12 @@
justify-content: center; justify-content: center;
} }
.ms-login .el-input__inner{ // .ms-login .el-input__inner{
height: 80px; // height: 80px;
line-height: 80px; // line-height: 80px;
border:1px solid rgba(220,220,220,1); // border:1px solid rgba(220,220,220,1);
border-radius:2px; // border-radius:2px;
} // }
.header_tab .el-tabs__nav-wrap::after{ .header_tab .el-tabs__nav-wrap::after{
background-color: #fff; background-color: #fff;

Loading…
Cancel
Save