117 lines
3.0 KiB
JavaScript
117 lines
3.0 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'ffa4eoKkz1E959Xmt/873cO', 'cmp.common.header');
|
|
// Scripts/mod/common/cmp.common.header.js
|
|
|
|
"use strict";
|
|
|
|
var SvcItem = require("nx.fx.sv.expand.item");
|
|
var RoleController = require("role_controller");
|
|
var PathTool = require("pathtool");
|
|
cc.Class({
|
|
"extends": SvcItem,
|
|
properties: {
|
|
isSelf: {
|
|
"default": false,
|
|
displayName: "是否属于自己"
|
|
},
|
|
icon: {
|
|
"default": null,
|
|
type: cc.Sprite
|
|
},
|
|
frame: {
|
|
"default": null,
|
|
type: cc.Sprite
|
|
},
|
|
lev: {
|
|
"default": null,
|
|
type: cc.Label
|
|
},
|
|
desc: {
|
|
"default": null,
|
|
type: cc.Label
|
|
},
|
|
leader_icon: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
bg: {
|
|
"default": null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
// LIFE-CYCLE CALLBACKS:
|
|
// 数据重置
|
|
rebind: function rebind(_idx, _data, _key) {
|
|
this._super(_idx, _data, _key);
|
|
|
|
// 刷新
|
|
this.setData(_data);
|
|
},
|
|
onLoad: function onLoad() {
|
|
this.normal = new cc.Material.createWithBuiltin("2d-sprite");
|
|
this.gray = new cc.Material.createWithBuiltin("2d-gray-sprite");
|
|
if (this.isSelf) {
|
|
var role_vo = RoleController.getInstance().getRoleVo();
|
|
this.setData(role_vo);
|
|
//需要绑定属性改变监听
|
|
}
|
|
},
|
|
start: function start() {},
|
|
setData: function setData(_data) {
|
|
if (nx.dt.objEmpty(_data)) {
|
|
return false;
|
|
}
|
|
this.setEmpty();
|
|
if (_data.desc) {
|
|
this.desc.string = _data.desc;
|
|
}
|
|
if (_data.is_leader) {
|
|
this.leader_icon.active = _data.is_leader;
|
|
}
|
|
if (this.lev) {
|
|
this.lev.string = _data.lev || "";
|
|
}
|
|
this.loadHeadRes(_data.face || _data.face_id);
|
|
this.loadFrameRes(_data.avatar || _data.avatar_bid || _data.avatar_base_id || _data.avatar_id);
|
|
},
|
|
setEmpty: function setEmpty() {
|
|
if (this.lev) {
|
|
this.lev.string = "";
|
|
}
|
|
this.desc.string = "";
|
|
this.leader_icon.active = false;
|
|
this.bg.active = true;
|
|
this.frame.spriteFrame = null;
|
|
},
|
|
// 设置锁定状态
|
|
setLockStatus: function setLockStatus(bool) {
|
|
if (bool) {
|
|
this.icon.setMaterial(this.gray);
|
|
this.frame.setMaterial(this.gray);
|
|
} else {
|
|
this.icon.setMaterial(this.normal);
|
|
this.frame.setMaterial(this.normal);
|
|
}
|
|
},
|
|
setHeadRes: function setHeadRes(res) {
|
|
this.loadHeadRes(res);
|
|
},
|
|
setFrameRes: function setFrameRes(res) {
|
|
this.loadFrameRes(res);
|
|
},
|
|
// 加载资源,这里可能需要判断一下加载回来的是不是我需要的资源,私有方法 不能外部调用,外部滴啊用请用 setHeadRes
|
|
loadHeadRes: function loadHeadRes(res_id) {
|
|
if (!res_id) return;
|
|
nx.bridge.setAvatarByFaceId(this.icon, "", res_id);
|
|
},
|
|
loadFrameRes: function loadFrameRes(bid) {
|
|
if (!bid) return;
|
|
nx.bridge.setAvatarFrame(this.frame, "", bid);
|
|
},
|
|
addCallBack: function addCallBack(cb) {
|
|
this.touch_cb = cb;
|
|
this.openTouch(true, this.touch_cb.bind(this));
|
|
} // update (dt) {},
|
|
});
|
|
|
|
cc._RF.pop(); |