123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- const Api = require('../net/Api');
- const { GameNotificationKey } = require("../utils/GameEnum");
- const HomeApi = require("../net/HomeApi");
- const AlertManager = require("../utils/AlertManager");
- cc.Class({
- extends: cc.Component,
- properties: {
- bgSpriteFrames: [cc.SpriteFrame],
-
- headSprite: cc.Sprite,
- nickRichText: cc.RichText,
- jobLevelLabel: cc.Label,
-
- jobTitleLabel: cc.Label,
- effectLabel: cc.Label,
- cancelResidentBtn: cc.Button,
- recallArtistBtn: cc.Button,
- bgSprite: {
- get: function() {
- if (!this._bgSprite) {
- this._bgSprite = this.getComponent(cc.Sprite);
- }
- return this._bgSprite;
- },
- set: function(value) {
- this._bgSprite = value;
- }
- }
- },
- init(uid, buildingInfo, isSelf, artistData, selectedCallback) {
- this.uid = uid;
- this.buildingInfo = buildingInfo;
- this.artistData = artistData;
- this.isSelf = isSelf;
- this.selectedCallback = selectedCallback;
- this.jobLevelLabel.string = this.artistData.jobLevel;
- this.jobTitleLabel.string = this.artistData.jobName;
- if (this.artistData.isStationed === 0) { // 没有任何驻场艺人
- this.cancelResidentBtn.node.active = false;
- this.recallArtistBtn.node.active = false;
- this.bgSprite.spriteFrame = this.bgSpriteFrames[0];
- } else if (this.artistData.isStationed === 1) { // 入驻了自己家园
- this.cancelResidentBtn.node.active = true;
- this.recallArtistBtn.node.active = false;
- this.bgSprite.spriteFrame = this.bgSpriteFrames[1];
- } else { // 入驻他人家园
- this.cancelResidentBtn.node.active = false;
- this.recallArtistBtn.node.active = true;
- }
- this.nickRichText.string = `<color=#584a47>${this.artistData.nick}</c> <img src='50002'/>`;
- this.effectLabel.string = `加成效果: 收益增加${this.artistData.addition}%`;
- Api.createImageFromUrl(this.artistData.head, (spriteFrame) => {
- this.headSprite.spriteFrame = spriteFrame;
- }, null);
- },
- cancelResident() {
- this.cancelResidentEvent();
- } ,
- // 召回自己艺人
- recallArtist() {
- this.recallArtistEvent();
- },
- onLoad () {
- this.bgSprite = this.getComponent(cc.Sprite);
- this.node.on(cc.Node.EventType.TOUCH_END, function () {
- this._bgSprite.spriteFrame = this.bgSpriteFrames[1];
- this.selectedCallback(this.artistData);
- GameEvent.fire(GameNotificationKey.ChangeArtistResidentState, this.artistData.jobId)
- }, this);
- GameEvent.on(GameNotificationKey.ChangeArtistResidentState, this, (jobId) => {
- if (this.artistData.jobId != jobId) {
- this._bgSprite.spriteFrame = this.bgSpriteFrames[0];
- }
- });
- this.recallArtistEvent = _.debounce(() => {
- AlertManager.showArtistOperationAlert(this.buildingInfo, this.uid, this.isSelf, this.artistData);
- }, 1000, true);
- this.cancelResidentEvent = _.debounce(() => {
- HomeApi.friendExpelRecall(this.artistData.id || this.artistData.uid, (responseData) => {
- this.cancelResidentBtn.node.active = false;
- // 取消入驻要收取所有金币
- GameEvent.fire(GameNotificationKey.RefreshResidentArtistList);
- GameEvent.fire(GameNotificationKey.ResidentArtist, this.uid, this.buildingInfo.buildingId);
- GameEvent.fire(GameNotificationKey.NoticeRoleOpt, this.uid, 6);
- }, (code, msg) => {
- console.log(msg);
- });
- }, 1000, true);
- },
- onDestroy() {
- GameEvent.off(GameNotificationKey.ChangeArtistResidentState, this);
- },
- start () {
- },
- // update (dt) {},
- });
|