UIAirdropItem.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import auto_airdropItem from "../../../ui/uidata/Interface/auto_airdropItem";
  2. import UIBase from "../../../framework/ui/UIBase";
  3. import UIHelp from "../../../framework/ui/UIHelp";
  4. import bundleManager from "../../../manager/bundleManager";
  5. const {ccclass, menu, property} = cc._decorator;
  6. @ccclass
  7. @menu("UI/Interface/UIAirdropItem")
  8. export default class UIAirdropItem extends UIBase {
  9. ui: auto_airdropItem = null;
  10. protected static prefabUrl = "Interface/airdropItem";
  11. protected static className = "UIAirdropItem";
  12. @property(cc.Label)
  13. itemNameLabel: cc.Label = null;
  14. @property(cc.Sprite)
  15. itemSprite: cc.Sprite = null;
  16. @property(cc.Label)
  17. numsLabel: cc.Label = null;
  18. @property(cc.Sprite)
  19. bgSprite: cc.Sprite = null;
  20. @property(cc.SpriteFrame)
  21. bgSpriteFrames: cc.SpriteFrame []= [];
  22. onUILoad() {
  23. this.ui = this.node.addComponent(auto_airdropItem);
  24. }
  25. onShow() {
  26. }
  27. /**
  28. *
  29. * @param info 依赖item表的数据
  30. * @param type
  31. * @param showNums
  32. */
  33. refresh(info: any, type?: number, showNums = true) {
  34. this.itemNameLabel.string = info.itemname;
  35. if (info.resPath1) {
  36. bundleManager.setBundleFrame('UI', info.resPath1, this.itemSprite.node);
  37. }
  38. if (type != null){
  39. this.bgSprite.spriteFrame = this.bgSpriteFrames[type];
  40. }
  41. if (!showNums){
  42. this.itemNameLabel.string = info.detail;
  43. this.numsLabel.node.active = false;
  44. }else {
  45. this.numsLabel.string = `X${info.nums}`;
  46. }
  47. }
  48. refreshRole(info: any) {
  49. this.itemNameLabel.string = info.itemname;
  50. this.numsLabel.string = `X${info.nums}`;
  51. if (info.roleRes) {
  52. bundleManager.setBundleFrame('UI', `man/${info.roleRes}`, this.itemSprite.node);
  53. }
  54. }
  55. onHide() {
  56. }
  57. onStart() {
  58. }
  59. onClose() {
  60. UIHelp.CloseUI(UIAirdropItem);
  61. }
  62. }