- 新增用户注册和登录系统 (login.html, register.html) - 集成Supabase数据库连接 (config.js, api.js) - 完善数据库架构设计 (database-schema.sql) - 添加部署指南和配置文档 (DEPLOYMENT_GUIDE.md) - 修复主页面结构和功能完善 (index.html) - 支持通话记录保存到数据库 - 完整的账单管理和用户认证流程 - 集成OpenAI、Twilio、Stripe等API服务
447 lines
13 KiB
HTML
447 lines
13 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>注册 - 翻译服务平台</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
min-height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 20px;
|
|
}
|
|
|
|
.register-container {
|
|
background: white;
|
|
border-radius: 20px;
|
|
padding: 40px;
|
|
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
|
|
width: 100%;
|
|
max-width: 450px;
|
|
text-align: center;
|
|
}
|
|
|
|
.logo {
|
|
width: 80px;
|
|
height: 80px;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
border-radius: 20px;
|
|
margin: 0 auto 30px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 32px;
|
|
color: white;
|
|
font-weight: bold;
|
|
}
|
|
|
|
h1 {
|
|
color: #333;
|
|
margin-bottom: 10px;
|
|
font-size: 28px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.subtitle {
|
|
color: #666;
|
|
margin-bottom: 40px;
|
|
font-size: 16px;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 25px;
|
|
text-align: left;
|
|
}
|
|
|
|
label {
|
|
display: block;
|
|
margin-bottom: 8px;
|
|
color: #333;
|
|
font-weight: 500;
|
|
font-size: 14px;
|
|
}
|
|
|
|
input[type="text"],
|
|
input[type="email"],
|
|
input[type="password"],
|
|
input[type="tel"] {
|
|
width: 100%;
|
|
padding: 15px 20px;
|
|
border: 2px solid #e1e5e9;
|
|
border-radius: 12px;
|
|
font-size: 16px;
|
|
transition: all 0.3s ease;
|
|
background: #f8f9fa;
|
|
}
|
|
|
|
input[type="text"]:focus,
|
|
input[type="email"]:focus,
|
|
input[type="password"]:focus,
|
|
input[type="tel"]:focus {
|
|
outline: none;
|
|
border-color: #667eea;
|
|
background: white;
|
|
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
|
|
}
|
|
|
|
.password-strength {
|
|
margin-top: 8px;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.strength-weak { color: #e74c3c; }
|
|
.strength-medium { color: #f39c12; }
|
|
.strength-strong { color: #27ae60; }
|
|
|
|
.register-btn {
|
|
width: 100%;
|
|
padding: 15px;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
border: none;
|
|
border-radius: 12px;
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.register-btn:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
|
|
}
|
|
|
|
.register-btn:disabled {
|
|
opacity: 0.6;
|
|
cursor: not-allowed;
|
|
transform: none;
|
|
}
|
|
|
|
.terms {
|
|
font-size: 12px;
|
|
color: #666;
|
|
margin-bottom: 30px;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.terms a {
|
|
color: #667eea;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.terms a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
|
|
.divider {
|
|
margin: 30px 0;
|
|
position: relative;
|
|
text-align: center;
|
|
}
|
|
|
|
.divider::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 0;
|
|
right: 0;
|
|
height: 1px;
|
|
background: #e1e5e9;
|
|
}
|
|
|
|
.divider span {
|
|
background: white;
|
|
padding: 0 20px;
|
|
color: #666;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.login-link {
|
|
color: #667eea;
|
|
text-decoration: none;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.login-link:hover {
|
|
text-decoration: underline;
|
|
}
|
|
|
|
.error-message {
|
|
background: #fee;
|
|
color: #c33;
|
|
padding: 12px;
|
|
border-radius: 8px;
|
|
margin-bottom: 20px;
|
|
font-size: 14px;
|
|
border: 1px solid #fcc;
|
|
}
|
|
|
|
.success-message {
|
|
background: #efe;
|
|
color: #3c3;
|
|
padding: 12px;
|
|
border-radius: 8px;
|
|
margin-bottom: 20px;
|
|
font-size: 14px;
|
|
border: 1px solid #cfc;
|
|
}
|
|
|
|
.loading {
|
|
display: inline-block;
|
|
width: 20px;
|
|
height: 20px;
|
|
border: 2px solid #ffffff;
|
|
border-radius: 50%;
|
|
border-top-color: transparent;
|
|
animation: spin 1s ease-in-out infinite;
|
|
margin-right: 10px;
|
|
}
|
|
|
|
@keyframes spin {
|
|
to { transform: rotate(360deg); }
|
|
}
|
|
|
|
.form-row {
|
|
display: flex;
|
|
gap: 15px;
|
|
}
|
|
|
|
.form-row .form-group {
|
|
flex: 1;
|
|
}
|
|
|
|
@media (max-width: 480px) {
|
|
.register-container {
|
|
padding: 30px 20px;
|
|
margin: 10px;
|
|
}
|
|
|
|
h1 {
|
|
font-size: 24px;
|
|
}
|
|
|
|
.form-row {
|
|
flex-direction: column;
|
|
gap: 0;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="register-container">
|
|
<div class="logo">译</div>
|
|
<h1>创建账户</h1>
|
|
<p class="subtitle">加入我们的翻译服务平台</p>
|
|
|
|
<div id="message-container"></div>
|
|
|
|
<form id="registerForm">
|
|
<div class="form-group">
|
|
<label for="fullName">姓名</label>
|
|
<input type="text" id="fullName" name="fullName" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="email">邮箱地址</label>
|
|
<input type="email" id="email" name="email" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="phone">手机号码</label>
|
|
<input type="tel" id="phone" name="phone" placeholder="请输入手机号码">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="password">密码</label>
|
|
<input type="password" id="password" name="password" required>
|
|
<div id="passwordStrength" class="password-strength"></div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="confirmPassword">确认密码</label>
|
|
<input type="password" id="confirmPassword" name="confirmPassword" required>
|
|
</div>
|
|
|
|
<button type="submit" class="register-btn" id="registerBtn">
|
|
<span class="btn-text">创建账户</span>
|
|
</button>
|
|
</form>
|
|
|
|
<div class="terms">
|
|
注册即表示您同意我们的
|
|
<a href="#">服务条款</a> 和
|
|
<a href="#">隐私政策</a>
|
|
</div>
|
|
|
|
<div class="divider">
|
|
<span>已有账户?</span>
|
|
</div>
|
|
|
|
<a href="login.html" class="login-link">立即登录</a>
|
|
</div>
|
|
|
|
<!-- 引入必要的脚本 -->
|
|
<script src="https://unpkg.com/@supabase/supabase-js@2"></script>
|
|
<script src="config.js"></script>
|
|
<script src="api.js"></script>
|
|
|
|
<script>
|
|
// 密码强度检查
|
|
document.getElementById('password').addEventListener('input', function(e) {
|
|
const password = e.target.value;
|
|
const strengthDiv = document.getElementById('passwordStrength');
|
|
|
|
if (password.length === 0) {
|
|
strengthDiv.textContent = '';
|
|
return;
|
|
}
|
|
|
|
let strength = 0;
|
|
let feedback = [];
|
|
|
|
// 长度检查
|
|
if (password.length >= 8) strength++;
|
|
else feedback.push('至少8个字符');
|
|
|
|
// 包含数字
|
|
if (/\d/.test(password)) strength++;
|
|
else feedback.push('包含数字');
|
|
|
|
// 包含小写字母
|
|
if (/[a-z]/.test(password)) strength++;
|
|
else feedback.push('包含小写字母');
|
|
|
|
// 包含大写字母或特殊字符
|
|
if (/[A-Z]/.test(password) || /[^A-Za-z0-9]/.test(password)) strength++;
|
|
else feedback.push('包含大写字母或特殊字符');
|
|
|
|
// 显示强度
|
|
if (strength < 2) {
|
|
strengthDiv.className = 'password-strength strength-weak';
|
|
strengthDiv.textContent = '密码强度:弱 - ' + feedback.join('、');
|
|
} else if (strength < 3) {
|
|
strengthDiv.className = 'password-strength strength-medium';
|
|
strengthDiv.textContent = '密码强度:中等 - ' + feedback.join('、');
|
|
} else {
|
|
strengthDiv.className = 'password-strength strength-strong';
|
|
strengthDiv.textContent = '密码强度:强';
|
|
}
|
|
});
|
|
|
|
// 注册表单处理
|
|
document.getElementById('registerForm').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
|
|
const formData = new FormData(e.target);
|
|
const fullName = formData.get('fullName');
|
|
const email = formData.get('email');
|
|
const phone = formData.get('phone');
|
|
const password = formData.get('password');
|
|
const confirmPassword = formData.get('confirmPassword');
|
|
|
|
const registerBtn = document.getElementById('registerBtn');
|
|
|
|
// 验证密码匹配
|
|
if (password !== confirmPassword) {
|
|
showMessage('两次输入的密码不一致', 'error');
|
|
return;
|
|
}
|
|
|
|
// 验证密码强度
|
|
if (password.length < 6) {
|
|
showMessage('密码长度至少6个字符', 'error');
|
|
return;
|
|
}
|
|
|
|
// 显示加载状态
|
|
registerBtn.disabled = true;
|
|
registerBtn.innerHTML = '<span class="loading"></span>注册中...';
|
|
|
|
try {
|
|
const result = await apiManager.register(email, password, {
|
|
fullName: fullName,
|
|
phone: phone
|
|
});
|
|
|
|
if (result.success) {
|
|
showMessage('注册成功!请检查您的邮箱进行验证,然后登录。', 'success');
|
|
|
|
// 清空表单
|
|
document.getElementById('registerForm').reset();
|
|
document.getElementById('passwordStrength').textContent = '';
|
|
|
|
// 延迟跳转到登录页面
|
|
setTimeout(() => {
|
|
window.location.href = '../index.html';
|
|
}, 3000);
|
|
} else {
|
|
showMessage(result.error || '注册失败,请重试', 'error');
|
|
}
|
|
} catch (error) {
|
|
showMessage('注册失败:' + error.message, 'error');
|
|
} finally {
|
|
// 恢复按钮状态
|
|
registerBtn.disabled = false;
|
|
registerBtn.innerHTML = '<span class="btn-text">创建账户</span>';
|
|
}
|
|
});
|
|
|
|
// 显示消息
|
|
function showMessage(message, type) {
|
|
const messageContainer = document.getElementById('message-container');
|
|
const messageClass = type === 'success' ? 'success-message' : 'error-message';
|
|
|
|
messageContainer.innerHTML = `<div class="${messageClass}">${message}</div>`;
|
|
|
|
// 成功消息显示更长时间
|
|
const timeout = type === 'success' ? 5000 : 3000;
|
|
setTimeout(() => {
|
|
messageContainer.innerHTML = '';
|
|
}, timeout);
|
|
}
|
|
|
|
// 检查是否已登录
|
|
window.addEventListener('load', async () => {
|
|
// 等待API管理器初始化
|
|
await new Promise(resolve => {
|
|
const checkInit = () => {
|
|
if (window.apiManager && window.apiManager.supabase) {
|
|
resolve();
|
|
} else {
|
|
setTimeout(checkInit, 100);
|
|
}
|
|
};
|
|
checkInit();
|
|
});
|
|
|
|
// 如果已登录,直接跳转到主页
|
|
if (apiManager.currentUser) {
|
|
window.location.href = '../index.html';
|
|
}
|
|
});
|
|
|
|
// 实时验证确认密码
|
|
document.getElementById('confirmPassword').addEventListener('input', function(e) {
|
|
const password = document.getElementById('password').value;
|
|
const confirmPassword = e.target.value;
|
|
|
|
if (confirmPassword && password !== confirmPassword) {
|
|
e.target.style.borderColor = '#e74c3c';
|
|
} else {
|
|
e.target.style.borderColor = '#e1e5e9';
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |