const jcgamelog = require('../../jcfw/service/jcgamelog'); const NetManage = require('../../manages/NetManage'); const { operation, OperationType } = require('../../Operation/Operation'); cc.Class({ extends: cc.Component, properties: { nd_my: { default: null, type: cc.Node, }, tableView: { default: null, type: cc.Node, }, spine_hero: { default: null, type: sp.Skeleton, }, nd_btn1:{ default: null, type: cc.Node, }, nd_btn2:{ default: null, type: cc.Node, }, tableContent:{ default:null, type:cc.Node } }, // LIFE-CYCLE CALLBACKS: init(data) { this.rankData = data; }, onLoad() { // set can open NetManage.getRankOpenList((res)=>{ var rankList = res.list; if(rankList.includes(2) && this.nd_btn2) this.nd_btn2.active = true; }); jcgamelog.addOperation(OperationType.BUTTON, 'get into rank'); cc.Notifier.on('clickrankhero', this, this.clickrankhero.bind(this)); }, onClickFirstRank(){ NetManage.getactivityRankingList(1, (data) => { this.initTable(JSON.stringify(data)); }); }, onClickSecondRank(){ NetManage.getactivityRankingList(2, (data) => { this.initTable(JSON.stringify(data)); }); }, initTable(rankData){ this.tableContent.destroyAllChildren(); var data = JSON.parse(rankData); this.nd_my.getComponent('cellRank').initdata(data.my_ranked); setTimeout(() => { this.tableView .getComponent('tableView') .initTableView(data.rows.length, { array: data.rows, target: this, }); if (data.rows.length > 0) { cc.Notifier.emit('clickrankhero', { account_id: data.rows[0].user.account_id, hero_id: data.rows[0].user.hero_id, }); } }, 100); }, onDestroy() { cc.Notifier.off('clickrankhero', this); }, clickrankhero(v) { var skinres = cc.playerData.getheroSkinbyId(v.hero_id, 0); cc.loader.loadRes( 'spine/heropic/pic_hero' + skinres, sp.SkeletonData, function (err, sp) { this.spine_hero.skeletonData = sp; this.spine_hero._updateSkeletonData(); this.spine_hero.setAnimation(0, 'animation', true); }.bind(this) ); }, start() { this.initTable(this.rankData); }, onclose() { this.node.destroy(); }, // update (dt) {}, });