login.vue
10.4 KB
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
<template>
<view class="login-wrapper">
<!-- 1. Logo 及品牌信息 -->
<view class="logo-section">
<view class="logo-box">
<!-- 渐变绿火焰 SVG 矢量图,无需本地图片 -->
<svg viewBox="0 0 24 24" class="logo-svg">
<path
d="M12 2C12 2 6 7.5 6 13C6 16.8 9.1 20 12 20C14.9 20 18 16.8 18 13C18 7.5 12 2 12 2ZM12 16C10.3 16 9 14.7 9 13C9 10.5 12 7.5 12 7.5C12 7.5 15 10.5 15 13C15 14.7 13.7 16 12 16Z"
fill="url(#flameGradient)"
/>
<defs>
<linearGradient id="flameGradient" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#8fc31f" />
<stop offset="100%" stop-color="#00b074" />
</linearGradient>
</defs>
</svg>
</view>
<view class="brand-title">FitFlow 悦动健身</view>
<view class="brand-slogan">健康极简 · 开启你的蜕变时刻</view>
</view>
<!-- 2. 登录方式 Tab 切换 -->
<view class="tab-container">
<view class="tab-item" :class="{ active: activeTab === 'sms' }" @click="activeTab = 'sms'">
<u-icon
name="phone"
size="18"
:color="activeTab === 'sms' ? '#0a1931' : '#7a8290'"
class="tab-icon"
/>
<text>免密登录</text>
</view>
<view
class="tab-item"
:class="{ active: activeTab === 'password' }"
@click="activeTab = 'password'"
>
<u-icon
name="lock"
size="18"
:color="activeTab === 'password' ? '#0a1931' : '#7a8290'"
class="tab-icon"
/>
<text>密码登录</text>
</view>
</view>
<!-- 3. 表单区域 -->
<view class="form-container">
<!-- 手机号码 -->
<view class="form-item-wrapper">
<text class="form-label">手机号码</text>
<view class="input-box">
<u-icon name="phone" size="20" color="#a1a8b3" class="input-icon" />
<input
type="number"
v-model="phoneNumber"
placeholder="请输入您的手机号"
placeholder-style="color: #a1a8b3"
maxlength="11"
class="native-input"
/>
</view>
</view>
<!-- 验证码 / 密码(支持免密与密码登录切换) -->
<view class="form-item-wrapper" v-if="activeTab === 'sms'">
<text class="form-label">验证码</text>
<view class="code-row">
<view class="input-box flex-1">
<u-icon name="chat" size="20" color="#a1a8b3" class="input-icon" />
<input
type="number"
v-model="verifyCode"
placeholder="6位验证码"
placeholder-style="color: #a1a8b3"
maxlength="6"
class="native-input"
/>
</view>
<!-- 获取验证码按钮 -->
<view class="code-btn" :class="{ disabled: countdown > 0 }" @click="handleGetCode">
<text>{{ countdown > 0 ? `${countdown}s 后重试` : '获取验证码' }}</text>
</view>
</view>
</view>
<!-- 密码输入框(密码登录模式时显示) -->
<view class="form-item-wrapper" v-else>
<text class="form-label">登录密码</text>
<view class="input-box">
<u-icon name="lock" size="20" color="#a1a8b3" class="input-icon" />
<input
type="password"
v-model="password"
placeholder="请输入您的密码"
placeholder-style="color: #a1a8b3"
class="native-input"
/>
</view>
</view>
</view>
<!-- 4. 用户协议与隐私政策 -->
<view class="agreement-container" @click="isAgreed = !isAgreed">
<view class="checkbox-box" :class="{ checked: isAgreed }">
<u-icon v-if="isAgreed" name="checkbox-mark" size="12" color="#ffffff" />
</view>
<view class="agreement-text">
我已阅读并同意 FitFlow
<text class="link-text" @click.stop="goToAgreement('service')">《用户服务协议》</text>
与
<text class="link-text" @click.stop="goToAgreement('privacy')">《隐私政策》</text>
</view>
</view>
<!-- 5. 立即登录按钮 -->
<view class="submit-btn" @click="handleLogin">
<text>立即登录</text>
<u-icon name="arrow-right" size="14" color="#ffffff" class="btn-arrow" />
</view>
</view>
</template>
<script setup>
import { ref } from 'vue';
const activeTab = ref('sms'); // sms: 免密, password: 密码
const phoneNumber = ref('');
const verifyCode = ref('');
const password = ref('');
const isAgreed = ref(false);
// 验证码倒计时逻辑
const countdown = ref(0);
const handleGetCode = () => {
if (countdown.value > 0) return;
if (!phoneNumber.value || phoneNumber.value.length !== 11) {
uni.showToast({ title: '请输入正确的手机号码', icon: 'none' });
return;
}
uni.showToast({ title: '验证码已发送', icon: 'success' });
countdown.value = 60;
const timer = setInterval(() => {
countdown.value--;
if (countdown.value <= 0) {
clearInterval(timer);
}
}, 1000);
};
// 登录提交事件
const handleLogin = () => {
if (!isAgreed.value) {
uni.showToast({ title: '请先阅读并同意用户协议与隐私政策', icon: 'none' });
return;
}
if (!phoneNumber.value) {
uni.showToast({ title: '请输入手机号码', icon: 'none' });
return;
}
uni.showToast({ title: '登录成功', icon: 'success' });
};
// 协议点击跳转
const goToAgreement = (type) => {
uni.showToast({
title: `跳转至${type === 'service' ? '用户协议' : '隐私政策'}`,
icon: 'none',
});
};
</script>
<style lang="scss" scoped>
.login-wrapper {
min-height: 100vh;
background-color: #ffffff;
padding: 80rpx 50rpx;
box-sizing: border-box;
// 1. Logo
.logo-section {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 70rpx;
margin-top: 40rpx;
.logo-box {
width: 140rpx;
height: 140rpx;
border-radius: 40rpx;
background: #ffffff;
border: 3rpx solid #d2ee9e;
box-shadow: 0 16rpx 40rpx rgba(111, 214, 32, 0.12);
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 30rpx;
.logo-svg {
width: 76rpx;
height: 76rpx;
}
}
.brand-title {
font-size: 46rpx;
font-weight: bold;
color: #0a1931;
letter-spacing: 2rpx;
}
.brand-slogan {
font-size: 26rpx;
color: #9097a3;
margin-top: 12rpx;
}
}
// 2. Tab
.tab-container {
height: 96rpx;
background-color: #f1f3f7;
border-radius: 20rpx;
display: flex;
padding: 8rpx;
box-sizing: border-box;
margin-bottom: 50rpx;
.tab-item {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
font-size: 28rpx;
color: #7a8290;
font-weight: 500;
transition: all 0.2s ease;
border-radius: 16rpx;
.tab-icon {
margin-right: 12rpx;
}
&.active {
background-color: #ffffff;
color: #0a1931;
font-weight: bold;
box-shadow: 0 4rpx 16rpx rgba(10, 25, 49, 0.05);
}
}
}
// 3. Form
.form-container {
.form-item-wrapper {
margin-bottom: 36rpx;
.form-label {
font-size: 26rpx;
color: #0a1931;
font-weight: bold;
display: block;
margin-bottom: 16rpx;
}
.input-box {
height: 104rpx;
background-color: #f4f6fa;
border: 2rpx solid #e1e6eb;
border-radius: 24rpx;
display: flex;
align-items: center;
padding: 0 30rpx;
box-sizing: border-box;
.input-icon {
margin-right: 16rpx;
}
.native-input {
flex: 1;
height: 100%;
font-size: 28rpx;
color: #0a1931;
}
}
// 验证码一栏的双列布局
.code-row {
display: flex;
align-items: center;
.flex-1 {
flex: 1;
}
.code-btn {
width: 220rpx;
height: 104rpx;
border-radius: 24rpx;
background-color: #f9fdf2;
border: 2rpx solid #d0ee9c;
display: flex;
justify-content: center;
align-items: center;
margin-left: 20rpx;
font-size: 26rpx;
color: #8fc31f;
font-weight: bold;
transition: all 0.2s ease;
&:active {
opacity: 0.8;
}
&.disabled {
color: #b0b8c4;
background-color: #f4f6fa;
border-color: #e1e6eb;
}
}
}
}
}
// 4. Agreement
.agreement-container {
display: flex;
align-items: flex-start;
margin-top: 40rpx;
margin-bottom: 50rpx;
padding: 0 6rpx;
.checkbox-box {
width: 32rpx;
height: 32rpx;
border: 2rpx solid #c2c9d3;
border-radius: 8rpx;
margin-right: 16rpx;
margin-top: 4rpx;
display: flex;
justify-content: center;
align-items: center;
transition: all 0.15s ease;
box-sizing: border-box;
&.checked {
border-color: #00b074;
background-color: #00b074;
}
}
.agreement-text {
flex: 1;
font-size: 24rpx;
color: #7a8290;
line-height: 1.5;
.link-text {
color: #8fc31f;
font-weight: 500;
}
}
}
// 5. Submit Button
.submit-btn {
height: 104rpx;
border-radius: 24rpx;
background: linear-gradient(135deg, #79d621 0%, #00b074 100%);
box-shadow: 0 16rpx 40rpx rgba(0, 176, 116, 0.25);
display: flex;
justify-content: center;
align-items: center;
color: #ffffff;
font-size: 32rpx;
font-weight: bold;
letter-spacing: 2rpx;
transition: all 0.2s ease;
&:active {
transform: scale(0.98);
opacity: 0.9;
}
.btn-arrow {
margin-left: 10rpx;
}
}
}
</style>