[fix][V]:完善login提交表单操作,完成对接login接口

master
Romesum 5 years ago
parent 368427f8fe
commit 93b03a473f

@ -49,6 +49,7 @@
<script> <script>
import {get, post} from "~/utils"; import {get, post} from "~/utils";
import {showFail, showSuccess} from "~/utils/dialog";
export default { export default {
name: "login", name: "login",
@ -62,15 +63,13 @@
character: [{ character: [{
label: '超级管理员', label: '超级管理员',
value: '3' value: '3'
}, }, {
{ label: '管理员',
label: '管理员', value: '2'
value: '2' }, {
}, label: '老师',
{ value: '1'
label: '老师', }
value: '1'
}
], ],
rules: { rules: {
account: [{ account: [{
@ -89,16 +88,24 @@
} }
}, },
methods: { methods: {
submitForm (formName) { submitForm(formName) {
this.$refs[formName].validate(async (valid) => { this.$refs[formName].validate(async (valid) => {
if (valid) { if (valid) {
await post('lb/user/login', { await post('lb/user/login', {
auth: this.ruleForm.identity, auth: this.ruleForm.identity,
username: this.ruleForm.account, username: this.ruleForm.account,
password: this.ruleForm.psw password: this.ruleForm.psw
}).then(res => {
showSuccess("登录成功", this)
//
setTimeout(() => {
if (this.ruleForm.identity === '1') this.$router.push('/teacher')
else if (this.ruleForm.identity === '2') this.$router.push('/manager')
else if (this.ruleForm.identity === '3') this.$router.push('/supManager')
}, 1000)
}).catch(e => {
showFail(e.msg, this)
}) })
//
await this.$router.push('/teacher')
} else { } else {
console.log('error submit!!'); console.log('error submit!!');
return false; return false;

Loading…
Cancel
Save