123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <template>
- <div class="login flex row">
- <img class="left" src="../../../static/images/loginbg_left.png" />
- <div class="right flex column">
- <img class="logo" src="../../../static/images/logo.png" />
- <span class="welcome">欢迎登陆</span>
- <el-form class="form" ref="loginForm" :model="loginForm" label-width="80px" label-position="top"
- :rules="loginRules" hide-required-asterisk>
- <el-form-item label="账号:" prop="account">
- <el-input v-model="loginForm.account" @keyup.enter.native="handleLogin" placeholder="请输入账号" maxlength="20" clearable></el-input>
- </el-form-item>
- <el-form-item label="密码:" prop="password">
- <el-input v-model="loginForm.password" @keyup.enter.native="handleLogin" placeholder="请输入密码" maxlength="20" show-password clearable></el-input>
- </el-form-item>
- <el-form-item>
- <el-button class="loginbtn blackbtn" :loading="loading" @click.native.prevent="handleLogin">登陆</el-button>
- </el-form-item>
- </el-form>
- </div>
- </div>
- </template>
- <script>
- import {
- login
- } from "@/api/login";
- import store from '@/store/index'
- export default {
- name: "Login",
- data() {
- return {
- loginForm: {
- account: "",
- password: "",
- },
- loginRules: {
- account: [{
- required: true,
- trigger: "blur",
- message: "用户名不能为空"
- }],
- password: [{
- required: true,
- trigger: "blur",
- message: "密码不能为空"
- }]
- },
- loading: false,
- };
- },
- watch: {
- $route: {
- handler: function (route) {
- this.redirect = route.query && route.query.redirect;
- },
- immediate: true
- }
- },
- created() {},
- methods: {
- // 登录
- handleLogin() {
- this.$refs.loginForm.validate(valid => {
- if (valid) {
- this.loading = true;
- let params = {
- account: this.loginForm.account,
- password: this.$md5(this.loginForm.password)
- }
- login(params).then(res => {
- if (res.code == 0) {
- store.commit('SET_USER_INFO',res.data)
- store.commit('SET_USER_TOKEN',res.data.token)
- this.$router.push("/goods");
- }
- }).catch(()=>{
- this.loading=false
- });
- }
- });
- }
- }
- };
- </script>
- <style lang="less">
- .login {
- padding: 0 0 0 0 !important;
- background-color: white !important;
- }
- .left {
- width: 33%;
- }
- .right {
- width: 67%;
- background: url("../../../static/images/loginbg_right.png") no-repeat 100% 0%;
- background-size: contain;
- padding: 5%;
- .logo {
- width: 100px;
- height: auto;
- }
- .form {
- font-weight: bold;
- margin-top: 50px;
- margin-left: 50px;
- .el-input {
- width: 400px;
- }
- .loginbtn {
- width: 200px;
- margin-top: 20px;
- }
- }
- .welcome {
- color: #060101;
- font-size: x-large;
- font-weight: bold;
- margin-top: 10px;
- }
- }
- </style>
|