123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- const DWTool = require("../utils/DWTool");
- const {GameNotificationKey} = require('../utils/GameEnum');
- var TalentApi = require('../net/TalentApi');
- //任务状态[0 : 完成可领取, 1 : 未完成, 2 : 完成已领取]
- var TalentMissionItemType = cc.Enum({
- Gain: 0,
- NoFinished: 1,
- Finished: 2,
- });
- cc.Class({
- extends: cc.Component,
- properties: {
- awardNode1: cc.Node,
- awardItemNode1: cc.Node,
- countLabel1: cc.Label,
- awardNode2: cc.Node,
- awardItemNode2: cc.Node,
- countLabel2: cc.Label,
- awardRichText: cc.RichText,
- noButton: cc.Button,
- gainButton: cc.Button,
- finishButton: cc.Button,
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- start () {
- },
- hideAllButton() {
- this.noButton.node.active = false;
- this.gainButton.node.active = false;
- this.finishButton.node.active = false;
- },
- onDisable() {
- this.awardNode1.active = false;
- this.awardNode2.active = false;
- },
- configData(model, invitedCount) {
- this.model = model;
- this.hideAllButton();
- switch (model.state) {
- case TalentMissionItemType.NoFinished:
- this.noButton.node.active = true;
- break;
- case TalentMissionItemType.Finished:
- this.finishButton.node.active = true;
- break;
- case TalentMissionItemType.Gain:
- this.gainButton.node.active = true;
- break;
- }
- let coin = model.coin;
- let diamond = model.diamond;
- let ticket = model.ticket;
- if (coin > 0) {
- this.awardNode1.active = true;
- cc.loader.loadRes("talent/talent_invite_coin", cc.SpriteFrame, (err, spriteFrame) => {
- if (err) {
- } else {
- this.awardItemNode1.getComponent('cc.Sprite').spriteFrame = spriteFrame;
- }
- });
- this.countLabel1.string = DWTool.coinParse(coin);
- }
- if (diamond > 0) {
- if (this.awardNode1.active) {
- this.awardNode2.active = true;
- cc.loader.loadRes("talent/talent_invite_diamond", cc.SpriteFrame, (err, spriteFrame) => {
- if (err) {
- } else {
- this.awardItemNode2.getComponent('cc.Sprite').spriteFrame = spriteFrame;
- }
- });
- this.countLabel2.string = DWTool.coinParse(diamond);
- } else {
- this.awardNode1.active = true;
- cc.loader.loadRes("talent/talent_invite_diamond", cc.SpriteFrame, (err, spriteFrame) => {
- if (err) {
- } else {
- this.awardItemNode1.getComponent('cc.Sprite').spriteFrame = spriteFrame;
- }
- });
- this.countLabel1.string = DWTool.coinParse(diamond);
- }
- }
- if (ticket > 0) {
- if (this.awardNode1.active) {
- this.awardNode2.active = true;
- cc.loader.loadRes("talent/talent_invite_ticket", cc.SpriteFrame, (err, spriteFrame) => {
- if (err) {
- } else {
- this.awardItemNode2.getComponent('cc.Sprite').spriteFrame = spriteFrame;
- }
- });
- this.countLabel2.string = DWTool.coinParse(ticket);
- } else {
- this.awardNode1.active = true;
- cc.loader.loadRes("talent/talent_invite_ticket", cc.SpriteFrame, (err, spriteFrame) => {
- if (err) {
- } else {
- this.awardItemNode1.getComponent('cc.Sprite').spriteFrame = spriteFrame;
- }
- });
- this.countLabel1.string = DWTool.coinParse(ticket);
- }
- }
- this.awardRichText.string = `签约奖励\n<color=#AF7434 >(艺人:${invitedCount}/${model.count}名)</c>`;
- },
- gainAward() {
- TalentApi.postGainAward(this.model.id, (responseData) => {
- this.refreshButtonState();
- }, (error) => {
- console.log('星探领取 error' + error);
- });
- },
- refreshButtonState() {
- this.model.state = TalentMissionItemType.Finished;
- this.hideAllButton();
- this.finishButton.node.active = true;
- GameEvent.fire(GameNotificationKey.TalentGainAward, this.model);
- },
- // update (dt) {},
- });
|