|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <div class="login-container">
|
|
|
3
|
+ <div class="login-content">
|
|
|
4
|
+ <div class="login-box">
|
|
|
5
|
+ <div class="login-header">
|
|
|
6
|
+ <img src="../../assets/logo.png" alt="logo" class="logo" />
|
|
|
7
|
+ <h2>请填写您的信息</h2>
|
|
|
8
|
+ <p class="subtitle">用于记录考试参与情况</p>
|
|
|
9
|
+ </div>
|
|
|
10
|
+
|
|
|
11
|
+ <van-form @submit="onSubmit" class="login-form">
|
|
|
12
|
+ <van-cell-group inset>
|
|
|
13
|
+ <van-field
|
|
|
14
|
+ v-model="formData.userCode"
|
|
|
15
|
+ name="userCode"
|
|
|
16
|
+ placeholder="请输入您的工号"
|
|
|
17
|
+ :rules="[{ required: true, message: '请输入工号' }]"
|
|
|
18
|
+ >
|
|
|
19
|
+ <template #left-icon>
|
|
|
20
|
+ <van-icon name="idcard-o" />
|
|
|
21
|
+ </template>
|
|
|
22
|
+ </van-field>
|
|
|
23
|
+ <van-field
|
|
|
24
|
+ v-model="formData.userName"
|
|
|
25
|
+ name="userName"
|
|
|
26
|
+ placeholder="请输入您的姓名"
|
|
|
27
|
+ :rules="[{ required: true, message: '请输入姓名' }]"
|
|
|
28
|
+ >
|
|
|
29
|
+ <template #left-icon>
|
|
|
30
|
+ <van-icon name="contact" />
|
|
|
31
|
+ </template>
|
|
|
32
|
+ </van-field>
|
|
|
33
|
+ </van-cell-group>
|
|
|
34
|
+ <div class="submit-btn">
|
|
|
35
|
+ <van-button
|
|
|
36
|
+ round
|
|
|
37
|
+ block
|
|
|
38
|
+ type="primary"
|
|
|
39
|
+ native-type="submit"
|
|
|
40
|
+ :loading="isLoading"
|
|
|
41
|
+ >
|
|
|
42
|
+ 确认进入
|
|
|
43
|
+ </van-button>
|
|
|
44
|
+ </div>
|
|
|
45
|
+ </van-form>
|
|
|
46
|
+ </div>
|
|
|
47
|
+ </div>
|
|
|
48
|
+ </div>
|
|
|
49
|
+</template>
|
|
|
50
|
+
|
|
|
51
|
+<script setup lang="ts">
|
|
|
52
|
+import { ref } from 'vue'
|
|
|
53
|
+import { useRouter, useRoute } from 'vue-router'
|
|
|
54
|
+import { showToast } from 'vant'
|
|
|
55
|
+
|
|
|
56
|
+const router = useRouter()
|
|
|
57
|
+const route = useRoute()
|
|
|
58
|
+const isLoading = ref(false)
|
|
|
59
|
+
|
|
|
60
|
+const formData = ref({
|
|
|
61
|
+ userCode: '',
|
|
|
62
|
+ userName: ''
|
|
|
63
|
+})
|
|
|
64
|
+
|
|
|
65
|
+async function onSubmit() {
|
|
|
66
|
+ if (!formData.value.userCode.trim() || !formData.value.userName.trim()) {
|
|
|
67
|
+ showToast('请完整填写工号和姓名')
|
|
|
68
|
+ return
|
|
|
69
|
+ }
|
|
|
70
|
+
|
|
|
71
|
+ try {
|
|
|
72
|
+ isLoading.value = true
|
|
|
73
|
+
|
|
|
74
|
+ // 模拟生成一个临时 token 或直接标记为游客
|
|
|
75
|
+ const tempToken = `guest_${Date.now()}`
|
|
|
76
|
+
|
|
|
77
|
+ // 保存游客信息
|
|
|
78
|
+ localStorage.setItem('token', tempToken)
|
|
|
79
|
+ localStorage.setItem('userCode', formData.value.userCode.trim())
|
|
|
80
|
+ localStorage.setItem('userName', formData.value.userName.trim())
|
|
|
81
|
+ localStorage.setItem('userId', 'guest') // 标记为游客
|
|
|
82
|
+ localStorage.setItem('guestMode', 'true') // 可选:显式标记游客模式
|
|
|
83
|
+
|
|
|
84
|
+ showToast({
|
|
|
85
|
+ type: 'success',
|
|
|
86
|
+ message: '信息提交成功'
|
|
|
87
|
+ })
|
|
|
88
|
+
|
|
|
89
|
+ // 跳回原扫码页面(/fcbkdatistart),保留原始 query 参数
|
|
|
90
|
+ // 注意:route.query 中应包含 examId, testRole 等参数(如果从该页跳转而来)
|
|
|
91
|
+ // 如果不是从 fcbkdatistart 进来的,可默认跳首页或提示
|
|
|
92
|
+
|
|
|
93
|
+ const targetPath = '/sgsafeh5/fcbkdatistart'
|
|
|
94
|
+ const originalQuery = route.query // 如果是从 fcbkdatistart 跳过来的,query 会保留
|
|
|
95
|
+
|
|
|
96
|
+ // 更健壮的方式:检查是否有必要参数,否则跳首页
|
|
|
97
|
+ if (originalQuery.examId) {
|
|
|
98
|
+ await router.replace({ path: targetPath, query: originalQuery })
|
|
|
99
|
+ } else {
|
|
|
100
|
+
|
|
|
101
|
+ }
|
|
|
102
|
+ } catch (error) {
|
|
|
103
|
+ console.error('游客信息提交失败:', error)
|
|
|
104
|
+ showToast('提交失败,请重试')
|
|
|
105
|
+ } finally {
|
|
|
106
|
+ isLoading.value = false
|
|
|
107
|
+ }
|
|
|
108
|
+}
|
|
|
109
|
+</script>
|
|
|
110
|
+
|
|
|
111
|
+<style lang="scss" scoped>
|
|
|
112
|
+/* 样式保持不变,仅微调标题 */
|
|
|
113
|
+.login-container {
|
|
|
114
|
+ height: 100vh;
|
|
|
115
|
+ width: 100vw;
|
|
|
116
|
+ display: flex;
|
|
|
117
|
+ align-items: center;
|
|
|
118
|
+ justify-content: center;
|
|
|
119
|
+ background: linear-gradient(135deg, #1890ff 0%, #1d39c4 100%);
|
|
|
120
|
+ position: relative;
|
|
|
121
|
+ overflow: hidden;
|
|
|
122
|
+
|
|
|
123
|
+ &::before {
|
|
|
124
|
+ content: '';
|
|
|
125
|
+ position: absolute;
|
|
|
126
|
+ width: 200%;
|
|
|
127
|
+ height: 200%;
|
|
|
128
|
+ top: -50%;
|
|
|
129
|
+ left: -50%;
|
|
|
130
|
+ background: url('@/assets/login-bg.svg') repeat;
|
|
|
131
|
+ opacity: 0.1;
|
|
|
132
|
+ animation: move 10s linear infinite;
|
|
|
133
|
+ }
|
|
|
134
|
+}
|
|
|
135
|
+
|
|
|
136
|
+.login-content {
|
|
|
137
|
+ position: relative;
|
|
|
138
|
+ z-index: 1;
|
|
|
139
|
+ width: 100%;
|
|
|
140
|
+ padding: 20px;
|
|
|
141
|
+}
|
|
|
142
|
+
|
|
|
143
|
+.login-box {
|
|
|
144
|
+ width: 100%;
|
|
|
145
|
+ max-width: 400px;
|
|
|
146
|
+ margin: 0 auto;
|
|
|
147
|
+ padding: 30px 24px;
|
|
|
148
|
+ background: rgba(255, 255, 255, 0.9);
|
|
|
149
|
+ backdrop-filter: blur(10px);
|
|
|
150
|
+ border-radius: 16px;
|
|
|
151
|
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
|
|
|
152
|
+
|
|
|
153
|
+ .login-header {
|
|
|
154
|
+ text-align: center;
|
|
|
155
|
+ margin-bottom: 32px;
|
|
|
156
|
+
|
|
|
157
|
+ .logo {
|
|
|
158
|
+ width: 64px;
|
|
|
159
|
+ height: 64px;
|
|
|
160
|
+ margin-bottom: 16px;
|
|
|
161
|
+ }
|
|
|
162
|
+
|
|
|
163
|
+ h2 {
|
|
|
164
|
+ font-size: 24px;
|
|
|
165
|
+ color: #1a1a1a;
|
|
|
166
|
+ margin: 0 0 8px;
|
|
|
167
|
+ font-weight: 600;
|
|
|
168
|
+ }
|
|
|
169
|
+
|
|
|
170
|
+ .subtitle {
|
|
|
171
|
+ font-size: 14px;
|
|
|
172
|
+ color: #666;
|
|
|
173
|
+ margin: 0;
|
|
|
174
|
+ }
|
|
|
175
|
+ }
|
|
|
176
|
+
|
|
|
177
|
+ :deep(.van-cell-group) {
|
|
|
178
|
+ background: transparent;
|
|
|
179
|
+
|
|
|
180
|
+ .van-field {
|
|
|
181
|
+ background: rgba(255, 255, 255, 0.8);
|
|
|
182
|
+ border-radius: 8px;
|
|
|
183
|
+ margin-bottom: 16px;
|
|
|
184
|
+
|
|
|
185
|
+ &:last-child {
|
|
|
186
|
+ margin-bottom: 0;
|
|
|
187
|
+ }
|
|
|
188
|
+
|
|
|
189
|
+ .van-field__left-icon {
|
|
|
190
|
+ margin-right: 8px;
|
|
|
191
|
+ color: #666;
|
|
|
192
|
+ }
|
|
|
193
|
+ }
|
|
|
194
|
+ }
|
|
|
195
|
+
|
|
|
196
|
+ .submit-btn {
|
|
|
197
|
+ margin-top: 24px;
|
|
|
198
|
+
|
|
|
199
|
+ .van-button {
|
|
|
200
|
+ height: 44px;
|
|
|
201
|
+ font-size: 16px;
|
|
|
202
|
+ background: linear-gradient(135deg, #1890ff 0%, #1d39c4 100%);
|
|
|
203
|
+ border: none;
|
|
|
204
|
+
|
|
|
205
|
+ &--loading {
|
|
|
206
|
+ opacity: 0.8;
|
|
|
207
|
+ }
|
|
|
208
|
+ }
|
|
|
209
|
+ }
|
|
|
210
|
+}
|
|
|
211
|
+
|
|
|
212
|
+@keyframes move {
|
|
|
213
|
+ 0% {
|
|
|
214
|
+ transform: translate(0, 0);
|
|
|
215
|
+ }
|
|
|
216
|
+ 100% {
|
|
|
217
|
+ transform: translate(-50%, -50%);
|
|
|
218
|
+ }
|
|
|
219
|
+}
|
|
|
220
|
+
|
|
|
221
|
+@media screen and (max-width: 480px) {
|
|
|
222
|
+ .login-box {
|
|
|
223
|
+ padding: 24px 16px;
|
|
|
224
|
+
|
|
|
225
|
+ .login-header h2 {
|
|
|
226
|
+ font-size: 20px;
|
|
|
227
|
+ }
|
|
|
228
|
+ }
|
|
|
229
|
+}
|
|
|
230
|
+</style>
|