let viewCell = require('viewCell'); var gameConfig = require('gameConfig'); var Utils = require('Utils'); const { uimanger } = require('../UIManger'); const { playerInfoUI } = require('../../tips/PlayInfomationTips'); cc.Class({ extends: viewCell, properties: { nd_click: { default: null, type: cc.Node, }, sp_head: { default: null, type: cc.Sprite, }, sp_headkuang: { default: null, type: cc.Sprite, }, sp_dw: { default: null, type: cc.Sprite, }, lb_name: { default: null, type: cc.Label, }, lb_duanwei: { default: null, type: cc.Label, }, lb_score: { default: null, type: cc.Label, }, lb_rank: { default: null, type: cc.Label, }, lb_lv: { default: null, type: cc.Label, }, ndranksps: { default: [], type: cc.Node, }, }, // LIFE-CYCLE CALLBACKS: // onLoad () {}, init: function (index, data, reload, group) { if (index >= data.array.length) { this.node.active = false; return; } this.target = data.target; var sdata = data.array[index]; this.initdata(sdata); }, replacepos(text, start, stop) { var mid = '*****'; let mystr = text.toString().substr(0, start - 1) + mid + text.toString().substr(stop + 1); return mystr; }, initdata(v) { var u = JSON.stringify(v); v.user.ranked = v.ranked; v = v.user; var headid = v.head_id; var kuangid = v.head_frame; Utils.setitem(this, headid, this.sp_head); Utils.setitem(this, kuangid, this.sp_headkuang); var rankcfg = gameConfig.rank[v.rank]; cc.loader.loadRes( 'textures/rankIcon/' + rankcfg.icon, cc.SpriteFrame, function (err, res) { if (!err && this.isValid) { this.sp_dw.spriteFrame = res; } }.bind(this) ); for (var i = 0; i < this.ndranksps.length; i++) { this.ndranksps[i].active = false; } this.lb_name.string = v.name; this.lb_duanwei.string = this.replacepos(v.address, 7, 37); this.lb_score.string = JSON.parse(u).value; this.lb_lv.string = v.level; if (v.ranked < 1) { this.lb_rank.string = '50+'; } else if (v.ranked < this.ndranksps.length) { this.ndranksps[v.ranked - 1].active = true; this.lb_rank.string = ''; } else { this.lb_rank.string = v.ranked; } this.account_id = v.account_id; this.hero_id = v.hero_id; if (!this.hero_id) { this.hero_id = 30100; } }, onclickinfo() { cc.Notifier.emit('clickrankhero', { account_id: this.account_id, hero_id: this.hero_id, }); uimanger.showUI(playerInfoUI,this.account_id); }, onDisable() { cc.Notifier.off('clickrankhero', this); this.inited = false; }, onEnable() { if (!this.inited) { cc.Notifier.on( 'clickrankhero', this, this.clickrankhero.bind(this) ); this.inited = true; } }, clickrankhero(v) { if (v.account_id == this.account_id) { this.nd_click.active = true; } else { this.nd_click.active = false; } }, // update (dt) {}, });