|
|
@@ -1,8 +1,10 @@
|
|
|
-import { View, Input, Button, Text, Image } from '@tarojs/components'
|
|
|
+import { View, Text } from '@tarojs/components'
|
|
|
import { useState, useEffect } from 'react'
|
|
|
import Taro from '@tarojs/taro'
|
|
|
import { useAuth } from '@/utils/auth'
|
|
|
import { cn } from '@/utils/cn'
|
|
|
+import { Button } from '@/components/ui/button'
|
|
|
+import { Input } from '@/components/ui/input'
|
|
|
|
|
|
export default function Register() {
|
|
|
const [username, setUsername] = useState('')
|
|
|
@@ -132,101 +134,76 @@ export default function Register() {
|
|
|
{/* 用户名输入框 */}
|
|
|
<View className="space-y-2">
|
|
|
<Text className="text-sm font-medium text-gray-700">用户名</Text>
|
|
|
- <View className="relative">
|
|
|
- <View className="absolute left-3 top-1/2 -translate-y-1/2">
|
|
|
- <View className="i-heroicons-user-20-solid w-5 h-5 text-gray-400" />
|
|
|
- </View>
|
|
|
- <Input
|
|
|
- className="w-full h-12 pl-10 pr-4 bg-gray-50 rounded-lg text-gray-900 placeholder-gray-500 focus:bg-white focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent"
|
|
|
- placeholder="请输入用户名(3-20个字符)"
|
|
|
- value={username}
|
|
|
- onInput={(e) => setUsername(e.detail.value)}
|
|
|
- maxlength={20}
|
|
|
- />
|
|
|
- </View>
|
|
|
+ <Input
|
|
|
+ leftIcon="i-heroicons-user-20-solid"
|
|
|
+ placeholder="请输入用户名(3-20个字符)"
|
|
|
+ value={username}
|
|
|
+ onInput={(e) => setUsername(e.detail.value)}
|
|
|
+ maxlength={20}
|
|
|
+ size="lg"
|
|
|
+ variant="filled"
|
|
|
+ />
|
|
|
</View>
|
|
|
|
|
|
{/* 邮箱输入框 */}
|
|
|
<View className="space-y-2">
|
|
|
<Text className="text-sm font-medium text-gray-700">邮箱(可选)</Text>
|
|
|
- <View className="relative">
|
|
|
- <View className="absolute left-3 top-1/2 -translate-y-1/2">
|
|
|
- <View className="i-heroicons-envelope-20-solid w-5 h-5 text-gray-400" />
|
|
|
- </View>
|
|
|
- <Input
|
|
|
- className="w-full h-12 pl-10 pr-4 bg-gray-50 rounded-lg text-gray-900 placeholder-gray-500 focus:bg-white focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent"
|
|
|
- placeholder="请输入邮箱地址"
|
|
|
- type="text"
|
|
|
- value={email}
|
|
|
- onInput={(e) => setEmail(e.detail.value)}
|
|
|
- maxlength={50}
|
|
|
- />
|
|
|
- </View>
|
|
|
+ <Input
|
|
|
+ leftIcon="i-heroicons-envelope-20-solid"
|
|
|
+ placeholder="请输入邮箱地址"
|
|
|
+ type="text"
|
|
|
+ value={email}
|
|
|
+ onInput={(e) => setEmail(e.detail.value)}
|
|
|
+ maxlength={50}
|
|
|
+ size="lg"
|
|
|
+ variant="filled"
|
|
|
+ />
|
|
|
</View>
|
|
|
|
|
|
{/* 密码输入框 */}
|
|
|
<View className="space-y-2">
|
|
|
<Text className="text-sm font-medium text-gray-700">密码</Text>
|
|
|
- <View className="relative">
|
|
|
- <View className="absolute left-3 top-1/2 -translate-y-1/2">
|
|
|
- <View className="i-heroicons-lock-closed-20-solid w-5 h-5 text-gray-400" />
|
|
|
- </View>
|
|
|
- <Input
|
|
|
- className="w-full h-12 pl-10 pr-12 bg-gray-50 rounded-lg text-gray-900 placeholder-gray-500 focus:bg-white focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent"
|
|
|
- placeholder="请输入密码(至少6位)"
|
|
|
- password={!showPassword}
|
|
|
- value={password}
|
|
|
- onInput={(e) => setPassword(e.detail.value)}
|
|
|
- maxlength={20}
|
|
|
- />
|
|
|
- <View
|
|
|
- className="absolute right-3 top-1/2 -translate-y-1/2"
|
|
|
- onClick={() => setShowPassword(!showPassword)}
|
|
|
- >
|
|
|
- <View className={cn(
|
|
|
- "w-5 h-5 text-gray-400",
|
|
|
- showPassword ? "i-heroicons-eye-20-solid" : "i-heroicons-eye-slash-20-solid"
|
|
|
- )} />
|
|
|
- </View>
|
|
|
- </View>
|
|
|
+ <Input
|
|
|
+ leftIcon="i-heroicons-lock-closed-20-solid"
|
|
|
+ rightIcon={showPassword ? "i-heroicons-eye-20-solid" : "i-heroicons-eye-slash-20-solid"}
|
|
|
+ placeholder="请输入密码(至少6位)"
|
|
|
+ password={!showPassword}
|
|
|
+ value={password}
|
|
|
+ onInput={(e) => setPassword(e.detail.value)}
|
|
|
+ maxlength={20}
|
|
|
+ size="lg"
|
|
|
+ variant="filled"
|
|
|
+ onRightIconClick={() => setShowPassword(!showPassword)}
|
|
|
+ />
|
|
|
</View>
|
|
|
|
|
|
{/* 确认密码输入框 */}
|
|
|
<View className="space-y-2">
|
|
|
<Text className="text-sm font-medium text-gray-700">确认密码</Text>
|
|
|
- <View className="relative">
|
|
|
- <View className="absolute left-3 top-1/2 -translate-y-1/2">
|
|
|
- <View className="i-heroicons-lock-closed-20-solid w-5 h-5 text-gray-400" />
|
|
|
- </View>
|
|
|
- <Input
|
|
|
- className="w-full h-12 pl-10 pr-12 bg-gray-50 rounded-lg text-gray-900 placeholder-gray-500 focus:bg-white focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent"
|
|
|
- placeholder="请再次输入密码"
|
|
|
- password={!showConfirmPassword}
|
|
|
- value={confirmPassword}
|
|
|
- onInput={(e) => setConfirmPassword(e.detail.value)}
|
|
|
- maxlength={20}
|
|
|
- />
|
|
|
- <View
|
|
|
- className="absolute right-3 top-1/2 -translate-y-1/2"
|
|
|
- onClick={() => setShowConfirmPassword(!showConfirmPassword)}
|
|
|
- >
|
|
|
- <View className={cn(
|
|
|
- "w-5 h-5 text-gray-400",
|
|
|
- showConfirmPassword ? "i-heroicons-eye-20-solid" : "i-heroicons-eye-slash-20-solid"
|
|
|
- )} />
|
|
|
- </View>
|
|
|
- </View>
|
|
|
+ <Input
|
|
|
+ leftIcon="i-heroicons-lock-closed-20-solid"
|
|
|
+ rightIcon={showConfirmPassword ? "i-heroicons-eye-20-solid" : "i-heroicons-eye-slash-20-solid"}
|
|
|
+ placeholder="请再次输入密码"
|
|
|
+ password={!showConfirmPassword}
|
|
|
+ value={confirmPassword}
|
|
|
+ onInput={(e) => setConfirmPassword(e.detail.value)}
|
|
|
+ maxlength={20}
|
|
|
+ size="lg"
|
|
|
+ variant="filled"
|
|
|
+ onRightIconClick={() => setShowConfirmPassword(!showConfirmPassword)}
|
|
|
+ />
|
|
|
</View>
|
|
|
|
|
|
{/* 注册按钮 */}
|
|
|
<Button
|
|
|
className={cn(
|
|
|
- "w-full h-12 rounded-lg font-medium text-white transition-all duration-200",
|
|
|
+ "w-full",
|
|
|
isLoading || !username || !password || !confirmPassword
|
|
|
- ? "bg-gray-300 cursor-not-allowed"
|
|
|
- : "bg-green-500 hover:bg-green-600 active:bg-green-700 shadow-lg"
|
|
|
+ ? "bg-gray-300"
|
|
|
+ : "bg-green-500 hover:bg-green-600"
|
|
|
)}
|
|
|
- loading={isLoading}
|
|
|
+ size="lg"
|
|
|
+ variant="default"
|
|
|
onClick={handleRegister}
|
|
|
disabled={isLoading || !username || !password || !confirmPassword}
|
|
|
>
|