PigBank.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. const { ccclass, property } = cc._decorator;
  2. /**
  3. * 存钱罐界面样式
  4. * @author 薛鸿潇
  5. */
  6. @ccclass
  7. export default class PigBank extends cc.Component {
  8. @property({ type: cc.Label, displayName: '按钮描述' })
  9. private lbl_get_desc: cc.Label = null!;
  10. @property({ type: cc.Label, displayName: '存款数量' })
  11. private lbl_deposit: cc.Label = null!;
  12. @property({ type: cc.Node, displayName: '提示动画' })
  13. private node_tip_anim: cc.Node = null!;
  14. @property({ type: cc.Animation, displayName: '提现动画' })
  15. private anim_btn_cash: cc.Animation = null!;
  16. onLoad() {
  17. }
  18. start() {
  19. this.initCashDesc();
  20. mk.audio.playEffect("pigBank",false);
  21. }
  22. update(dt) {
  23. if (gData.pigbank.init_data) {
  24. gData.pigbank.init_data = false;
  25. this.initCashDesc();
  26. }
  27. if (gData.pigbank.adData) {
  28. cc.log('存钱罐提现', gData.pigbank.adData)
  29. gData.pigbank.adData = null;
  30. }
  31. }
  32. /**
  33. * 提现描述展示
  34. */
  35. private initCashDesc() {
  36. if (gData.pigbank.cash_enable) {
  37. this.lbl_get_desc.string = '直接提现';
  38. this.node_tip_anim.active = false;
  39. this.anim_btn_cash.play();
  40. } else {
  41. if (gData.pigbank.cur_cash_count >= gData.pigbank.cash_min_limit) {
  42. this.lbl_get_desc.string = '明日可提现';
  43. } else {
  44. this.lbl_get_desc.string = '满' + gData.pigbank.cash_min_limit + '元可提';
  45. }
  46. this.node_tip_anim.active = true;
  47. this.anim_btn_cash.stop();
  48. this.anim_btn_cash.node.scale = 1;
  49. }
  50. this.initDeposit()
  51. }
  52. /**
  53. * 初始化存钱罐金额
  54. * - 精确到分
  55. */
  56. private initDeposit() {
  57. const new_count = gData.pigbank.cur_cash_count.toFixed(2)
  58. this.lbl_deposit.string = new_count + '元';
  59. }
  60. /**
  61. * 提现操作
  62. */
  63. private clickCashOP() {
  64. if (!gData.pigbank.cash_enable) return;
  65. gData.pigbank.cashOP();
  66. mk.ui.closePanel(this.node.name);
  67. }
  68. /**
  69. * 打开帮助界面完成回调
  70. */
  71. private async clickOpenHelpCall() {
  72. gData.help.init_desc_name = this.node.name;
  73. }
  74. }