index.vue
4.84 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
<!--
* @Date: 2026-01-08 13:01:56
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2026-01-20 10:54:19
* @FilePath: /xyxBooking-weapp/src/pages/volunteerLogin/index.vue
* @Description: 义工登录页面
-->
<template>
<view class="login-page">
<view class="logo-section">
<image :src="logo" mode="aspectFit" />
<text class="app-name">义工登录</text>
</view>
<view class="login-card">
<view class="title">欢迎回来</view>
<view class="input-group">
<text class="label">账号</text>
<input v-model="username" placeholder="请输入账号" placeholder-class="input-placeholder" cursorSpacing="40rpx" />
</view>
<view class="input-group">
<text class="label">密码</text>
<input v-model="password" password placeholder="请输入密码" placeholder-class="input-placeholder"
cursorSpacing="40rpx" />
</view>
<button class="login-btn" @tap="handleLogin">立即登录</button>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue'
import Taro, { useDidShow } from '@tarojs/taro'
import { mainStore } from '@/stores/main'
import { volunteerLoginAPI, checkRedeemPermissionAPI } from '@/api/index'
import { useReplace } from '@/hooks/useGo'
import logo from '@/assets/images/logo.png'
const store = mainStore()
const replace = useReplace()
const username = ref('')
const password = ref('')
/**
* @description: 检查核销权限并重定向
*/
const check_permission_and_redirect = async () => {
try {
const permission_res = await checkRedeemPermissionAPI()
if (permission_res?.code !== 1) return
if (permission_res?.data) store.changeUserInfo(permission_res.data)
if (permission_res?.data?.can_redeem === true) replace('verificationResult')
} catch (e) { }
}
useDidShow(() => {
check_permission_and_redirect()
})
const handleLogin = async () => {
if (!username.value || !password.value) {
Taro.showToast({ title: '请输入账号密码', icon: 'none' })
return
}
Taro.showLoading({ title: '登录中...' })
const login_res = await volunteerLoginAPI({ uuid: username.value, password: password.value })
Taro.hideLoading()
if (login_res?.code !== 1) {
Taro.showToast({ title: login_res?.msg || '登录失败', icon: 'none' })
return
}
Taro.showLoading({ title: '校验权限中...' })
const permission_res = await checkRedeemPermissionAPI()
Taro.hideLoading()
if (permission_res?.code !== 1) {
Taro.showToast({ title: permission_res?.msg || '权限校验失败', icon: 'none' })
return
}
if (permission_res?.data) store.changeUserInfo(permission_res.data)
if (permission_res?.data?.can_redeem === true) {
Taro.showToast({ title: permission_res?.msg || login_res?.msg || '登录成功', icon: 'success' })
setTimeout(() => replace('verificationResult'), 1200)
return
}
Taro.showToast({ title: permission_res?.msg || '暂无核销权限', icon: 'none' })
}
</script>
<style lang="less">
.login-page {
min-height: 100vh;
background-color: #F6F6F6;
display: flex;
flex-direction: column;
align-items: center;
padding-top: 120rpx;
.logo-section {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 60rpx;
image {
width: 120rpx;
height: 120rpx;
border-radius: 50%;
margin-bottom: 24rpx;
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.1);
background-color: #fff;
}
.app-name {
font-size: 36rpx;
font-weight: 600;
color: #333;
letter-spacing: 2rpx;
}
}
.login-card {
width: 690rpx;
background: #fff;
border-radius: 24rpx;
padding: 60rpx 40rpx;
box-shadow: 0 12rpx 40rpx rgba(0, 0, 0, 0.04);
box-sizing: border-box;
.title {
font-size: 44rpx;
font-weight: bold;
color: #333;
margin-bottom: 60rpx;
padding-left: 10rpx;
}
.input-group {
background-color: #F7F8FA;
border-radius: 12rpx;
padding: 28rpx 30rpx;
margin-bottom: 32rpx;
display: flex;
align-items: center;
transition: all 0.3s;
.label {
font-size: 30rpx;
color: #333;
font-weight: 500;
width: 90rpx;
margin-right: 20rpx;
}
input {
flex: 1;
font-size: 30rpx;
color: #333;
height: 44rpx;
min-height: 44rpx;
}
.input-placeholder {
color: #C0C4CC;
}
}
.login-btn {
margin-top: 80rpx;
background: #A67939;
color: #fff;
height: 96rpx;
line-height: 96rpx;
border-radius: 48rpx;
font-size: 34rpx;
font-weight: 500;
box-shadow: 0 12rpx 30rpx rgba(166, 121, 57, 0.3);
border: none;
&::after {
border: none;
}
&:active {
opacity: 0.9;
transform: scale(0.99);
}
}
}
}
</style>