import { _decorator, Component, game, Label, Node, Sprite } from 'cc'; import { UtilsPanel } from '../../scene/script/UtilsPanel'; import { ViewItemPro } from '../../scene/script/components/ViewItemPro'; import { nav_info } from '../../scene/script/NavInfo'; import { Pay, ShopData } from './Pay'; import { UtilsFormat } from '../../scene/script/UtilsFormat'; const { ccclass } = _decorator; @ccclass('ItemPay') export class ItemPay extends ViewItemPro { private sp_icon: Sprite = null; private lb_count: Label = null; private money = 0; private gold = 0; protected onLoad(){ UtilsPanel.getAllNeedCom(this, this.node, false); UtilsPanel.addBtnEvent(this.node, this.onClick, this); } public init(data:any, index: number, p0?: any): void { let p = Pay.data_shop; if(index == p.DefaultPrice.length){ this.money = -1; this.lb_count.string = "أدخل المبلغ"; index = 99; } else{ this.money = p.DefaultPrice[index]; this.gold = Pay.clacGold(this.money); this.lb_count.string = UtilsFormat.formatMoney(this.gold); } if(index > 4 && this.money != -1)index = 4; UtilsPanel.setItemIcon(nav_info.bundle, "texture/1"+index+"/spriteFrame", this.sp_icon); } public onClick(){ if(this.money == -1){ nav_info.scene.showByUrl("prefab/paycustom"); } else{ game.emit("select_item", this.money, this.node); } } }