var SDKManage = require("SDKManage"); cc.Class({ extends: cc.Component, properties: { nd_friend: { default: null, type: cc.Node, }, nd_apply: { default: null, type: cc.Node, }, nd_blacklist: { default: null, type: cc.Node, }, edit_find: { default: null, type: cc.EditBox, }, pb_oneFriend: { default: null, type: cc.Prefab, }, // contents content_friend: { default: null, type: cc.Node, }, content_apply: { default: null, type: cc.Node, }, content_blacklist: { default: null, type: cc.Node, }, }, onLoad() { // get friendlist cc.chatMgr.sendmsg("CMFriendList"); cc.Notifier.on("friendlist", this, this.getFriendList.bind(this)); this.setToFriend(); }, start() {}, setToNone() { this.edit_find.string = ""; this.nd_friend.active = false; this.nd_apply.active = false; this.nd_blacklist.active = false; }, testinitOne(index) { for (let i = 0; i < 50; i += 1) { const node = cc.instantiate(this.pb_oneFriend); switch (index) { case 0: node.getComponent("SingleFriendList").setToFriendList(); this.content_friend.addChild(node); break; case 1: node.getComponent("SingleFriendList").setToApplyList(); this.content_apply.addChild(node); break; case 2: node.getComponent("SingleFriendList").setToBlackList(); this.content_blacklist.addChild(node); break; } } }, setToFriend() { this.setToNone(); this.nd_friend.active = true; this.testinitOne(0); }, setToApply() { this.setToNone(); this.nd_apply.active = true; this.testinitOne(1); }, setToBlackList() { this.setToNone(); this.nd_blacklist.active = true; this.testinitOne(2); }, onClose() { this.node.destroy(); }, onSearch() { console.log(`search:${this.edit_find.string}`); }, onClickToggle(event, data) { switch (data) { case "0": this.setToFriend(); break; case "1": this.setToApply(); break; case "2": this.setToBlackList(); break; } }, getFriendList(msg) { this.friend_list = []; for (var m = 0; m < msg.friend_list.length; m++) { this.friend_list.push(msg.friend_list[m]); } for (var i = this.friend_list.length - 1; i >= 0; i--) { if ( this.friend_list[i].base_data["account_id"] == SDKManage.account_id ) { this.friend_list.splice(i, 1); break; } } console.log(this.friend_list); }, });