import { _decorator, Toggle,Node } from "cc"; import { GameUILayers, gui } from "../../../core/ui/ui"; import ui_base from "../../../core/ui/ui_base"; import { UIWaiting } from "../../../module_basic/ui_waiting/UIWaiting"; import { ModuleDef } from "../../../Scripts/ModuleDef"; import { Layout_Rank } from "./Layout_Rank"; import { UI_Rank_Item } from "./UI_Rank_Item"; import { ani_ui } from "../UI_Main/UI_Main"; import { Hall } from "../../hall/Hall"; const { ccclass, property } = _decorator; type page = 1 | 2;//1总榜2好友榜 let type: page = 1; @ccclass('UI_Rank') export class UI_Rank extends ui_base { private _owner: { head: string, nickName: string, score: number, userId: number, [key: string]: any }; private _data: { head: string, nickName: string, score: number, userId: number, [key: string]: any }[]; _openContext: any; constructor() { super(ModuleDef.GAME, 'ui/UI_Rank/Rank', GameUILayers.HUD, Layout_Rank); } protected onCreated() { const layout = this.getLayout(); ani_ui(layout.Close_Btn.node.parent); this.onButtonEvent(layout.Close_Btn, async (button: any) => { //关闭设置界面 gui.close(UI_Rank); }, this); layout.onList1 = (item: Node, index: number) => { item.getComponent(UI_Rank_Item).showInfo(index + 1, type, this._data[index], false); } layout.onList2 = (item: Node, index: number) => { // item.getComponent(ui_skin_block).showInfo(index + 1, this._data2[index]); } layout.Rank_Toggle_1.isChecked = type == 1; layout.Rank_Toggle_2.isChecked = type == 2; this.show(); this.onToggleEvent(layout.Rank_Toggle_1, (tg: Toggle, i: page) => { if (tg.isChecked) this.show(i) }, this, 1); this.onToggleEvent(layout.Rank_Toggle_2, (tg: Toggle, i: page) => { if (tg.isChecked) this.show(i) }, this, 2); } private async show(t?: null | page) { const layout = this.getLayout(); if (t != null) { if (t == type) return; type = t; // button_sound(); } layout.Rank_Toggle_1.isChecked = type == 1; layout.Rank_Toggle_2.isChecked = type == 2; if (type == 1 || t == null) { await gui.show(UIWaiting); layout.list1.node.active = true; layout.list2.node.active = false; layout.list1.numItems = 0; const d = await Hall.getInstance().player.get_rank_floor(); this._data = d.list; this._owner = d.owner; let index = d.index; layout.list1.numItems = this._data.length; if (!this._owner) { this._owner = { head: Hall.getInstance().player.avatarUrl, nickName: Hall.getInstance().player.nickName, score: 0, userId: 0, province: Hall.getInstance().player.user_info.province }; } layout.own1_item.showInfo(index, type, this._owner, true); gui.close(UIWaiting); } if (type == 2) { await gui.show(UIWaiting); layout.list2.node.active = true; layout.list1.node.active = false; layout.list2.numItems = 0; const d = await Hall.getInstance().player.get_rank_floor(); this._data = d.list; this._owner = d.owner; let index = d.index; layout.list2.numItems = this._data.length; if (!this._owner) { this._owner = { head: Hall.getInstance().player.avatarUrl, nickName: Hall.getInstance().player.nickName, score: 0, userId: 0, province: Hall.getInstance().player.user_info.province }; } layout.own2_item.showInfo(index, type, this._owner, true); gui.close(UIWaiting); } } }