| | |
| | | <div class="login-form"> |
| | | <div class="form-item flex"> |
| | | <img class="form-item-icon" :src="require('../../assets/login/account@2x.png')" alt=""> |
| | | <el-input v-model="loginForm.account" placeholder="请输入账号"></el-input> |
| | | <el-input v-model="loginForm.username" placeholder="请输入账号"></el-input> |
| | | </div> |
| | | |
| | | <div class="form-item flex mt-40"> |
| | |
| | | </div> |
| | | </template> |
| | | <script> |
| | | import { loginReq } from './service' |
| | | export default { |
| | | name: 'Login', |
| | | data() { |
| | |
| | | windowWidth: window.innerWidth, |
| | | |
| | | loginForm: { |
| | | account: '', |
| | | username: '', |
| | | password: '' |
| | | }, |
| | | viewWidth: '', |
| | |
| | | // 添加处理窗口大小变化的方法 |
| | | handleResize() { |
| | | this.viewWidth = window.innerWidth |
| | | console.log(this.viewWidth) |
| | | }, |
| | | login() { |
| | | this.$router.push('/') |
| | | console.log(this.loginForm) |
| | | if (this.loginForm.username == '') { |
| | | this.$message.warning('请输入账号') |
| | | return |
| | | } |
| | | if (this.loginForm.password == '') { |
| | | this.$message.warning('请输入密码') |
| | | return |
| | | } |
| | | loginReq(this.loginForm).then(res => { |
| | | sessionStorage.setItem('token', res.token) |
| | | sessionStorage.setItem('userInfo', JSON.stringify(res.userInfo.user)) |
| | | this.$router.push('/system') |
| | | }) |
| | | } |
| | | } |
| | | } |