123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- import { IPlatform } from "../IPlatform";
- import { LiangLiangSDK } from "../libs/liangliangSDK";
- export class BasePlatform implements IPlatform{
- public openID:string;
- currentVersion:string="1.0.2";
- /**
- * 后台开关
- */
- config:any;
- /**
- * 广告与互推
- */
- adConfig:any;
- constructor()
- {
- }
- /**
- * 登录
- * @param success 成功
- * @param failure 失败
- */
- login(success:Function,failure:Function):void{
- LiangLiangSDK.Init(success,failure);
- }
- /**
- * 登录成功钩子,子类重写来做一些其他事情
- */
- protected __loginSuccess():void{
-
- }
- /**
- * 跳转
- * @param data
- * @param success
- * @param failure
- */
- navigate2Mini(data:any,success?:Function,failure?:Function):void{
-
- }
- /**
- * 分享
- * @param data
- * @param success
- * @param failure
- */
- shareMessage(data:any,success?:Function,failure?:Function):void{
- }
- /**
- * 被动分享
- */
- onShareAppMessage():void{
- }
- /**
- * 显示Banner
- * @param data
- */
- showBanner(data:any):void{
- }
- /**
- * 隐藏Banner
- */
- hideBanner():void{
-
- }
- /**
- * 显示激励广告
- * @param success
- * @param failure
- */
- showRewardedVideo(success?:Function,failure?:Function):void{
- }
- /**
- * 显示插屏广告
- */
- showInsertAd(success?:Function,failure?:Function):void{
-
- }
- /**
- * 显示原生广告
- */
- showNativeAd(success?:Function,failure?:Function):void{
- }
- /**
- * 打点
- * @param eventName
- * @param data
- */
- sendEvent(eventName:string,data?:any):void{
-
- }
- /**
- * 设置加载进度
- * @param progress
- */
- setLoadingProgress(progress:number):void{
- }
- /**
- * 加载完成
- * @param completeHandler
- */
- loadingComplete(completeHandler?:Function):void{
- if(completeHandler){
- completeHandler();
- }
- }
- /**
- * 游戏互推
- * @param num
- */
- getRandomPageAd(num: number): any[] {
- return [];
- }
- protected __getRandomAd(num: number, list: any[]): any[] {
- if (num > list.length) {
- num = list.length;
- }
- let adlist: any[] = list.slice(0);
- let result: any[] = [];
- let index: number;
- let adData: any;
- while (result.length < num) {
- index = Math.floor(Math.random() * adlist.length);
- adData = adlist[index];
- if (result.indexOf(adData) < 0) {
- result.push(adData);
- }
- }
- return result;
- }
- /**
- * 是否显示互导
- */
- get canJump():boolean{
- return this.zs_jump_switch==1?true:false;
- }
- /**
- * 配置的版本号与当前版本一致时,则下方开关对当前版本生效;配置的版本号和当前版本不一致时,则当前版本默认所有开关均关闭。
- */
- get zs_version():string{
- return this.config.zs_version;
- }
- /**
- * 配置为0时,则不展示接入此开关的导出;配置为1时,接入此开关的导出位置正常展示
- */
- get zs_jump_switch():number{
- if(this.currentVersion!=this.config.zs_version){
- return 0;
- }
- return this.config.zs_jump_switch;
- }
- /**
- * 配置为0时,则文字直接展示在上移后的位置/文字不延时;配置为1时,则文字上移/延时
- */
- get zs_switch():number{
- if(this.currentVersion!=this.config.zs_version){
- return 0;
- }
- return this.config.zs_switch;
- }
- /**
- * 配置为0时,则不展示接入此开关的导出;配置为1时,接入此开关的导出位置正常展示
- */
- get zs_full_screen_jump():number{
- if(this.currentVersion!=this.config.zs_version){
- return 0;
- }
- return this.config.zs_full_screen_jump;
- }
- /**
- * 按钮延迟时间
- */
- get zs_button_delay_time():number{
- if(this.currentVersion!=this.config.zs_version){
- return 0;
- }
- return this.config.zs_button_delay_time;
- }
- /**
- * 配置为0时,下方按钮为“点击跳过”,点击此按钮可直接关闭当前插屏式原生;配置为1时,下方按钮文字调用官方接口,点击此按钮跳转广告。(无论开关什么状态,点击插屏式原生左上角的关闭按钮均可关闭当前插屏式原生,点击广告图片均可以跳转至广告,示例发群里)
- */
- get zs_native_click_switch():number{
- if(this.currentVersion!=this.config.zs_version){
- return 0;
- }
- return this.config.zs_native_click_switch;
- }
- get zs_banner_show_time():number{
- return this.config.zs_banner_show_time;
- }
- /**
- * 延迟时间
- */
- get delayTime():number{
- return 2000;
- }
- /**
- * 是否显示原生和插屏广告
- */
- get showNativa():number{
- if(this.currentVersion!=this.config.zs_version){
- return 0;
- }
- return 1;
- }
-
- /**
- * 可显示次数
- */
- get zs_click_award_num():number{
- if(this.currentVersion!=this.config.zs_version){
- return 0;
- }
- let value:number=Number(this.config.zs_click_award_num);
- if(isNaN(value)){
- return 0;
- }else{
- if(value!=0){
- return value;
- }
- }
- return 0;
- }
- /**
- * 进度条上涨百分比
- */
- get zs_click_award_add():number{
- return this.config.zs_click_award_add;
- }
-
- /**
- * 进度条不点下降百分比
- */
- get zs_click_award_back():number{
- return this.config.zs_click_award_back;
- }
- /**
- * 砸金蛋区间
- */
- get zs_click_award_percent():number[]{
- let percent:number[] = [];
- let str:string = this.config.zs_click_award_percent;
- str = str.replace("[", "");
- str = str.replace("]", "");
- let items:string[] = str.split(",");
- for(let i:number = 0; i < items.length; i++){
- percent.push(Number(items[i]));
- }
- return percent;
- }
- }
|