|
|
@@ -1,222 +0,0 @@
|
|
1
|
|
-<!-- 代码已包含 CSS:使用 TailwindCSS , 安装 TailwindCSS 后方可看到布局样式效果 -->
|
|
2
|
|
-
|
|
3
|
|
-<template>
|
|
4
|
|
- <div class="flex items-center justify-center min-h-screen bg-gradient-to-br from-blue-50 to-white"
|
|
5
|
|
- :style="{
|
|
6
|
|
- backgroundImage: `url(${bgImage})`,
|
|
7
|
|
- backgroundSize: 'cover',
|
|
8
|
|
- backgroundPosition: 'center',
|
|
9
|
|
- backgroundRepeat: 'no-repeat'
|
|
10
|
|
- }">
|
|
11
|
|
- <div class="w-[480px] p-8">
|
|
12
|
|
- <div class="text-center mb-8">
|
|
13
|
|
- <el-icon class="text-primary" style="width: 48px;height: 48px;font-size: 48px">
|
|
14
|
|
- <Headset />
|
|
15
|
|
- </el-icon>
|
|
16
|
|
- <h1 class="text-3xl font-bold text-primary mt-4">智能质检管理平台</h1>
|
|
17
|
|
- </div>
|
|
18
|
|
- <div class="bg-white rounded-lg p-8 shadow-md">
|
|
19
|
|
- <div class="space-y-6 mb-6">
|
|
20
|
|
- <div class="relative">
|
|
21
|
|
- <el-input v-model="username" placeholder="请输入用户名/手机号" :prefix-icon="User" size="large"
|
|
22
|
|
- class="!rounded-button" />
|
|
23
|
|
- </div>
|
|
24
|
|
- <div class="relative">
|
|
25
|
|
- <el-input v-model="password" :type="showPassword ? 'text' : 'password'" placeholder="请输入密码"
|
|
26
|
|
- :prefix-icon="Lock" size="large" class="!rounded-button">
|
|
27
|
|
- <template #suffix>
|
|
28
|
|
- <el-icon class="cursor-pointer" @click="showPassword = !showPassword">
|
|
29
|
|
- <component :is="showPassword ? 'View' : 'Hide'" />
|
|
30
|
|
- </el-icon>
|
|
31
|
|
- </template>
|
|
32
|
|
- </el-input>
|
|
33
|
|
- </div>
|
|
34
|
|
- <div class="relative flex space-x-4">
|
|
35
|
|
- <el-input v-model="captcha" placeholder="请输入验证码" size="large" class="!rounded-button" />
|
|
36
|
|
- <img :src="codeUrl" alt="验证码" class="h-[40px] w-[120px] cursor-pointer rounded"
|
|
37
|
|
- @click="refreshCaptcha" />
|
|
38
|
|
- </div>
|
|
39
|
|
- </div>
|
|
40
|
|
- <div class="flex items-center mb-6">
|
|
41
|
|
- <el-checkbox v-model="rememberMe">记住密码</el-checkbox>
|
|
42
|
|
- </div>
|
|
43
|
|
- <el-button type="primary" :loading="loading"
|
|
44
|
|
- class="w-full !h-[44px] !text-base !rounded-button whitespace-nowrap" @click="handleLogin">
|
|
45
|
|
- 登录
|
|
46
|
|
- </el-button>
|
|
47
|
|
- <!-- <div class="flex justify-between my-4">
|
|
48
|
|
- <el-button link type="primary" @click="handleRegister" class="whitespace-nowrap">
|
|
49
|
|
- 快速注册
|
|
50
|
|
- </el-button>
|
|
51
|
|
- <el-button link type="primary" @click="handleForgetPassword" class="whitespace-nowrap">
|
|
52
|
|
- 忘记密码
|
|
53
|
|
- </el-button>
|
|
54
|
|
- </div> -->
|
|
55
|
|
- <!-- <div class="relative text-center my-8">
|
|
56
|
|
- <span class="px-4 bg-white text-gray-400 text-sm relative z-10">
|
|
57
|
|
- 其他登录方式
|
|
58
|
|
- </span>
|
|
59
|
|
- <div class="absolute top-1/2 left-0 w-full h-[1px] bg-gray-200 -z-0"></div>
|
|
60
|
|
- </div>
|
|
61
|
|
- <el-button class="w-full !h-[44px] !rounded-button whitespace-nowrap flex items-center justify-center"
|
|
62
|
|
- @click="handlePhoneLogin">
|
|
63
|
|
- <el-icon class="mr-2">
|
|
64
|
|
- <Iphone />
|
|
65
|
|
- </el-icon>
|
|
66
|
|
- 手机号一键登录
|
|
67
|
|
- </el-button> -->
|
|
68
|
|
- </div>
|
|
69
|
|
- <div class="text-center mt-8">
|
|
70
|
|
- <!-- <p class="text-gray-400 text-sm mb-2">
|
|
71
|
|
- 登录即表示同意
|
|
72
|
|
- <el-button link type="primary" @click="handleUserAgreement" class="whitespace-nowrap">
|
|
73
|
|
- 《用户协议》
|
|
74
|
|
- </el-button>
|
|
75
|
|
- 和
|
|
76
|
|
- <el-button link type="primary" @click="handlePrivacyPolicy" class="whitespace-nowrap">
|
|
77
|
|
- 《隐私政策》
|
|
78
|
|
- </el-button>
|
|
79
|
|
- </p> -->
|
|
80
|
|
- <p class="text-gray-400 text-sm">Copyright © 2024 智能质检管理平台</p>
|
|
81
|
|
- </div>
|
|
82
|
|
- </div>
|
|
83
|
|
- </div>
|
|
84
|
|
-</template>
|
|
85
|
|
-
|
|
86
|
|
-<script setup>
|
|
87
|
|
-import { ref } from 'vue';
|
|
88
|
|
-import { ElMessage } from 'element-plus';
|
|
89
|
|
-import { getCodeImg } from '@/api/login'
|
|
90
|
|
-import { User, Lock, View, Hide, Key } from '@element-plus/icons-vue';
|
|
91
|
|
-import Cookies from 'js-cookie'
|
|
92
|
|
-import { encrypt } from '@/utils/jsencrypt'
|
|
93
|
|
-import useUserStore from '@/store/modules/user'
|
|
94
|
|
-import bgImage from '@/assets/logo/logoBj.jpg'; // 导入背景图
|
|
95
|
|
-
|
|
96
|
|
-const userStore = useUserStore()
|
|
97
|
|
-const router = useRouter()
|
|
98
|
|
-const { proxy } = getCurrentInstance()
|
|
99
|
|
-const redirect = ref(undefined)
|
|
100
|
|
-
|
|
101
|
|
-const username = ref('');
|
|
102
|
|
-const password = ref('');
|
|
103
|
|
-const captcha = ref('');
|
|
104
|
|
-const showPassword = ref(false);
|
|
105
|
|
-const rememberMe = ref(false);
|
|
106
|
|
-const captchaText = ref('ABCD1234');
|
|
107
|
|
-
|
|
108
|
|
-const refreshCaptcha = () => {
|
|
109
|
|
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
|
110
|
|
- let result = '';
|
|
111
|
|
- for (let i = 0; i < 8; i++) {
|
|
112
|
|
- result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
113
|
|
- }
|
|
114
|
|
- captchaText.value = result;
|
|
115
|
|
-};
|
|
116
|
|
-
|
|
117
|
|
-const codeUrl = ref('')
|
|
118
|
|
-const loading = ref(false)
|
|
119
|
|
-// 验证码开关
|
|
120
|
|
-const captchaEnabled = ref(true)
|
|
121
|
|
-const uuid = ref('');
|
|
122
|
|
-const getCode = () => {
|
|
123
|
|
- getCodeImg().then((res) => {
|
|
124
|
|
- captchaEnabled.value =
|
|
125
|
|
- res.data.captchaEnabled === undefined ? true : res.data.captchaEnabled
|
|
126
|
|
- if (captchaEnabled.value) {
|
|
127
|
|
- codeUrl.value = 'data:image/gif;base64,' + res.data.img
|
|
128
|
|
- uuid.value = res.data.uuid
|
|
129
|
|
- }
|
|
130
|
|
- })
|
|
131
|
|
-}
|
|
132
|
|
-
|
|
133
|
|
-const handleLogin = () => {
|
|
134
|
|
- if (!username.value) {
|
|
135
|
|
- ElMessage.warning('请输入用户名');
|
|
136
|
|
- return;
|
|
137
|
|
- }
|
|
138
|
|
- if (!password.value) {
|
|
139
|
|
- ElMessage.warning('请输入密码');
|
|
140
|
|
- return;
|
|
141
|
|
- }
|
|
142
|
|
- if (!captcha.value) {
|
|
143
|
|
- ElMessage.warning('请输入验证码');
|
|
144
|
|
- return;
|
|
145
|
|
- }
|
|
146
|
|
- loading.value = true
|
|
147
|
|
-
|
|
148
|
|
- if (rememberMe.value) {
|
|
149
|
|
- Cookies.set('username', username.value, { expires: 30 })
|
|
150
|
|
- Cookies.set('password', encrypt(password.value), {
|
|
151
|
|
- expires: 30
|
|
152
|
|
- })
|
|
153
|
|
- Cookies.set('rememberMe', rememberMe.value, { expires: 30 })
|
|
154
|
|
- } else {
|
|
155
|
|
- // 否则移除
|
|
156
|
|
- Cookies.remove('username')
|
|
157
|
|
- Cookies.remove('password')
|
|
158
|
|
- Cookies.remove('rememberMe')
|
|
159
|
|
- }
|
|
160
|
|
- loading.value = true
|
|
161
|
|
- // 调用action的登录方法
|
|
162
|
|
- userStore
|
|
163
|
|
- .login({
|
|
164
|
|
- username: username.value,
|
|
165
|
|
- password: password.value,
|
|
166
|
|
- rememberMe: rememberMe.value,
|
|
167
|
|
- code: captcha.value,
|
|
168
|
|
- uuid: uuid.value
|
|
169
|
|
- })
|
|
170
|
|
- .then(() => {
|
|
171
|
|
- router.push({ path: redirect.value || '/' })
|
|
172
|
|
- })
|
|
173
|
|
- .catch(() => {
|
|
174
|
|
- loading.value = false
|
|
175
|
|
- // 重新获取验证码
|
|
176
|
|
- if (captchaEnabled.value) {
|
|
177
|
|
- getCode()
|
|
178
|
|
- }
|
|
179
|
|
- })
|
|
180
|
|
-
|
|
181
|
|
-};
|
|
182
|
|
-
|
|
183
|
|
-getCode();
|
|
184
|
|
-</script>
|
|
185
|
|
-
|
|
186
|
|
-<style scoped>
|
|
187
|
|
-/* .el-input :deep(.el-input__wrapper) {
|
|
188
|
|
- background-color: #f8fafc;
|
|
189
|
|
- border: 1px solid #e2e8f0;
|
|
190
|
|
- box-shadow: none !important;
|
|
191
|
|
-}
|
|
192
|
|
-
|
|
193
|
|
-.el-input :deep(.el-input__wrapper.is-focus) {
|
|
194
|
|
- border-color: #409eff;
|
|
195
|
|
-}
|
|
196
|
|
-
|
|
197
|
|
-.el-input :deep(.el-input__inner) {
|
|
198
|
|
- height: 100%;
|
|
199
|
|
-}
|
|
200
|
|
-
|
|
201
|
|
-.el-input :deep(.el-input__prefix) {
|
|
202
|
|
- font-size: 1.25rem;
|
|
203
|
|
- color: #64748b;
|
|
204
|
|
-} */
|
|
205
|
|
-
|
|
206
|
|
-.text-primary {
|
|
207
|
|
-color: #409EFF;
|
|
208
|
|
-
|
|
209
|
|
-}
|
|
210
|
|
-/* 淡入动画 */
|
|
211
|
|
-@keyframes fadeIn {
|
|
212
|
|
-from {
|
|
213
|
|
-opacity: 0;
|
|
214
|
|
-transform: translateY(20px);
|
|
215
|
|
-}
|
|
216
|
|
-to {
|
|
217
|
|
-opacity: 1;
|
|
218
|
|
-transform: translateY(0);
|
|
219
|
|
-}
|
|
220
|
|
-}
|
|
221
|
|
-
|
|
222
|
|
-</style>
|