12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- const TapTapTool = require("../utils/TapTapTool");
- const DWTool = require("../utils/DWTool");
- const {GameNotificationKey} = require('../utils/GameEnum');
- cc.Class({
- extends: cc.Component,
- properties: {
- dayRichText: cc.RichText,
- itemSprite: cc.Sprite,
- itemCountRichText: cc.RichText,
- isGainNode: cc.Node,
- isSigned: {
- get: function() {
- if (!this._isSigned) {
- this._isSigned = false;
- }
- return this._isSigned;
- },
- set: function(value) {
- this._isSigned = value;
- if (this._isSigned) {
- this.isGainNode.active = true;
- } else {
- this.isGainNode.active = false;
- }
- }
- },
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {
- GameEvent.on(GameNotificationKey.LoginRewardGainOneDay, this, (rewardId) => {
- if (this.model.rewardId == rewardId) {
- this.isSigned = true;
- }
- });
- },
- onDestroy() {
- GameEvent.off(GameNotificationKey.LoginRewardGainOneDay, this);
- },
- start () {
- },
- init(model) {
- this.model = model;
- this.configData();
- },
- configData() {
- this.dayRichText.string = `<b>${this.model.title}</b>`;
- let gold = TapTapTool.goldStrToClass(this.model.coin);
- if (this.model.diamond > 0) {
- DWTool.loadResSpriteFrame("./textures/loginReward/login_reward_diamond")
- .then((spriteFrame) => {
- this.itemSprite.spriteFrame = spriteFrame;
- }).catch((err) => {
- console.log(err);
- });
- this.itemCountRichText.string = `<b><outline color=#000000 width=2>钻石 X${this.model.diamond}</outline></b>`;
- } else if (gold.n > 0) {
- DWTool.loadResSpriteFrame("./textures/loginReward/login_reward_coin")
- .then((spriteFrame) => {
- this.itemSprite.spriteFrame = spriteFrame;
- }).catch((err) => {
- console.log(err);
- });
- this.itemCountRichText.string = `<b><outline color=#000000 width=2>金币 X${TapTapTool.parseToString(gold)}</outline></b>`;
- }
- if (GameGlobal.userLoginReward.rewardCount >= this.model.rewardId) {
- this.isSigned = true;
- } else {
- this.isSigned = false;
- }
- }
- // update (dt) {},
- });
|