123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- import { IPlatform } from "./IPlatform";
- export class PlatformManager {
- static impl: IPlatform;
- /**
- * 初始化
- * @param impl
- */
- static init(impl: IPlatform): void {
- this.impl = impl;
- }
- /**
- * 登录
- * @param success 成功
- * @param failure 失败
- */
- static login(success: Function, failure?: Function): void {
- this.impl.login(success, failure);
- }
- /**
- * 跳转
- * @param data
- * @param success
- * @param failure
- */
- static navigate2Mini(data: any, success?: Function, failure?: Function): void {
- this.impl.navigate2Mini(data, success, failure);
- }
- /**
- * 随机跳转
- * @param success
- * @param failure
- */
- static randomNavigate2Mini(success?: Function, failure?: Function):void{
- let list:any[]=this.getRandomPageAd(20);
- let index:number=Math.floor(Math.random()*list.length);
- let data:any=list[index];
- this.navigate2Mini(data,success,failure);
- }
- /**
- * 分享
- * @param data
- * @param success
- * @param failure
- */
- static shareMessage(data: any, success?: Function, failure?: Function): void {
- this.impl.shareMessage(data, success, failure);
- }
- /**
- * 被动分享
- */
- static onShareAppMessage(): void {
- this.impl.onShareAppMessage();
- }
- /**
- * 显示Banner
- * @param data
- */
- static showBanner(data?: any): void {
- this.impl.showBanner(data);
- }
- /**
- * 隐藏Banner
- */
- static hideBanner(): void {
- this.impl.hideBanner();
- }
- /**
- * 显示激励广告
- * @param data
- * @param success
- * @param failure
- */
- static showRewardedVideo(success?: Function, failure?: Function): void {
- this.impl.showRewardedVideo(success, failure);
- }
- /**
- * 显示插屏广告
- */
- static showInsertAd(success?: Function, failure?: Function): void {
- this.impl.showInsertAd(success, failure);
- }
- /**
- * 显示原生广告
- */
- static showNativeAd(success?: Function, failure?: Function): void {
- this.impl.showNativeAd(success, failure);
- }
- /**
- * 打点
- * @param eventName
- * @param data
- */
- static sendEvent(eventName: string, data?: any): void {
- this.impl.sendEvent(eventName, data);
- }
- /**
- * 设置加载进度
- * @param progress
- */
- static setLoadingProgress(progress: number): void {
- this.impl.setLoadingProgress(progress);
- }
- /**
- * 加载完成
- * @param completeHandler
- */
- static loadingComplete(completeHandler?: Function): void {
- this.impl.loadingComplete(completeHandler);
- }
- /**
- * 游戏互推
- * @param num
- */
- static getRandomPageAd(num: number): any[] {
- return this.impl.getRandomPageAd(num);
- }
- }
|