PlatformManager.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. * 被动分享
  42. */
  43. static onShareAppMessage(): void {
  44. this.impl.onShareAppMessage();
  45. }
  46. /**
  47. * 显示Banner
  48. * @param data
  49. */
  50. static showBanner(data?: any): void {
  51. this.impl.showBanner(data);
  52. }
  53. /**
  54. * 隐藏Banner
  55. */
  56. static hideBanner(): void {
  57. this.impl.hideBanner();
  58. }
  59. /**
  60. * 显示激励广告
  61. * @param data
  62. * @param success
  63. * @param failure
  64. */
  65. static showRewardedVideo(success?: Function, failure?: Function): void {
  66. this.impl.showRewardedVideo(success, failure);
  67. }
  68. /**
  69. * 显示插屏广告
  70. */
  71. static showInsertAd(success?: Function, failure?: Function): void {
  72. this.impl.showInsertAd(success, failure);
  73. }
  74. /**
  75. * 显示原生广告
  76. */
  77. static showNativeAd(success?: Function, failure?: Function): void {
  78. this.impl.showNativeAd(success, failure);
  79. }
  80. /**
  81. * 打点
  82. * @param eventName
  83. * @param data
  84. */
  85. static sendEvent(eventName: string, data?: any): void {
  86. this.impl.sendEvent(eventName, data);
  87. }
  88. /**
  89. * 设置加载进度
  90. * @param progress
  91. */
  92. static setLoadingProgress(progress: number): void {
  93. this.impl.setLoadingProgress(progress);
  94. }
  95. /**
  96. * 加载完成
  97. * @param completeHandler
  98. */
  99. static loadingComplete(completeHandler?: Function): void {
  100. this.impl.loadingComplete(completeHandler);
  101. }
  102. /**
  103. * 游戏互推
  104. * @param num
  105. */
  106. static getRandomPageAd(num: number): any[] {
  107. return this.impl.getRandomPageAd(num);
  108. }
  109. }