feat: 完善挑战结算页面
This commit is contained in:
55
assets/prefabs/PagePKEnd.ts
Normal file
55
assets/prefabs/PagePKEnd.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { _decorator, Button, Node } from 'cc';
|
||||
import { BaseView } from 'db://assets/scripts/core/BaseView';
|
||||
import { ViewManager } from 'db://assets/scripts/core/ViewManager';
|
||||
import { ShareManager } from 'db://assets/scripts/utils/ShareManager';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('PagePKEnd')
|
||||
export class PagePKEnd extends BaseView {
|
||||
@property({ type: Node, tooltip: '返回首页按钮' })
|
||||
settingButton: Node | null = null;
|
||||
|
||||
onViewLoad(): void {
|
||||
this._resolveNodes();
|
||||
this._bindEvents();
|
||||
}
|
||||
|
||||
onViewShow(): void {
|
||||
console.log('[PagePKEnd] onViewShow');
|
||||
}
|
||||
|
||||
onViewDestroy(): void {
|
||||
this._unbindEvents();
|
||||
}
|
||||
|
||||
private _resolveNodes(): void {
|
||||
if (!this.settingButton || !this.settingButton.isValid) {
|
||||
this.settingButton = this.node.getChildByName('SettingButton');
|
||||
}
|
||||
|
||||
if (!this.settingButton) {
|
||||
console.warn('[PagePKEnd] 未找到 SettingButton 节点');
|
||||
}
|
||||
}
|
||||
|
||||
private _bindEvents(): void {
|
||||
const button = this.settingButton?.getComponent(Button);
|
||||
if (!button) {
|
||||
console.warn('[PagePKEnd] SettingButton 缺少 Button 组件');
|
||||
return;
|
||||
}
|
||||
|
||||
this.settingButton?.on(Button.EventType.CLICK, this._onHomeClick, this);
|
||||
}
|
||||
|
||||
private _unbindEvents(): void {
|
||||
if (this.settingButton && this.settingButton.isValid) {
|
||||
this.settingButton.off(Button.EventType.CLICK, this._onHomeClick, this);
|
||||
}
|
||||
}
|
||||
|
||||
private _onHomeClick(): void {
|
||||
ShareManager.instance.clearShareMode();
|
||||
ViewManager.instance.replace('PageHome');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user