GradeRewardItem.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import JsbSystem from "../../../mk/system/JsbSystem";
  2. import { UITween } from "../../component/tween/UITween";
  3. import { VideoAdType } from "../../data/GameData";
  4. const { ccclass, property } = cc._decorator;
  5. @ccclass
  6. export class GradeRewardItem extends cc.Component{
  7. @property({displayName:"名字", type: cc.Sprite})
  8. private sp_name: cc.Sprite = null;
  9. @property({displayName:"等级", type: cc.Label})
  10. private lbl_grade: cc.Label = null;
  11. @property({displayName:"金额",type: cc.Label})
  12. private lbl_value: cc.Label = null;
  13. @property({type: cc.Node})
  14. private node_unGetRewad: cc.Node = null;
  15. @property({type: cc.Node})
  16. private node_unluck: cc.Node = null;
  17. @property({type: cc.Node})
  18. private node_getRewad: cc.Node = null;
  19. public id: number;
  20. private data:any = {};
  21. onLoad(){
  22. }
  23. async start(){
  24. this.id = this.data.id;
  25. this.lbl_value.string = this.data.showMoney;
  26. this.lbl_grade.string = `LV:${this.data.level}`;
  27. this.sp_name.spriteFrame = await mk.loader.load('module/gradeReward/texture/name' + this.id, cc.SpriteFrame);
  28. this.changeBtnState();
  29. this.showUIAct();
  30. }
  31. changeBtnState()
  32. {
  33. if( this.data.status == 1)
  34. {
  35. this.node_unGetRewad.active = true;
  36. this.node_unluck.active = false;
  37. this.node_getRewad.active = false;
  38. }else if (this.data.status == 0){
  39. this.node_unGetRewad.active = false;
  40. this.node_unluck.active = true;
  41. this.node_getRewad.active = false;
  42. }
  43. else{
  44. this.node_unGetRewad.active = false;
  45. this.node_unluck.active = false;
  46. this.node_getRewad.active = true;
  47. }
  48. }
  49. setData(data)
  50. {
  51. this.data = data;
  52. }
  53. public showUIAct()
  54. {
  55. let p = this.node.position;
  56. this.node.position = cc.v3(540, p.y, 0);
  57. cc.tween(this.node).delay(0.9 - this.id * 0.1).call(()=>{
  58. this.node.active = true;
  59. }).to(0.2, {x: 0}).start();
  60. }
  61. private clickUnGetRewardBtn(){
  62. mk.audio.playEffect("button");
  63. if (cc.sys.isNative && !gData.loginData.isAuth) {
  64. // JsbSystem.WxAuth();
  65. gData.gameData.authUIType = 0;
  66. mk.ui.openPanel('module/authUI/authUI');
  67. return;
  68. }
  69. gData.adData.checkPopCashFull();
  70. gData.farmGradeData.HttpCashOut(this.data.id);
  71. // mk.ad.videoAdType = VideoAdType.farmGradeCashOut;
  72. // mk.ad.watchAd((success: boolean) => {
  73. // mk.console.log("watchFarmAd:" + success);
  74. // if (success) {
  75. // }
  76. // });
  77. }
  78. private clickNoReachBtn(){
  79. mk.audio.playEffect("button");
  80. mk.tip.pop('提现进度不足');
  81. }
  82. private clickGetRewardBtn(){
  83. mk.audio.playEffect("button");
  84. mk.tip.pop('该红包已提现');
  85. }
  86. }