|
@@ -15,8 +15,8 @@
|
|
|
<div class="app-title">ITT运营后台</div>
|
|
|
<div class="elform">
|
|
|
<el-form label-position="right" label-width="80px" :model="loginForm" :rules='rules' ref="loginForm">
|
|
|
- <el-form-item label="账号" prop="account">
|
|
|
- <el-input v-model="loginForm.account" placeholder="请输入登录账号"></el-input>
|
|
|
+ <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 v-model="loginForm.password" type="password" placeholder="请输入登录密码"></el-input>
|
|
@@ -32,6 +32,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { pwdLogin } from './../../request/request'
|
|
|
export default {
|
|
|
name: 'Login',
|
|
|
data() {
|
|
@@ -41,13 +42,13 @@ export default {
|
|
|
password: [
|
|
|
{ required: true, message: '请输入登录密码', trigger: 'change' }
|
|
|
],
|
|
|
- account: [
|
|
|
+ userName: [
|
|
|
{ required: true, message: '请输入登录账号', trigger: 'change' }
|
|
|
]
|
|
|
},
|
|
|
loginForm: {
|
|
|
password: '',
|
|
|
- account: ''
|
|
|
+ userName: ''
|
|
|
}
|
|
|
};
|
|
|
},
|
|
@@ -58,27 +59,35 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- mounted() {
|
|
|
- this.$cookie.set('token', '999')
|
|
|
- console.log('login mounted');
|
|
|
- },
|
|
|
methods: {
|
|
|
submitForm (formName) {
|
|
|
this.$refs[formName].validate((valid) => {
|
|
|
if (valid) {
|
|
|
- this.loading = true
|
|
|
- setTimeout(() => {
|
|
|
- this.loading = false
|
|
|
- sessionStorage.setItem("accessToken", '4322423423')
|
|
|
- this.$router.replace({
|
|
|
- path: '/main/user'
|
|
|
- })
|
|
|
- }, 1000);
|
|
|
+ this.pwdLoginFn(this.loginForm.userName, this.loginForm.password)
|
|
|
} else {
|
|
|
- console.log('error submit!!');
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
+ },
|
|
|
+ pwdLoginFn (userName,password) {
|
|
|
+ let data = {
|
|
|
+ userName: userName,
|
|
|
+ password: password
|
|
|
+ }
|
|
|
+ this.loading = true
|
|
|
+ pwdLogin(data).then(res => {
|
|
|
+ console.log(res,'loginvue');
|
|
|
+ const AccessToken = res.data.token
|
|
|
+ sessionStorage.setItem('AccessToken', AccessToken)
|
|
|
+ sessionStorage.setItem('userInfo', JSON.stringify(res.data))
|
|
|
+ this.$router.replace({
|
|
|
+ path: '/main/user'
|
|
|
+ })
|
|
|
+ }).finally(f => {
|
|
|
+ this.loading = false
|
|
|
+ }).catch(e => {
|
|
|
+ console.log(e);
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
};
|