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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
"use strict";
cc._RF.push(module, '8434eOqrx1E85rTPOvfwOkV', 'action_seven_login_item_panel');
// Scripts/mod/action/view/action_seven_login_item_panel.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     七天登录活动单个
// <br/>Create: 2019-04-17 16:29:20
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var Action_seven_login_itemPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("action", "action_seven_login_item");
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {
    this.status = 1;
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    this.main_container = this.root_wnd.getChildByName("main_container");
    ;
    var title_bg = this.main_container.getChildByName("title_bg");
    title_bg.zIndex = 21;
    this.title = this.main_container.getChildByName("title").getComponent(cc.Label);
    this.title.node.zIndex = 21;
    this.get = this.main_container.getChildByName("get");
    this.get.active = false;
    this.select = this.main_container.getChildByName("select");
    this.select.active = false;
    this.effect_node = this.seekChild("get_eff_node");
    this.effect = this.seekChild("get_eff_node", sp.Skeleton);
    this.effect_node.active = false;
    this.effect_node.zIndex = 20;
    var anima_path = PathTool.getSpinePath(PathTool.getEffectRes(257), "action");
    this.loadRes(anima_path, function (ske_data) {
      this.effect.skeletonData = ske_data;
      this.effect.setAnimation(0, PlayerAction.action, true);
    }.bind(this));
    this.icon = this.main_container.getChildByName("icon").getComponent(cc.Sprite);
 
    if (this.data) {
      this.updateInfo();
    }
 
    if (this.isSelect != null) {
      this.setSelect(this.isSelect);
    }
 
    if (this.status != null) {
      this.setStatus(this.status);
    } else {
      this.setStatus(1);
    }
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    Utils.onTouchEnd(this.main_container, function () {
      if (this.callback) {
        this.callback();
      }
    }.bind(this), 2);
  },
  setData: function setData(index) {
    this.data = index;
    this.updateInfo();
  },
  updateInfo: function updateInfo() {
    if (!this.root_wnd || !this.data) return; // -- var config = deepCopy(Config.ItemData.data_get_data(Config.LoginDaysData.data_day[index].rewards[1][1]))
    // -- config.quantity = Config.LoginDaysData.data_day[index].rewards[1][2]
    // -- this.goods_item:setData(config)
    // -- this.index = index
 
    var index = this.data;
 
    var StringUtil = require("string_util");
 
    this.title.string = Utils.TI18N("第") + StringUtil.numToChinese(index) + Utils.TI18N("天");
    this.loadRes(PathTool.getUIIconPath("actionsevenlogin", "seven_login_item" + index), function (resObject) {
      this.icon.spriteFrame = resObject;
    }.bind(this));
 
    if (index == 2 || index == 3) {
      if (this.effect2 == null) {
        var node = new cc.Node();
        node.setAnchorPoint(0.5, 0.5);
        node.setPosition(this.main_container.getContentSize().width / 2, this.main_container.getContentSize().height / 2);
        this.main_container.addChild(node, 19);
        this.effect2 = node.addComponent(sp.Skeleton);
        var anima_path = PathTool.getSpinePath(PathTool.getEffectRes(258), "action");
        this.loadRes(anima_path, function (ske_data) {
          if (this.effect2) {
            this.effect2.skeletonData = ske_data;
            this.effect2.setAnimation(0, PlayerAction.action, true);
          }
        }.bind(this));
      }
 
      if (this.effect2) {
        this.effect2.node.active = true;
      }
    } else {
      if (this.effect2) {
        this.effect2.node.active = false;
      }
    }
  },
  setStatus: function setStatus(status) {
    this.status = status;
    if (!this.root_wnd) return;
 
    if (this.status == 3) {
      //已领取
      this.get.active = true;
 
      if (this.effect2) {
        this.effect2.node.active = false;
      }
 
      if (this.effect_node) {
        this.effect_node.active = false;
      }
    } else {
      if (this.get) {
        this.get.active = false;
      }
    }
 
    if (this.status == 2) {
      //可领取
      if (this.effect_node) {
        this.effect_node.active = true;
      }
    } else {
      if (this.effect_node) {
        this.effect_node.active = false;
      }
    } // -- if this.status == 2 then --可领取
    // --     if this.effct == nil then
    // --         this.effect = createEffectSpine(PathTool.getEffectRes(257),cc.p(this.main_container:getContentSize().width/2, this.main_container:getContentSize().height/2),cc.p(0.5, 0.5),true,"action")
    // --         this.main_container:addChild(this.effect,20)
    // --     end
    // --     this.effect:setVisible(true)
    // -- else
    // --     if this.effect then
    // --         this.effect:setVisible(false)
    // --     end
    // -- end
 
  },
  setSelect: function setSelect(status) {
    this.isSelect = status;
    if (!this.root_wnd) return;
 
    if (status) {
      this.select.active = true;
    } else {
      this.select.active = false;
    }
  },
  addCallBack: function addCallBack(value) {
    this.callback = value;
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow(params) {},
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {
    if (this.effect) {
      this.effect.setToSetupPose();
      this.effect.clearTracks();
    }
 
    if (this.effect2) {
      this.effect2.setToSetupPose();
      this.effect2.clearTracks();
    }
 
    this.effect2 = null;
  }
});
 
cc._RF.pop();