| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import { _decorator, Component, Prefab, instantiate, UITransform } from 'cc';
- import { IFDataSource, InfiniteList } from '../../core/InfiniteList/InfiniteList';
- import { Http } from '../../core/net/Http';
- import { g } from '../../Data/g';
- import { platform } from '../../Data/platform';
- import { EachWindowItem } from './EachWindowItem';
- const { ccclass, property } = _decorator;
- @ccclass('EachWindow')
- export class EachWindow extends Component implements IFDataSource {
- @property({ type: Http, tooltip: "Http组件" }) http: Http;
- @property({ type: InfiniteList, tooltip: "列表组件" }) list: InfiniteList;
- @property({ type: Prefab, tooltip: "列表cell预制体" }) cell: Prefab;
- private prefabHeight: number;
- async start() {
- let prefab = instantiate(this.cell);
- this.prefabHeight = prefab.getComponent(UITransform).height;
- prefab.destroy();
- this.list.Init(this);
- }
- update() {
- if (g.downLoadData.needCheck) {
- g.downLoadData.needCheck = false;
- this.list.Reload();
- }
- }
- //#region IFDataSource
- public GetCellData(dataIndex: number): any {
- return g.downLoadData.recommendData[dataIndex];
- }
- public GetCellNumber(): number {
- return g.downLoadData.recommendData.length;
- }
- public GetCellSize(index: number): number {
- return this.prefabHeight ? this.prefabHeight : 100;
- }
- public GetCellView(index: number): EachWindowItem {
- let node = instantiate(this.cell);
- return node.getComponent(EachWindowItem);
- }
- public GetCellIdentifer(index: number): string {
- return "taskWindowItem";
- }
- //#endregion
- }
|