index.vue
4.16 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
<template>
<view class="min-h-screen bg-white flex flex-col">
<!-- Header -->
<NavHeader title="" :show-back="true" />
<view class="flex-1 flex flex-col px-[48rpx] pt-[120rpx]">
<!-- Logo/Title -->
<view class="mb-[100rpx]">
<!-- Logo Icon -->
<view class="flex justify-center mb-[40rpx]">
<view class="w-[160rpx] h-[160rpx] rounded-[32rpx] bg-gradient-to-br from-[#007AFF] to-[#0051D5] flex items-center justify-center shadow-lg">
<text class="text-white text-[80rpx] font-bold">M</text>
</view>
</view>
<!-- Title -->
<view class="text-center">
<view class="text-[52rpx] font-bold text-gray-900 mb-[16rpx]">欢迎登录</view>
<view class="text-[28rpx] text-gray-500">Manulife 臻奇智荟圈</view>
</view>
</view>
<!-- Form -->
<view class="space-y-[48rpx]">
<!-- Email -->
<view class="border-b border-gray-200 pb-[16rpx]">
<view class="text-[28rpx] text-gray-900 font-medium mb-[16rpx]">邮箱</view>
<input
v-model="form.email"
type="text"
placeholder="请输入工作邮箱"
placeholder-class="text-gray-300"
class="w-full text-[32rpx] text-gray-900 h-[80rpx]"
/>
</view>
<!-- Password -->
<view class="border-b border-gray-200 pb-[16rpx]">
<view class="text-[28rpx] text-gray-900 font-medium mb-[16rpx]">密码</view>
<input
v-model="form.password"
type="password"
placeholder="请输入密码"
placeholder-class="text-gray-300"
class="w-full text-[32rpx] text-gray-900 h-[80rpx]"
/>
</view>
<!-- Hint -->
<view class="text-[24rpx] text-gray-400 mt-[24rpx]">
账号由后台系统统一配置,请联系管理员获取
</view>
</view>
<!-- Actions -->
<view class="mt-[80rpx]">
<button
class="w-full h-[96rpx] bg-gradient-to-r from-[#007AFF] to-[#0051D5] rounded-[48rpx] flex items-center justify-center text-white text-[32rpx] font-bold shadow-lg active:scale-[0.98] transition-transform after:border-none"
@tap="handleLogin"
>
登录
</button>
</view>
</view>
</view>
</template>
<script setup>
import { reactive } from 'vue'
import Taro from '@tarojs/taro'
import { useGo } from '@/hooks/useGo'
import NavHeader from '@/components/NavHeader.vue'
const go = useGo()
const form = reactive({
email: '',
password: ''
})
/**
* 验证邮箱格式
* @param {string} email - 邮箱地址
* @returns {boolean} 是否有效
*/
const isValidEmail = (email) => {
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
return emailRegex.test(email)
}
/**
* Handle login action
*/
const handleLogin = () => {
// 验证邮箱
if (!form.email) {
Taro.showToast({ title: '请输入邮箱', icon: 'none' })
return
}
if (!isValidEmail(form.email)) {
Taro.showToast({ title: '请输入有效的邮箱地址', icon: 'none' })
return
}
// 验证密码
if (!form.password) {
Taro.showToast({ title: '请输入密码', icon: 'none' })
return
}
if (form.password.length < 6) {
Taro.showToast({ title: '密码长度至少6位', icon: 'none' })
return
}
// Mock login success
Taro.showLoading({ title: '登录中...', mask: true })
setTimeout(() => {
Taro.hideLoading()
Taro.showToast({ title: '登录成功', icon: 'success' })
setTimeout(() => {
// Redirect to home or previous page
Taro.reLaunch({ url: '/pages/index/index' })
}, 1500)
}, 1000)
}
</script>
<style lang="less">
/* Reset button default styles */
button::after {
border: none;
}
/* Enhance gradient effect for button */
button {
background: linear-gradient(135deg, #007AFF 0%, #0051D5 100%);
box-shadow: 0 8rpx 24rpx rgba(0, 122, 255, 0.3);
transition: all 0.3s ease;
&:active {
transform: scale(0.98);
box-shadow: 0 4rpx 12rpx rgba(0, 122, 255, 0.2);
}
}
/* Logo icon enhancement */
.shadow-lg {
box-shadow: 0 16rpx 32rpx rgba(0, 122, 255, 0.25);
}
</style>