398 lines
8.8 KiB
Vue
398 lines
8.8 KiB
Vue
|
|
<template>
|
|||
|
|
<div class="login-page">
|
|||
|
|
<div class="content">
|
|||
|
|
<div class="back-button" @click="goBack">
|
|||
|
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|||
|
|
<path
|
|||
|
|
d="M15 18L9 12L15 6"
|
|||
|
|
stroke="white"
|
|||
|
|
stroke-width="2"
|
|||
|
|
stroke-linecap="round"
|
|||
|
|
stroke-linejoin="round"
|
|||
|
|
/>
|
|||
|
|
</svg>
|
|||
|
|
</div>
|
|||
|
|
<div class="header">
|
|||
|
|
<h1 class="title">Sign up.</h1>
|
|||
|
|
<p class="subtitle">Redefine the styling experience with AI.</p>
|
|||
|
|
<p class="description">Use Styling Angel to speed up your fashion journey.</p>
|
|||
|
|
</div>
|
|||
|
|
<div class="login-container">
|
|||
|
|
<form @submit.prevent="handleSignup" class="login-form">
|
|||
|
|
<div class="input-group">
|
|||
|
|
<input
|
|||
|
|
type="email"
|
|||
|
|
v-model="formData.email"
|
|||
|
|
placeholder="Email"
|
|||
|
|
class="input-field"
|
|||
|
|
required
|
|||
|
|
/>
|
|||
|
|
</div>
|
|||
|
|
<div class="input-group">
|
|||
|
|
<input
|
|||
|
|
type="text"
|
|||
|
|
v-model="formData.name"
|
|||
|
|
placeholder="Name"
|
|||
|
|
class="input-field"
|
|||
|
|
required
|
|||
|
|
/>
|
|||
|
|
</div>
|
|||
|
|
<div class="input-group pwd">
|
|||
|
|
<input
|
|||
|
|
type="password"
|
|||
|
|
v-model="formData.password"
|
|||
|
|
placeholder="Your Password"
|
|||
|
|
class="input-field"
|
|||
|
|
required
|
|||
|
|
/>
|
|||
|
|
</div>
|
|||
|
|
<button type="submit" class="signup-btn">Sign up</button>
|
|||
|
|
<button type="button" class="google-button" @click="handleGoogleLogin">
|
|||
|
|
<div class="google-icon">
|
|||
|
|
<svg width="20" height="20" viewBox="0 0 24 24">
|
|||
|
|
<path
|
|||
|
|
fill="#4285F4"
|
|||
|
|
d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"
|
|||
|
|
/>
|
|||
|
|
<path
|
|||
|
|
fill="#34A853"
|
|||
|
|
d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"
|
|||
|
|
/>
|
|||
|
|
<path
|
|||
|
|
fill="#FBBC05"
|
|||
|
|
d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"
|
|||
|
|
/>
|
|||
|
|
<path
|
|||
|
|
fill="#EA4335"
|
|||
|
|
d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"
|
|||
|
|
/>
|
|||
|
|
</svg>
|
|||
|
|
</div>
|
|||
|
|
Sign up with Google
|
|||
|
|
</button>
|
|||
|
|
</form>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="footer">
|
|||
|
|
<p>Powered by AiDLab for Lane Crawford</p>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
</template>
|
|||
|
|
|
|||
|
|
<script setup lang="ts">
|
|||
|
|
import { ref, reactive, computed } from 'vue'
|
|||
|
|
import { useRouter } from 'vue-router'
|
|||
|
|
import { showToast } from 'vant'
|
|||
|
|
|
|||
|
|
const router = useRouter()
|
|||
|
|
|
|||
|
|
// 表单数据
|
|||
|
|
const formData = reactive({
|
|||
|
|
email: '',
|
|||
|
|
password: '',
|
|||
|
|
name:''
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
// 表单验证状态
|
|||
|
|
const formErrors = reactive({
|
|||
|
|
email: '',
|
|||
|
|
password: ''
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
// 加载状态
|
|||
|
|
const isLoading = ref(false)
|
|||
|
|
|
|||
|
|
// 表单验证规则
|
|||
|
|
const validateEmail = (email: string) => {
|
|||
|
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
|
|||
|
|
return emailRegex.test(email)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const validatePassword = (password: string) => {
|
|||
|
|
return password.length >= 6
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 验证表单
|
|||
|
|
const validateForm = () => {
|
|||
|
|
let isValid = true
|
|||
|
|
|
|||
|
|
// 重置错误信息
|
|||
|
|
formErrors.email = ''
|
|||
|
|
formErrors.password = ''
|
|||
|
|
formErrors.name = ''
|
|||
|
|
|
|||
|
|
if (!formData.name) {
|
|||
|
|
formErrors.name = '请输入姓名'
|
|||
|
|
isValid = false
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 验证邮箱
|
|||
|
|
if (!formData.email) {
|
|||
|
|
formErrors.email = '请输入邮箱地址'
|
|||
|
|
isValid = false
|
|||
|
|
} else if (!validateEmail(formData.email)) {
|
|||
|
|
formErrors.email = '请输入有效的邮箱地址'
|
|||
|
|
isValid = false
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 验证密码
|
|||
|
|
if (!formData.password) {
|
|||
|
|
formErrors.password = '请输入密码'
|
|||
|
|
isValid = false
|
|||
|
|
} else if (!validatePassword(formData.password)) {
|
|||
|
|
formErrors.password = '密码至少需要6位字符'
|
|||
|
|
isValid = false
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return isValid
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 计算属性:表单是否有效
|
|||
|
|
const isFormValid = computed(() => {
|
|||
|
|
return (
|
|||
|
|
formData.name &&
|
|||
|
|
formData.email &&
|
|||
|
|
formData.password &&
|
|||
|
|
validateEmail(formData.email) &&
|
|||
|
|
validatePassword(formData.password)
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
// 返回上一页
|
|||
|
|
const goBack = () => {
|
|||
|
|
router.go(-1)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 处理登录
|
|||
|
|
const handleSignup = async () => {
|
|||
|
|
if (!validateForm()) {
|
|||
|
|
showToast('请检查输入信息')
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
isLoading.value = true
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
// 模拟登录API调用
|
|||
|
|
await new Promise((resolve) => setTimeout(resolve, 2000))
|
|||
|
|
|
|||
|
|
// 这里添加实际的登录API调用
|
|||
|
|
// const response = await loginAPI(formData)
|
|||
|
|
|
|||
|
|
showToast('注册成功')
|
|||
|
|
|
|||
|
|
// 登录成功后跳转到主页或工作台
|
|||
|
|
router.push('/workshop')
|
|||
|
|
} catch (error) {
|
|||
|
|
console.error('注册失败:', error)
|
|||
|
|
showToast('注册失败,请重试')
|
|||
|
|
} finally {
|
|||
|
|
isLoading.value = false
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 处理Google登录
|
|||
|
|
const handleGoogleLogin = async () => {
|
|||
|
|
try {
|
|||
|
|
isLoading.value = true
|
|||
|
|
showToast('Google注册功能开发中...')
|
|||
|
|
|
|||
|
|
// 这里添加Google OAuth登录逻辑
|
|||
|
|
// const response = await googleLoginAPI()
|
|||
|
|
} catch (error) {
|
|||
|
|
console.error('Google注册失败:', error)
|
|||
|
|
showToast('Google注册失败,请重试')
|
|||
|
|
} finally {
|
|||
|
|
isLoading.value = false
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
// 实时验证输入
|
|||
|
|
const handleEmailInput = () => {
|
|||
|
|
if (formData.email && !validateEmail(formData.email)) {
|
|||
|
|
formErrors.email = '请输入有效的邮箱地址'
|
|||
|
|
} else {
|
|||
|
|
formErrors.email = ''
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const handlePasswordInput = () => {
|
|||
|
|
if (formData.password && !validatePassword(formData.password)) {
|
|||
|
|
formErrors.password = '密码至少需要6位字符'
|
|||
|
|
} else {
|
|||
|
|
formErrors.password = ''
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
</script>
|
|||
|
|
|
|||
|
|
<style scoped lang="less">
|
|||
|
|
.login-page {
|
|||
|
|
position: relative;
|
|||
|
|
color: #fff;
|
|||
|
|
width: 100%;
|
|||
|
|
height: 100vh;
|
|||
|
|
overflow: hidden;
|
|||
|
|
display: flex;
|
|||
|
|
flex-direction: column;
|
|||
|
|
background-image: url('@/assets/images/sginup_bg.png');
|
|||
|
|
background-size: cover;
|
|||
|
|
background-position: center;
|
|||
|
|
background-repeat: no-repeat;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.content {
|
|||
|
|
position: relative;
|
|||
|
|
z-index: 2;
|
|||
|
|
flex: 1;
|
|||
|
|
display: flex;
|
|||
|
|
flex-direction: column;
|
|||
|
|
padding: 2rem;
|
|||
|
|
padding-top: 6rem; /* 为状态栏留出空间 */
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.back-button {
|
|||
|
|
position: absolute;
|
|||
|
|
top: 2rem;
|
|||
|
|
left: 2rem;
|
|||
|
|
width: 4rem;
|
|||
|
|
height: 4rem;
|
|||
|
|
display: flex;
|
|||
|
|
align-items: center;
|
|||
|
|
justify-content: center;
|
|||
|
|
cursor: pointer;
|
|||
|
|
z-index: 3;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.header {
|
|||
|
|
margin-bottom: 4rem;
|
|||
|
|
color: white;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.title {
|
|||
|
|
font-size: 3.2rem;
|
|||
|
|
font-weight: bold;
|
|||
|
|
margin-bottom: 0.8rem;
|
|||
|
|
color: white;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.subtitle {
|
|||
|
|
font-size: 1.6rem;
|
|||
|
|
margin-bottom: 0.4rem;
|
|||
|
|
color: white;
|
|||
|
|
opacity: 0.9;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.description {
|
|||
|
|
font-size: 1.4rem;
|
|||
|
|
color: white;
|
|||
|
|
opacity: 0.8;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.login-container {
|
|||
|
|
display: flex;
|
|||
|
|
align-items: center;
|
|||
|
|
justify-content: center;
|
|||
|
|
margin-top: 30%;
|
|||
|
|
.login-form {
|
|||
|
|
position: relative;
|
|||
|
|
width: 100%;
|
|||
|
|
/* max-width: 70rem; */
|
|||
|
|
background: rgba(255, 255, 255, 0.03);
|
|||
|
|
backdrop-filter: blur(30px);
|
|||
|
|
border: 0.1rem solid rgba(255, 255, 255, 0.1);
|
|||
|
|
border-radius: 2rem;
|
|||
|
|
padding: 10rem 4rem;
|
|||
|
|
box-shadow: 0 0.8rem 3.2rem rgba(0, 0, 0, 0.1);
|
|||
|
|
overflow: hidden;
|
|||
|
|
margin: 0 10rem;
|
|||
|
|
height: 115rem;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.input-field {
|
|||
|
|
width: 100%;
|
|||
|
|
padding: 16px 20px;
|
|||
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|||
|
|
border-radius: 25px;
|
|||
|
|
background: rgba(255, 255, 255, 0.1);
|
|||
|
|
color: white;
|
|||
|
|
font-size: 1.6rem;
|
|||
|
|
outline: none;
|
|||
|
|
transition: all 0.3s ease;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.input-field::placeholder {
|
|||
|
|
color: rgba(255, 255, 255, 0.6);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.input-field:focus {
|
|||
|
|
border-color: rgba(255, 255, 255, 0.6);
|
|||
|
|
background: rgba(255, 255, 255, 0.15);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.input-group {
|
|||
|
|
margin-bottom: 5rem;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
.signup-btn {
|
|||
|
|
width: 100%;
|
|||
|
|
padding: 1.6rem;
|
|||
|
|
background: #000;
|
|||
|
|
color: white;
|
|||
|
|
border: none;
|
|||
|
|
border-radius: 25px;
|
|||
|
|
font-size: 1.6rem;
|
|||
|
|
margin-bottom: 37rem;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.google-button {
|
|||
|
|
width: 100%;
|
|||
|
|
padding: 16px;
|
|||
|
|
background: transparent;
|
|||
|
|
color: #000;
|
|||
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|||
|
|
border-radius: 25px;
|
|||
|
|
font-size: 16px;
|
|||
|
|
cursor: pointer;
|
|||
|
|
transition: all 0.3s ease;
|
|||
|
|
display: flex;
|
|||
|
|
align-items: center;
|
|||
|
|
justify-content: center;
|
|||
|
|
gap: 12px;
|
|||
|
|
background: rgba(255, 255, 255, 0.9);
|
|||
|
|
margin-bottom: 1rem;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.google-icon {
|
|||
|
|
width: 20px;
|
|||
|
|
height: 20px;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.signup-link {
|
|||
|
|
text-align: center;
|
|||
|
|
color: rgba(255, 255, 255, 0.7);
|
|||
|
|
font-size: 14px;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.signup-link a {
|
|||
|
|
color: white;
|
|||
|
|
text-decoration: none;
|
|||
|
|
font-weight: 500;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.signup-link a:hover {
|
|||
|
|
text-decoration: underline;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.footer {
|
|||
|
|
position: relative;
|
|||
|
|
z-index: 2;
|
|||
|
|
text-align: center;
|
|||
|
|
padding: 20px;
|
|||
|
|
color: white;
|
|||
|
|
font-size: 12px;
|
|||
|
|
opacity: 0.8;
|
|||
|
|
}
|
|||
|
|
</style>
|