FullOutputMediator.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. this.randomCpa();
  29. this.scheduleOnce(this.showContinueButton.bind(this), 1);
  30. this.scheduleOnce(this.showDaochuButton.bind(this), 3);
  31. }
  32. OnHide():void{
  33. this.ContinueButton.active = false;
  34. this.ButtonDaochuBack.active = false;
  35. this.continueShowBanner = true;
  36. PlatformManager.showBanner();
  37. }
  38. randomCpa():void{
  39. if(this.wx!=null)
  40. {
  41. let adList: any[] = LiangLiangSDK.GetList();
  42. let data = adList[Math.floor(Math.random()*adList.length)]
  43. this.wx.navigateToMiniProgram({
  44. appId: data.app_id,
  45. path: data.app_path,
  46. success: (res) =>
  47. {
  48. LiangLiangSDK.CpaReport(self.data);
  49. },
  50. fail: (res) => {
  51. // GUIManager.single.Show(UIConst.FULL_OUTPUT_UI);
  52. console.log("跳转失败!");
  53. },
  54. complete: (res) => {},
  55. });
  56. }
  57. }
  58. showContinueButton():void{
  59. this.ContinueButton.active = true;
  60. }
  61. showDaochuButton():void{
  62. this.ButtonDaochuBack.active = true;
  63. }
  64. /**
  65. * 返回主界面
  66. */
  67. BackToMain():void{
  68. SceneManager.single.Swicth("PrepareScene");
  69. this.HideSelf();
  70. if(LiangLiangSDK.CanWuChu() == true){
  71. this.randomCpa();
  72. }
  73. }
  74. ContinueGame():void{
  75. if(LiangLiangSDK.CanWuChu() == true){
  76. if(this.continueShowBanner == true){
  77. this.__bannerWuChu();
  78. }else{
  79. this.randomCpa();
  80. }
  81. }else{
  82. SceneManager.single.Swicth("PrepareScene");
  83. this.HideSelf();
  84. }
  85. }
  86. /**
  87. * 误触逻辑
  88. */
  89. private __bannerWuChu():void{
  90. this.scheduleOnce(()=>{
  91. PlatformManager.showBanner();
  92. this.scheduleOnce(()=>{
  93. PlatformManager.hideBanner();
  94. this.continueShowBanner = false;
  95. }, 1)
  96. }, 1)
  97. }
  98. private get wx():any{
  99. return window["wx"];
  100. }
  101. // update (deltaTime: number) {
  102. // // Your update function goes here.
  103. // }
  104. }