import User from "../../FrameWork/User/User"; import Common5 from "../../Platform/th/Common5"; import InterfaceManager from "../Manager/InterfaceManager"; import UserManager from "../Manager/UserManager"; import PrefabManage, { GameType } from "../PrefabManager/PrefabManage"; import CaiShangLevel2 from "./CaiShangLevel2"; const {ccclass, property} = cc._decorator; @ccclass export default class CaiShangItem extends cc.Component { @property(cc.SpriteFrame) renwuIconArray: cc.SpriteFrame[] = []; @property(cc.Sprite) renwuIcon: cc.Sprite = null; @property(cc.Label) nameLabel: cc.Label = null; @property(cc.Label) gongsiLabel: cc.Label = null; @property(cc.Label) menkanMoneyLabel: cc.Label = null; // LIFE-CYCLE CALLBACKS: // onLoad () {} caishangLevelNode = null data_ = null start () { } refreshView(caishangLevelNode,data_){ this.caishangLevelNode = caishangLevelNode this.data_ = data_ this.renwuIcon.spriteFrame = this.renwuIconArray[this.data_.id] this.nameLabel.string = this.data_.pName this.gongsiLabel.string = this.data_.GongSiName this.menkanMoneyLabel.string = Common5.getNumberChangeHanzi(this.data_.menkanMoney)+'' } challengeClickEvent(){ let times = User.getCaiShangChallengeNum() if(times>0){ if(UserManager.getCurMoney()-this.data_.menkanMoney >=0 ){ UserManager.subMoney(this.data_.menkanMoney) times-- User.setCaiShangChallengeNum(times) User.setCaiShangChallenge(User.getCaiShangChallenge()+1) this.caishangLevelNode.getComponent('CaiShangLevel1').refreshChallengeTime() PrefabManage.loadPrefabByType(GameType.CaiShangLevel2, null, (prefab)=>{ let script_:CaiShangLevel2 = prefab.getComponent('CaiShangLevel2') script_.setData(this.data_) }) }else{ PrefabManage.showTextTips('没钱就在门口看看吧') //Common5.showTips_customTime('没钱就在门口看看吧', 1) } }else{ PrefabManage.showTextTips('次数不足') //Common5.showTips_customTime('次数不足', 1) } } // update (dt) {} }