| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import { _decorator, Button, Component, Label, Node, SpriteFrame, Toggle } from 'cc';
- import { ui_rank_item } from './ui_rank_item';
- import List from '../../scripts/Component/List/List';
- import { Transmission } from '../../scripts/Component/data/Transmission';
- const { ccclass, property } = _decorator;
- type TransmissionType = {
- getRankByType:(type: number, cb?: (data: any, me: any) => void)=>void
- getNickName:(data: any)=>string
- }
- let type: number = 1;
- @ccclass('Layout_Rank')
- export class Layout_Rank extends Component {
- private _data: any;
- @property(Transmission)
- transmission: Transmission = null
- @property(Node)
- btnRank1: Node;
- @property(Node)
- btnRank2: Node;
- //列表
- @property(List)
- list: List = null;
- @property(ui_rank_item)
- me: ui_rank_item;
- onListRender(item: any, idx: number) {
- this.onList(item, idx);
- }
- showMe(data) {
- this.me.getNickName = this.transmission.data.getNickName
- this.me.node.active = true
- console.log("ME DATA:", data);
- this.me.showMe(data.rank, data)
- }
- protected start(): void {
- this.transmission.onSave(() => {
- this.btnRank1.on(Node.EventType.TOUCH_END, () => this.onType(2), this)
- this.btnRank2.on(Node.EventType.TOUCH_END, () => this.onType(1), this)
- this.showType();
- })
- }
- private onType(t: number): void {
- if (type == t) return;
- type = t;
- this.showType();
- }
- private showType(): void {
- //显示
- // let layout = this.layout as Layout_Rank;
- this.btnRank1.active = type == 1;
- this.btnRank2.active = type == 2;
- this.me.node.active = false;
- // //
- this.list.numItems = 0;
- let transmission = this.transmission.data as TransmissionType
-
- transmission.getRankByType(type,(data,me)=>{
-
- this._data = data;
- this.list.numItems = this._data.length;
- if(me){
- this.showMe(me)
- }
- })
- }
- public onList(item: Node, index: number) {
- let uiItem = item.getComponent(ui_rank_item)
- let transmission = this.transmission.data as TransmissionType
- uiItem.getNickName = transmission.getNickName;
- uiItem.showInfo(index, type, this._data[index]);
- };
- }
|