1
PC-20250623MANY\Administrator
2025-08-21 25c1d10f03df05104e323494fefd5af1e94c98f7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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
190
191
192
193
194
195
196
197
198
199
200
201
<template>
  <div class="login-container page-w page-content">
    <div class="login-left">
      <div class="logo-container flex-center">
        <img src="@/assets/images/logo.png" alt="Kuspit Pro" class="logo" />
      </div>
      <!-- <div class="slogan">
                <h1>Purchase, Trading</h1>
                <h2>All here</h2>
            </div> -->
    </div>
    <div class="login-right">
      <div class="login-form">
        <h2>{{ $t("dlan") }}</h2>
        <el-form :model="loginForm" :rules="rules" ref="loginForm">
          <el-form-item prop="phone">
            <label>{{ $t("hj27") }}</label>
            <el-input v-model="loginForm.phone" placeholder=""></el-input>
          </el-form-item>
          <el-form-item prop="userPwd">
            <label>{{ $t("Password") }}</label>
            <el-input
              v-model="loginForm.userPwd"
              type="password"
              placeholder=""
              show-password
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              class="login-button"
              @click="submitForm('loginForm')"
              :loading="isloading"
            >
              {{ $t("dlan") }}
            </el-button>
          </el-form-item>
          <div class="login-options">
            <span>{{ $t("hj14") }}?</span>
            <router-link to="/register" class="register-link">{{
              $t("ar1")
            }}</router-link>
          </div>
        </el-form>
      </div>
    </div>
  </div>
</template>
 
<script>
import * as api from "@/axios/api.js";
export default {
  name: "LoginView",
  data() {
    return {
      loginForm: {
        phone: "",
        userPwd: "",
      },
      rules: {
        phone: [
          { required: true, message: this.$t("请输入"), trigger: "blur" },
        ],
        userPwd: [
          { required: true, message: this.$t("请输入"), trigger: "blur" },
        ],
      },
      isloading: false,
    };
  },
  methods: {
    // 提交表单 登录
    submitForm(formName) {
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          // 登录逻辑
          this.isloading = true; // 显示加载状态
          let data = await api.login(this.loginForm);
 
          if (data.status == 0) {
            this.$store.commit("undataToken", data.data.token); // 存储token,vuex
            window.localStorage.setItem("USERTOKEN", data.data.token); // 存储token,浏览器
            this.$router.replace({ path: "/" }); // 跳转到首页
          }
          this.isloading = false; // 隐藏加载状态
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
  },
};
</script>
 
<style lang="scss" scoped>
::v-deep .el-input__inner {
  background: none;
  color: #fff;
  border: none;
  border-radius: 0;
  border-bottom: #ccc solid 1px;
}
.login-container {
  display: flex;
  height: 100vh;
  width: 100%;
  // background-color: #fff;
}
 
.login-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background-color: #333;
}
 
.logo-container {
  margin-bottom: 40px;
}
 
.logo {
  width: 200px;
}
 
.slogan {
  margin: 0 auto;
 
  h1 {
    font-size: 36px;
    color: #333;
    margin-bottom: 10px;
    font-weight: bold;
  }
 
  h2 {
    font-size: 36px;
    color: #287dff;
    font-weight: bold;
  }
}
 
.login-right {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}
 
.login-form {
  width: 70%;
  max-width: 400px;
 
  h2 {
    font-size: 24px;
    margin-bottom: 30px;
    font-weight: normal;
  }
 
  label {
    display: block;
    margin-bottom: 8px;
    color: #606266;
  }
 
  .el-form-item {
    margin-bottom: 25px;
  }
 
  .el-input {
    width: 100%;
  }
 
  .login-button {
    width: 100%;
    height: 50px;
    font-size: 16px;
    border-radius: 25px;
    margin-top: 10px;
  }
 
  .login-options {
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
    color: #606266;
 
    .register-link {
      color: #287dff;
      margin-left: 5px;
      text-decoration: none;
 
      &:hover {
        text-decoration: underline;
      }
    }
  }
}
</style>