GetGoodPanel.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { _decorator, assetManager, Component, ImageAsset, Node, RichText, Sprite, SpriteFrame, Texture2D } from 'cc';
  2. import { GetAwardVo } from '../../game/pack/GetAwardVo';
  3. import { gameManager } from '../../game/gameManager';
  4. const { ccclass, property } = _decorator;
  5. /**
  6. * 获取礼物界面
  7. */
  8. @ccclass('GetGoodPanel')
  9. export class GetGoodPanel extends Component {
  10. @property(Sprite)
  11. wupImg:Sprite = null!;
  12. @property(RichText)
  13. wupTitle:RichText = null!;
  14. @property(Node)
  15. btnLingqu:Node =null!;
  16. @property(Node)
  17. btnQure:Node = null!;
  18. private _data:GetAwardVo =null!;
  19. // [1]
  20. // dummy = '';
  21. // [2]
  22. // @property
  23. // serializableDummy = 0;
  24. start () {
  25. // [3]
  26. }
  27. // update (deltaTime: number) {
  28. // // [4] <color=#2D3461>蛋仔盲盒精致版</color><color=#FF5C00>*1</color>
  29. // }
  30. public SetData(data:GetAwardVo){
  31. if(!data)return;
  32. if(!data.id)return;
  33. console.log("设置显示的数据",data);
  34. this._data=data;
  35. this.wupTitle.string = `<color=#2D3461>${data.name}</color><color=#FF5C00>*${data.num}</color>`;
  36. const remoteUrl=data.icon?data.icon:"";
  37. var thiss=this;
  38. if(remoteUrl.length>10){
  39. assetManager.loadRemote<ImageAsset>(remoteUrl, {ext: '.png'}, function (err, imageAsset) {
  40. const spriteFrame = new SpriteFrame();
  41. const texture = new Texture2D();
  42. texture.image = imageAsset;
  43. spriteFrame.texture = texture;
  44. thiss.wupImg.spriteFrame=spriteFrame;
  45. });
  46. }
  47. const type=data.basicType?data.basicType:0;
  48. this.btnLingqu.active=type==1;
  49. this.btnQure.active=type==0;
  50. }
  51. public btnClose(){
  52. this.node.active=false;
  53. }
  54. public btnLingQue(){
  55. let http=gameManager.Instance.golabMemory.isReplse?"http://star.mstardance.com":"http://teststar.mstardance.com";
  56. let url=`${http}/starmini/address.html?id=${this._data.id}&icon=${this._data.icon}&name=${this._data.name}`;
  57. window.location.href = url;
  58. }
  59. }