var Utils = require('Utils'); cc.Class({ extends: cc.Component, properties: { addToBlack: { default: null, type: cc.Node, }, delete: { default: null, type: cc.Node, }, agree: { default: null, type: cc.Node, }, refuse: { default: null, type: cc.Node, }, addToFriend: { default: null, type: cc.Node, }, addNewFriend: { default: null, type: cc.Node, }, playerHead: { default: null, type: cc.Node, }, playerName: { default: null, type: cc.Node, }, inviteBtn: { default: null, type: cc.Node, }, }, init(data) { this.playerAccount = data.account_id; if (data.name) { this.playerName.getComponent(cc.Label).string = data.name; } else if (data.nickname) { this.playerName.getComponent(cc.Label).string = data.nickname; } if (data.head_id) { Utils.setitem( this, data.head_id, this.playerHead.getComponent(cc.Sprite) ); } else if (data.avatar_url) { Utils.setitem( this, data.avatar_url, this.playerHead.getComponent(cc.Sprite) ); } }, saveData(data) { this.tmpData = JSON.stringify(data); }, setToFriendList() { this.addToBlack.active = true; this.delete.active = true; }, setToApplyList() { this.agree.active = true; this.refuse.active = true; }, setToBlackList() { this.addToFriend.active = true; }, setToAddFriend() { this.addNewFriend.active = true; }, setToInvite() { this.inviteBtn.active = true; }, // friendlist onAddToBlacklist() { console.log('加入黑名单'); cc.chatMgr.sendmsg('CMFriendAddBlack', { user_info: JSON.parse(this.tmpData), //MFUserInfo }); }, onDelete() { console.log('删除好友'); cc.chatMgr.sendmsg('CMFriendDelete', { friend_id: this.playerAccount, }); }, // applylist onAgree() { console.log('同意申请'); console.log(`申请data:${this.tmpData}`); cc.chatMgr.sendmsg('CMFriendAgree', { apply: JSON.parse(this.tmpData), }); }, onRefuse() { console.log('拒绝申请'); console.log(`申请data:${this.tmpData}`); cc.chatMgr.sendmsg('CMFriendRefuse', { apply: JSON.parse(this.tmpData), }); }, // blacklist onAddToFriend() { console.log('加入好友列表'); cc.chatMgr.sendmsg('CMFriendDeleteBlack', { account_id: this.playerAccount, }); }, onAddNewFriend() { console.log('添加新朋友'); cc.chatMgr.sendmsg('CMFriendApply', { friend_id: this.playerAccount, msg: '', }); }, onInviteFriend() { console.log('邀请好友'); // 发送自定义消息 cc.chatMgr.sendmsg('CMSendCustomMsg', { target_list: this.playerAccount, msg: 'InvitePlay', param1: 0, param2: 0, param3: 0, }); }, });