Blame view

src/views/Login.vue 4.88 KB
9b7e125f   monkeyhouyi   属地页面
1
2
3
  <template>
    <div class="Login">
      <div class="login-wrap">
88e239f9   “wangming”   1
4
        <div class="login-wrap_header">内部系统</div>
9b7e125f   monkeyhouyi   属地页面
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
        <div class="login-wrap_container">
          <div class="welcome-text">欢迎登录!</div>
          <el-form
            ref="form"
            :model="form"
            :rules="rules"
            class="login-wrap_container-form"
          >
            <el-form-item label="账号" prop="account">
              <el-input
                v-model="form.account"
                placeholder="请输入账号"
              ></el-input>
            </el-form-item>
            <el-form-item label="密码" prop="password">
              <el-input
                type="password"
                v-model="form.password"
                placeholder="请输入密码"
                autocomplete="off"
              >
              </el-input>
            </el-form-item>
            <div class="password-remind">
88e239f9   “wangming”   1
29
              <!-- <registerForm>
9b7e125f   monkeyhouyi   属地页面
30
                <div class="user-register">账户注册</div>
88e239f9   “wangming”   1
31
              </registerForm> -->
9b7e125f   monkeyhouyi   属地页面
32
33
34
35
              <div class="forget-password">
                <!-- 忘记密码? -->
              </div>
            </div>
477ec56f   monkeyhouyi   权限
36
37
38
            <div class="login-button" @click="toHome">
              {{ loading ? "登录中。。。" : "登录" }}
            </div>
9b7e125f   monkeyhouyi   属地页面
39
40
41
42
43
44
45
46
47
48
49
          </el-form>
        </div>
      </div>
    </div>
  </template>
  
  <script>
  import { login } from "@/api/index";
  import { setToken } from "@/utils/auth";
  export default {
    name: "Login",
477ec56f   monkeyhouyi   权限
50
51
52
53
54
    components: {
      loginLoading() {
        return this.$store.state.user.loginLoading;
      },
    },
9b7e125f   monkeyhouyi   属地页面
55
56
57
    data() {
      return {
        form: {
5330d757   monkeyhouyi   公司信息管理完成
58
          account: "cdoffice",
9b7e125f   monkeyhouyi   属地页面
59
60
61
62
63
64
          password: "123456",
        },
        rules: {
          account: { required: true, message: "用户名不能为空", trigger: "blur" },
          password: { required: true, message: "密码不能为空", trigger: "blur" },
        },
477ec56f   monkeyhouyi   权限
65
        loading: false,
9b7e125f   monkeyhouyi   属地页面
66
67
      };
    },
477ec56f   monkeyhouyi   权限
68
69
70
71
72
    watch: {
      loginLoading(val) {
        if (!val) this.loading = false;
      },
    },
9b7e125f   monkeyhouyi   属地页面
73
74
75
76
    created() {},
    mounted() {},
    methods: {
      toHome() {
477ec56f   monkeyhouyi   权限
77
78
        if (this.loading) return;
  
9b7e125f   monkeyhouyi   属地页面
79
80
        this.$refs["form"].validate((valid) => {
          if (valid) {
477ec56f   monkeyhouyi   权限
81
82
83
84
85
86
87
88
89
90
            this.loading = true;
            this.$store.commit("SET_LOGIN_LOADING", true);
            this.$store
              .dispatch("Login", this.form)
              .then(() => {
                this.$router.push({ path: "/homePage" });
              })
              .catch(() => {
                this.$store.commit("SET_LOGIN_LOADING", false);
              });
9b7e125f   monkeyhouyi   属地页面
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
          }
        });
      },
    },
  };
  </script>
  
  <style scoped lang="scss">
  .Login {
    width: 100%;
    height: 100%;
    background-image: url("@/assets/images/login_bg.png"); /* 替换为你的图片路径 */
    background-size: cover; /* 背景图片覆盖整个元素 */
    background-position: center; /* 背景图片居中 */
    background-repeat: no-repeat; /* 不重复背景图片 */
    .login-wrap {
      width: 626px;
      position: absolute;
      top: 50%;
      right: 8%;
      transform: translateY(-50%);
      .login-wrap_header {
        width: 510px;
        margin: 0 auto;
        color: #5ed0fa;
        font-size: 40px;
        text-align: center;
      }
      .login-wrap_container {
        width: 100%;
        height: 520px;
        padding: 64px 67px 67px;
        box-sizing: border-box;
        background-image: url("@/assets/images/login-box-container.png");
        background-size: 100% 100%;
        background-repeat: no-repeat;
        text-align: left;
        position: relative;
        .welcome-text {
          width: 392px;
          margin: 0 auto 20px;
          font-size: 20px;
          font-weight: 700;
          color: #5ed0fa;
        }
        .login-wrap_container-form {
          width: 392px;
          margin: 0 auto;
          :deep(.el-form-item__label) {
            font-size: 16px;
            font-weight: 700;
            color: #5ed0fa;
            padding: 0;
          }
          :deep(.el-input__inner) {
            background: none;
            border: none;
            border-bottom: 1px solid #5ed0fa;
            padding: 0;
            border-radius: 0;
            color: #5ed0fa;
          }
          .password-remind {
            width: 100%;
            margin-bottom: 30px;
            display: flex;
            -webkit-box-pack: justify;
            -ms-flex-pack: justify;
            -webkit-box-align: center;
            align-items: center;
            justify-content: space-between;
            .user-register {
              color: #5ed0fa;
              font-weight: 700;
              cursor: pointer;
            }
            .forget-password {
              color: #5ed0fa;
              font-weight: 700;
              cursor: pointer;
            }
          }
          .login-button {
            width: 100%;
            height: 46px;
            line-height: 46px;
            text-align: center;
            background-image: url("@/assets/images/login-btn.png");
            background-size: 100%;
            background-repeat: no-repeat;
            cursor: pointer;
            color: #5ed0fa;
            font-size: 18px;
          }
        }
      }
    }
  }
  </style>