PigBank.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import JsbSystem from "../../../mk/system/JsbSystem";
  2. const { ccclass, property } = cc._decorator;
  3. /**
  4. * 存钱罐界面样式
  5. * @author 薛鸿潇
  6. */
  7. @ccclass
  8. export default class PigBank extends cc.Component {
  9. @property({ type: cc.Label, displayName: '按钮描述' })
  10. private lbl_get_desc: cc.Label = null!;
  11. @property({ type: cc.Label, displayName: '存款数量' })
  12. private lbl_deposit: cc.Label = null!;
  13. @property({ type: cc.Node, displayName: '提示动画' })
  14. private node_tip_anim: cc.Node = null!;
  15. @property({ type: cc.Animation, displayName: '提现动画' })
  16. private anim_btn_cash: cc.Animation = null!;
  17. onLoad() {
  18. }
  19. start() {
  20. this.initCashDesc();
  21. mk.audio.playEffect("pigBank", false);
  22. // let target_node = gData.gameData.gameStyle.icon_hb;
  23. // const end_world_pos = target_node.parent.convertToWorldSpaceAR(target_node.getPosition());
  24. // const end_node_pos = gData.gameData.gameStyle.node.parent.convertToNodeSpaceAR(end_world_pos);
  25. // let start_node_pos = new cc.Vec2(0, -300);
  26. // mk.fly.PlayCoinAnim(1, 10, start_node_pos, end_node_pos, () => {
  27. // if (!gData.gameData.init_coin) gData.gameData.gameData.redMoney = 1234
  28. // });
  29. }
  30. update(dt) {
  31. if (gData.pigbank.init_data) {
  32. this.initCashDesc();
  33. }
  34. if (gData.pigbank.adData) {
  35. cc.log('存钱罐提现', gData.pigbank.adData)
  36. }
  37. }
  38. lateUpdate() {
  39. gData.pigbank.init_data = false;
  40. gData.pigbank.adData = null;
  41. }
  42. /**
  43. * 提现描述展示
  44. */
  45. private initCashDesc() {
  46. if (gData.gameData.gameData.isWithdrawable) {
  47. this.lbl_get_desc.string = '直接提现';
  48. this.node_tip_anim.active = false;
  49. this.anim_btn_cash.play();
  50. } else {
  51. if (gData.gameData.gameData.piggyBank >= gData.pigbank.cash_min_limit) {
  52. this.lbl_get_desc.string = '明日可提现';
  53. } else {
  54. this.lbl_get_desc.string = '满' + gData.pigbank.cash_min_limit + '元可提';
  55. }
  56. this.node_tip_anim.active = true;
  57. this.anim_btn_cash.stop();
  58. this.anim_btn_cash.node.scale = 1;
  59. }
  60. this.initDeposit()
  61. }
  62. /**
  63. * 初始化存钱罐金额
  64. * - 精确到分
  65. */
  66. private initDeposit() {
  67. const new_count = gData.gameData.gameData.piggyBank / 100;
  68. this.lbl_deposit.string = new_count.toFixed(2) + '元';
  69. }
  70. /**
  71. * 提现操作
  72. */
  73. private clickCashOP() {
  74. mk.audio.playEffect("button");
  75. if (!gData.gameData.gameData.isWithdrawable) {
  76. mk.tip.pop('明日可提现')
  77. return;
  78. } else if (gData.gameData.gameData.piggyBank < gData.pigbank.cash_min_limit) {
  79. mk.tip.pop('满' + gData.pigbank.cash_min_limit + '元可提现')
  80. return;
  81. }
  82. if (!gData.loginData.isAuth) {
  83. JsbSystem.WxAuth();
  84. return;
  85. }
  86. gData.pigbank.cashOP();
  87. mk.ui.closePanel(this.node.name);
  88. }
  89. /**
  90. * 打开帮助界面完成回调
  91. */
  92. private async clickOpenHelpCall() {
  93. let des = "1、游戏内观看任意视频,都会获得现金。\n\n2、存款达到0.3元后,次日登陆,可无门槛提现。\n\n3、提现后,存款清零,可重新开始。";
  94. gData.help.des = des;
  95. }
  96. /** 点击关闭 */
  97. onClickClose() {
  98. mk.ad.checkShowInterByChance();
  99. }
  100. }