RedBagTask.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import Util from "../../../before/util/Util";
  2. const { ccclass, property } = cc._decorator;
  3. @ccclass
  4. export default class RedBagTask extends cc.Component {
  5. @property({ displayName: '数字组', type: cc.Label })
  6. private lbl_value: cc.Label[] = [];
  7. @property({ displayName: '任务描述', type: cc.RichText })
  8. private rt_task_des: cc.RichText = null;
  9. @property({ displayName: '任务进度条', type: cc.Sprite })
  10. private sp_taskProgress: cc.Sprite = null;
  11. @property({ displayName: '任务进度文本', type: cc.Label })
  12. private lbl_taskProgress: cc.Label = null;
  13. @property({ displayName: '按钮动画', type: cc.Animation })
  14. private openBtn_ani: cc.Animation = null;
  15. @property(cc.Label)
  16. private lbl_reward_value: cc.Label = null;
  17. @property(cc.Sprite)
  18. private spr_cash_out: cc.Sprite = null;
  19. @property(cc.Label)
  20. private lbl_progress: cc.Label = null;
  21. @property(cc.Animation)
  22. private node_cash: cc.Animation = null;
  23. start() {
  24. mk.ad.showBanner();
  25. this.initTaskProgressUI();
  26. this.initCashOutStyle(gData.gameData.gameData.redMoney);
  27. this.showChangePart();
  28. }
  29. onEnable() {
  30. mk.ad.showBanner();
  31. }
  32. onDisable() {
  33. mk.ad.destoryBanner();
  34. }
  35. update(dt) {
  36. if (gData.reward.add_redbag_value) {
  37. this.initCashOutStyle(gData.gameData.gameData.redMoney + gData.reward.add_redbag_value);
  38. }
  39. }
  40. private initTaskProgressUI() {
  41. cc.tween(this.sp_taskProgress).delay(0.2).to(0.3, { fillRange: 0.4 }, {
  42. onUpdate: () => {
  43. let str = this.sp_taskProgress.fillRange * 100;
  44. this.lbl_taskProgress.string = str.toFixed(0) + "%";
  45. }
  46. }).start();
  47. cc.tween(this)
  48. }
  49. showChangePart() {
  50. //this.changePart.active = true
  51. let len = this.lbl_value.length;
  52. this.schedule(() => {
  53. for (var i = 0; i < len; i++) {
  54. let ran = Util.rnd(0, 9);
  55. this.lbl_value[i].string = `${ran}`;
  56. }
  57. }, 0.1)
  58. }
  59. /**
  60. * 底部提现相关样式
  61. */
  62. private initCashOutStyle(redMoney: number = 0) {
  63. const cash_bar = gData.redBagCash.cash_bar;
  64. let cash_data = gData.redBagCash.getItemDataByIndex(cash_bar);
  65. if (!cash_data) return;
  66. const newRedMoney = redMoney > cash_data.type_value ? cash_data.type_value : redMoney;
  67. this.lbl_reward_value.string = cash_data.money / 100 + '元';
  68. this.lbl_progress.string = newRedMoney + '/' + cash_data.type_value;
  69. const fillRange = newRedMoney / cash_data.type_value >= 1 ? 1 : newRedMoney / cash_data.type_value;
  70. // this.spr_cash_out.fillRange = fillRange;
  71. cc.tween(this.spr_cash_out).to(fillRange, { fillRange: fillRange }).start();
  72. if (redMoney >= cash_data.type_value) {
  73. this.node_cash.play();
  74. } else {
  75. this.node_cash.stop();
  76. }
  77. }
  78. private clickVideoBtn() {
  79. }
  80. private clickGetRewardBtn() {
  81. //gData.receiptNotice.receip_rmb = gData.blessingBag.rbNum;
  82. //mk.ui.openPanel('module/newNotice/newNotice');
  83. }
  84. /**
  85. * 提现操作
  86. */
  87. private clickCashOut() {
  88. mk.audio.playEffect("button");
  89. gData.reward.addReward();
  90. //mk.ui.closePanel(this.node.name);
  91. let path = 'module/newCashUI/walletCashOut';
  92. mk.ui.openPanel(path);
  93. }
  94. private clickCloseBtn() {
  95. mk.audio.playEffect("closeButton");
  96. }
  97. }