import { _decorator, Component, Node, Prefab, instantiate, JsonAsset, Label, RichText, EventHandler, UITransform, ScrollView, Sprite } from 'cc'; import InfiniteCell from '../core/InfiniteList/InfiniteCell'; import { IFDataSource, InfiniteList } from '../core/InfiniteList/InfiniteList'; import { ResourcesUtils } from '../core/resourceManager/ResourcesUtils'; import { ConfigData } from '../Data/ConfigData'; import { g } from '../Data/g'; import { DiamondWithItem } from '../Item/DiamondWithItem'; import { NoviceWindow } from './NoviceWindow'; const { ccclass, property } = _decorator; @ccclass('DiamondWithWin') export class DiamondWithWin extends Component implements IFDataSource { @property({ tooltip: "list列表", type: InfiniteList }) public list: InfiniteList; @property({ tooltip: "Item预制体", type: Prefab }) item: Prefab; @property({ tooltip: "神石总值文本", type: Label }) public diamondTxt: Label; @property({ tooltip: "可兑换金币金额", type: RichText }) public moneyTxt: RichText; @property({ tooltip: "item回调,刷新界面", type: EventHandler }) public initBack: EventHandler; // @property({ tooltip: "新手手势", type: Sprite }) // handSprite: Sprite; public withConfig: any; public prefabHeight: number = 0; async start() { if (NoviceWindow.isNovicing) { NoviceWindow.isNovicing = false; // this.handSprite.node.active = true; // this.list.getComponent(ScrollView).enabled = false; } let prefab = instantiate(this.item); this.prefabHeight = prefab.getComponent(UITransform).height; // this.withConfig = await (await ResourcesUtils.load("Configs/diamondWithdraw", JsonAsset, this.node)).json; this.withConfig = ConfigData.configMap.get("diamondWithdraw"); this.initUI(); for (let i = 0; i < this.withConfig.length; i++) { this.withConfig[i].backFun = this.initBack; } this.list.Init(this); this.list.Reload(true); } update() { // if (this.handSprite.node.active && !NoviceWindow.isNovicing) { // this.handSprite.node.active = false; // } } public async initUI() { this.moneyTxt.string = "" + g.userData.diamond / ConfigData.configMap.get("systemConfig").moneyRate + " 元"; this.diamondTxt.string = g.userData.diamond + ""; } public updateUI() { this.initUI(); this.list.Refresh(); this.list.getComponent(ScrollView).enabled = true; } //#region IFDataSource public GetCellNumber(): number { return this.withConfig.length; } public GetCellIdentifer(dataIndex: number): string { return "DiamondWithItem"; } public GetCellSize(dataIndex: number): number { return this.prefabHeight; } public GetCellView(dataIndex: number, identifier?: string): DiamondWithItem { let node = instantiate(this.item); return node.getComponent(DiamondWithItem); } public GetCellData?(dataIndex: number): any { return this.withConfig[dataIndex]; } //#endregion }