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
"use strict";
cc._RF.push(module, 'a6edfwxtjVGI7l+ZssJ6RMJ', 'role_face_item');
// Scripts/mod/role/view/role_face_item.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     头像框子项
// <br/>Create: 2019-04-16 17:32:33
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var RoleController = require("role_controller");
 
var Role_face_itemPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("roleinfo", "role_face_item");
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {},
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    this.icon_bg_nd = this.seekChild("icon_bg");
    this.select_nd = this.seekChild("select");
    this.select_nd.active = false;
    this.use_icon_nd = this.seekChild("use");
    this.use_icon_nd.active = false;
    this.face_icon_sp = this.seekChild("icon", cc.Sprite);
    this.face_name_lb = this.seekChild("label", cc.Label);
    this.face_name_bg_sp = this.seekChild("name_bg", cc.Sprite);
    this.active_nd = this.seekChild("active");
    this.active_nd.active = false;
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    this.root_wnd.on(cc.Node.EventType.TOUCH_END, function () {
      if (this.call_fun) {
        this.call_fun(this, this.vo);
      }
    }, this);
  },
  setTouchFunc: function setTouchFunc(value) {
    this.call_fun = value;
  },
  setData: function setData(data) {
    cc.log(data); // this.vo = data;
    // this.index = index;
 
    if (this.root_wnd) this.onShow();
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow() {
    if (this.vo == null) return;
    var data = this.vo;
 
    if (data.has != 0) {
      this.active_nd.active = false;
    } else {
      this.active_nd.active = true;
    }
 
    var face_id = data.res_id || 0;
    var res = PathTool.getUIIconPath("headcircle", "txt_cn_headcircle_" + face_id);
 
    if (face_id == 0) {
      this.face_icon_sp.node.scale = 1;
    } else {
      this.face_icon_sp.node.sacle = 0.95;
    }
 
    this.loadRes(res, function (sp) {
      this.face_icon_sp.spriteFrame = sp;
    }.bind(this));
    var conifg = Config.avatar_data.data_avatar[data.base_id];
 
    if (config) {
      this.icon_bg_nd.y = this.icon_bg_nd.y - config.offy;
    }
 
    var name = data.name || "";
    this.face_name_lb.string = name;
    this.updateRedPoint();
  },
  updateRedPoint: function updateRedPoint() {},
  setSelected: function setSelected(bool) {
    this.select_nd.active = bool;
  },
  showLock: function showLock(bool) {
    this.is_can_active = false;
    this.is_lock = bool;
  },
  showUseIcon: function showUseIcon(bool) {
    this.is_use = bool;
    this.use_icon_nd.active = boo;
  },
  isHaveData: function isHaveData() {
    if (this.vo) {
      return true;
    }
 
    return false;
  },
  getData: function getData() {
    return this.vo;
  },
  getIsLock: function getIsLock() {
    return this.is_lock;
  },
  getIsActive: function getIsActive() {
    return this.is_can_active;
  },
  getIsUse: function getIsUse() {
    return this.is_use;
  },
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {}
});
 
cc._RF.pop();