123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- 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],
- effectSpriteFrames: [cc.SpriteFrame],
-
- headSprite: cc.Sprite,
- effectSprite: 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;
- }
- },
- flag: {
- get: function () {
- if (!this._flag) {
- this._flag = 0;
- }
- return this._flag;
- },
- set: function (value) {
- this._flag = value;
- this._bgSprite.spriteFrame = this.bgSpriteFrames[value];
- this.effectSprite.spriteFrame = this.effectSpriteFrames[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, () => {
- this.selectedCallback(this.artistData);
- }, this);
- 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);
- },
- setStyle(uid) {
- this.flag = (this.artistData.uid === uid) ? 1 : 0;
- },
- selectItem() {
- this.flag = 1;
- this.selectedCallback(this.artistData);
- },
- start () {
- },
-
- });
|