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
"use strict";
cc._RF.push(module, '52cc4oQJd9LYbs/Zl1qWqSH', 'gift_select_item_panel');
// Scripts/mod/backpack/view/gift_select_item_panel.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-04-15 14:12:31
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var Gift_select_itemPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.width = 544;
    this.height = 128;
    this.index = arguments[0] || 1;
    this.is_break = false;
    this.old_lev = 0;
    this.attr_list = {};
    this.initPanel();
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {},
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    this.root_wnd = new cc.Node("gift_select_item");
    this.root_wnd.setAnchorPoint(0.5, 0);
    this.root_wnd.setContentSize(cc.size(this.width, this.height));
    this.bg = Utils.createImage(this.root_wnd, null, 0, this.height / 2, cc.v2(0.5, 0.5), true, 0, true);
    this.bg.node.setContentSize(cc.size(this.width, this.height));
    var res = PathTool.getCommonIcomPath("common_1029");
    this.loadRes(res, function (sf_obj) {
      this.bg.spriteFrame = sf_obj;
    }.bind(this)); // 头像
 
    this.goods_item = ItemsPool.getInstance().getItem("backpack_item");
    this.goods_item.initConfig(false, 0.9, false, true);
    this.goods_item.setParent(this.root_wnd);
    this.goods_item.show();
    this.goods_item.setPosition(-205, 65); // 名字
 
    this.goods_name = Utils.createLabel(24, new cc.Color(0x76, 0x45, 0x19, 0xff), null, -112, this.height / 2, "", this.root_wnd, 0, cc.v2(0, 0.5));
    this.registerEvent();
 
    if (this.vo) {
      this.updateInfo();
    }
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    Utils.onTouchEnd(this.root_wnd, function () {
      if (!this.vo) return;
 
      if (this.call_fun) {
        this.call_fun(this.index, this.vo);
      }
    }.bind(this), 1);
  },
  // [[
  //  @功能:设置数据
  //  @参数:
  //  @返回值:
  //  ]]
  setData: function setData(data) {
    if (data == null) return;
    this.vo = data;
    this.updateInfo();
  },
  updateInfo: function updateInfo() {
    if (!this.root_wnd) return;
    var config = Utils.getItemConfig(this.vo.base_id);
    if (!config) return;
    this.goods_item.setData(config);
    var name = config.name || "";
    var num = this.vo.quantity || 1;
    this.goods_name.string = name + "*" + num;
  },
  setSelected: function setSelected(bool) {
    bool = bool || false;
    var res = PathTool.getCommonIcomPath("common_1029");
 
    if (bool == true) {
      var res = PathTool.getCommonIcomPath("common_1020");
    }
 
    this.loadRes(res, function (sf_obj) {
      this.bg.spriteFrame = sf_obj;
    }.bind(this));
  },
  isHaveData: function isHaveData() {
    if (this.vo) {
      return true;
    }
 
    return false;
  },
  clickHandler: function clickHandler() {
    if (this.call_fun) {
      call_fun(this.vo);
    }
  },
  addCallBack: function addCallBack(value) {
    this.call_fun = value;
  },
  getData: function getData() {
    return this.vo;
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow(params) {},
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {
    if (this.goods_item) {
      this.goods_item.deleteMe();
      this.goods_item = null;
    }
 
    this.vo = null;
  }
});
 
cc._RF.pop();