feat(任务主页): 增加标签页切换功能
在 home_active 方法中调用 switch_tab 以默认激活首页标签 重构 btn_func 方法,根据传入参数切换不同标签页 新增 switch_tab 方法,统一管理标签页与对应按钮的激活状态
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -55,7 +55,7 @@ export class MissionHomeComp extends CCComp {
|
|||||||
home_active(){
|
home_active(){
|
||||||
this.uodate_data()
|
this.uodate_data()
|
||||||
this.node.active=true
|
this.node.active=true
|
||||||
|
this.switch_tab('home')
|
||||||
}
|
}
|
||||||
uodate_data(){
|
uodate_data(){
|
||||||
|
|
||||||
@@ -63,8 +63,24 @@ export class MissionHomeComp extends CCComp {
|
|||||||
isWxClient(){
|
isWxClient(){
|
||||||
return typeof wx !== 'undefined' && typeof (wx as any).getSystemInfoSync === 'function';
|
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');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user