Files

105 lines
2.3 KiB
JavaScript
Raw Permalink Normal View History

2026-05-23 22:10:14 +08:00
// Learn cc.Class:
const SvcItem = require("nx.fx.sv.expand.item")
cc.Class({
extends: SvcItem,
properties: {
head_icon:{
default:null,
type:cc.Node
},
level:{
default:null,
type:cc.Label
},
pname:{
default:null,
type:cc.Label
},
check:{
default:null,
type:cc.Node
},
fabHeader:{
default:null,
type:cc.Prefab
}
},
// 数据重置
rebind: function( _idx, _data, _key ) {
this._super( _idx, _data, _key );
// 刷新
this.setData(this.mdata)
},
setData(data){
if(nx.dt.objEmpty(data)){
return false;
}
this.friend_vo = data.vo;
// this.select_cb = data.select_cb;
this.delete_cb = data.delete_cb;
// this.check.active = data.is_select;
if(this.delete_cb==null){
return false;
}
this.fxindex = this.friend_vo.srv_id + this.friend_vo.rid;
this.updateWidget();
},
updateWidget: function() {
//头像
if(!this.play_head){
this.play_head = cc.instantiate(this.fabHeader);
this.play_head.parent = this.head_icon;
}
let cmp = this.play_head.getComponent("cmp.common.header");
if(cmp){
cmp.setData(this.friend_vo);
}
this.level.string = this.friend_vo.lev || "";
this.pname.string = this.friend_vo.name || "";
},
onFocus(){
this.check.active = true;
},
outFocus(){
this.check.active = false;
},
// selectItem: function() {
// if (this.select_cb)
// this.check.active = !this.check.active;
// this.select_cb(this.index, this.friend_vo);
// },
deleteItem: function() {
let self = this;
var str = nx.text.getKey("ChatDelaFriMsg");
var fun = function (_key,_box) {
_box.close();
if(_key == "btn_sure"){
if (self.delete_cb)
self.delete_cb(self.fxindex, self.friend_vo);
}
// self.node.destroy();
}.bind(this)
nx.mbox(str, ["btn_sure"], fun,"DeleteFriend")
},
start () {
},
// update (dt) {},
});