123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- const Api = require('../net/APi')
- cc.Class({
- extends: cc.Component,
- properties: {
- avatarSprite: cc.Sprite,
- rankSprite: cc.Sprite,
- rankLabel: cc.Label,
- nameLabel: cc.Label,
- genderSprite: cc.Sprite,
- artistLevelSprite: cc.Sprite,
- jobLevelNameLabel: cc.Label,
- incomeLabel: cc.Label,
- incomeNumberLabel: cc.Label,
- rankFrames: [cc.SpriteFrame],
- genderFrames: [cc.SpriteFrame],
- jobLevelBgs: [cc.SpriteFrame],
- },
-
- setListViewAdapter(adapter) {
- this.listAdapter = adapter;
- },
- updateItem(userInfo, itemId) {
- this._itemId = itemId;
- this.user = userInfo;
- this._bindData(userInfo);
- },
- bindMySelf(userInfo) {
- this._bindData(userInfo);
- },
- _bindData(userInfo) {
- if (userInfo.rank <= 3) {
- switch (userInfo.rank) {
- case 1:
- this.rankSprite.node.active = true;
- this.rankLabel.node.active = false;
- this.rankSprite.spriteFrame = this.rankFrames[0];
- break;
- case 2:
- this.rankSprite.node.active = true;
- this.rankLabel.node.active = false;
- this.rankSprite.spriteFrame = this.rankFrames[1];
- break;
- case 3:
- this.rankSprite.node.active = true;
- this.rankLabel.node.active = false;
- this.rankSprite.spriteFrame = this.rankFrames[2];
- break;
- default:
- this.rankSprite.node.active = false;
- this.rankLabel.node.active = true;
- let rankString = '未上榜';
- this.rankLabel.string = rankString;
- break;
- }
- } else {
- this.rankSprite.node.active = false;
- this.rankLabel.node.active = true;
- let rankString = userInfo.rank;
- this.rankLabel.string = rankString;
- }
- if (userInfo.jobLevel != undefined) {
- this.artistLevelSprite.node.active = true;
- this.artistLevelSprite.spriteFrame = this.jobLevelBgs[userInfo.jobLevel - 1];
- } else {
- this.artistLevelSprite.node.active = false;
- }
- if (userInfo.jobLevelName != undefined) {
- this.jobLevelNameLabel.string = userInfo.jobLevelName;
- } else {
- this.jobLevelNameLabel.string = '';
- }
- if (userInfo.salary != undefined) {
- this.incomeNumberLabel.string = userInfo.salary;
- } else {
- this.incomeNumberLabel.string = '';
- }
- Api.createImageFromUrl(userInfo.head, (spriteFrame) => {
- this.avatarSprite.spriteFrame = spriteFrame;
- }, () => {
- });
- this.genderSprite.spriteFrame = this.genderFrames[userInfo.gender];
- this.nameLabel.string = userInfo.nick;
- },
- start() {
- },
-
- });
|