登录修改

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)">
<i class="el-icon-back"></i>
</div>
<div v-if="!isReg">
<h2>密码登录</h2>
<div v-if="!isReg" class="ms-login">
<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-item prop="username">
<p class="label">用户名</p>
@ -34,18 +75,7 @@
<el-button type="text" class="ques" @click="toReg(true)">前往注册</el-button>
<el-button type="text" class="forget" @click="forget">忘记密码</el-button>
</div>
<!-- <p class="login-tips">其他登陆方式</p>
<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>
</el-form> -->
</div>
<register v-else :isReg.sync="isReg" @updateInfo="updateInfo"></register>
</div>
@ -59,7 +89,8 @@
</div>
<span slot="footer" class="dialog-footer">
<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>
</el-dialog>
@ -115,6 +146,7 @@ import register from './RegisterForm';
export default {
data: function() {
return {
activeName: '0',
isReg: false,
loginForm: {
username: '15794146134',
@ -124,6 +156,14 @@ export default {
username: [{ 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,
userId: '',
schoolId: '',
@ -159,13 +199,14 @@ export default {
})
},
methods: {
getSchool() {
this.$refs.login.validate(valid => {
getSchool(form) {
this.$refs[form].validate(valid => {
if (valid) {
let data = {
account: this.loginForm.username,
password: this.loginForm.password,
schoolId: 2105
account: this.activeName == '0' ? this.loginForm.username : this.phoneParam.userphone,
password: this.activeName == '0' ? this.loginForm.password : this.phoneParam.phonePassword,
schoolId: 2105,
source: this.activeName
};
this.$get(this.api.loginSchool, data)
.then(res => {
@ -182,7 +223,7 @@ export default {
this.studentId = this.schoolList[0].studentId
// this.getRole()
this.roleId = 4
this.submitForm()
this.submitForm(form)
}else{
this.$message.error('账号不存在')
}
@ -197,7 +238,7 @@ export default {
}
});
},
getRole() {
getRole(form) {
// this.userId = this.schoolList.find((n,k) => {
// return n.schoolId == this.schoolId
// }).userId
@ -230,7 +271,7 @@ export default {
this.roleDialog = true
}else{
this.roleId = this.roleList[0].roleId
this.submitForm()
this.submitForm(form)
}
})
.catch(res => {});
@ -239,15 +280,15 @@ export default {
this.loginForm.username = data.username
this.loginForm.password = data.password
},
roleSure(){
roleSure(form){
if(this.roleId){
this.submitForm()
this.submitForm(form)
}else{
this.$message.error('请选择角色!');
}
},
submitForm() {
this.$refs.login.validate(valid => {
submitForm(form) {
this.$refs[form].validate(valid => {
if (valid) {
let data = {
roleId: this.roleId,
@ -485,17 +526,6 @@ export default {
border-radius: 23px;
border: 0;
}
.links{
margin: 20px 0 20px;
}
.ques{
color: #105cb2;
font-size: 14px;
}
.forget{
color: #ffa94e;
font-size: 14px;
}
.login-tips{
margin-bottom: 20px;
font-size: 16px;
@ -529,4 +559,15 @@ export default {
color: #9076FF;
}
}
.links{
margin: 20px 0 20px;
}
.ques{
color: #105cb2;
font-size: 14px;
}
.forget{
color: #ffa94e;
font-size: 14px;
}
</style>

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

Loading…
Cancel
Save