PlatformManager.ts 2.5 KB

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