PlatformManager.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import { _decorator, Component, Node } from 'cc';
  2. import { IPlatform } from './IPlatform';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('PlatformManager')
  5. export class PlatformManager{
  6. static impl:IPlatform;
  7. /**
  8. * 初始化
  9. * @param impl
  10. */
  11. static init(impl:IPlatform):void{
  12. this.impl=impl;
  13. }
  14. /**
  15. * 登录
  16. * @param success 成功
  17. * @param failure 失败
  18. */
  19. static login(success:Function,failure?:Function):void{
  20. this.impl.login(success,failure);
  21. }
  22. /**
  23. * 跳转
  24. * @param data
  25. * @param success
  26. * @param failure
  27. */
  28. static navigate2Mini(data:any,success?:Function,failure?:Function):void{
  29. this.impl.navigate2Mini(data,success,failure);
  30. }
  31. /**
  32. * 分享
  33. * @param data
  34. * @param success
  35. * @param failure
  36. */
  37. static shareMessage(data:any,success?:Function,failure?:Function):void{
  38. this.impl.shareMessage(data,success,failure);
  39. }
  40. /**
  41. * 显示Banner
  42. * @param data
  43. */
  44. static showBanner(data?:any):void{
  45. this.impl.showBanner(data);
  46. }
  47. /**
  48. * 隐藏Banner
  49. */
  50. static hideBanner():void{
  51. this.impl.hideBanner();
  52. }
  53. /**
  54. * 显示激励广告
  55. * @param data
  56. * @param success
  57. * @param failure
  58. */
  59. static showRewardedVideo(success?:Function,failure?:Function):void{
  60. this.impl.showRewardedVideo(success,failure);
  61. }
  62. /**
  63. * 显示插屏广告
  64. */
  65. static showInsertAd(success?:Function,failure?:Function):void{
  66. this.impl.showInsertAd(success,failure);
  67. }
  68. /**
  69. * 显示原生广告
  70. */
  71. static showNativeAd(success?:Function,failure?:Function):void{
  72. this.impl.showNativeAd(success,failure);
  73. }
  74. /**
  75. * 打点
  76. * @param eventName
  77. * @param data
  78. */
  79. static sendEvent(eventName:string,data?:any):void{
  80. this.impl.sendEvent(eventName,data);
  81. }
  82. /**
  83. * 设置加载进度
  84. * @param progress
  85. */
  86. static setLoadingProgress(progress:number):void{
  87. this.impl.setLoadingProgress(progress);
  88. }
  89. /**
  90. * 加载完成
  91. * @param completeHandler
  92. */
  93. static loadingComplete(completeHandler?:Function):void{
  94. this.impl.loadingComplete(completeHandler);
  95. }
  96. /**
  97. * 游戏互推
  98. * @param num
  99. */
  100. static getRandomPageAd(num: number): any[] {
  101. return this.impl.getRandomPageAd(num);
  102. }
  103. }