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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
"use strict";
cc._RF.push(module, 'e65ef2LNbxCWIi0KVVHhhhm', 'action_limit_common_item');
// Scripts/mod/action/view/action_limit_common_item.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     
// <br/>Create: 2019-04-18 15:16:30
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var ActionController = require("action_controller");
 
var TaskConst = require("task_const");
 
var TimeTool = require("timetool");
 
var ActionConst = require("action_const");
 
var ActionLimitCommonItem = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("action", "action_limit_yuanzhen_item");
    this.ctrl = ActionController.getInstance();
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {
    this.action_yuanzhen_id = 13005;
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    var main_container = this.root_wnd.getChildByName("main_container");
    this.btn_goto = main_container.getChildByName("btn_goto");
    this.btn_goto.getChildByName("Text_6").getComponent(cc.Label).string = Utils.TI18N("前往");
    this.btn_goto.active = false;
    this.btn_get = main_container.getChildByName("btn_get");
    this.btn_get.getChildByName("Text_5").getComponent(cc.Label).string = Utils.TI18N("领取");
    this.btn_get.active = false;
    this.btn_has = main_container.getChildByName("btn_has");
    this.btn_has.active = false;
    this.goods_con = main_container.getChildByName("good_cons");
    this.Image_1 = main_container.getChildByName("Image_1");
    this.line = main_container.getChildByName("line");
 
    if (this.action_id == this.action_yuanzhen_id) {// this.line.active = false;
      // this.title_desc = createRichLabel(22, cc.c4b(0x64,0x32,0x23,0xff), cc.p(0,0.5), cc.p(14,129), nil, nil, 400)
      // main_container:addChild(this.title_desc)
      // this.goal_desc = createRichLabel(26, cc.c4b(0x93,0x53,0x22,0xff), cc.p(0.5,0.5), cc.p(596,127), nil, nil, 400)
      // main_container:addChild(this.goal_desc)
      // this.time_desc = createRichLabel(22, cc.c4b(0x93,0x53,0x22,0xff), cc.p(0.5,0.5), cc.p(594,24), nil, nil, 400)
      // main_container:addChild(this.time_desc)
      // let size = this.goods_con:getContentSize()
      // this.item_scrollview = createScrollView(size.width, size.height, 0, 0, this.goods_con, ScrollViewDir.vertical ) 
    } else {
      this.btn_goto.y = 0;
      this.btn_get.y = 0;
      this.btn_has.y = 0;
      this.Image_1.active = false; // --标题
 
      this.title_desc = Utils.createLabel(28, new cc.Color(0x64, 0x32, 0x23, 0xff), null, -196, 24, null, null, null, cc.v2(0, 0.5));
      main_container.addChild(this.title_desc.node); // --小标题
 
      this.little_desc = Utils.createRichLabel(22, new cc.Color(0x95, 0x53, 0x22, 0xff), cc.v2(0, 1), cc.v2(-196, -4), null, 320);
      this.little_desc.horizontalAlign = cc.macro.TextAlignment.LEFT;
      main_container.addChild(this.little_desc.node);
      this.time_desc = Utils.createLabel(22, new cc.Color(0x93, 0x53, 0x22, 0xff), null, 254, -52, null, null, null, cc.v2(0.5, 0.5));
      main_container.addChild(this.time_desc.node);
      this.item = ItemsPool.getInstance().getItem("backpack_item"); //BackPackItem.new(false, true, false, 0.9, false, true)  
 
      this.item.initConfig(false, 0.9, false, true);
      this.item.setPosition(-264, 0);
      this.item.setParent(main_container);
      this.item.show();
    }
 
    if (this.data) {
      this.setData(this.data);
    }
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    this.btn_get.on('click', function () {
      Utils.playButtonSound(1);
      if (!this.data) return;
 
      if (this.holiday_bid == ActionConst.ActionRankCommonType.yuanzhen_adventure) {
        this.ctrl.sender24812(this.data.config.id);
      } else if (this.holiday_bid == ActionConst.ActionRankCommonType.exercise_1) {
        this.ctrl.sender24814(this.data.config.id);
      } else if (this.holiday_bid == ActionConst.ActionRankCommonType.exercise_2) {
        this.ctrl.sender24816(this.data.config.id);
      } else if (this.holiday_bid == ActionConst.ActionRankCommonType.exercise_3) {
        this.ctrl.sender24818(this.data.config.id);
      }
    }, this);
    this.btn_goto.on('click', this.onGotoBtn, this);
  },
  onGotoBtn: function onGotoBtn() {
    if (!this.data) return;
    if (!this.data.config) return; // -- 特殊跳转 特殊处理
 
    if (this.data.config.source_id == 130051) {
      // --跳转到元宵厨房的
      var tab_vo = this.ctrl.getActionSubTabVo(ActionConst.AnimateActionCommonType.YuanZhen_Kitchen);
 
      if (tab_vo && this.ctrl.action_operate && this.ctrl.action_operate.tab_list[tab_vo.bid]) {
        this.ctrl.action_operate.handleSelectedTab(this.ctrl.action_operate.tab_list[tab_vo.bid]);
      } else {
        message(Utils.TI18N("该活动已结束"));
      }
    } else if (this.data.config.source_id == 250131) {// --跳转到沙滩保卫战.
      // var MainuiController = require("mainui_controller")
      // var BattleConst = require("battle_const")
      // MainuiController.getInstance().requestOpenBattleRelevanceWindow(BattleConst.Fight_Type.SandybeachBossFight)
    } else if (this.data.config.source_id == 250132 || this.data.config.source_id == 250133 || this.data.config.source_id == 250134) {
      var jump_id = ActionConst.ActionRankCommonType.time_summon;
 
      if (this.data.config.source_id == 250133) {// jump_id = ActionConst.ActionRankCommonType.action_skin_buy
      } else if (this.data.config.source_id == 250134) {
        jump_id = ActionConst.ActionRankCommonType.limit_exercise;
      }
 
      var _tab_vo = this.ctrl.getActionSubTabVo(jump_id);
 
      if (_tab_vo && this.ctrl.action_operate && this.ctrl.action_operate.tab_list[_tab_vo.bid]) {
        this.ctrl.action_operate.handleSelectedTab(this.ctrl.action_operate.tab_list[_tab_vo.bid]);
      } else {
        message(Utils.TI18N("该活动已结束"));
      }
    } else {
      var config = Config.source_data.data_source_data[this.data.config.source_id];
 
      if (config) {
        var BackpackController = require("backpack_controller");
 
        BackpackController.getInstance().gotoItemSources(config.evt_type, config.extend);
      } else {
        var StrongerController = require("stronger_controller");
 
        StrongerController.getInstance().clickCallBack(this.data.config.source_id);
      }
    }
  },
  setData: function setData(data) {
    this.data = data;
    if (!this.root_wnd) return;
    this.holiday_bid = data.holiday_bid;
    this.btn_goto.active = data.status == TaskConst.task_status.un_finish;
    this.btn_get.active = data.status == TaskConst.task_status.finish;
    this.btn_has.active = data.status == TaskConst.task_status.completed;
 
    if (this.time_desc) {
      this.time_desc.node.active = data.status != TaskConst.task_status.completed;
    }
 
    if (this.action_id == this.action_yuanzhen_id) {// this.title_desc.string = data.desc
      // if(data.status == TaskConst.task_status.finish){
      //     this.goal_desc:setString(string_format("<div fontColor=#249003>%s</div>", data.goal))
      // }else{
      //     this.goal_desc.string = data.goal
      // }
      // let data_list = data.item_list
      // let setting = {}
      // setting.scale = 0.8
      // setting.max_count = 4
      // // -- setting.is_center = true
      // this.item_list = commonShowSingleRowItemList(this.item_scrollview, this.item_list, data_list, setting) 
    } else {
      this.title_desc.string = data.title;
      var desc = data.desc + data.goal;
 
      if (data.status == TaskConst.task_status.finish) {
        this.little_desc.string = cc.js.formatStr(StringUtil.parseStr("<div fontColor=#249003>%s</div>").string, desc);
      } else {
        this.little_desc.string = desc;
      }
 
      if (this.item && data.item_list != null && Utils.next(data.item_list) != null) {
        this.item.setData({
          bid: data.item_list[0][0],
          num: data.item_list[0][1]
        });
      }
    }
 
    if (this.time_desc.node.active) {
      var time = data.end_time - gcore.SmartSocket.getTime();
 
      if (time < 0) {
        time = 0;
      }
 
      this.time_desc.string = cc.js.formatStr("%s%s", Utils.TI18N("剩余"), TimeTool.getDayOrHour(time));
    }
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow(params) {},
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {
    if (this.item) {
      this.item.deleteMe();
      this.item = null;
    }
  }
});
 
cc._RF.pop();