var DWTool = require('../utils/DWTool'); var {UserJobType, UserInformationType} = require('../utils/GameEnum'); cc.Class({ extends: cc.Component, properties: { levelLabel: cc.Label, //等级 jobRichText: cc.RichText, //职业称呼 salaryLabel: cc.Label, //年薪 levelProgressBar: cc.ProgressBar, //年薪突破进度条 propertyLabel1: cc.Label, //魅力 propertyLabel2: cc.Label, //能力 propertyLabel3: cc.Label, //影响力 jobSprite: cc.Sprite, //职业类型icon //突破转职按钮 upgradeButton: cc.Button, }, // LIFE-CYCLE CALLBACKS: // onLoad () {}, start () { }, init() { }, // update (dt) {}, onDisable() { this.levelProgressBar.progress = 0; this.upgradeButton.node.active = false; }, setUserData(userInfo, role) { this.userInfo = userInfo; this.role = role; if (this.userInfo.jobLevelName != undefined) { this.jobRichText.string = ""+this.userInfo.jobLevelName+""; } this.levelLabel.string = this.userInfo.jobLevel; this.salaryLabel.string = DWTool.coinParse(this.userInfo.salary); this.propertyLabel1.string = this.userInfo.charm; this.propertyLabel2.string = this.userInfo.ability; this.propertyLabel3.string = this.userInfo.effect; this.upgradeButton.node.active = true; if (this.role == UserInformationType.MyArtist) { if (this.userInfo.upgradeSalary == 0) { this.upgradeButton.node.active = false; } else if (this.userInfo.salary >= this.userInfo.upgradeSalary) { this.upgradeButton.node.active = true; } else { this.upgradeButton.node.active = false; } } else { this.upgradeButton.node.active = false; } if (this.userInfo.jobLevel == 0) { this.levelProgressBar.progress = 0; } else if (this.userInfo.upgradeSalary == 0) { this.levelProgressBar.progress = 1; } else if (this.userInfo.salary >= this.userInfo.upgradeSalary) { this.levelProgressBar.progress = 1; } else { this.levelProgressBar.progress = this.userInfo.salary / this.userInfo.upgradeSalary; } this.refreshJobIcon(); }, refreshJobIcon() { this.jobSprite.node.active = true; switch (this.userInfo.jobId) { case UserJobType.None: this.jobSprite.node.active = false; break; case UserJobType.MC: cc.loader.loadRes('userInformation/userinformation_job_mc', cc.SpriteFrame, (err, spriteFrame) => { this.jobSprite.spriteFrame = spriteFrame; }); break; case UserJobType.Dancer: cc.loader.loadRes('userInformation/userinformation_job_dancer', cc.SpriteFrame, (err, spriteFrame) => { this.jobSprite.spriteFrame = spriteFrame; }); break; case UserJobType.Singer: cc.loader.loadRes('userInformation/userinformation_job_singer', cc.SpriteFrame, (err, spriteFrame) => { this.jobSprite.spriteFrame = spriteFrame; }); break; case UserJobType.Actor: cc.loader.loadRes('userInformation/userinformation_job_actor', cc.SpriteFrame, (err, spriteFrame) => { this.jobSprite.spriteFrame = spriteFrame; }); break; case UserJobType.Electronic: cc.loader.loadRes('userInformation/userinformation_job_electronic', cc.SpriteFrame, (err, spriteFrame) => { this.jobSprite.spriteFrame = spriteFrame; }); break; } } });