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
"use strict";
cc._RF.push(module, '56ddfEKCh1IY6rdCbRxxvY1', 'orderaction_tesk_item_panel');
// Scripts/mod/orderaction/view/orderaction_tesk_item_panel.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     战令三期 任务itme
// <br/>Create: 2019-08-12 14:31:05
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var StrongerController = require("stronger_controller");
 
var OrderactionController = require("orderaction_controller");
 
var Orderaction_tesk_itemPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("orderaction", "tesk_item1");
    this.ctrl = OrderactionController.getInstance();
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {
    this.tab_name = [Utils.TI18N("每日"), Utils.TI18N("每周"), Utils.TI18N("每月")];
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    var main_container = this.root_wnd.getChildByName("main_container");
    this.btn_goto = main_container.getChildByName("btn_goto");
    var goto_lab = this.btn_goto.getChildByName("Text_3").getComponent(cc.Label);
    goto_lab.string = Utils.TI18N("前往");
    this.btn_goto.active = false;
    this.btn_get = main_container.getChildByName("btn_get");
    var get_lab = this.btn_get.getChildByName("Text_3").getComponent(cc.Label);
    get_lab.string = Utils.TI18N("领取");
    this.btn_get.active = false;
    this.spr_get = main_container.getChildByName("spr_get");
    this.spr_get.active = false;
    this.big_title_head = main_container.getChildByName("big_title_head").getComponent(cc.Label);
    this.big_title_head.string = "";
    this.big_title = main_container.getChildByName("big_title").getComponent(cc.Label);
    this.big_title.string = "";
    this.small_title = main_container.getChildByName("small_title").getComponent(cc.Label);
    this.small_title.string = "";
 
    if (!this.task_reward) {
      this.task_reward = ItemsPool.getInstance().getItem("backpack_item");
      this.task_reward.initConfig(false, 0.7);
      this.task_reward.setParent(main_container);
      this.task_reward.setPosition(59, 57);
      this.task_reward.setDefaultTip();
      this.task_reward.show();
    }
 
    if (this.data) {
      this.updateData(this.data);
    }
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    Utils.onTouchEnd(this.btn_get, function () {
      if (this.data && this.data.goal_id) {
        this.ctrl.send25302(this.data.goal_id);
      }
    }.bind(this), 1);
    Utils.onTouchEnd(this.btn_goto, function () {
      if (this.data && this.data.show_icon != "") {
        this.ctrl.openOrderActionMainView(false);
        StrongerController.getInstance().clickCallBack(this.data.show_icon);
      }
    }.bind(this), 1);
  },
  updateData: function updateData(data) {
    if (this.task_reward) {
      if (data.award && data.award[0]) {
        this.task_reward.setData({
          bid: data.award[0][0],
          num: data.award[0][1]
        });
      }
    }
 
    if (data.tab_index) {
      this.big_title_head.string = "【" + this.tab_name[data.tab_index - 1] + "】";
    }
 
    this.big_title.string = data.title || "";
    var desc = data.desc || "";
    var value = Utils.getMoneyString(data.value || 0);
    var target_val = Utils.getMoneyString(data.target_val || 0);
    var str = cc.js.formatStr("%s (%s/%s)", desc, value, target_val);
    this.small_title.string = str;
    this.btn_goto.active = data.status == 0;
    this.btn_get.active = data.status == 1;
    this.spr_get.active = data.status == 2;
  },
  setData: function setData(data) {
    if (!data) return;
    this.data = data;
 
    if (this.root_wnd) {
      this.updateData(data);
    }
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow(params) {},
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {
    if (this.task_reward) {
      this.task_reward.deleteMe();
      this.task_reward = null;
    }
  }
});
 
cc._RF.pop();