difenduandada
2024-12-31 34abe6963b344c882358274957f4b992456fee40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"use strict";
cc._RF.push(module, 'd26faE6G8ZLraoQcJNfkcq7', 'action_func_award_Item');
// Scripts/mod/action/view/action_func_award_Item.js
 
"use strict";
 
var PathTool = require("pathtool");
 
var FuncAwardItem = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("action", "action_fund_item");
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {},
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    var self = this;
    self.container = self.root_wnd.getChildByName("container");
    var image_bg_sp = self.container.getChildByName("image_bg").getComponent(cc.Sprite);
    this.loadRes(PathTool.getUIIconPath("actionfund", "actionfund_1002"), function (res) {
      image_bg_sp.spriteFrame = res;
    }.bind(this));
    self.txt_time = self.container.getChildByName("txt_time");
    self.txt_time.color = new cc.Color(100, 50, 35);
 
    if (this.data) {
      this.setData(this.data);
    }
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {},
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow(params) {},
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  setData: function setData(data) {
    if (!data) return;
    var self = this;
    this.data = data;
    if (this.root_wnd == null) return;
    self.txt_time.getComponent(cc.Label).string = "累计" + (data.day || 1) + "天";
    var bid = data.award[0][0];
    var num = data.award[0][1];
 
    if (!self.item_node) {
      self.item_node = ItemsPool.getInstance().getItem("backpack_item");
      self.item_node.setDefaultTip(true, false);
      self.item_node.setPosition(0, 25);
      self.item_node.setParent(this.container);
      this.item_node.initConfig(false, 0.9, false, true);
      this.item_node.show();
    }
 
    self.item_node.setData({
      bid: bid,
      num: num
    });
  },
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {
    if (this.item_node) {
      this.item_node.deleteMe();
    }
  }
});
 
cc._RF.pop();