import NumberToImage from "../../Script/NumberToImage"; import CareerList from "./CareerList"; const { ccclass, property } = cc._decorator; //排行榜 @ccclass export default class CareerManager extends cc.Component { @property(cc.Sprite) //用户头像换图 phone: cc.Sprite = null; @property(cc.Node) //用户头像换图 bg: cc.Node = null; private rankList: CareerList; //排行榜 listData: any; //总列表信息 selfData: any; //自己信息 rankNumber: number; //用户自己排名 有可能不在排行榜内99+ rankTotal: number; //获取排行榜用户数量 现在为100 onLoad() { this.node.opacity = 0; // this.init(); } //初始化数据 init(data, topData) { this.rankList = cc.find("ScrollView", this.node).getComponent(CareerList); this.listData = data; this.selfData = null; this.rankNumber = 100; this.rankTotal = 100; this.rankList.setData(data, topData); // 获取当前日期 let currentDate = new Date(); let month = currentDate.getMonth() + 1; let day = currentDate.getDate(); if (this.bg.getChildByName("month")) this.bg.getChildByName("month").getComponent(cc.Label).string = month.toString(); if (this.bg.getChildByName("day")) this.bg.getChildByName("day").getComponent(cc.Label).string = day.toString(); } start() { } //实际设置排行数据 // public getRankData(data) { // if (data) { // // console.log(data); // cc.fx.GameTool.getRankData(data, this, 6); // this.setPic(this.selfData.pic); // } // } //返回按钮 public backClick() { cc.director.loadScene("LoadScene"); } //最上方用户动画 //设置头像 处理的逻辑比较多,不用公共类的了 // public setPic(pic) { // this.phone.node.parent.getChildByName("icon").active = false; // this.phone.node.active = false; // fetch(pic) // .then(response => { // return response.headers.get('Content-Length'); // }) // .then(errNo => { // if (errNo == "5093") { // this.phone.node.parent.getChildByName("icon").active = true; // } // }) // .catch(error => { // // console.error('Error fetching X-Info:', error); // }); // var self = this; // cc.assetManager.loadRemote(pic, { ext: '.png' }, (err, texture: cc.Texture2D) => { // if (texture) { // self.phone.node.active = true; // self.phone.spriteFrame = new cc.SpriteFrame(texture); // } // else { // } // }) // } public setData(data, topData) { this.selfData = data; this.rankList.setData(this.listData, topData); if (data) { if (data.length) { if (data.length > 0) { this.rankNumber = data[0].rank; this.rankTotal = data.length; } } } } }