Files
fc/dev/project/library/imports/b9/b96da73f-1031-46ef-91f9-3bcab61534ed.js
T
2026-05-24 10:21:26 +08:00

389 lines
11 KiB
JavaScript

"use strict";
cc._RF.push(module, 'b96dac/EDFG75H5O8q2FTTt', 'cmp.friend.item');
// Scripts/mod/friend/cmp/cmp.friend.item.js
"use strict";
var PathTool = require("pathtool");
var FriendController = require("friend_controller");
var FriendConst = require("friend_const");
var FriendVo = require("friend_vo");
var TimeTool = require("timetool");
var SvcItem = require("nx.fx.sv.expand.item");
var HomeModel = require("home.mod");
cc.Class({
"extends": SvcItem,
properties: {
role_name: {
"default": null,
type: cc.Label
},
role_power: {
"default": null,
type: cc.Label
},
is_online: {
"default": null,
type: cc.Node
},
is_offline: {
"default": null,
type: cc.Node
},
head_img: {
"default": null,
type: cc.Sprite
},
add_label: {
"default": null,
type: cc.Label
},
head_con: {
"default": null,
type: cc.Node
},
del_btn: {
"default": null,
type: cc.Button
},
img_btn: {
"default": null,
type: cc.Button
},
rev_img_btn: {
"default": null,
type: cc.Button
},
add_btn: {
"default": null,
type: cc.Button
},
allow_btn: {
//好友申请
"default": null,
type: cc.Node
},
remove_btn: {
//黑名单移除按钮
"default": null,
type: cc.Node
},
nds: {
"default": null,
type: cc.Node
},
btns: {
"default": null,
type: cc.Node
},
fabPlayer: {
"default": null,
type: cc.Prefab
}
},
// LIFE-CYCLE CALLBACKS:
onLoad: function onLoad() {
this.is_del = false;
},
rebind: function rebind(_idx, _data, _key) {
this._super(_idx, _data, _key);
this.open_type = Number(_key) || FriendConst.Type.MyFriend;
//头像
if (!this.play_head) {
this.play_head = cc.instantiate(this.fabPlayer);
this.play_head.parent = this.head_con;
var cmp = this.play_head.getComponent("cmp.common.header");
cmp.addCallBack(function () {
FriendController.getInstance().openFriendCheckPanel(true, this.vo);
}.bind(this));
}
// 刷新
this.setData(this.mdata);
},
start: function start() {},
onFocus: function onFocus() {},
outFocus: function outFocus() {},
//私聊
touchPrivateChat: function touchPrivateChat() {
if (!this.vo) return;
if (this.my_friend) {
//私聊
var ChatController = require("chat_controller");
var ChatConst = require("chat_const");
var vo = {
avatar_bid: this.vo.avatar_bid,
career: this.vo.career,
dun_id: this.vo.dun_id,
face_id: this.vo.face_id,
gid: this.vo.gid,
gift_status: this.vo.gift_status,
gname: this.vo.gname,
group_id: this.vo.group_id,
gsrv_id: this.vo.gsrv_id,
intimacy: this.vo.intimacy,
is_awake: this.vo.is_awake,
is_cross: this.vo.is_cross,
is_draw: this.vo.is_draw,
is_moshengren: this.vo.is_moshengren,
is_online: this.vo.is_online,
is_present: this.vo.is_present,
is_used: this.vo.is_used,
is_vip: this.vo.is_vip,
lev: this.vo.lev,
login_out_time: this.vo.login_out_time,
login_time: this.vo.login_time,
main_partner_id: this.vo.main_partner_id,
name: this.vo.name,
partner_bid: this.vo.partner_bid,
partner_lev: this.vo.partner_lev,
partner_star: this.vo.partner_star,
power: this.vo.power,
rid: this.vo.rid,
sex: this.vo.sex,
srv_id: this.vo.srv_id,
talk_time: this.vo.talk_time
};
ChatController.getInstance().openChatPanel(ChatConst.Channel.Friend, "friend", vo);
nx.bridge.closePanel("WndFriend");
}
},
touchAdd: function touchAdd() {
if (!this.vo) return;
if (this.apply_panel) {
FriendController.getInstance().accept(this.vo.srv_id, this.vo.rid, 1);
}
},
touchHome: function touchHome() {
nx.bridge.createPanel("WndHome", {
srv_id: this.mdata.srv_id,
rid: this.mdata.rid
});
nx.bridge.closePanel("WndFriend");
},
//拒绝好友申请
touchRefuse: function touchRefuse() {
if (!this.vo) return;
FriendController.getInstance().accept(this.vo.srv_id, this.vo.rid, 0);
},
//黑名单移除
touchRemove: function touchRemove() {
if (!this.vo) return;
FriendController.getInstance().deleteBlackList(this.vo.rid, this.vo.srv_id);
},
touchAllow: function touchAllow() {
if (!this.vo) return;
nx.gui.setLocked(this.allow_btn, "", true);
nx.gui.getComponent(this.allow_btn, "", cc.Button);
// bt.interactable = false;
FriendController.getInstance().addOther(this.vo.srv_id, this.vo.rid);
},
touchDel: function touchDel() {
if (!this.vo) return;
if (this.apply_panel) {
FriendController.getInstance().accept(this.vo.srv_id, this.vo.rid, 0);
} else if (this.my_friend) {
FriendController.getInstance().delOther(this.vo.srv_id, this.vo.rid);
}
},
touchInfo: function touchInfo() {
if (!this.vo) return;
FriendController.getInstance().sender_13316(0, this.vo.rid, this.vo.srv_id);
},
touchInfo2: function touchInfo2() {
if (!this.vo) return;
FriendController.getInstance().sender_13316(1, this.vo.rid, this.vo.srv_id);
},
setData: function setData(data) {
if (nx.dt.objEmpty(data)) {
return;
}
this.unBindEvent();
this.vo = data;
if (this.vo == null) return;
var data = this.vo;
gcore.Timer.set(function () {
this.updateMessage();
}.bind(this), 60, 1);
var cmp = this.play_head.getComponent("cmp.common.header");
cmp.setData(data);
if (data.name != null) {
this.role_name.string = data.name || "";
}
if (data.lev != null) {
this.role_power.string = data.lev;
}
nx.gui.setActive(this.role_power.node.parent, "", data.lev);
this.updateOnlineTime();
this.addVoBindEvent();
},
// 更新在线时间
updateOnlineTime: function updateOnlineTime() {
if (!this.vo) return;
var str = "";
if (this.vo.is_online != null && this.vo.is_online == 0) {
this.is_online.active = false;
this.is_offline.active = true;
} else {
this.is_online.active = true;
this.is_offline.active = false;
}
},
addVoBindEvent: function addVoBindEvent() {
// 直接用数据去监听这样避免了刷新的频繁
if (this.vo && this.vo != null && this.vo.bind) {
if (this.item_update_event == null) {
this.item_update_event = this.vo.bind(FriendVo.UPDATE_FRIEND_ATTR_LOGIN_OUT_TIME, function (vo) {
this.updateOnlineTime();
}, this);
}
}
},
unBindEvent: function unBindEvent() {
if (this.vo) {
if (this.item_update_event != null) {
this.vo.unbind(this.item_update_event);
this.item_update_event = null;
}
this.vo = null;
}
},
//根据类型创建显隐相关控件
updateMessage: function updateMessage() {
this.nds.active = false;
this.btns.active = true;
for (var i in this.nds.children) {
var btn = nx.gui.getComponent(this.nds.children[i], "img", cc.Button);
btn.interactable = true;
this.nds.children[i].active = true;
}
for (var _i in this.btns.children) {
var btn2 = this.btns.children[_i].getComponent(cc.Button);
btn2.interactable = true;
this.btns.children[_i].active = false;
}
this.hideAllPanel();
if (this.open_type == FriendConst.Type.MyFriend) {
this.is_del = this.vo.del_status || false;
this.updateMyFriend();
} else if (this.open_type == FriendConst.Type.ApplyList) {
this.is_del = false;
this.updateApplyPanel();
} else if (this.open_type == FriendConst.Type.BlackList) {
this.is_del = false;
this.updateBlackPanel();
} else if (this.open_type == FriendConst.Type.Find) {
this.is_del = false;
this.updateRecommendPanel();
}
},
hideAllPanel: function hideAllPanel() {
if (this.my_friend) this.my_friend = false;
// if (this.award_panel)
// this.award_panel = false;
if (this.apply_panel) this.apply_panel = false;
if (this.black_panel) this.black_panel = false;
if (this.del_friend_btn) this.del_friend_btn = false;
if (this.recommend_panel) this.recommend_panel = false;
},
//更新好友列表的控件
updateMyFriend: function updateMyFriend() {
if (!this.my_friend) {
//赠送按钮
this.my_friend = true;
// this.nds.children[3].active = false;
this.btns.active = false;
}
this.nds.active = true;
if (this.vo == null) return;
if (this.vo.is_present != null && this.vo.is_present == 1) {
this.img_btn.interactable = false;
} else {
this.img_btn.interactable = true;
}
if (this.vo.is_draw != null && this.vo.is_draw == 1) {
nx.mTip.openTip("bar.friend.rev", true);
this.rev_img_btn.interactable = true;
} else {
this.rev_img_btn.interactable = false;
}
if (this.vo.is_home != null && this.vo.is_home == 1) {
//开启家园
this.nds.children[3].active = true;
} else {
this.nds.children[3].active = false;
}
// if (this.is_del)
// this.setDelStatus(this.is_del)
},
//更新赠送的控件
updateAwardPanel: function updateAwardPanel() {
// if (!this.award_panel) {
// //友情点标志
// this.add_label.string = nx.text.getKey("friend_str30");
// this.award_panel = true;
// this.nds.active = false;
// }
// this.del_btn.node.active = false;
// if (!this.vo)
// return
// if (this.vo.is_present != null && this.vo.is_present == 1) {
// this.add_btn.interactable = false;
// }
},
//更新申请列表的控件
updateApplyPanel: function updateApplyPanel() {
if (!this.apply_panel) {
this.del_btn.node.active = true;
this.add_btn.node.active = true;
this.apply_panel = true;
// this.add_label.string = nx.text.getKey("friend_str31");
this.nds.active = false;
}
},
//更新黑名单的控件
updateBlackPanel: function updateBlackPanel() {
if (!this.black_panel) {
this.black_panel = true;
this.nds.active = false;
this.remove_btn.active = true;
}
},
//更新推荐好友的控件
updateRecommendPanel: function updateRecommendPanel() {
if (!this.recommend_panel) {
this.nds.active = false;
this.allow_btn.active = true;
nx.gui.setLocked(this.allow_btn, "", false);
this.recommend_panel = true;
}
},
isHaveData: function isHaveData() {
if (this.vo) return true;else return false;
},
setDelStatus: function setDelStatus(bool) {
if (bool) this.hideAllPanel();
this.is_del = bool;
if (!this.button && !bool) return;
if (this.button) {
if (bool) {
this.add_label.string = nx.text.getKey("friend_str4");
this.nds.active = false;
}
}
if (!bool) this.updateMyFriend();
},
getData: function getData() {
return this.vo;
},
onDestroy: function onDestroy() {
this.unBindEvent();
this.vo = null;
} // update (dt) {},
});
cc._RF.pop();