123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- const Api = require('../net/APi')
- cc.Class({
- extends: cc.Component,
- properties: {
- avatarSprite: cc.Sprite,
- avatarBorderSprite: cc.Sprite,
- rankSprite: cc.Sprite,
- rankText: cc.RichText,
- nameText: cc.RichText,
- genderSprite: cc.Sprite,
- starCountLabel: cc.Label,
- starNode: cc.Node,
- jobLevelStar: cc.Node,
- jobLevelLabel: cc.Label,
- jobLevelNameText: cc.RichText,
- incomeText: cc.RichText,
- incomeNumberText: cc.RichText,
- bgFrames: [cc.SpriteFrame],
- borderFrames: [cc.SpriteFrame],
- rankFrames: [cc.SpriteFrame],
- genderFrames: [cc.SpriteFrame],
- },
- // onLoad () {},
- setListViewAdapter(adapter) {
- this.listAdapter = adapter;
- },
- setType(type) {
- if (type === 0) {
- this.nameText.node.y = 0;
- this.starCountLabel.node.active = true;
- this.starNode.active = true;
- this.jobLevelStar.active = false;
- this.jobLevelLabel.node.active = false;
- this.jobLevelNameText.node.active = false;
- this.incomeText.node.active = false;
- this.incomeNumberText.node.active = false;
- } else {
- this.nameText.node.y = 20;
- this.starCountLabel.node.active = false;
- this.starNode.active = false;
- this.jobLevelStar.active = true;
- this.jobLevelLabel.node.active = true;
- this.jobLevelNameText.node.active = true;
- this.incomeText.node.active = true;
- this.incomeNumberText.node.active = true;
- }
- },
- updateItem(userInfo, itemId) {
- this.node.getComponent(cc.Sprite).spriteFrame = this.bgFrames[0];
- this.avatarBorderSprite.spriteFrame = this.borderFrames[0];
- this._itemId = itemId;
- this.user = userInfo;
- this._bindData(userInfo);
- },
- bindMySelf(userInfo) {
- this.node.getComponent(cc.Sprite).spriteFrame = this.bgFrames[1];
- this.avatarBorderSprite.spriteFrame = this.borderFrames[1];
- this._bindData(userInfo);
- },
- _bindData(userInfo) {
- switch (userInfo.rank) {
- case 1:
- this.rankSprite.node.active = true;
- this.rankText.node.active = false;
- this.rankSprite.spriteFrame = this.rankFrames[0];
- break;
- case 2:
- this.rankSprite.node.active = true;
- this.rankText.node.active = false;
- this.rankSprite.spriteFrame = this.rankFrames[1];
- break;
- case 3:
- this.rankSprite.node.active = true;
- this.rankText.node.active = false;
- this.rankSprite.spriteFrame = this.rankFrames[2];
- break;
- default:
- this.rankSprite.node.active = false;
- this.rankText.node.active = true;
- let rankString = userInfo.rank == 0 ? '未上榜' : userInfo.rank;
- this.rankText.string = `<outline color=#692e0e width=2><b>${rankString}</b></outline>`;
- break;
- }
- this.starCountLabel.string = userInfo.stars;
- this.jobLevelLabel.string = userInfo.jobLevel;
- this.jobLevelNameText.string = `<b>${userInfo.jobLevelName}</b>`;
- this.incomeNumberText.string = `<outline color=#ffffff width=2><b>${userInfo.salary}</b></outline>`;
- Api.createImageFromUrl(userInfo.head, (spriteFrame) => {
- this.avatarSprite.spriteFrame = spriteFrame;
- }, () => {
- });
- this.genderSprite.spriteFrame = this.genderFrames[userInfo.gender];
- this.nameText.string = `<img src=gender/>` + userInfo.nick;
- },
- start() {
- },
- // update (dt) {},
- });
|