123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- const GameModule = require('../utils/GameModule');
- cc.Class({
- extends: cc.Component,
- properties: {
- friendNode: {
- tooltip: '我的好友容器',
- default: null,
- type: cc.Node
- },
- recommendNode: {
- tooltip: '推荐好友容器',
- default: null,
- type: cc.Node
- },
- searchNode: {
- tooltip: '找朋友容器',
- default: null,
- type: cc.Node
- },
- friendTab: [cc.Node],
- bottomNode: cc.Node,
- goldCountRichText: cc.RichText,
- friendCountRichText: cc.RichText
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {
- this.isFirst = true;
- if (GameGlobal.winSize.height <= 1000) {
- this.content.height = 800;
- }
- this.tabList = [{
- wrap: this.friendNode,
- init: () => {
- this._initFriend();
- },
- }, {
- wrap: this.recommendNode,
- init: () => {
- this._initRecommend();
- }
- }, {
- wrap: this.searchNode,
- init: () => {
- this._initSearch();
- }
- }];
- },
- init(index = 0) {
- this.tabIndex = index;
- this._initTab();
- },
- start () {
- },
- onDestroy() {
- },
- _initTab () {
- for(let i = 0; i < this.friendTab.length; i++) {
- this.friendTab[i] = this.friendTab[i].getComponent('GameFriendTab');
- this.friendTab[i].init();
- }
- this.handleTab(null, this.tabIndex);
- },
- /**
- * Tab切换
- * @param {number} tabIndex [0: 我的好友, 1: 推荐好友,2:找朋友]
- */
- handleTab(event, tabIndex) {
- this.friendTab.forEach((item, index) => {
- if(tabIndex == index) {
- item.show();
- this.tabList[index].wrap.active = true;
- this.tabList[index].init.apply(this);
- if (this.isFirst) {
- this.isFirst = false
- } else {
- GameModule.audioMng.playClickButton();
- }
- } else {
- item.hide();
- this.tabList[index].wrap.active = false;
- }
- this.tabIndex = tabIndex;
- })
- },
- /**
- * 我的好友
- */
- _initFriend () {
- if(!this.initFriendDone) {
- this.initFriendDone = true;
- this.friendNode = this.friendNode.getComponent('GameMyFriend');
- this.friendNode.init();
- }
- },
- /**
- * 推荐
- */
- _initRecommend() {
- if(!this.RecommendDone) {
- this.RecommendDone = true;
- // this.countryNode = this.countryNode.getComponent('GameCountryRank');
- // this.countryNode.init();
- }
- },
- /**
- * 找朋友
- */
- _initSearch() {
- if(!this.initSearchDone) {
- this.initSearchDone = true;
- this.searchNode = this.searchNode.getComponent('GameFriendSearch');
- this.searchNode.init(this);
- }
- },
- closeNode() {
- GameModule.audioMng.playClickButton();
- this.node.destroy();
- },
- gainGold() {
- }
- // update (dt) {},
- });
|