FullOutputMediator.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import { _decorator, Component, Node } from 'cc';
  2. import { GUIManager } from '../../../engines/gui/GUIManager';
  3. import { GUIMediator } from '../../../engines/gui/GUIMediator';
  4. import { SceneManager } from '../../../engines/scenes/SceneManager';
  5. import { LiangLiangSDK } from '../../../libs/liangliangSDK';
  6. import { PlatformManager } from '../../../Platform/PlatformManager';
  7. import { UIConst } from '../UIConst';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('FullOutputMediator')
  10. export class FullOutputMediator extends GUIMediator {
  11. continueShowBanner:boolean = true;
  12. @property({
  13. type:Node
  14. })
  15. ContinueButton:Node=null;
  16. @property({
  17. type:Node
  18. })
  19. ButtonDaochuBack:Node=null;
  20. start () {
  21. // Your initialization goes here.
  22. }
  23. OnShow(data?:any):void{
  24. PlatformManager.hideBanner();
  25. this.ContinueButton.active = false;
  26. this.ButtonDaochuBack.active = false;
  27. this.data=data;
  28. if(LiangLiangSDK.CanWuChu()){
  29. this.randomCpa();
  30. }
  31. this.scheduleOnce(this.showContinueButton.bind(this), 1);
  32. this.scheduleOnce(this.showDaochuButton.bind(this), 3);
  33. }
  34. OnHide():void{
  35. this.ContinueButton.active = false;
  36. this.ButtonDaochuBack.active = false;
  37. this.continueShowBanner = true;
  38. PlatformManager.showBanner();
  39. }
  40. randomCpa():void{
  41. if(this.wx!=null)
  42. {
  43. let adList: any[] = LiangLiangSDK.GetList();
  44. let data = adList[Math.floor(Math.random()*adList.length)]
  45. this.wx.navigateToMiniProgram({
  46. appId: data.app_id,
  47. path: data.app_path,
  48. success: (res) =>
  49. {
  50. LiangLiangSDK.CpaReport(self.data);
  51. },
  52. fail: (res) => {
  53. // GUIManager.single.Show(UIConst.FULL_OUTPUT_UI);
  54. console.log("跳转失败!");
  55. },
  56. complete: (res) => {},
  57. });
  58. }
  59. }
  60. showContinueButton():void{
  61. this.ContinueButton.active = true;
  62. }
  63. showDaochuButton():void{
  64. this.ButtonDaochuBack.active = true;
  65. }
  66. /**
  67. * 返回主界面
  68. */
  69. BackToMain():void{
  70. SceneManager.single.Swicth("PrepareScene");
  71. this.HideSelf();
  72. if(LiangLiangSDK.CanWuChu() == true){
  73. this.randomCpa();
  74. }
  75. }
  76. ContinueGame():void{
  77. if(LiangLiangSDK.CanWuChu() == true){
  78. if(this.continueShowBanner == true){
  79. this.__bannerWuChu();
  80. }else{
  81. this.randomCpa();
  82. }
  83. }else{
  84. SceneManager.single.Swicth("PrepareScene");
  85. this.HideSelf();
  86. }
  87. }
  88. /**
  89. * 误触逻辑
  90. */
  91. private __bannerWuChu():void{
  92. this.scheduleOnce(()=>{
  93. PlatformManager.showBanner();
  94. this.scheduleOnce(()=>{
  95. PlatformManager.hideBanner();
  96. this.continueShowBanner = false;
  97. }, 1)
  98. }, 1)
  99. }
  100. private get wx():any{
  101. return window["wx"];
  102. }
  103. // update (deltaTime: number) {
  104. // // Your update function goes here.
  105. // }
  106. }