| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- import CashOutData from "../datas/CashOutData";
- import GameM, { AUDIO_TYPE } from "../manager/GameM";
- import UiM from "../manager/UiM";
- import CashOut from "../ui/CashOut";
- import EffectNode from "../ui/EffectNode";
- /** 常规提现item */
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class CashItem extends cc.Component {
- //noget--
- @property(cc.Node)
- noGetNode: cc.Node = null;
- @property(cc.Label)
- labShowNum: cc.Label = null;
- @property(cc.Node)
- btnOpen: cc.Node = null;
- @property(cc.ProgressBar)
- proBar: cc.ProgressBar = null;
- //tip
- @property(cc.Node)
- nodeTime: cc.Node = null;
- @property(cc.Label)
- labTime: cc.Label = null;
- //hasget--
- @property(cc.Node)
- hasGetNode: cc.Node = null;
- @property(cc.Label)
- labGetMoney: cc.Label = null;
- //car--
- @property(cc.Sprite)
- car: cc.Sprite = null;
- @property(cc.Label)
- labCarLv: cc.Label = null;
- @property(cc.Label)
- labRedCode: cc.Label = null;
- hasGet: boolean = false
- cfg = null
- start() {
- }
- init(cfg, hasGet, redCode, amount) {
- this.cfg = cfg
- this.hasGet = hasGet
- cc.loader.loadRes('carPic/side/side_' + cfg.type_value, cc.SpriteFrame, (err, assets) => {
- if (err) {
- cc.error(err);
- return;
- }
- this.car.spriteFrame = assets;
- })
- this.labCarLv.string = `${cfg.type_value}`
- this.noGetNode.active = !this.hasGet
- this.hasGetNode.active = this.hasGet
- this.labRedCode.string = ""
- //已经领取
- if (this.hasGet) {
- this.labRedCode.string = redCode
- this.labGetMoney.string = `${(amount * 0.01).toFixed(2)}`
- }
- else {
- this.labShowNum.string = cfg.moneyshow
- this.nodeTime.active = true
- let days = Number(cfg.time) - GameM.commonData.loginDays
- if (days <= 0) {
- days = 0
- }
- else if (days == 1) {
- days = 1
- }
- else {
- if (Number(cfg.time) > 30) {
- days = 30
- } else {
- days = Number(cfg.time)
- }
- }
- if (days == 0) {
- // this.labTime.string = '今日可领'
- let dis = cfg.type_value - GameM.commonData.maxCarLevel
- this.labTime.string = `还差${dis}级`
- }
- else if (days == 1) {
- this.labTime.string = '次日领取'
- }
- else {
- this.labTime.string = `${days}日领取`
- }
- //可领取
- if (GameM.commonData.maxCarLevel >= cfg.type_value && days == 0) {
- this.btnOpen.active = true
- this.proBar.node.active = false
- this.nodeTime.active = false
- this.labShowNum.node.y = 160
- }
- else {
- this.btnOpen.active = false
- this.proBar.node.active = true
- this.nodeTime.active = true
- this.labShowNum.node.y = 135
- let pro = GameM.commonData.maxCarLevel / cfg.type_value
- if (pro > 1) {
- pro = 1
- }
- this.proBar.progress = pro
- }
- }
- }
- setRedCode(withdrawalCode) {
- this.labRedCode.string = withdrawalCode
- }
- clickOpen() {
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- this.goCash()
- }
- goCash() {
- if (GameM.commonData.isAuth) {
- if (GameM.commonData.redMoney < 3000) {
- EffectNode.instance.PlayTip('红包币不足')
- return
- }
- // CashOutData.Instance.checkDefeatBoss(this.cfg)
- if (CashOutData.Instance.checkShowTip(this.cfg)) {
- let curCashCfg = CashOutData.Instance.getCashByIndex(this.cfg.index)
- if (curCashCfg) {
- UiM.Instance.cashNode.getComponent(CashOut).onTixian(curCashCfg)
- }
- }
- }
- else {
- UiM.Instance.cashNode.getComponent(CashOut).showAuth()
- }
- }
- clickMonster() {
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- if (CashOutData.Instance.checkShowTip(this.cfg)) {
- this.goCash()
- }
- }
- }
|