feat(任务主页): 增加标签页切换功能

在 home_active 方法中调用 switch_tab 以默认激活首页标签
重构 btn_func 方法,根据传入参数切换不同标签页
新增 switch_tab 方法,统一管理标签页与对应按钮的激活状态
This commit is contained in:
panw
2026-04-01 16:15:32 +08:00
parent ed0d08b804
commit b92d5d931d
2 changed files with 868 additions and 692 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -55,7 +55,7 @@ export class MissionHomeComp extends CCComp {
home_active(){
this.uodate_data()
this.node.active=true
this.switch_tab('home')
}
uodate_data(){
@@ -63,8 +63,24 @@ export class MissionHomeComp extends CCComp {
isWxClient(){
return typeof wx !== 'undefined' && typeof (wx as any).getSystemInfoSync === 'function';
}
btn_func(e:string,data:any){
btn_func(e: any, data: string){
if (['home', 'hero', 'rank'].includes(data)) {
this.switch_tab(data);
}
}
switch_tab(tab: string) {
if (this.heros_page) this.heros_page.active = tab === 'hero';
if (this.rank_page) this.rank_page.active = tab === 'rank';
const setBtnActive = (btn: Node, isActive: boolean) => {
const activeNode = btn?.getChildByName('active');
if (activeNode) activeNode.active = isActive;
}
setBtnActive(this.home_btn, tab === 'home');
setBtnActive(this.hero_btn, tab === 'hero');
setBtnActive(this.rank_btn, tab === 'rank');
}