const jcgamelog = require('../../jcfw/service/jcgamelog'); 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, }, }, // LIFE-CYCLE CALLBACKS: init(data) { this.rankData = data; }, onLoad() { jcgamelog.addOperation(OperationType.BUTTON, 'get into rank'); cc.Notifier.on('clickrankhero', this, this.clickrankhero.bind(this)); }, 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() { var data = JSON.parse(this.rankData); this.nd_my.getComponent('cellRank').initdata(data.my_ranked); 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, }); } }, onclose() { this.node.destroy(); }, // update (dt) {}, });