import { _decorator, assetManager, Component, ImageAsset, Node, RichText, Sprite, SpriteFrame, Texture2D } from 'cc'; import { GetAwardVo } from '../../game/pack/GetAwardVo'; import { gameManager } from '../../game/gameManager'; const { ccclass, property } = _decorator; /** * 获取礼物界面 */ @ccclass('GetGoodPanel') export class GetGoodPanel extends Component { @property(Sprite) wupImg:Sprite = null!; @property(RichText) wupTitle:RichText = null!; @property(Node) btnLingqu:Node =null!; @property(Node) btnQure:Node = null!; private _data:GetAwardVo =null!; // [1] // dummy = ''; // [2] // @property // serializableDummy = 0; start () { // [3] } // update (deltaTime: number) { // // [4] 蛋仔盲盒精致版*1 // } public SetData(data:GetAwardVo){ if(!data)return; if(!data.id)return; console.log("设置显示的数据",data); this._data=data; this.wupTitle.string = `${data.name}*${data.num}`; const remoteUrl=data.icon?data.icon:""; var thiss=this; this.wupImg.spriteFrame=null; if(remoteUrl.length>10){ assetManager.loadRemote(remoteUrl, function (err, imageAsset) { if(err){ return console.warn("ImageAssert load failed, err:" + err.message,remoteUrl); } thiss.wupImg.spriteFrame = SpriteFrame.createWithImage(imageAsset); // const spriteFrame = new SpriteFrame(); // const texture = new Texture2D(); // texture.image = imageAsset; // spriteFrame.texture = texture; // thiss.wupImg.spriteFrame=spriteFrame; }); } const type=data.basicType?data.basicType:0; this.btnLingqu.active=type==1; this.btnQure.active=type==0; } public btnClose(){ this.wupImg.spriteFrame=null; this.node.active=false; } public btnLingQue(){ let http=gameManager.Instance.golabMemory.isReplse?"http://star.mstardance.com":"http://teststar.mstardance.com"; let url=`${http}/starmini/address.html?id=${this._data.id}&icon=${this._data.icon}&name=${this._data.name}`; window.location.href = url; } }