update
This commit is contained in:
@@ -383,7 +383,9 @@ export class PreloadUI extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
async onLogin() {}
|
||||
async onLogin() {
|
||||
ViewManager.I.openMainView("loginPanel/LoginPanel");
|
||||
}
|
||||
|
||||
// 请求个人数据
|
||||
private async reqMyInfo() {
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
import { _decorator, EditBox } from "cc";
|
||||
import Utils from "../../../Main/Common/Utils";
|
||||
import li_BaseView from "../../../Main/Common/li_BaseView";
|
||||
import { GButton } from "../../../Main/Common/GButton";
|
||||
import { ViewManager } from "../../../Main/Manager/ViewManager";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**
|
||||
* 登录页面
|
||||
* 预制体位于 resources/loginPanel/LoginPanel
|
||||
*/
|
||||
@ccclass("LoginPanel")
|
||||
export class LoginPanel extends li_BaseView {
|
||||
private _nodeTab: any = {};
|
||||
|
||||
/**
|
||||
* 组件初始化时调用
|
||||
*/
|
||||
onLoadCT(): void {
|
||||
// 解析节点,将子节点存储到 _nodeTab 中
|
||||
Utils.parseNode(this.node, this._nodeTab);
|
||||
|
||||
// 初始化UI
|
||||
this.initUI();
|
||||
|
||||
// 注册事件监听
|
||||
this.registerListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化UI
|
||||
*/
|
||||
private initUI(): void {
|
||||
// 这里可以初始化一些默认值
|
||||
// 例如:清空输入框等
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册事件监听
|
||||
*/
|
||||
private registerListener(): void {
|
||||
// 绑定登录按钮点击事件
|
||||
if (this._nodeTab.LoginBtn) {
|
||||
GButton.BandClick(this._nodeTab.LoginBtn, this.onClickLogin, this);
|
||||
}
|
||||
|
||||
// 绑定注册按钮点击事件
|
||||
if (this._nodeTab.registerBtn) {
|
||||
GButton.BandClick(this._nodeTab.registerBtn, this.onClickRegister, this);
|
||||
}
|
||||
|
||||
// 绑定忘记密码按钮点击事件
|
||||
if (this._nodeTab.forgetPasswordBtn) {
|
||||
GButton.BandClick(
|
||||
this._nodeTab.forgetPasswordBtn,
|
||||
this.onClickForgetPassword,
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
// 绑定关闭按钮点击事件
|
||||
if (this._nodeTab.closeBtn) {
|
||||
GButton.BandClick(this._nodeTab.closeBtn, this.onClickClose, this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击登录按钮
|
||||
*/
|
||||
private onClickLogin(): void {
|
||||
// 获取邮箱和密码输入框
|
||||
const emailInput = this._nodeTab.EmailInput?.getComponent(EditBox);
|
||||
const passwordInput = this._nodeTab.PasswordInput?.getComponent(EditBox);
|
||||
|
||||
if (!emailInput || !passwordInput) {
|
||||
console.error("未找到邮箱或密码输入框");
|
||||
return;
|
||||
}
|
||||
|
||||
const email = emailInput.string.trim();
|
||||
const password = passwordInput.string.trim();
|
||||
|
||||
// 验证输入
|
||||
if (!email) {
|
||||
console.log("请输入邮箱");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.isValidEmail(email)) {
|
||||
console.log("请输入有效的邮箱地址");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
if (!password) {
|
||||
console.log("请输入密码");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: 调用后端接口进行登录
|
||||
console.log("登录:", email, password);
|
||||
this.requestLogin(email, password);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用后端登录接口
|
||||
*/
|
||||
private requestLogin(email: string, password: string): void {
|
||||
// TODO: 实现后端登录接口调用
|
||||
// 示例:
|
||||
// const loginData = {
|
||||
// email: email,
|
||||
// password: password
|
||||
// };
|
||||
// NetworkManager.request('/api/login', loginData, (response) => {
|
||||
// if (response.success) {
|
||||
// // 登录成功,保存token等信息
|
||||
// // LoginData.I.token = response.token;
|
||||
// // 关闭登录界面,跳转到主界面
|
||||
// this.close();
|
||||
// } else {
|
||||
// // 登录失败,显示错误信息
|
||||
// console.error('登录失败:', response.message);
|
||||
// }
|
||||
// });
|
||||
|
||||
console.log("TODO: 实现登录接口调用");
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击注册按钮
|
||||
*/
|
||||
private onClickRegister(): void {
|
||||
// 打开注册页面
|
||||
ViewManager.I.openMainView("loginPanel/RegisterPanel");
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击忘记密码按钮
|
||||
*/
|
||||
private onClickForgetPassword(): void {
|
||||
// 打开安全验证页面
|
||||
ViewManager.I.openMainView("loginPanel/SafeCheckPanel");
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击关闭按钮
|
||||
*/
|
||||
private onClickClose(): void {
|
||||
// 关闭当前界面
|
||||
this.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证邮箱格式
|
||||
*/
|
||||
private isValidEmail(email: string): boolean {
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
return emailRegex.test(email);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "ce7e3167-8ed8-4e5c-921b-0c91aeaf36c4",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
import { _decorator, EditBox } from "cc";
|
||||
import Utils from "../../../Main/Common/Utils";
|
||||
import li_BaseView from "../../../Main/Common/li_BaseView";
|
||||
import { GButton } from "../../../Main/Common/GButton";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**
|
||||
* 修改密码页面
|
||||
* 预制体位于 resources/loginPanel/NewPasswordPanel
|
||||
*/
|
||||
@ccclass("NewPasswordPanel")
|
||||
export class NewPasswordPanel extends li_BaseView {
|
||||
private _nodeTab: any = {};
|
||||
|
||||
// 用于存储从安全验证页面传递过来的邮箱和验证码信息
|
||||
private _email: string = "";
|
||||
private _verificationCode: string = "";
|
||||
|
||||
/**
|
||||
* 组件初始化时调用
|
||||
*/
|
||||
onLoadCT(): void {
|
||||
// 解析节点,将子节点存储到 _nodeTab 中
|
||||
Utils.parseNode(this.node, this._nodeTab);
|
||||
|
||||
// 初始化UI
|
||||
this.initUI();
|
||||
|
||||
// 注册事件监听
|
||||
this.registerListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开界面时传入的数据
|
||||
*/
|
||||
openUIData(data: any): void {
|
||||
if (data) {
|
||||
this._email = data.email || "";
|
||||
this._verificationCode = data.code || "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化UI
|
||||
*/
|
||||
private initUI(): void {
|
||||
// 清空输入框
|
||||
const password1Input = this._nodeTab.Password1Input?.getComponent(EditBox);
|
||||
const password2Input = this._nodeTab.Password2Input?.getComponent(EditBox);
|
||||
|
||||
if (password1Input) {
|
||||
password1Input.string = "";
|
||||
}
|
||||
|
||||
if (password2Input) {
|
||||
password2Input.string = "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册事件监听
|
||||
*/
|
||||
private registerListener(): void {
|
||||
// 绑定确定按钮点击事件
|
||||
if (this._nodeTab.ConfirmBtn) {
|
||||
GButton.BandClick(this._nodeTab.ConfirmBtn, this.onClickConfirm, this);
|
||||
}
|
||||
|
||||
// 绑定关闭按钮点击事件
|
||||
if (this._nodeTab.CloseBtn) {
|
||||
GButton.BandClick(this._nodeTab.CloseBtn, this.onClickClose, this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击确定按钮
|
||||
*/
|
||||
private onClickConfirm(): void {
|
||||
// 获取两个密码输入框
|
||||
const password1Input = this._nodeTab.Password1Input?.getComponent(EditBox);
|
||||
const password2Input = this._nodeTab.Password2Input?.getComponent(EditBox);
|
||||
|
||||
if (!password1Input || !password2Input) {
|
||||
console.error("未找到密码输入框");
|
||||
return;
|
||||
}
|
||||
|
||||
const password1 = password1Input.string.trim();
|
||||
const password2 = password2Input.string.trim();
|
||||
|
||||
// 验证输入
|
||||
if (!password1) {
|
||||
console.log("请输入新密码");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
if (!password2) {
|
||||
console.log("请再次输入新密码");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
if (password1.length < 6) {
|
||||
console.log("密码长度不能少于6位");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
if (password1 !== password2) {
|
||||
console.log("两次输入的密码不一致");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: 调用后端接口修改密码
|
||||
console.log("修改密码:", password1);
|
||||
this.requestChangePassword(password1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用后端修改密码接口
|
||||
*/
|
||||
private requestChangePassword(newPassword: string): void {
|
||||
// TODO: 实现后端修改密码接口调用
|
||||
// 示例:
|
||||
// const data = {
|
||||
// email: this._email,
|
||||
// code: this._verificationCode,
|
||||
// newPassword: newPassword
|
||||
// };
|
||||
// NetworkManager.request('/api/changePassword', data, (response) => {
|
||||
// if (response.success) {
|
||||
// // 修改密码成功
|
||||
// console.log('密码修改成功');
|
||||
// // TODO: 显示成功提示
|
||||
// // 关闭当前界面
|
||||
// this.close();
|
||||
// // 可以选择跳转回登录页面
|
||||
// // ViewManager.I.openMainView('loginPanel/LoginPanel');
|
||||
// } else {
|
||||
// // 修改密码失败,显示错误信息
|
||||
// console.error('密码修改失败:', response.message);
|
||||
// // TODO: 显示错误提示
|
||||
// }
|
||||
// });
|
||||
|
||||
console.log("TODO: 实现修改密码接口调用");
|
||||
console.log("邮箱:", this._email);
|
||||
console.log("验证码:", this._verificationCode);
|
||||
console.log("新密码:", newPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击关闭按钮
|
||||
*/
|
||||
private onClickClose(): void {
|
||||
// 关闭当前界面
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "e11c6ea1-b27a-4e49-8494-baf1a534fc75",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
import { _decorator, EditBox, Label } from "cc";
|
||||
import Utils from "../../../Main/Common/Utils";
|
||||
import li_BaseView from "../../../Main/Common/li_BaseView";
|
||||
import { GButton } from "../../../Main/Common/GButton";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**
|
||||
* 注册页面
|
||||
* 预制体位于 resources/loginPanel/RegisterPanel
|
||||
*/
|
||||
@ccclass("RegisterPanel")
|
||||
export class RegisterPanel extends li_BaseView {
|
||||
private _nodeTab: any = {};
|
||||
|
||||
// 验证码倒计时
|
||||
private _countdown: number = 0;
|
||||
private _countdownTimer: any = null;
|
||||
|
||||
/**
|
||||
* 组件初始化时调用
|
||||
*/
|
||||
onLoadCT(): void {
|
||||
// 解析节点,将子节点存储到 _nodeTab 中
|
||||
Utils.parseNode(this.node, this._nodeTab);
|
||||
|
||||
// 初始化UI
|
||||
this.initUI();
|
||||
|
||||
// 注册事件监听
|
||||
this.registerListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化UI
|
||||
*/
|
||||
private initUI(): void {
|
||||
// 初始化发送按钮状态
|
||||
this.updateSendBtnState(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册事件监听
|
||||
*/
|
||||
private registerListener(): void {
|
||||
// 绑定发送验证码按钮点击事件
|
||||
if (this._nodeTab.SendBtn) {
|
||||
GButton.BandClick(this._nodeTab.SendBtn, this.onClickSendCode, this);
|
||||
}
|
||||
|
||||
// 绑定注册按钮点击事件
|
||||
if (this._nodeTab.RegisterBtn) {
|
||||
GButton.BandClick(this._nodeTab.RegisterBtn, this.onClickRegister, this);
|
||||
}
|
||||
|
||||
// 绑定关闭按钮点击事件
|
||||
if (this._nodeTab.CloseBtn) {
|
||||
GButton.BandClick(this._nodeTab.CloseBtn, this.onClickClose, this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击发送验证码按钮
|
||||
*/
|
||||
private onClickSendCode(): void {
|
||||
// 如果正在倒计时,不允许再次发送
|
||||
if (this._countdown > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取邮箱输入框
|
||||
const emailInput = this._nodeTab.EmailInput?.getComponent(EditBox);
|
||||
|
||||
if (!emailInput) {
|
||||
console.error("未找到邮箱输入框");
|
||||
return;
|
||||
}
|
||||
|
||||
const email = emailInput.string.trim();
|
||||
|
||||
// 验证邮箱
|
||||
if (!email) {
|
||||
console.log("请输入邮箱");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.isValidEmail(email)) {
|
||||
console.log("请输入有效的邮箱地址");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: 调用后端接口发送验证码
|
||||
console.log("发送验证码到:", email);
|
||||
this.requestSendCode(email);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用后端接口发送验证码
|
||||
*/
|
||||
private requestSendCode(email: string): void {
|
||||
// TODO: 实现后端发送验证码接口调用
|
||||
// 示例:
|
||||
// const data = { email: email, type: 'register' };
|
||||
// NetworkManager.request('/api/sendCode', data, (response) => {
|
||||
// if (response.success) {
|
||||
// // 发送成功,开始倒计时
|
||||
// this.startCountdown();
|
||||
// } else {
|
||||
// // 发送失败,显示错误信息
|
||||
// console.error('发送验证码失败:', response.message);
|
||||
// }
|
||||
// });
|
||||
|
||||
console.log("TODO: 实现发送验证码接口调用");
|
||||
// 临时模拟发送成功,启动倒计时
|
||||
this.startCountdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始倒计时
|
||||
*/
|
||||
private startCountdown(): void {
|
||||
this._countdown = 60; // 60秒倒计时
|
||||
this.updateSendBtnState(false);
|
||||
|
||||
this._countdownTimer = setInterval(() => {
|
||||
this._countdown--;
|
||||
|
||||
if (this._countdown <= 0) {
|
||||
// 倒计时结束
|
||||
clearInterval(this._countdownTimer);
|
||||
this._countdownTimer = null;
|
||||
this.updateSendBtnState(true);
|
||||
} else {
|
||||
// 更新按钮文本
|
||||
this.updateSendBtnState(false);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新发送按钮状态
|
||||
*/
|
||||
private updateSendBtnState(canSend: boolean): void {
|
||||
if (!this._nodeTab.SendBtn) return;
|
||||
|
||||
const label = this._nodeTab.SendBtn.getComponentInChildren(Label);
|
||||
if (label) {
|
||||
if (canSend) {
|
||||
label.string = "发送验证码";
|
||||
} else {
|
||||
label.string = `${this._countdown}秒后重试`;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: 可以设置按钮的可交互状态
|
||||
// const button = this._nodeTab.SendBtn.getComponent(Button);
|
||||
// if (button) {
|
||||
// button.interactable = canSend;
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击注册按钮
|
||||
*/
|
||||
private onClickRegister(): void {
|
||||
// 获取输入框
|
||||
const emailInput = this._nodeTab.EmailInput?.getComponent(EditBox);
|
||||
const passwordInput = this._nodeTab.PasswordInput?.getComponent(EditBox);
|
||||
const codeInput = this._nodeTab.CodeInput?.getComponent(EditBox);
|
||||
|
||||
if (!emailInput || !passwordInput || !codeInput) {
|
||||
console.error("未找到输入框");
|
||||
return;
|
||||
}
|
||||
|
||||
const email = emailInput.string.trim();
|
||||
const password = passwordInput.string.trim();
|
||||
const code = codeInput.string.trim();
|
||||
|
||||
// 验证输入
|
||||
if (!email) {
|
||||
console.log("请输入邮箱");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.isValidEmail(email)) {
|
||||
console.log("请输入有效的邮箱地址");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
if (!password) {
|
||||
console.log("请输入密码");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
if (password.length < 6) {
|
||||
console.log("密码长度不能少于6位");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
if (!code) {
|
||||
console.log("请输入验证码");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: 调用后端接口进行注册
|
||||
console.log("注册:", email, password, code);
|
||||
this.requestRegister(email, password, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用后端注册接口
|
||||
*/
|
||||
private requestRegister(email: string, password: string, code: string): void {
|
||||
// TODO: 实现后端注册接口调用
|
||||
// 示例:
|
||||
// const data = {
|
||||
// email: email,
|
||||
// password: password,
|
||||
// code: code
|
||||
// };
|
||||
// NetworkManager.request('/api/register', data, (response) => {
|
||||
// if (response.success) {
|
||||
// // 注册成功
|
||||
// console.log('注册成功');
|
||||
// // 关闭注册界面
|
||||
// this.close();
|
||||
// } else {
|
||||
// // 注册失败,显示错误信息
|
||||
// console.error('注册失败:', response.message);
|
||||
// }
|
||||
// });
|
||||
|
||||
console.log("TODO: 实现注册接口调用");
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击关闭按钮
|
||||
*/
|
||||
private onClickClose(): void {
|
||||
// 清理倒计时定时器
|
||||
if (this._countdownTimer) {
|
||||
clearInterval(this._countdownTimer);
|
||||
this._countdownTimer = null;
|
||||
}
|
||||
|
||||
// 关闭当前界面
|
||||
this.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证邮箱格式
|
||||
*/
|
||||
private isValidEmail(email: string): boolean {
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
return emailRegex.test(email);
|
||||
}
|
||||
|
||||
/**
|
||||
* 界面销毁时调用
|
||||
*/
|
||||
protected onDestroy(): void {
|
||||
// 清理倒计时定时器
|
||||
if (this._countdownTimer) {
|
||||
clearInterval(this._countdownTimer);
|
||||
this._countdownTimer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "565b780d-f431-4e60-aa02-73df95d28a88",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
import { _decorator, EditBox, Label } from "cc";
|
||||
import Utils from "../../../Main/Common/Utils";
|
||||
import li_BaseView from "../../../Main/Common/li_BaseView";
|
||||
import { GButton } from "../../../Main/Common/GButton";
|
||||
import { ViewManager } from "../../../Main/Manager/ViewManager";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**
|
||||
* 安全验证页面
|
||||
* 预制体位于 resources/loginPanel/SafeCheckPanel
|
||||
*/
|
||||
@ccclass("SafeCheckPanel")
|
||||
export class SafeCheckPanel extends li_BaseView {
|
||||
private _nodeTab: any = {};
|
||||
|
||||
// 验证码倒计时
|
||||
private _countdown: number = 0;
|
||||
private _countdownTimer: any = null;
|
||||
|
||||
/**
|
||||
* 组件初始化时调用
|
||||
*/
|
||||
onLoadCT(): void {
|
||||
// 解析节点,将子节点存储到 _nodeTab 中
|
||||
Utils.parseNode(this.node, this._nodeTab);
|
||||
|
||||
// 初始化UI
|
||||
this.initUI();
|
||||
|
||||
// 注册事件监听
|
||||
this.registerListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化UI
|
||||
*/
|
||||
private initUI(): void {
|
||||
// 初始化发送按钮状态
|
||||
this.updateSendBtnState(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册事件监听
|
||||
*/
|
||||
private registerListener(): void {
|
||||
// 绑定发送验证码按钮点击事件
|
||||
if (this._nodeTab.SendBtn) {
|
||||
GButton.BandClick(this._nodeTab.SendBtn, this.onClickSendCode, this);
|
||||
}
|
||||
|
||||
// 绑定确定按钮点击事件
|
||||
if (this._nodeTab.ConfirmBtn) {
|
||||
GButton.BandClick(this._nodeTab.ConfirmBtn, this.onClickConfirm, this);
|
||||
}
|
||||
|
||||
// 绑定关闭按钮点击事件
|
||||
if (this._nodeTab.CloseBtn) {
|
||||
GButton.BandClick(this._nodeTab.CloseBtn, this.onClickClose, this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击发送验证码按钮
|
||||
*/
|
||||
private onClickSendCode(): void {
|
||||
// 如果正在倒计时,不允许再次发送
|
||||
if (this._countdown > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取邮箱输入框
|
||||
const emailInput = this._nodeTab.EmailInput?.getComponent(EditBox);
|
||||
|
||||
if (!emailInput) {
|
||||
console.error("未找到邮箱输入框");
|
||||
return;
|
||||
}
|
||||
|
||||
const email = emailInput.string.trim();
|
||||
|
||||
// 验证邮箱
|
||||
if (!email) {
|
||||
console.log("请输入邮箱");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.isValidEmail(email)) {
|
||||
console.log("请输入有效的邮箱地址");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: 调用后端接口发送验证码
|
||||
console.log("发送验证码到:", email);
|
||||
this.requestSendCode(email);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用后端接口发送验证码
|
||||
*/
|
||||
private requestSendCode(email: string): void {
|
||||
// TODO: 实现后端发送验证码接口调用
|
||||
// 示例:
|
||||
// const data = { email: email, type: 'forgetPassword' };
|
||||
// NetworkManager.request('/api/sendCode', data, (response) => {
|
||||
// if (response.success) {
|
||||
// // 发送成功,开始倒计时
|
||||
// this.startCountdown();
|
||||
// } else {
|
||||
// // 发送失败,显示错误信息
|
||||
// console.error('发送验证码失败:', response.message);
|
||||
// }
|
||||
// });
|
||||
|
||||
console.log("TODO: 实现发送验证码接口调用");
|
||||
// 临时模拟发送成功,启动倒计时
|
||||
this.startCountdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始倒计时
|
||||
*/
|
||||
private startCountdown(): void {
|
||||
this._countdown = 60; // 60秒倒计时
|
||||
this.updateSendBtnState(false);
|
||||
|
||||
this._countdownTimer = setInterval(() => {
|
||||
this._countdown--;
|
||||
|
||||
if (this._countdown <= 0) {
|
||||
// 倒计时结束
|
||||
clearInterval(this._countdownTimer);
|
||||
this._countdownTimer = null;
|
||||
this.updateSendBtnState(true);
|
||||
} else {
|
||||
// 更新按钮文本
|
||||
this.updateSendBtnState(false);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新发送按钮状态
|
||||
*/
|
||||
private updateSendBtnState(canSend: boolean): void {
|
||||
if (!this._nodeTab.SendBtn) return;
|
||||
|
||||
const label = this._nodeTab.SendBtn.getComponentInChildren(Label);
|
||||
if (label) {
|
||||
if (canSend) {
|
||||
label.string = "发送验证码";
|
||||
} else {
|
||||
label.string = `${this._countdown}秒后重试`;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: 可以设置按钮的可交互状态
|
||||
// const button = this._nodeTab.SendBtn.getComponent(Button);
|
||||
// if (button) {
|
||||
// button.interactable = canSend;
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击确定按钮
|
||||
*/
|
||||
private onClickConfirm(): void {
|
||||
// 获取邮箱和验证码输入框
|
||||
const emailInput = this._nodeTab.EmailInput?.getComponent(EditBox);
|
||||
const codeInput = this._nodeTab.CodeInput?.getComponent(EditBox);
|
||||
|
||||
if (!emailInput || !codeInput) {
|
||||
console.error("未找到邮箱或验证码输入框");
|
||||
return;
|
||||
}
|
||||
|
||||
const email = emailInput.string.trim();
|
||||
const code = codeInput.string.trim();
|
||||
|
||||
// 验证输入
|
||||
if (!email) {
|
||||
console.log("请输入邮箱");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.isValidEmail(email)) {
|
||||
console.log("请输入有效的邮箱地址");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
if (!code) {
|
||||
console.log("请输入验证码");
|
||||
// TODO: 显示提示信息
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: 调用后端接口验证验证码
|
||||
console.log("验证验证码:", email, code);
|
||||
this.requestVerifyCode(email, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用后端接口验证验证码
|
||||
*/
|
||||
private requestVerifyCode(email: string, code: string): void {
|
||||
// TODO: 实现后端验证验证码接口调用
|
||||
// 示例:
|
||||
// const data = {
|
||||
// email: email,
|
||||
// code: code,
|
||||
// type: 'forgetPassword'
|
||||
// };
|
||||
// NetworkManager.request('/api/verifyCode', data, (response) => {
|
||||
// if (response.success) {
|
||||
// // 验证成功,跳转到修改密码页面
|
||||
// this.openNewPasswordPanel(email, code);
|
||||
// } else {
|
||||
// // 验证失败,显示错误信息
|
||||
// console.error('验证码错误:', response.message);
|
||||
// // TODO: 显示错误提示
|
||||
// }
|
||||
// });
|
||||
|
||||
console.log("TODO: 实现验证验证码接口调用");
|
||||
// 临时模拟验证成功,跳转到修改密码页面
|
||||
this.openNewPasswordPanel(email, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开修改密码页面
|
||||
*/
|
||||
private openNewPasswordPanel(email: string, code: string): void {
|
||||
// 关闭当前页面
|
||||
this.close();
|
||||
|
||||
// 打开修改密码页面,并传递邮箱和验证码信息
|
||||
ViewManager.I.openMainView("loginPanel/NewPasswordPanel", {
|
||||
email: email,
|
||||
code: code,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击关闭按钮
|
||||
*/
|
||||
private onClickClose(): void {
|
||||
// 清理倒计时定时器
|
||||
if (this._countdownTimer) {
|
||||
clearInterval(this._countdownTimer);
|
||||
this._countdownTimer = null;
|
||||
}
|
||||
|
||||
// 关闭当前界面
|
||||
this.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证邮箱格式
|
||||
*/
|
||||
private isValidEmail(email: string): boolean {
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
return emailRegex.test(email);
|
||||
}
|
||||
|
||||
/**
|
||||
* 界面销毁时调用
|
||||
*/
|
||||
protected onDestroy(): void {
|
||||
// 清理倒计时定时器
|
||||
if (this._countdownTimer) {
|
||||
clearInterval(this._countdownTimer);
|
||||
this._countdownTimer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "d3dfdbed-8fb1-4348-b9d4-32c6b9406310",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"ver": "1.1.50",
|
||||
"importer": "prefab",
|
||||
"imported": true,
|
||||
"uuid": "6972298a-8553-4fe8-8296-06f6d886d450",
|
||||
"uuid": "aa097cc9-b234-4077-8b2e-e543767ca13f",
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
|
||||
@@ -27,18 +27,21 @@
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 154
|
||||
},
|
||||
{
|
||||
"__id__": 156
|
||||
},
|
||||
{
|
||||
"__id__": 158
|
||||
},
|
||||
{
|
||||
"__id__": 160
|
||||
},
|
||||
{
|
||||
"__id__": 162
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 160
|
||||
"__id__": 164
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@@ -284,23 +287,23 @@
|
||||
"__id__": 121
|
||||
},
|
||||
{
|
||||
"__id__": 133
|
||||
"__id__": 135
|
||||
},
|
||||
{
|
||||
"__id__": 141
|
||||
"__id__": 143
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 149
|
||||
"__id__": 151
|
||||
},
|
||||
{
|
||||
"__id__": 151
|
||||
"__id__": 153
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 153
|
||||
"__id__": 155
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@@ -3074,10 +3077,13 @@
|
||||
},
|
||||
{
|
||||
"__id__": 130
|
||||
},
|
||||
{
|
||||
"__id__": 132
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 132
|
||||
"__id__": 134
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@@ -3343,6 +3349,62 @@
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "e1FEs4AnFF84EGMms/npks"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Button",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 121
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 133
|
||||
},
|
||||
"clickEvents": [],
|
||||
"_interactable": true,
|
||||
"_transition": 0,
|
||||
"_normalColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_hoverColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 211,
|
||||
"g": 211,
|
||||
"b": 211,
|
||||
"a": 255
|
||||
},
|
||||
"_pressedColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_disabledColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 124,
|
||||
"g": 124,
|
||||
"b": 124,
|
||||
"a": 255
|
||||
},
|
||||
"_normalSprite": null,
|
||||
"_hoverSprite": null,
|
||||
"_pressedSprite": null,
|
||||
"_disabledSprite": null,
|
||||
"_duration": 0.1,
|
||||
"_zoomScale": 1.2,
|
||||
"_target": null,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "36gJ21lkFNkIiRuVYHtlnX"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
@@ -3367,18 +3429,18 @@
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 134
|
||||
},
|
||||
{
|
||||
"__id__": 136
|
||||
},
|
||||
{
|
||||
"__id__": 138
|
||||
},
|
||||
{
|
||||
"__id__": 140
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 140
|
||||
"__id__": 142
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@@ -3415,11 +3477,11 @@
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 133
|
||||
"__id__": 135
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 135
|
||||
"__id__": 137
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
@@ -3443,11 +3505,11 @@
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 133
|
||||
"__id__": 135
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 137
|
||||
"__id__": 139
|
||||
},
|
||||
"_customMaterial": null,
|
||||
"_srcBlendFactor": 2,
|
||||
@@ -3488,11 +3550,11 @@
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 133
|
||||
"__id__": 135
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 139
|
||||
"__id__": 141
|
||||
},
|
||||
"clickEvents": [],
|
||||
"_interactable": true,
|
||||
@@ -3562,18 +3624,18 @@
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 142
|
||||
},
|
||||
{
|
||||
"__id__": 144
|
||||
},
|
||||
{
|
||||
"__id__": 146
|
||||
},
|
||||
{
|
||||
"__id__": 148
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 148
|
||||
"__id__": 150
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@@ -3610,11 +3672,11 @@
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 141
|
||||
"__id__": 143
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 143
|
||||
"__id__": 145
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
@@ -3638,11 +3700,11 @@
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 141
|
||||
"__id__": 143
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 145
|
||||
"__id__": 147
|
||||
},
|
||||
"_customMaterial": null,
|
||||
"_srcBlendFactor": 2,
|
||||
@@ -3709,11 +3771,11 @@
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 141
|
||||
"__id__": 143
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 147
|
||||
"__id__": 149
|
||||
},
|
||||
"clickEvents": [],
|
||||
"_interactable": true,
|
||||
@@ -3782,7 +3844,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 150
|
||||
"__id__": 152
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
@@ -3810,7 +3872,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 152
|
||||
"__id__": 154
|
||||
},
|
||||
"_customMaterial": null,
|
||||
"_srcBlendFactor": 2,
|
||||
@@ -3868,7 +3930,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 155
|
||||
"__id__": 157
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
@@ -3896,7 +3958,7 @@
|
||||
},
|
||||
"_enabled": false,
|
||||
"__prefab": {
|
||||
"__id__": 157
|
||||
"__id__": 159
|
||||
},
|
||||
"_customMaterial": null,
|
||||
"_srcBlendFactor": 2,
|
||||
@@ -3941,7 +4003,7 @@
|
||||
},
|
||||
"_enabled": false,
|
||||
"__prefab": {
|
||||
"__id__": 159
|
||||
"__id__": 161
|
||||
},
|
||||
"_type": 3,
|
||||
"_inverted": false,
|
||||
@@ -3953,6 +4015,25 @@
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "ccqvpyXtxAKoDFDkk+CXDL"
|
||||
},
|
||||
{
|
||||
"__type__": "ce7e3FnjthOXJIbDJGurzbE",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 163
|
||||
},
|
||||
"m_rootNode": null,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "d5Jg3zVgVPlKq3fn8Mi7K2"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
@@ -3962,6 +4043,7 @@
|
||||
"__id__": 0
|
||||
},
|
||||
"fileId": "06liSCoLBIbI3C6sNktTBJ",
|
||||
"instance": null,
|
||||
"targetOverrides": null
|
||||
}
|
||||
]
|
||||
@@ -35,10 +35,13 @@
|
||||
},
|
||||
{
|
||||
"__id__": 132
|
||||
},
|
||||
{
|
||||
"__id__": 134
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 134
|
||||
"__id__": 136
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@@ -3274,6 +3277,25 @@
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "16wyEMuj1Meq5zmjtv4o5c"
|
||||
},
|
||||
{
|
||||
"__type__": "e11c66hsnpOSYSUuvGlNPx1",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 135
|
||||
},
|
||||
"m_rootNode": null,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "b9CUMt3LlG0J8Jsuq+d3u5"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
@@ -3283,6 +3305,7 @@
|
||||
"__id__": 0
|
||||
},
|
||||
"fileId": "e8L1H16d9HP6FYp51BeRWn",
|
||||
"instance": null,
|
||||
"targetOverrides": null
|
||||
}
|
||||
]
|
||||
@@ -35,10 +35,13 @@
|
||||
},
|
||||
{
|
||||
"__id__": 204
|
||||
},
|
||||
{
|
||||
"__id__": 206
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 206
|
||||
"__id__": 208
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@@ -5101,6 +5104,25 @@
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "d3J11kwgJNxr/AEbd2kVpm"
|
||||
},
|
||||
{
|
||||
"__type__": "565b7gN9DFOYKoCc9+V0oqI",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 207
|
||||
},
|
||||
"m_rootNode": null,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "335TfMiNxP2bYMZhXg1isT"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
@@ -5110,6 +5132,7 @@
|
||||
"__id__": 0
|
||||
},
|
||||
"fileId": "72g0/xfadLzKbZU8hLeUmn",
|
||||
"instance": null,
|
||||
"targetOverrides": null
|
||||
}
|
||||
]
|
||||
@@ -35,10 +35,13 @@
|
||||
},
|
||||
{
|
||||
"__id__": 158
|
||||
},
|
||||
{
|
||||
"__id__": 160
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 160
|
||||
"__id__": 162
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@@ -3962,6 +3965,25 @@
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "beWC4jbyNGzplzxhBUPZzq"
|
||||
},
|
||||
{
|
||||
"__type__": "d3dfdvtj7FDSLnUMsa5QGMQ",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 161
|
||||
},
|
||||
"m_rootNode": null,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "36C8lniCNDfLQLX2kQVYKP"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
@@ -3971,6 +3993,7 @@
|
||||
"__id__": 0
|
||||
},
|
||||
"fileId": "342wdtF7JC273lhsG3dRQw",
|
||||
"instance": null,
|
||||
"targetOverrides": null
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user