12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288 |
- import YZ_Constant, { BannerLocation } from "./YZ_Constant";
- import PlatUtils from "./PlatUtils";
- import { utils } from "./Utils";
- import YZ_LocalStorage from "./YZ_LocalStorage";
- const { ccclass, property } = cc._decorator;
- @ccclass("BannerIdInfo")
- export class BannerIdInfo {
- @property({ type: cc.Enum(BannerLocation), displayName: "广告条位置" })
- location: BannerLocation = BannerLocation.None;
- @property({ displayName: "广告条ID" })
- bannerId: string = "";
- };
- @ccclass("NativeBannerInfo")
- export class NativeBannerInfo {
- /**
- * 广告条的位置
- * 1:Home-首页
- * 2:Level-选关
- * 3:Skin-皮肤
- * 4:Game-游戏
- * 5:Pause-暂停
- * 6:Over-结算
- */
- location: BannerLocation = BannerLocation.None;
- /**
- * 是否显示结算大banner
- */
- show_st_banner: string = "false";
- /**
- * 默认原生banner关闭按钮大小,默认为60
- */
- banner_close_but_size: number = 40;
- /**
- * 默认banner关闭按钮透明度 默认为120
- */
- banner_close_but_alpha: number = 120;
- /**
- * 默认banner关闭按钮高度 默认为220
- */
- banner_show_height: number = 160;
- /**
- * 默认banner关闭按钮点击区域默认为80
- */
- banner_close_but_range: number = 40;
- /**
- * 默认原生banner关闭按钮,是否显示。默认为显示:"true"
- */
- banner_close_but_show = "true";
- /**
- * 结算前banner整体缩放,默认为1
- */
- st_banner_scale: number = 1;
- /**
- * 结算前banner下载按钮的图片地址
- */
- st_banner_down_btn_image: string = "";
- /**
- * 结算前banner下载按钮显示类型,默认不配置,则不显示,配置后则显示,值为2:显示循环播放放大缩小效果,
- */
- st_banner_down_but_show: number = 0;
- /**
- * 结算前banner,下载按钮距离广告顶部间距,默认贴紧广告顶部值是-111
- */
- st_banner_down_but_margin_top: number = 0;
- /**
- * 结算前banner,关闭按钮点击区域大小
- */
- st_banner_close_but_range: number = 55;
- /**
- * 结算前banner,关闭按钮图片大小
- */
- st_banner_close_but_size: number = 55;
- /**
- * 结算前banner关闭按钮,是否显示。默认为显示:"true"
- */
- st_banner_close_but_show: string = "true";
- /**
- * 结算前banner距离底部的距离
- */
- st_banner_bottom: number = 0;
- /**
- * 结算前banner关闭按钮透明度
- * 0-255
- */
- st_banner_close_but_alpha: number = 255;
- /**
- * banner点击后是不是需要刷新数据
- */
- banner_click_refresh: string = "true";
- /**
- * 自动刷新时间,单位:秒,默认为:-1 不刷新
- */
- auto_refresh: number = -1;
- /**
- * 样式
- * -1 :默认、0:单图片缩放、1:单图片和自定义宽高、2:默认样式自定义宽高
- */
- st_banner_style: number = -1;
- /**
- * 结算banner样式-宽,默认:821 单位:像素
- */
- st_banner_width: number = -1;
- /**
- * 结算banner样式-高:默认:589 单位:像素
- */
- st_banner_height: number = -1;
- /**
- * 结算banner是否显示备用广告
- * 默认:1 显示,-1 为不显示
- */
- st_banner_show_back_up: number = 1;
- /**
- * 是否显示banner
- * 默认:1 显示, -1为不显示;
- */
- is_show_banner: number = 1;
- //显示互推banner
- is_show_rec: number = -1;
- //延迟显示时间
- delay_show_time: number = 0;
- //关闭按钮间隔多少次触发广告跳转
- banner_close_showAd_interval: number = 0;
- //普通原生Banner背景透明遮罩透明度 大于0则显示当前值的透明遮罩层
- bg_mask_opacity: number = 0;
- //结算原生banner背景透明遮罩透明度 大于0则显示当前值的透明遮罩层
- st_banner_bg_mask_opacity: number = 0;
- // 对齐方式:bottom top
- _alignType: string = "bottom";
- /**
- * 初始化
- * @param location 位置
- * @param info 配置
- */
- init(location: BannerLocation, info: any) {
- this.location = location;
- this.banner_close_but_alpha = info.banner_close_but_alpha ? info.banner_close_but_alpha : this.banner_close_but_alpha;
- this.banner_close_but_range = info.banner_close_but_range ? info.banner_close_but_range : this.banner_close_but_range;
- this.banner_close_but_size = info.banner_close_but_size ? info.banner_close_but_size : this.banner_close_but_size;
- this.banner_show_height = info.banner_show_height ? info.banner_show_height : this.banner_show_height;
- this.banner_close_but_show = info.banner_close_but_show ? info.banner_close_but_show : this.banner_close_but_show;
- this.bg_mask_opacity = info.bg_mask_opacity ? info.bg_mask_opacity : this.bg_mask_opacity;
- this.st_banner_close_but_range = info.st_banner_close_but_range ? info.st_banner_close_but_range : this.st_banner_close_but_range;
- this.st_banner_close_but_size = info.st_banner_close_but_size ? info.st_banner_close_but_size : this.st_banner_close_but_size;
- this.st_banner_down_btn_image = info.st_banner_down_btn_image ? info.st_banner_down_btn_image : this.st_banner_down_btn_image;
- this.st_banner_down_but_margin_top = info.st_banner_down_but_margin_top ? info.st_banner_down_but_margin_top : this.st_banner_down_but_margin_top;
- this.st_banner_down_but_show = info.st_banner_down_but_show ? info.st_banner_down_but_show : this.st_banner_down_but_show;
- this.st_banner_scale = info.st_banner_scale ? info.st_banner_scale : this.st_banner_scale;
- this.show_st_banner = info.show_st_banner ? info.show_st_banner : this.show_st_banner;
- this.st_banner_close_but_show = info.st_banner_close_but_show ? info.st_banner_close_but_show : this.st_banner_close_but_show;
- this.st_banner_bottom = info.st_banner_bottom ? info.st_banner_bottom : this.st_banner_bottom;
- this.st_banner_close_but_alpha = info.st_banner_close_but_alpha ? info.st_banner_close_but_alpha : this.st_banner_close_but_alpha;
- this.banner_click_refresh = info.banner_click_refresh ? info.banner_click_refresh : this.banner_click_refresh;
- this.auto_refresh = info.auto_refresh ? info.auto_refresh : this.auto_refresh;
- this.st_banner_style = info.st_banner_style ? info.st_banner_style : this.st_banner_style;
- this.st_banner_width = info.st_banner_width ? info.st_banner_width : this.st_banner_width;
- this.st_banner_height = info.st_banner_height ? info.st_banner_height : this.st_banner_height;
- this.st_banner_show_back_up = info.st_banner_show_back_up ? info.st_banner_show_back_up : this.st_banner_show_back_up;
- this.is_show_banner = info.is_show_banner ? info.is_show_banner : this.is_show_banner;
- this.is_show_rec = info.is_show_rec ? info.is_show_rec : this.is_show_rec;
- this.delay_show_time = info.delay_show_time ? info.delay_show_time : this.delay_show_time;
- this.st_banner_bg_mask_opacity = info.st_banner_bg_mask_opacity ? info.st_banner_bg_mask_opacity : this.st_banner_bg_mask_opacity;
- this._alignType = info.align_type ? info.align_type : this._alignType;
- this.banner_close_showAd_interval = info.banner_close_showAd_interval ? info.banner_close_showAd_interval : this.banner_close_showAd_interval;
- }
- toStrong() {
- return `location=${this.location}&is_show_banner=${this.is_show_banner}&banner_close_but_show=${this.banner_close_but_show}&banner_close_but_alpha=${this.banner_close_but_alpha}&banner_close_but_range=${this.banner_close_but_range}&banner_close_but_size=${this.banner_close_but_size}&banner_show_height=${this.banner_show_height}&st_banner_close_but_range=${this.st_banner_close_but_range}&st_banner_close_but_size=${this.st_banner_close_but_size}&st_banner_down_btn_image=${this.st_banner_down_btn_image}&st_banner_down_but_margin_top=${this.st_banner_down_but_margin_top}&st_banner_down_but_show=${this.st_banner_down_but_show}&st_banner_scale=${this.st_banner_scale}&show_st_banner=${this.show_st_banner}&st_banner_close_but_show=${this.st_banner_close_but_show}&st_banner_bottom=${this.st_banner_bottom}&st_banner_close_but_alpha=${this.st_banner_close_but_alpha}&banner_click_refresh=${this.banner_click_refresh}&auto_refresh=${this.auto_refresh}&st_banner_style=${this.st_banner_style}&st_banner_width=${this.st_banner_width}&st_banner_height=${this.st_banner_height}&st_banner_show_back_up=${this.st_banner_show_back_up}&is_show_rec=${this.is_show_rec}`;
- }
- }
- @ccclass("CustomAdInfo")
- export class CustomAdInfo {
- /**
- * 广告条的位置
- * 1:Home-首页
- * 2:Level-选关
- * 3:Skin-皮肤
- * 4:Game-游戏
- * 5:Pause-暂停
- * 6:Over-结算
- * 其中选项没有的话,可以自定义
- */
- location: BannerLocation = BannerLocation.None;
- /**
- * 是否显示结算大banner
- */
- is_show_ad: string = "true";
- /**
- * 距离顶部的距离
- */
- top: number = -1;
- /**
- * 距离左边的距离
- */
- left: number = -1;
- /**
- * 距离右边的距离
- */
- right: number = -1;
- /**
- * 距离底部的距离
- */
- bottom: number = -1;
- /**
- * 广告ID
- */
- id: string = "";
- /**
- * 刷新时间
- */
- refresh_time: number = -1;
- /**
- * 广告宽度
- */
- width: number = 0;
- /**
- * 广告高度
- */
- height: number = 0;
- /**
- * 显示成功后是否隐藏banner
- */
- hide_banner: string = "false";
- /**
- * 是否居中显示
- * about:左右居中
- * updown:上下
- * all:上下和左右居中
- */
- is_center: string = "false";
- /**
- * 改变位置的时候是否刷新广告
- */
- change_location_refresh_ad = "true";
- //当前obj对象
- customAdObj: any = null;
- /**
- * 初始化
- * @param location 位置
- * @param info 配置
- */
- init(location: BannerLocation, info: any) {
- this.location = location;
- this.top = "top" in info ? info.top : -1;
- this.right = "right" in info ? info.right : -1;
- this.left = "left" in info ? info.left : -1;
- this.bottom = "bottom" in info ? info.bottom : -1;
- this.id = "id" in info ? info.id : "";
- this.refresh_time = "refresh_time" in info ? info.refresh_time : -1;
- this.is_show_ad = "is_show_ad" in info ? info.is_show_ad : "true";
- this.width = "width" in info ? info.width : 0;
- this.height = "height" in info ? info.height : 0;
- this.hide_banner = "hide_banner" in info ? info.hide_banner : "false";
- this.change_location_refresh_ad = "change_location_refresh_ad" in info ? info.change_location_refresh_ad : "false";
- this.is_center = "is_center" in info ? info.is_center : "all";
- }
- toStrong() {
- return `customAdInfo>>>>#location=${this.location}#top=${this.top}#left=${this.left}#right=${this.right}#bottom=${this.bottom}#refreshTime=${this.refresh_time}#id=${this.id}#width=${this.width}#height=${this.height}#is_center=${this.is_center}`;
- }
- }
- @ccclass("WechatConfig")
- export class WechatConfig {
- appID: string = "";
- bannerIds: BannerIdInfo[] = [];
- videoId: string = "";
- insertId: string = "";
- jumpId: string = "";
- appBoxId: string = "";
- boxId: string = "";
- bannerBoxId: string = "";
- customAdInfos: CustomAdInfo[] = [];
- isAttributed: boolean = false;
- version: string = "";
- nativeBannerId: string = "";
- nativeInsertIds: string = "";
- /**
- * 根据位置获取bannerId
- * @param location BannerLocation
- */
- public getBannerId(location: BannerLocation) {
- for (let i = 0; i < this.bannerIds.length; i++) {
- if (this.bannerIds[i].location == location) {
- return this.bannerIds[i].bannerId;
- }
- }
- if (this.bannerIds.length > 0) {
- return this.bannerIds[0].bannerId;
- }
- return "";
- }
- /**
- * 设定原生模版配置
- * @param location 位置
- * @param bannerInfo 配置
- */
- public setCustomAdInfo(location, custInfo: any) {
- let nativeCustomAd = new CustomAdInfo();
- nativeCustomAd.init(location, custInfo);
- this.customAdInfos.push(nativeCustomAd);
- }
- /**
- * 根据位置获取原生模版配置
- * @param location BannerLocation
- */
- public getCustomAdInfoInfo(location: BannerLocation) {
- utils.showLog("根据位置获取原生模版配置>>location=", location);
- for (let i = 0; i < this.customAdInfos.length; i++) {
- if (this.customAdInfos[i].location == location) {
- utils.showLog("根据位置获取原生模版配置>>info=", this.customAdInfos[i].toStrong());
- return this.customAdInfos[i];
- }
- }
- return null;
- }
- /**
- * 设定bannerId
- * @param location BannerLocation
- * @param bannerId
- */
- public setBannerId(location: BannerLocation, bannerId: string) {
- for (let i = 0; i < this.bannerIds.length; i++) {
- if (this.bannerIds[i].location == location) {
- this.bannerIds[i].bannerId = bannerId;
- return;
- }
- }
- }
- }
- @ccclass("QQConfig")
- export class QQConfig {
- QQ: boolean = true;
- appID: string = "";
- bannerId: string = "";
- insertId: string = "";
- videoId: string = "";
- boxId: string = "";
- version: string = "";
- bannerBoxId: string = "";
- }
- @ccclass("OppoConfig")
- export class OppoConfig {
- public appID: string = "";
- public channel: string = "oppo";
- bannerId: string = "";
- insertId: string = "";
- videoId: string = "";
- nativeBannerIds: string[] = [];
- nativeTryGameIds: string[] = [];
- nativeInsertIds: string[] = [];
- nativeSingleAdIds: string[] = [];
- packageName: string = "";
- nativeBannerInfos: NativeBannerInfo[] = [];
- recGameBannerId: string = "";
- recPortalId: string = "";
- version: string = "";
- recGameDrawerId: string = "";
- umengId: String = ""; //友盟ID
- intersitialAdConfigs: any[] = []; //插屏ID配置
- bannerAdConfigs: any[] = []; //Banner配置
- /**
- * 根据位置获取原生banner配置
- * @param location BannerLocation
- */
- public getNativeBannerInfo(location: BannerLocation) {
- utils.showLog("根据位置获取原生banner配置>>location=", location);
- for (let i = 0; i < this.nativeBannerInfos.length; i++) {
- if (this.nativeBannerInfos[i].location == location) {
- utils.showLog("根据位置获取原生banner配置>>info=", this.nativeBannerInfos[i].toStrong());
- return this.nativeBannerInfos[i];
- }
- }
- return new NativeBannerInfo();
- }
- /**
- * 设定原生banner配置
- * @param location 位置
- * @param bannerInfo 配置
- */
- public setNativeBannerInfo(location, bannerInfo: any) {
- let nativeBannerInfo: NativeBannerInfo = new NativeBannerInfo();
- nativeBannerInfo.init(location, bannerInfo);
- this.nativeBannerInfos.push(nativeBannerInfo);
- }
- }
- @ccclass("VivoConfig")
- export class VivoConfig {
- showAd: boolean = true;
- appID: string = "";
- bannerId: string = "";
- insertId: string = "";
- videoId: string = ""
- nativeTryGameIds: string[] = [];
- nativeBannerIds: string[] = [];
- nativeInsertIds: string[] = [];
- nativeBannerInfos: NativeBannerInfo[] = [];
- customAdInfos: CustomAdInfo[] = [];
- nativeSingleAdIds: string[] = [];
- recGameBannerId: string = "";
- recPortalId: string = "";
- version: string = "";
- umengId: String = ""; //友盟ID
- /**
- * 根据位置获取原生banner配置
- * @param location BannerLocation
- */
- public getNativeBannerInfo(location: BannerLocation) {
- utils.showLog("根据位置获取原生banner配置>>location=", location);
- for (let i = 0; i < this.nativeBannerInfos.length; i++) {
- if (this.nativeBannerInfos[i].location == location) {
- utils.showLog("根据位置获取原生banner配置>>info=", this.nativeBannerInfos[i].toStrong());
- return this.nativeBannerInfos[i];
- }
- }
- return new NativeBannerInfo();
- }
- /**
- * 根据位置获取原生模版配置
- * @param location BannerLocation
- */
- public getCustomAdInfoInfo(location: BannerLocation) {
- utils.showLog("根据位置获取原生模版配置>>location=", location);
- for (let i = 0; i < this.customAdInfos.length; i++) {
- if (this.customAdInfos[i].location == location) {
- utils.showLog("根据位置获取原生模版配置>>info=", this.customAdInfos[i].toStrong());
- return this.customAdInfos[i];
- }
- }
- return new CustomAdInfo();
- }
- /**
- * 设定原生banner配置
- * @param location 位置
- * @param bannerInfo 配置
- */
- public setNativeBannerInfo(location, bannerInfo: any) {
- let nativeBannerInfo: NativeBannerInfo = new NativeBannerInfo();
- nativeBannerInfo.init(location, bannerInfo);
- this.nativeBannerInfos.push(nativeBannerInfo);
- }
- /**
- * 设定原生模版配置
- * @param location 位置
- * @param bannerInfo 配置
- */
- public setCustomAdInfo(location, custInfo: any) {
- let nativeCustomAd = new CustomAdInfo();
- nativeCustomAd.init(location, custInfo);
- this.customAdInfos.push(nativeCustomAd);
- }
- }
- @ccclass("YzRedBagInfo")
- export class YzRedBagInfo {
- private _progress: number = 0; //当前进度
- private _totalProgress: number = 5; //总进度
- private _balance: number = 0.00; //余额
- private _totalMoeny: number = 0;
- private _lastOpenFreeRedBagTime: string = "";
- private _progressInfos: any = null;
- private _lastOpenLevel: string = "-1";
- private _freeRedBagCount: number = 0; //现金红包次数
- public withdrawaMoneys = [5, 20, 45, 50]
- constructor() {
- if (PlatUtils.IsTest) {
- this._progressInfos = [
- {
- level: 0,
- min_money: 0.1,
- max_money: 5,
- type: 1
- },
- {
- level: 4,
- min_money: 0.1,
- max_money: 3,
- type: 3
- },
- {
- level: 5,
- min_money: 0.001,
- max_money: 0.005,
- type: 2
- }
- ]
- }
- this._progress = YZ_LocalStorage.getItem(YZ_Constant.ST_RED_BAG_PROGRESS) ? YZ_LocalStorage.getItem(YZ_Constant.ST_RED_BAG_PROGRESS) : 0;
- this._totalProgress = YZ_LocalStorage.getItem(YZ_Constant.ST_RED_BAG_TOTAL_PROGRESS) ? YZ_LocalStorage.getItem(YZ_Constant.ST_RED_BAG_TOTAL_PROGRESS) : 5;
- this._balance = YZ_LocalStorage.getItem(YZ_Constant.ST_RED_BAG_BALANCE) ? parseFloat(YZ_LocalStorage.getItem(YZ_Constant.ST_RED_BAG_BALANCE)) : 0.00;
- this._totalMoeny = YZ_LocalStorage.getItem(YZ_Constant.ST_RED_BAG_TOTAL_MONEY) ? parseFloat(YZ_LocalStorage.getItem(YZ_Constant.ST_RED_BAG_TOTAL_MONEY)) : 0.00;
- this._lastOpenFreeRedBagTime = YZ_LocalStorage.getItem(YZ_Constant.ST_FREE_RED_BAG_TIME) ? YZ_LocalStorage.getItem(YZ_Constant.ST_FREE_RED_BAG_TIME) : "";
- this._lastOpenLevel = YZ_LocalStorage.getItem(YZ_Constant.ST_LAST_OPEN_LEVEL) ? YZ_LocalStorage.getItem(YZ_Constant.ST_LAST_OPEN_LEVEL) : "-1";
- }
- public get freeRedBagCount() {
- return this._freeRedBagCount;
- }
- public set freeRedBagCount(value: number) {
- this._freeRedBagCount = value;
- }
- public get lastOpenLevel() {
- return this._lastOpenLevel;
- }
- public set lastOpenLevel(value: string) {
- this._lastOpenLevel = value;
- YZ_LocalStorage.setItem(YZ_Constant.ST_LAST_OPEN_LEVEL, value);
- }
- public get progress() {
- return this._progress;
- }
- public set progress(value: number) {
- this._progress = value;
- if (this._progress > this._totalProgress) {
- this._progress = this._totalProgress;
- } else {
- utils._rewardRedBagPanelShowCount = -1;
- }
- YZ_LocalStorage.setItem(YZ_Constant.ST_RED_BAG_PROGRESS, this._progress + '');
- cc.game.emit("YZ_RED_BAG_PROGRESS_CHANGE");
- }
- public get totalProgress() {
- return this._totalProgress;
- }
- public set totalProgress(value: number) {
- this._totalProgress = value;
- YZ_LocalStorage.setItem(YZ_Constant.ST_RED_BAG_TOTAL_PROGRESS, value + '');
- }
- public get totalMoney() {
- return this._totalMoeny;
- }
- public set totalMoney(value: number) {
- this._totalMoeny = value;
- YZ_LocalStorage.setItem(YZ_Constant.ST_RED_BAG_TOTAL_MONEY, value + '');
- }
- public set progressInfos(values: []) {
- this._progressInfos = values;
- }
- public get progressInfos() {
- return this._progressInfos;
- }
- public get curProgressInfo() {
- if (this._progressInfos && this._progressInfos.length > 0) {
- if (parseInt(this.lastOpenLevel) > 0 && parseInt(this.lastOpenLevel) >= utils.currentLevel) {
- return this._progressInfos[this._progressInfos.length - 1];
- }
- let temp = this.lastOpenLevel ? this._progressInfos[0] : this._progressInfos[1];
- for (let i = 0; i < this._progressInfos.length; i++) {
- //@ts-ignore
- if (utils.currentLevel <= this._progressInfos[i].level) {
- temp = this._progressInfos[i];
- break;
- }
- }
- console.log("curInfo " + JSON.stringify(temp));
- return temp;
- }
- return null;
- }
- public get balance() {
- return this._balance;
- }
- public set balance(value: number) {
- this._balance = value;
- YZ_LocalStorage.setItem(YZ_Constant.ST_RED_BAG_BALANCE, value + '');
- cc.game.emit("YZ_RED_BAG_BALANCE_CHANGE");
- }
- public get lastOpenFreeRedBagTime() {
- return this._lastOpenFreeRedBagTime;
- }
- public set lastOpenFreeRedBagTime(value: string) {
- this._lastOpenFreeRedBagTime = value;
- YZ_LocalStorage.setItem(YZ_Constant.ST_FREE_RED_BAG_TIME, value + '');
- }
- /**
- * 今天是否有免费的红包
- */
- public get isFreeRedBag(): boolean {
- cc.log("是否有免费红包:" + new Date().toDateString() != this._lastOpenFreeRedBagTime);
- return new Date().toDateString() != this._lastOpenFreeRedBagTime;
- }
- }
- @ccclass("HuaWeiConfig")
- export class HuaWeiConfig {
- appID: string = "";
- bannerId: string = "";
- insertId: string = "";
- videoId: string = "";
- nativeSplashId: string = "";
- nativeTryGameIds: string[] = [];
- nativeBannerIds: string[] = [];
- nativeInsertIds: string[] = [];
- nativeBannerInfos: NativeBannerInfo[] = [];
- version: string = "";
- umengId: string = "";
- /**
- * 根据位置获取原生banner配置
- * @param location BannerLocation
- */
- public getNativeBannerInfo(location: BannerLocation) {
- utils.showLog("根据位置获取原生banner配置>>location=", location);
- for (let i = 0; i < this.nativeBannerInfos.length; i++) {
- if (this.nativeBannerInfos[i].location == location) {
- utils.showLog("根据位置获取原生banner配置>>info=", this.nativeBannerInfos[i].toStrong());
- return this.nativeBannerInfos[i];
- }
- }
- return new NativeBannerInfo();
- }
- /**
- * 设定原生banner配置
- * @param location 位置
- * @param bannerInfo 配置
- */
- public setNativeBannerInfo(location, bannerInfo: any) {
- let nativeBannerInfo: NativeBannerInfo = new NativeBannerInfo();
- nativeBannerInfo.init(location, bannerInfo);
- this.nativeBannerInfos.push(nativeBannerInfo);
- }
- }
- @ccclass("NativeAndroidConfig")
- export class NativeAndroidConfig {
- appID: string = "";
- channel: string = "";
- version: string = "";
- }
- @ccclass("BaiduConfig")
- export class BaiduConfig {
- appID: string = "";
- appSID: string = "";
- bannerId: string = "";
- videoId: string = "";
- version: string = "";
- }
- @ccclass("WiFiConfig")
- export class WiFiConfig {
- appID: string = "";
- bannerId: string = "";
- videoId: string = "";
- version: string = "";
- }
- @ccclass("KwaiConfig")
- export class KwaiConfig {
- appID: string = "";
- videoId: string = "";
- insertId: string = "";
- version: string = "";
- }
- @ccclass("HagoConfig")
- export class HagoConfig {
- appID: string = "";
- videoId: string = "";
- version: string = "";
- }
- @ccclass("NativeIosConfig")
- export class NativeIosConfig {
- appID: string = "";
- bannerId: string = "";
- insertId: string = "";
- videoId: string = "";
- version: string = "";
- }
- @ccclass("DouyinConfig")
- export class DouyinConfig {
- Douyin: boolean = true;
- appID: string = "";
- bannerId: string = "";
- insertId: string = "";
- videoId: string = "";
- version: string = "";
- }
- @ccclass("QuTouTiaoConfig")
- export class QTTConfig {
- QuTouTiao: boolean = true;
- showAd: boolean = true;
- gamename: string = "";
- appID: string = "";
- appKey: string = "";
- }
- @ccclass("UCConfig")
- export class UCConfig {
- appID: string = "";
- appKey: string = "";
- version: string = "";
- }
- @ccclass("CocosConfig")
- export class CocosConfig {
- appID: string = "";
- appKey: string = "";
- appSecret: string = "";
- bannerId: string = "";
- videoId: string = "";
- insertId: string = "";
- }
- @ccclass("XiaoMiConfig")
- export class XiaoMiConfig {
- appID: string = "";
- bannerId: string = "";
- videoId: string = "";
- insertId: string = "";
- nativeSplashId: string = "";
- nativeTryGameIds: string[] = [];
- nativeBannerIds: string[] = [];
- nativeInsertIds: string[] = [];
- nativeBannerInfos: NativeBannerInfo[] = [];
- version: string = "";
- /**
- * 根据位置获取原生banner配置
- * @param location BannerLocation
- */
- public getNativeBannerInfo(location: BannerLocation) {
- utils.showLog("根据位置获取原生banner配置>>location=", location);
- for (let i = 0; i < this.nativeBannerInfos.length; i++) {
- if (this.nativeBannerInfos[i].location == location) {
- utils.showLog("根据位置获取原生banner配置>>info=", this.nativeBannerInfos[i].toStrong());
- return this.nativeBannerInfos[i];
- }
- }
- return new NativeBannerInfo();
- }
- /**
- * 设定原生banner配置
- * @param location 位置
- * @param bannerInfo 配置
- */
- public setNativeBannerInfo(location, bannerInfo: any) {
- let nativeBannerInfo: NativeBannerInfo = new NativeBannerInfo();
- nativeBannerInfo.init(location, bannerInfo);
- this.nativeBannerInfos.push(nativeBannerInfo);
- }
- }
- @ccclass("BiliConfig")
- export class BiliConfig {
- appID: string = "";
- bannerId: string = "";
- videoId: string = "";
- }
- @ccclass("FaceBookConfig")
- export class FaceBookConfig {
- appID: string = "";
- bannerId: string = "";
- insertId: string = "";
- videoId: string = "";
- version: string = "";
- }
- @ccclass("OtherConfig")
- export class OtherConfig {
- shareTitle: string = "";
- shareImgUrl: string = "";
- shareIcon: string = "";
- shareDesc: string = "";
- @property({ type: cc.JsonAsset, displayName: "本地配置文件", tooltip: "将Common/Config/下面的配置文件拖放到此处" })
- localConfig: cc.JsonAsset = null;
- @property({ type: cc.Prefab, displayName: "日志输出组件", tooltip: "将Common/Prefabs/LogoutView拖放到此处" })
- logoutView: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "原生广告条组件,将Common/Prefabs/NativeBanner拖到此处", displayName: "原生广告条组件" })
- nativeBanner: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "原生插屏组件,将Common/Prefabs/NativeInsert拖到此处", displayName: "原生插屏组件" })
- nativeInsert: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "原生插屏组件,将Common/Prefabs/nativeSplashView拖到此处", displayName: "原生开屏组件" })
- nativeSplashView: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "底部推荐游戏广告Banner, 将Common/Prefabs/RecommendGamesBanner拖到此处" })
- recommendGamesBanner: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "推荐游戏横条,将Common/Prefabs/RecommendGamesBar拖到此处" })
- recommendGamesBar: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "推荐游戏圆形挂件,将Common/Prefabs/TryGamesWidget拖到此处" })
- tryGamesWidget: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "侧边更多游戏面板挂件,将Common/Prefabs/MoreGamesWidget拖到此处" })
- moreGamesWidget: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "录屏按钮组件,将Common/Prefabs/RecordWidget拖到此处" })
- recordWidget: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "快捷方式按钮,将Common/Prefabs/ShortcutWidget拖到此处 " })
- shortcutWidget: cc.Prefab = null;
- // @property({ type: cc.Prefab, tooltip: "游戏盒子,将Common/Prefabs/GameBox拖到此处 " })
- gameBox: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "6元素交叉推广组件,将Common/Prefabs/CrossWidget6拖到此处" })
- crossWidget6: cc.Prefab = null;
- // @property({ type: cc.Prefab, tooltip: "激励插屏推广组件,将Common/Prefabs/RewardInsert拖到此处" })
- rewardInsert: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "结算页面推广组件,将Common/Prefabs/StatementRecomment拖到此处" })
- statementRecomment: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "单个原生广告,将Common/Prefabs/SingleNativeAd拖到此处" })
- singleNativeAd: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "分享录屏弹窗,将Common/Prefabs/ShareRecordPanel拖到此处" })
- shareRecordPanel: cc.Prefab = null;
- // @property({ type: cc.Prefab, tooltip: "原生退出游戏弹窗,将Common/Prefabs/GameExitDialog拖到此处" })
- gameExitDialog: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "五倍奖励宝箱弹窗,将Common/Prefabs/RewardBoxPanel拖到此处" })
- rewardBoxPanel: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "奖励转盘抽奖弹窗,将Common/Prefabs/RewardTurntablePanel拖到此处" })
- rewardTurnTablePanel: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "添加桌面激励弹窗,将Common/Prefabs/RewardShortCutPanel拖到此处" })
- rewardShortCutPanel: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "原生抖动试玩,将Common/Prefabs/NativeTryGameWidget拖到此处", displayName: "原生抖动组件" })
- nativeTryGameWidget: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "结算前互推面板,将Common/Prefabs/BeforGameOverRecGamesPanel拖到此处", displayName: "结算前互推面板" })
- beforGameOverRecGamesPanel: cc.Prefab = null;
- // @property({ type: cc.Prefab, tooltip: "红包提现框,将Common/Prefabs/WithdrawalWidget拖到此处", displayName: "红包提现框挂件" })
- withdrawalWidget: cc.Prefab = null;
- // @property({ type: cc.Prefab, tooltip: "红包提现弹窗,将Common/Prefabs/WithdrawalPanel拖到此处", displayName: "红包提现弹窗" })
- withdrawalPanel: cc.Prefab = null;
- // @property({ type: cc.Prefab, tooltip: "红包进度挂件,将Common/Prefabs/RedBagProgressWidget拖到此处", displayName: "红包进度挂件" })
- redBagProgressWidget: cc.Prefab = null;
- // @property({ type: cc.Prefab, tooltip: "拆红包弹窗,将Common/Prefabs/OpenRedBagPanel拖到此处", displayName: "拆红包弹窗" })
- openRedBagPanel: cc.Prefab = null;
- // @property({ type: cc.Prefab, tooltip: "恭喜获得红包弹窗,将Common/Prefabs/RewardRedBagPanel拖到此处", displayName: "恭喜获得红包弹窗" })
- rewardRedBagPanel: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "幸运宝箱弹窗,将Common/Prefabs/RewardLuckBoxPanel拖到此处", displayName: "幸运宝箱弹窗" })
- rewardLuckBoxPanel: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "竖状互推窗口,将Common/Prefabs/VerticalRecommentPanel拖到此处", displayName: "竖状互推窗口" })
- verticalRecommentPanel: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "隐私协议挂件,将Common/Prefabs/PrivacyWidget拖到此处", displayName: "隐私协议挂件" })
- privacyWidget: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "隐私协议弹窗,将Common/Prefabs/PrivacyPanel拖到此处", displayName: "隐私协议弹窗" })
- privacyPanel: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "指引的手势,将Common/Prefabs/HandPrefab拖到此处", displayName: "指引的手势" })
- handPrefab: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "实名制认证弹窗,将Common/Prefabs/YzRealNameAuthPanel拖到此处", displayName: "实名制认证弹窗" })
- yzRealNameAuthPanel: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "模版广告推荐弹窗,将Common/Prefabs/YzCustomAdPanel拖到此处", displayName: "模版广告推荐弹窗" })
- yzCustomAdPanel: cc.Prefab = null;
- @property({ type: cc.Prefab, tooltip: "登录弹窗,将Common/Prefabs/YzLoginPanel拖到此处", displayName: "登录弹窗" })
- yzLoginPanel: cc.Prefab = null;
- //游玩统计SDK:ID
- yw_app_id: string = "";
- }
- @ccclass("CommonConfig")
- export default class CommonConfig {
- wechatconfig: WechatConfig = new WechatConfig();
- oppoconfig: OppoConfig = new OppoConfig();
- vivoconfig: VivoConfig = new VivoConfig();
- nativeAndroidConfig: NativeAndroidConfig = new NativeAndroidConfig();
- baiduconfig: BaiduConfig = new BaiduConfig();
- douyinconfig: DouyinConfig = new DouyinConfig();
- wifiConfig: WiFiConfig = new WiFiConfig();
- qqconfig: QQConfig = new QQConfig();
- qttconfig: QTTConfig = new QTTConfig();
- xiaomiConfig: XiaoMiConfig = new XiaoMiConfig();
- ucConfig: UCConfig = new UCConfig();
- cocosConfig: CocosConfig = new CocosConfig();
- biliConfig: BiliConfig = new BiliConfig();
- kwaiConfig: KwaiConfig = new KwaiConfig();
- nativeIoSConfig: NativeIosConfig = new NativeIosConfig();
- hagoConfig: HagoConfig = new HagoConfig();
- huaweiConfig: HuaWeiConfig = new HuaWeiConfig();
- faceBookConfig: FaceBookConfig = new FaceBookConfig();
- @property({ type: OtherConfig, tooltip: "其他配置", displayName: "其他配置" })
- otherconfig: OtherConfig = new OtherConfig();
- public init(data: string) {
- this._init_other(data);
- if (PlatUtils.IsWechat) {
- return this._init_wechat(data);
- } else if (PlatUtils.IsOPPO) {
- return this._init_oppo(data);
- } else if (PlatUtils.IsVIVO) {
- return this._init_vivo(data);
- } else if (PlatUtils.IsDouyin) {
- return this._init_douyin(data);
- } else if (PlatUtils.IsQQ) {
- return this._init_qq(data);
- } else if (PlatUtils.IsBaidu) {
- return this._init_baidu(data);
- } else if (PlatUtils.IsQTT) {
- return this._init_qtt(data);
- } else if (PlatUtils.IsXiaoMi) {
- return this._init_xiaomi(data);
- } else if (PlatUtils.ISUC) {
- return this._init_uc(data);
- } else if (PlatUtils.ISCocos) {
- return this._init_cocos(data);
- } else if (PlatUtils.IsNativeAndroid) {
- return this._init_native_android();;
- } else if (PlatUtils.IsNativeIOS) {
- return this._init_native_ios(data);;
- } else if (PlatUtils.IsBili) {
- return this._init_bili(data);;
- } else if (PlatUtils.IsKwai) {
- return this._init_kwai(data);;
- } else if (PlatUtils.IsWiFi) {
- return this._init_wifi(data);;
- } else if (PlatUtils.IsHago) {
- return this._init_hago(data);;
- } else if (PlatUtils.IsHuaWei) {
- return this._init_huawei(data);;
- } else if (PlatUtils.IsFaceBook) {
- return this._init_facebook(data);;
- } else {
- return true;
- }
- }
- private _init_other(data: string) {
- if (!data) return false;
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.other) {
- if (configObj.other.yw_app_id) {
- this.otherconfig.yw_app_id = configObj.other.yw_app_id;
- } else {
- utils.showLog("warn:" + "本地配置数据不包含‘yw_app_id’字段!");
- }
- }
- }
- }
- private _init_wechat(data: string) {
- if (!data) return false;
- utils.showLog("本地配置数据:", data);
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.wechat) {
- if (configObj.wechat.app_id) {
- this.wechatconfig.appID = configObj.wechat.app_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- if (configObj.wechat.intersititia_pos_id) {
- this.wechatconfig.insertId = configObj.wechat.intersititia_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
- return false;
- }
- if (configObj.wechat.video_pos_id) {
- this.wechatconfig.videoId = configObj.wechat.video_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
- return false;
- }
- if (configObj.wechat.app_box_pos_id) {
- this.wechatconfig.appBoxId = configObj.wechat.app_box_pos_id;
- } else {
- utils.showLog("本地配置数据不包含‘app_box_pos_id’字段!");
- // return false;
- }
- if (configObj.wechat.version) {
- this.wechatconfig.version = configObj.wechat.version;
- } else {
- utils.showLog("本地配置数据不包含‘version’字段!");
- }
- if (configObj.wechat.is_attributed) {
- this.wechatconfig.isAttributed = configObj.wechat.is_attributed;
- }
- if (configObj.wechat.banner_pos_id) {
- for (let key in configObj.wechat.banner_pos_id) {
- let bannerInfo: BannerIdInfo = new BannerIdInfo();
- bannerInfo.location = this._bannerLocationStringToEnum(key);
- bannerInfo.bannerId = configObj.wechat.banner_pos_id[key];
- this.wechatconfig.bannerIds.push(bannerInfo);
- }
- } else {
- utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
- return false;
- }
- if (configObj.wechat.shares) {
- if (configObj.wechat.shares.sy_title) {
- this.otherconfig.shareTitle = configObj.wechat.shares.sy_title;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares.shareTitle’字段!");
- return false;
- }
- if (configObj.wechat.shares.sy_img) {
- this.otherconfig.shareImgUrl = configObj.wechat.shares.sy_img;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares.shareImgUrl’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares’字段!");
- return false;
- }
- if (configObj.wechat.banner_box_pos_id) {
- this.wechatconfig.bannerBoxId = configObj.wechat.banner_box_pos_id;
- } else {
- utils.showLog("error" + "本地配置中不包含 ‘banner_box_pos_id’ 字段");
- }
- if (configObj.wechat.native_banner_pos_id) {
- this.wechatconfig.nativeBannerId = configObj.wechat.native_banner_pos_id;
- } else {
- utils.showLog("error" + "本地配置中不包含 native_banner_pos_id 字段");
- }
- if (configObj.wechat.native_intersititial_pos_id) {
- this.wechatconfig.nativeInsertIds = configObj.wechat.native_intersititial_pos_id;
- } else {
- utils.showLog("error" + "本地配置中不包含 native_intersititial_pos_id 字段");
- }
- } else {
- utils.showLog("error" + "本地配置数据不包含‘wechat’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不是合法的json数据!");
- return false;
- }
- return true;
- }
- private _init_oppo(data: string) {
- if (!data) return false;
- utils.showLog("本地配置数据:", data);
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.oppo) {
- if (configObj.oppo.app_id) {
- this.oppoconfig.appID = configObj.oppo.app_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- if (configObj.oppo.package_name) {
- this.oppoconfig.packageName = configObj.oppo.package_name;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘package_name’字段!");
- return false;
- }
- if (configObj.oppo.banner_pos_id) {
- this.oppoconfig.bannerId = configObj.oppo.banner_pos_id;
- }
- // else {
- // utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
- // return false;
- // }
- if (configObj.oppo.rec_game_drawer_id) {
- this.oppoconfig.recGameDrawerId = configObj.oppo.rec_game_drawer_id;
- } else {
- utils.showLog("error" + "rec_game_drawer_id");
- }
- // if (configObj.oppo.intersititia_pos_id) {
- // this.oppoconfig.insertId = configObj.oppo.intersititia_pos_id;
- // } else {
- // utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
- // // return false;
- // }
- if (configObj.oppo.video_pos_id) {
- this.oppoconfig.videoId = configObj.oppo.video_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
- return false;
- }
- if (configObj.oppo.native_banner_pos_id) {
- this.oppoconfig.nativeBannerIds = configObj.oppo.native_banner_pos_id;
- }
- // else {
- // utils.showLog("error" + "本地配置数据不包含‘native_banner_pos_id’字段!");
- // return false;
- // }
- if (configObj.oppo.native_trygame_pos_id) {
- this.oppoconfig.nativeTryGameIds = configObj.oppo.native_trygame_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘native_trygame_pos_id’字段!");
- // return false;
- }
- if (configObj.oppo.intersitial_configs) {
- this.oppoconfig.intersitialAdConfigs = configObj.oppo.intersitial_configs;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘intersitial_configs’字段!");
- return false;
- }
- if (configObj.oppo.banner_configs) {
- this.oppoconfig.bannerAdConfigs = configObj.oppo.banner_configs;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘banner_configs’字段!");
- return false;
- }
- // if (configObj.oppo.native_intersititial_pos_id) {
- // this.oppoconfig.nativeInsertIds = configObj.oppo.native_intersititial_pos_id;
- // } else {
- // utils.showLog("error" + "本地配置数据不包含‘native_intersititial_pos_id’字段!");
- // return false;
- // }
- if (configObj.oppo.native_single_pos_id) {
- this.oppoconfig.nativeSingleAdIds = configObj.oppo.native_single_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘native_single_pos_id’字段!");
- return false;
- }
- if (configObj.oppo.rec_portal_id) {
- this.oppoconfig.recPortalId = configObj.oppo.rec_portal_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘rec_portal_id’字段!");
- }
- if (configObj.oppo.rec_game_banner_id) {
- this.oppoconfig.recGameBannerId = configObj.oppo.rec_game_banner_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘rec_game_banner_id’字段!");
- }
- if (configObj.oppo.version) {
- //@ts-ignore
- if (window.new_version) {
- //@ts-ignore
- this.oppoconfig.version = window.new_version;
- utils.showLog("获取到注入的版本号:" + this.oppoconfig.version);
- } else {
- this.oppoconfig.version = configObj.oppo.version;
- }
- } else {
- utils.showLog("error" + "本地配置数据不包含‘version’字段!");
- return false;
- }
- if (configObj.oppo.umeng_id) {
- this.oppoconfig.umengId = configObj.oppo.umeng_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘umeng_id’字段!");
- }
- } else {
- utils.showLog("error" + "本地配置数据不包含‘oppo’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不是合法的json数据!");
- return false;
- }
- return true;
- }
- private _init_vivo(data: string) {
- if (!data) return false;
- utils.showLog("本地配置数据:", data);
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.vivo) {
- if (configObj.vivo.app_id) {
- this.vivoconfig.appID = configObj.vivo.app_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- if (configObj.vivo.intersititia_pos_id) {
- this.vivoconfig.insertId = configObj.vivo.intersititia_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
- return false;
- }
- if (configObj.vivo.video_pos_id) {
- this.vivoconfig.videoId = configObj.vivo.video_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
- return false;
- }
- if (configObj.vivo.banner_pos_id) {
- this.vivoconfig.bannerId = configObj.vivo.banner_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
- return false;
- }
- if (configObj.vivo.native_banner_pos_id) {
- this.vivoconfig.nativeBannerIds = configObj.vivo.native_banner_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘native_banner_pos_id’字段!");
- return false;
- }
- if (configObj.vivo.native_trygame_pos_id) {
- this.vivoconfig.nativeTryGameIds = configObj.vivo.native_trygame_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘native_trygame_pos_id’字段!");
- // return false;
- }
- if (configObj.vivo.native_intersititial_pos_id) {
- this.vivoconfig.nativeInsertIds = configObj.vivo.native_intersititial_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘native_intersititial_pos_id’字段!");
- return false;
- }
- if (configObj.vivo.rec_portal_id) {
- this.vivoconfig.recPortalId = configObj.vivo.rec_portal_id;
- } else {
- utils.showLog("warn" + "本地配置数据不包含‘rec_portal_id’字段!");
- }
- if (configObj.vivo.rec_game_banner_id) {
- this.vivoconfig.recGameBannerId = configObj.vivo.rec_game_banner_id;
- } else {
- utils.showLog("warn" + "本地配置数据不包含‘rec_game_banner_id’字段!");
- }
- if (configObj.vivo.native_single_pos_id) {
- this.vivoconfig.nativeSingleAdIds = configObj.vivo.native_single_pos_id;
- } else {
- utils.showLog("warn" + "本地配置数据不包含‘native_single_pos_id’字段!");
- }
- if (configObj.vivo.umeng_id) {
- this.vivoconfig.umengId = configObj.vivo.umeng_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘umeng_id’字段,不启用友盟统计!");
- }
- if (configObj.vivo.version) {
- this.vivoconfig.version = configObj.vivo.version;
- } else {
- utils.showLog("warn:" + "本地配置数据不包含‘version’字段!");
- }
- } else {
- utils.showLog("error" + "本地配置数据不包含‘vivo’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不是合法的json数据!");
- return false;
- }
- return true;
- }
- private _init_baidu(data: string) {
- if (!data) return false;
- utils.showLog("本地配置数据:", data);
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.baidu) {
- if (configObj.baidu.app_id) {
- this.baiduconfig.appID = configObj.baidu.app_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- if (configObj.baidu.app_sid) {
- this.baiduconfig.appSID = configObj.baidu.app_sid;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_sid’字段!")
- }
- if (configObj.baidu.video_pos_id) {
- this.baiduconfig.videoId = configObj.baidu.video_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
- return false;
- }
- if (configObj.baidu.banner_pos_id) {
- this.baiduconfig.bannerId = configObj.baidu.banner_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
- return false;
- }
- if (configObj.baidu.version) {
- this.baiduconfig.version = configObj.baidu.version;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘version’字段!");
- return false;
- }
- if (configObj.baidu.shares) {
- if (configObj.baidu.shares.sy_title) {
- this.otherconfig.shareTitle = configObj.baidu.shares.sy_title;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares.sy_title’字段!");
- return false;
- }
- if (configObj.baidu.shares.sy_img) {
- this.otherconfig.shareImgUrl = configObj.baidu.shares.sy_img;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares.sy_img’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不包含‘baidu’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不是合法的json数据!");
- return false;
- }
- return true;
- }
- private _init_wifi(data: string) {
- if (!data) return false;
- utils.showLog("本地配置数据:", data);
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.wifi) {
- if (configObj.wifi.app_id) {
- this.wifiConfig.appID = configObj.wifi.app_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- if (configObj.wifi.version) {
- this.wifiConfig.version = configObj.wifi.version;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘version’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不包含‘baidu’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不是合法的json数据!");
- return false;
- }
- return true;
- }
- private _init_douyin(data: string) {
- if (!data) return false;
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.toutiao) {
- if (configObj.toutiao.app_id) {
- this.douyinconfig.appID = configObj.toutiao.app_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- if (configObj.toutiao.banner_pos_id) {
- this.douyinconfig.bannerId = configObj.toutiao.banner_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
- return false;
- }
- if (configObj.toutiao.video_pos_id) {
- this.douyinconfig.videoId = configObj.toutiao.video_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
- return false;
- }
- if (configObj.toutiao.intersititia_pos_id) {
- this.douyinconfig.insertId = configObj.toutiao.intersititia_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
- return false;
- }
- if (configObj.toutiao.version) {
- this.douyinconfig.version = configObj.toutiao.version;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘version’字段!");
- return false;
- }
- if (configObj.toutiao.shares) {
- if (configObj.toutiao.shares.sy_title) {
- this.otherconfig.shareTitle = configObj.toutiao.shares.sy_title;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares.sy_title’字段!");
- return false;
- }
- if (configObj.toutiao.shares.sy_img) {
- this.otherconfig.shareImgUrl = configObj.toutiao.shares.sy_img;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares.sy_img’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares’字段!");
- return false;
- }
- }
- } else {
- utils.showLog("warn:" + "本地配置数据不是合法的json数据!");
- return false;
- }
- return true;
- }
- private _init_qq(data: string) {
- if (!data) return false;
- utils.showLog("本地配置数据:", data);
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.qq) {
- if (configObj.qq.app_id) {
- this.qqconfig.appID = configObj.qq.app_id;
- } else {
- utils.showMsg("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- if (configObj.qq.video_pos_id) {
- this.qqconfig.videoId = configObj.qq.video_pos_id;
- } else {
- utils.showMsg("error" + "本地配置数据不包含‘video_pos_id’字段!");
- return false;
- }
- if (configObj.qq.banner_pos_id) {
- this.qqconfig.bannerId = configObj.qq.banner_pos_id;
- } else {
- utils.showMsg("error" + "本地配置数据不包含‘banner_pos_id’字段!");
- return false;
- }
- if (configObj.qq.intersititia_pos_id) {
- this.qqconfig.insertId = configObj.qq.intersititia_pos_id;
- } else {
- utils.showMsg("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
- return false;
- }
- if (configObj.qq.box_pos_id) {
- this.qqconfig.boxId = configObj.qq.box_pos_id;
- } else {
- utils.showMsg("error" + "本地配置数据不包含‘box_pos_id’字段!");
- return false;
- }
- if (configObj.qq.banner_box_pos_id) {
- this.qqconfig.bannerBoxId = configObj.qq.banner_box_pos_id;
- } else {
- utils.showMsg("error" + "本地配置数据不包含‘banner_box_pos_id’字段!");
- return false;
- }
- if (configObj.qq.shares) {
- if (configObj.qq.shares.sy_title) {
- this.otherconfig.shareTitle = configObj.qq.shares.sy_title;
- } else {
- utils.showMsg("error" + "本地配置数据不包含‘shares.shareTitle’字段!");
- return false;
- }
- if (configObj.qq.shares.sy_img) {
- this.otherconfig.shareImgUrl = configObj.qq.shares.sy_img;
- } else {
- utils.showMsg("error" + "本地配置数据不包含‘shares.shareImgUrl’字段!");
- return false;
- }
- } else {
- utils.showMsg("error" + "本地配置数据不包含‘shares’字段!");
- return false;
- }
- if (configObj.qq.version) {
- this.qqconfig.version = configObj.qq.version;
- } else {
- utils.showMsg("error" + "本地配置数据不包含‘version’字段!");
- return false;
- }
- } else {
- utils.showMsg("error" + "本地配置数据不包含‘qq’字段!");
- return false;
- }
- } else {
- utils.showMsg("error" + "本地配置数据不是合法的json数据!");
- return false;
- }
- return true;
- }
- /**
- * 初始化趣头条
- * 这里只输出配置不做任何处理
- * @param data 数据
- */
- private _init_qtt(data: string): boolean {
- if (!data) return false;
- utils.showLog("本地配置数据:", data);
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.qutoutiao) {
- if (configObj.qutoutiao.app_id) {
- this.qttconfig.appID = configObj.qutoutiao.app_id;
- utils.showLog("this.qttconfig.appID:", this.qttconfig.appID);
- utils.showLog("configObj.qutoutiao.app_id:", configObj.qutoutiao.app_id);
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- if (configObj.qutoutiao.app_key) {
- this.qttconfig.appKey = configObj.qutoutiao.app_key;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_key’字段!");
- return false;
- }
- if (configObj.qutoutiao.game_name) {
- this.qttconfig.gamename = configObj.qutoutiao.game_name;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_key’字段!");
- return false;
- }
- }
- }
- return true;
- }
- private _bannerLocationStringToEnum(str: string) {
- switch (str) {
- case "home": {
- return BannerLocation.Home;
- }
- case "game": {
- return BannerLocation.Game;
- }
- case "level": {
- return BannerLocation.Level;
- }
- case "skin": {
- return BannerLocation.Skin;
- }
- case "pause": {
- return BannerLocation.Pause;
- }
- case "over": {
- return BannerLocation.Over;
- }
- default:
- return BannerLocation.None;
- }
- }
- /**
- * 初始化小米
- * @param data 配置
- */
- private _init_xiaomi(data: string) {
- if (!data) return false;
- utils.showLog("本地配置数据:", data);
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.xiaomi) {
- if (configObj.xiaomi.app_id) {
- this.xiaomiConfig.appID = configObj.xiaomi.app_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- if (configObj.xiaomi.intersititia_pos_id) {
- this.xiaomiConfig.insertId = configObj.xiaomi.intersititia_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
- return false;
- }
- if (configObj.xiaomi.video_pos_id) {
- this.xiaomiConfig.videoId = configObj.xiaomi.video_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
- return false;
- }
- if (configObj.xiaomi.banner_pos_id) {
- this.xiaomiConfig.bannerId = configObj.xiaomi.banner_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
- return false;
- }
- if (configObj.xiaomi.native_banner_pos_id) {
- this.xiaomiConfig.nativeBannerIds = configObj.xiaomi.native_banner_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘native_banner_pos_id’字段!");
- return false;
- }
- if (configObj.xiaomi.native_trygame_pos_id) {
- this.xiaomiConfig.nativeTryGameIds = configObj.xiaomi.native_trygame_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘native_trygame_pos_id’字段!");
- // return false;
- }
- if (configObj.xiaomi.native_intersititial_pos_id) {
- this.xiaomiConfig.nativeInsertIds = configObj.xiaomi.native_intersititial_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘native_intersititial_pos_id’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不包含‘xiaomi’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不是合法的json数据!");
- return false;
- }
- return true;
- }
- /**
- * 初始化uc
- * @param data 配置
- */
- private _init_uc(data: string) {
- if (!data) return false;
- utils.showLog("本地配置数据:", data);
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.uc) {
- if (configObj.uc.app_id) {
- this.ucConfig.appID = configObj.uc.app_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- if (configObj.uc.version) {
- this.ucConfig.version = configObj.uc.version;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘version’字段!");
- return false;
- }
- if (configObj.uc.shares) {
- if (configObj.uc.shares.sy_title) {
- this.otherconfig.shareTitle = configObj.uc.shares.sy_title;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares.shareTitle’字段!");
- return false;
- }
- if (configObj.uc.shares.sy_img) {
- this.otherconfig.shareImgUrl = configObj.uc.shares.sy_img;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares.shareImgUrl’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不包含‘uc’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不是合法的json数据!");
- return false;
- }
- return true;
- }
- /**
- * 初始化uc
- * @param data 配置
- */
- private _init_cocos(data: string) {
- if (!data) return false;
- utils.showLog("本地配置数据:", data);
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.cocos) {
- if (configObj.cocos.app_id) {
- this.cocosConfig.appID = configObj.cocos.app_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- if (configObj.cocos.video_pos_id) {
- this.cocosConfig.videoId = configObj.cocos.video_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
- return false;
- }
- if (configObj.cocos.banner_pos_id) {
- this.cocosConfig.bannerId = configObj.cocos.banner_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
- return false;
- }
- if (configObj.cocos.intersititia_pos_id) {
- this.cocosConfig.insertId = configObj.cocos.intersititia_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
- return false;
- }
- if (configObj.cocos.shares) {
- if (configObj.cocos.shares.sy_title) {
- this.otherconfig.shareTitle = configObj.cocos.shares.sy_title;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares.shareTitle’字段!");
- return false;
- }
- if (configObj.cocos.shares.sy_img) {
- this.otherconfig.shareImgUrl = configObj.cocos.shares.sy_img;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares.shareImgUrl’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不包含‘cocos’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不是合法的json数据!");
- return false;
- }
- return true;
- }
- /**
- * 初始化原生安卓平台
- * @param data 配置
- */
- private _init_native_android() {
- if (!utils.Tool_Native) {
- return false;
- }
- let data = utils.Tool_Native.getNativeData()
- utils.showLog("原生安卓平台本地配置数据:", data);
- if (!data) {
- utils.showLog("error : 安卓本地配置数据配置错误!")
- return false;
- }
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.app_id) {
- this.nativeAndroidConfig.appID = configObj.app_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- if (configObj.version) {
- this.nativeAndroidConfig.version = configObj.version;
- } else {
- utils.showMsg("error" + "本地配置数据不包含‘version’字段!");
- return false;
- }
- if (configObj.channel) {
- this.nativeAndroidConfig.channel = configObj.channel;
- utils.showLog("原生平台渠道号 channel=" + configObj.channel);
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不是合法的json数据!");
- return false;
- }
- return true;
- }
- /**
- * 初始化原生IOS
- */
- private _init_native_ios(data: string) {
- if (!data) return false;
- utils.showLog("本地配置数据:", data);
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.ios.app_id) {
- this.nativeIoSConfig.appID = configObj.ios.app_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- if (configObj.ios.video_pos_id) {
- this.nativeIoSConfig.videoId = configObj.ios.video_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
- return false;
- }
- if (configObj.ios.version) {
- this.nativeIoSConfig.version = configObj.ios.version;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘version’字段!");
- return false;
- }
- if (configObj.ios.banner_pos_id) {
- this.nativeIoSConfig.bannerId = configObj.ios.banner_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
- return false;
- }
- if (configObj.ios.intersititia_pos_id) {
- this.nativeIoSConfig.insertId = configObj.ios.intersititia_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不是合法的json数据!");
- return false;
- }
- return true;
- }
- /**
- * 初始化bili
- * @param data 配置
- */
- private _init_bili(data: string) {
- if (!data) return false;
- utils.showLog("本地配置数据:", data);
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.bili.shares.sy_title) {
- this.otherconfig.shareTitle = configObj.bili.shares.sy_title;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares.sy_title’字段!");
- return false;
- }
- if (configObj.bili.shares.sy_img) {
- this.otherconfig.shareImgUrl = configObj.bili.shares.sy_img;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares.sy_img’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不是合法的json数据!");
- return false;
- }
- return true;
- }
- /**
- * 初始化快手
- * @param data 配置
- */
- private _init_kwai(data: string) {
- if (!data) return false;
- utils.showLog("本地配置数据:", data);
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.kwai.app_id) {
- this.kwaiConfig.appID = configObj.kwai.app_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- if (configObj.kwai.video_pos_id) {
- this.kwaiConfig.videoId = configObj.kwai.video_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
- return false;
- }
- if (configObj.kwai.intersititia_pos_id) {
- this.kwaiConfig.insertId = configObj.kwai.intersititia_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
- }
- if (configObj.kwai.version) {
- this.kwaiConfig.version = configObj.kwai.version;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘version’字段!");
- return false;
- }
- if (configObj.kwai.shares) {
- if (configObj.kwai.shares.sy_title) {
- this.otherconfig.shareTitle = configObj.kwai.shares.sy_title;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares.sy_title’字段!");
- return false;
- }
- if (configObj.kwai.shares.sy_img) {
- this.otherconfig.shareImgUrl = configObj.kwai.shares.sy_img;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares.sy_img’字段!");
- return false;
- }
- if (configObj.kwai.shares.sy_icon) {
- this.otherconfig.shareIcon = configObj.kwai.shares.sy_icon;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares.sy_icon");
- return false;
- }
- if (configObj.kwai.shares.sy_desc) {
- this.otherconfig.shareDesc = configObj.kwai.shares.sy_desc;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares.sy_desc’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不包含‘shares’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不是合法的json数据!");
- return false;
- }
- return true;
- }
- /**
- * 初始化facebook
- * @param data 配置
- */
- private _init_facebook(data: string) {
- if (!data) return false;
- utils.showLog("本地配置数据:", data);
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.faceBook.app_id) {
- this.faceBookConfig.appID = configObj.faceBook.app_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- if (configObj.faceBook.video_pos_id) {
- this.faceBookConfig.videoId = configObj.faceBook.video_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
- return false;
- }
- if (configObj.faceBook.intersititia_pos_id) {
- this.faceBookConfig.insertId = configObj.faceBook.intersititia_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
- return false;
- }
- if (configObj.faceBook.banner_pos_id) {
- this.faceBookConfig.bannerId = configObj.faceBook.banner_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
- return false;
- }
- if (configObj.faceBook.version) {
- this.faceBookConfig.version = configObj.faceBook.version;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘version’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不是合法的json数据!");
- return false;
- }
- utils.showLog("success" + "本地配置数据验证完成!");
- return true;
- }
- /**
- * 初始化Hago
- * @param data 配置
- */
- private _init_hago(data: string) {
- if (!data) return false;
- utils.showLog("本地配置数据:", data);
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.hago.app_id) {
- this.hagoConfig.appID = configObj.hago.app_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- if (configObj.hago.video_pos_id) {
- this.hagoConfig.videoId = configObj.hago.video_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
- return false;
- }
- if (configObj.hago.version) {
- this.hagoConfig.version = configObj.hago.version;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘version’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不是合法的json数据!");
- return false;
- }
- return true;
- }
- /**
- * 初始化Huawei
- * @param data 配置
- */
- private _init_huawei(data: string) {
- if (!data) return false;
- utils.showLog("本地配置数据:", data);
- let configObj: any = JSON.parse(data);
- if (configObj) {
- if (configObj.huawei.app_id) {
- this.huaweiConfig.appID = configObj.huawei.app_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
- return false;
- }
- if (configObj.huawei.video_pos_id) {
- this.huaweiConfig.videoId = configObj.huawei.video_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
- return false;
- }
- if (configObj.huawei.banner_pos_id) {
- this.huaweiConfig.bannerId = configObj.huawei.banner_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
- return false;
- }
- if (configObj.huawei.native_banner_pos_id) {
- this.huaweiConfig.nativeBannerIds = configObj.huawei.native_banner_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘native_banner_pos_id’字段!");
- }
- if (configObj.huawei.native_intersititial_pos_id) {
- this.huaweiConfig.nativeInsertIds = configObj.huawei.native_intersititial_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘native_intersititial_pos_id’字段!");
- }
- if (configObj.huawei.native_trygame_pos_id) {
- this.huaweiConfig.nativeTryGameIds = configObj.huawei.native_trygame_pos_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘native_trygame_pos_id’字段!");
- }
- if (configObj.huawei.native_splash_id) {
- this.huaweiConfig.nativeSplashId = configObj.huawei.native_splash_id;
- }
- else {
- utils.showLog("error" + "本地配置数据不包含‘native_splash_id’字段!")
- }
- if (configObj.huawei.umeng_id) {
- this.huaweiConfig.umengId = configObj.huawei.umeng_id;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘umeng_id’字段,不启用友盟统计!");
- }
- if (configObj.huawei.version) {
- this.huaweiConfig.version = configObj.huawei.version;
- } else {
- utils.showLog("error" + "本地配置数据不包含‘version’字段!");
- return false;
- }
- } else {
- utils.showLog("error" + "本地配置数据不是合法的json数据!");
- return false;
- }
- return true;
- }
- }
|