| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- import JsbSystem from "../../../mk/system/JsbSystem";
- import { DataEventId, GameProp } from "../../data/GameData";
- const { ccclass, property } = cc._decorator;
- /**
- * 存钱罐界面样式
- * @author 薛鸿潇
- */
- @ccclass
- export default class PigBank extends cc.Component {
- @property({ type: cc.Label, displayName: '按钮描述' })
- private lbl_get_desc: cc.Label = null!;
- @property({ type: cc.Label, displayName: '存款数量' })
- private lbl_deposit: cc.Label = null!;
- @property({ type: cc.Node, displayName: '提示动画' })
- private node_tip_anim: cc.Node = null!;
- @property({ type: cc.Animation, displayName: '提现动画' })
- private anim_btn_cash: cc.Animation = null!;
- onLoad() {
- }
- start() {
- this.initCashDesc();
- mk.audio.playEffect("pigBank", false);
- // let target_node = gData.gameData.gameStyle.icon_hb;
- // const end_world_pos = target_node.parent.convertToWorldSpaceAR(target_node.getPosition());
- // const end_node_pos = gData.gameData.gameStyle.node.parent.convertToNodeSpaceAR(end_world_pos);
- // let start_node_pos = new cc.Vec2(0, -300);
- // mk.fly.PlayCoinAnim(1, 10, start_node_pos, end_node_pos, () => {
- // if (!gData.gameData.init_coin) gData.gameData.gameData.redMoney = 1234
- // });
- }
- update(dt) {
- if (gData.pigbank.init_data) {
- this.initCashDesc();
- }
- if (gData.pigbank.adData) {
- cc.log('存钱罐提现', gData.pigbank.adData)
- }
- }
- lateUpdate() {
- gData.pigbank.init_data = false;
- gData.pigbank.adData = null;
- }
- /**
- * 提现描述展示
- */
- private initCashDesc() {
- if (gData.gameData.gameData.isWithdrawable) {
- this.lbl_get_desc.string = '直接提现';
- this.node_tip_anim.active = false;
- this.anim_btn_cash.play();
- } else {
- if (gData.gameData.gameData.piggyBank >= gData.pigbank.cash_min_limit) {
- this.lbl_get_desc.string = '明日可提现';
- } else {
- this.lbl_get_desc.string = '满' + (gData.pigbank.cash_min_limit / 100).toFixed(2) + '元可提';
- }
- this.node_tip_anim.active = true;
- this.anim_btn_cash.stop();
- this.anim_btn_cash.node.scale = 1;
- }
- this.initDeposit()
- }
- /**
- * 初始化存钱罐金额
- * - 精确到分
- */
- private initDeposit() {
- const new_count = gData.gameData.gameData.piggyBank / 100;
- this.lbl_deposit.string = new_count.toFixed(2) + '元';
- }
- /**
- * 提现操作
- */
- private clickCashOP() {
- mk.audio.playEffect("button");
- if (!gData.gameData.gameData.isWithdrawable) {
- if (gData.gameData.gameData.piggyBank < gData.pigbank.cash_min_limit) {
- mk.tip.pop('满' + (gData.pigbank.cash_min_limit / 100).toFixed(2) + '元可提现')
- }
- else {
- mk.tip.pop('明日可提现')
- }
- return;
- } else if (gData.gameData.gameData.piggyBank < gData.pigbank.cash_min_limit) {
- mk.tip.pop('满' + (gData.pigbank.cash_min_limit / 100).toFixed(2) + '元可提现')
- return;
- }
- if (!gData.loginData.isAuth) {
- JsbSystem.WxAuth();
- return;
- }
- mk.data.sendDataEvent(DataEventId.jarWithDrawal, "存钱罐提现成功");
- gData.pigbank.cashOP();
- mk.ui.closePanel(this.node.name);
- }
- /**
- * 打开帮助界面完成回调
- */
- private async clickOpenHelpCall() {
- let des = "1、游戏内观看任意视频,都会获得现金。\n\n2、存款达到0.3元后,次日登陆,可无门槛提现。\n\n3、提现后,存款清零,可重新开始。";
- gData.help.des = des;
- }
- /** 点击关闭 */
- onClickClose() {
- mk.ad.checkShowInterByChance();
- }
- onDestroy() {
- const isAutoOpenPanel = gData.gameData.getProp(GameProp.isAutoOpenPanel);
- if (isAutoOpenPanel === 1) {
- // 必须是可签到才弹
- if (!gData.gameData.gameData.isSignInToday && gData.sign.haveSignDay()) {
- mk.ui.openPanel('module/sign/sign');
- }
- else {
- gData.guideToWxData.checkPop();
- gData.gameData.setProp(GameProp.isAutoOpenPanel, 2);
- }
- }
- }
- onDisable() {
- if (gData.pigbank.success) {
- gData.pigbank.success = false;
- gData.safeDepositBoxData.creatPacketAnim(2);
- }
- }
- }
|