GetGoodPanel.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. this.wupImg.spriteFrame=null;
  39. if(remoteUrl.length>10){
  40. assetManager.loadRemote<ImageAsset>(remoteUrl, function (err, imageAsset) {
  41. if(err){
  42. return console.warn("ImageAssert load failed, err:" + err.message,remoteUrl);
  43. }
  44. thiss.wupImg.spriteFrame = SpriteFrame.createWithImage(imageAsset);
  45. // const spriteFrame = new SpriteFrame();
  46. // const texture = new Texture2D();
  47. // texture.image = imageAsset;
  48. // spriteFrame.texture = texture;
  49. // thiss.wupImg.spriteFrame=spriteFrame;
  50. });
  51. }
  52. const type=data.basicType?data.basicType:0;
  53. this.btnLingqu.active=type==1;
  54. this.btnQure.active=type==0;
  55. }
  56. public btnClose(){
  57. this.wupImg.spriteFrame=null;
  58. this.node.active=false;
  59. }
  60. public btnLingQue(){
  61. let http=gameManager.Instance.golabMemory.isReplse?"http://star.mstardance.com":"http://teststar.mstardance.com";
  62. let url=`${http}/starmini/address.html?id=${this._data.id}&icon=${this._data.icon}&name=${this._data.name}`;
  63. window.location.href = url;
  64. }
  65. }