CommonConfig.ts 84 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288
  1. import YZ_Constant, { BannerLocation } from "./YZ_Constant";
  2. import PlatUtils from "./PlatUtils";
  3. import { utils } from "./Utils";
  4. import YZ_LocalStorage from "./YZ_LocalStorage";
  5. const { ccclass, property } = cc._decorator;
  6. @ccclass("BannerIdInfo")
  7. export class BannerIdInfo {
  8. @property({ type: cc.Enum(BannerLocation), displayName: "广告条位置" })
  9. location: BannerLocation = BannerLocation.None;
  10. @property({ displayName: "广告条ID" })
  11. bannerId: string = "";
  12. };
  13. @ccclass("NativeBannerInfo")
  14. export class NativeBannerInfo {
  15. /**
  16. * 广告条的位置
  17. * 1:Home-首页
  18. * 2:Level-选关
  19. * 3:Skin-皮肤
  20. * 4:Game-游戏
  21. * 5:Pause-暂停
  22. * 6:Over-结算
  23. */
  24. location: BannerLocation = BannerLocation.None;
  25. /**
  26. * 是否显示结算大banner
  27. */
  28. show_st_banner: string = "false";
  29. /**
  30. * 默认原生banner关闭按钮大小,默认为60
  31. */
  32. banner_close_but_size: number = 40;
  33. /**
  34. * 默认banner关闭按钮透明度 默认为120
  35. */
  36. banner_close_but_alpha: number = 120;
  37. /**
  38. * 默认banner关闭按钮高度 默认为220
  39. */
  40. banner_show_height: number = 160;
  41. /**
  42. * 默认banner关闭按钮点击区域默认为80
  43. */
  44. banner_close_but_range: number = 40;
  45. /**
  46. * 默认原生banner关闭按钮,是否显示。默认为显示:"true"
  47. */
  48. banner_close_but_show = "true";
  49. /**
  50. * 结算前banner整体缩放,默认为1
  51. */
  52. st_banner_scale: number = 1;
  53. /**
  54. * 结算前banner下载按钮的图片地址
  55. */
  56. st_banner_down_btn_image: string = "";
  57. /**
  58. * 结算前banner下载按钮显示类型,默认不配置,则不显示,配置后则显示,值为2:显示循环播放放大缩小效果,
  59. */
  60. st_banner_down_but_show: number = 0;
  61. /**
  62. * 结算前banner,下载按钮距离广告顶部间距,默认贴紧广告顶部值是-111
  63. */
  64. st_banner_down_but_margin_top: number = 0;
  65. /**
  66. * 结算前banner,关闭按钮点击区域大小
  67. */
  68. st_banner_close_but_range: number = 55;
  69. /**
  70. * 结算前banner,关闭按钮图片大小
  71. */
  72. st_banner_close_but_size: number = 55;
  73. /**
  74. * 结算前banner关闭按钮,是否显示。默认为显示:"true"
  75. */
  76. st_banner_close_but_show: string = "true";
  77. /**
  78. * 结算前banner距离底部的距离
  79. */
  80. st_banner_bottom: number = 0;
  81. /**
  82. * 结算前banner关闭按钮透明度
  83. * 0-255
  84. */
  85. st_banner_close_but_alpha: number = 255;
  86. /**
  87. * banner点击后是不是需要刷新数据
  88. */
  89. banner_click_refresh: string = "true";
  90. /**
  91. * 自动刷新时间,单位:秒,默认为:-1 不刷新
  92. */
  93. auto_refresh: number = -1;
  94. /**
  95. * 样式
  96. * -1 :默认、0:单图片缩放、1:单图片和自定义宽高、2:默认样式自定义宽高
  97. */
  98. st_banner_style: number = -1;
  99. /**
  100. * 结算banner样式-宽,默认:821 单位:像素
  101. */
  102. st_banner_width: number = -1;
  103. /**
  104. * 结算banner样式-高:默认:589 单位:像素
  105. */
  106. st_banner_height: number = -1;
  107. /**
  108. * 结算banner是否显示备用广告
  109. * 默认:1 显示,-1 为不显示
  110. */
  111. st_banner_show_back_up: number = 1;
  112. /**
  113. * 是否显示banner
  114. * 默认:1 显示, -1为不显示;
  115. */
  116. is_show_banner: number = 1;
  117. //显示互推banner
  118. is_show_rec: number = -1;
  119. //延迟显示时间
  120. delay_show_time: number = 0;
  121. //关闭按钮间隔多少次触发广告跳转
  122. banner_close_showAd_interval: number = 0;
  123. //普通原生Banner背景透明遮罩透明度 大于0则显示当前值的透明遮罩层
  124. bg_mask_opacity: number = 0;
  125. //结算原生banner背景透明遮罩透明度 大于0则显示当前值的透明遮罩层
  126. st_banner_bg_mask_opacity: number = 0;
  127. // 对齐方式:bottom top
  128. _alignType: string = "bottom";
  129. /**
  130. * 初始化
  131. * @param location 位置
  132. * @param info 配置
  133. */
  134. init(location: BannerLocation, info: any) {
  135. this.location = location;
  136. this.banner_close_but_alpha = info.banner_close_but_alpha ? info.banner_close_but_alpha : this.banner_close_but_alpha;
  137. this.banner_close_but_range = info.banner_close_but_range ? info.banner_close_but_range : this.banner_close_but_range;
  138. this.banner_close_but_size = info.banner_close_but_size ? info.banner_close_but_size : this.banner_close_but_size;
  139. this.banner_show_height = info.banner_show_height ? info.banner_show_height : this.banner_show_height;
  140. this.banner_close_but_show = info.banner_close_but_show ? info.banner_close_but_show : this.banner_close_but_show;
  141. this.bg_mask_opacity = info.bg_mask_opacity ? info.bg_mask_opacity : this.bg_mask_opacity;
  142. this.st_banner_close_but_range = info.st_banner_close_but_range ? info.st_banner_close_but_range : this.st_banner_close_but_range;
  143. this.st_banner_close_but_size = info.st_banner_close_but_size ? info.st_banner_close_but_size : this.st_banner_close_but_size;
  144. this.st_banner_down_btn_image = info.st_banner_down_btn_image ? info.st_banner_down_btn_image : this.st_banner_down_btn_image;
  145. 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;
  146. this.st_banner_down_but_show = info.st_banner_down_but_show ? info.st_banner_down_but_show : this.st_banner_down_but_show;
  147. this.st_banner_scale = info.st_banner_scale ? info.st_banner_scale : this.st_banner_scale;
  148. this.show_st_banner = info.show_st_banner ? info.show_st_banner : this.show_st_banner;
  149. this.st_banner_close_but_show = info.st_banner_close_but_show ? info.st_banner_close_but_show : this.st_banner_close_but_show;
  150. this.st_banner_bottom = info.st_banner_bottom ? info.st_banner_bottom : this.st_banner_bottom;
  151. this.st_banner_close_but_alpha = info.st_banner_close_but_alpha ? info.st_banner_close_but_alpha : this.st_banner_close_but_alpha;
  152. this.banner_click_refresh = info.banner_click_refresh ? info.banner_click_refresh : this.banner_click_refresh;
  153. this.auto_refresh = info.auto_refresh ? info.auto_refresh : this.auto_refresh;
  154. this.st_banner_style = info.st_banner_style ? info.st_banner_style : this.st_banner_style;
  155. this.st_banner_width = info.st_banner_width ? info.st_banner_width : this.st_banner_width;
  156. this.st_banner_height = info.st_banner_height ? info.st_banner_height : this.st_banner_height;
  157. this.st_banner_show_back_up = info.st_banner_show_back_up ? info.st_banner_show_back_up : this.st_banner_show_back_up;
  158. this.is_show_banner = info.is_show_banner ? info.is_show_banner : this.is_show_banner;
  159. this.is_show_rec = info.is_show_rec ? info.is_show_rec : this.is_show_rec;
  160. this.delay_show_time = info.delay_show_time ? info.delay_show_time : this.delay_show_time;
  161. this.st_banner_bg_mask_opacity = info.st_banner_bg_mask_opacity ? info.st_banner_bg_mask_opacity : this.st_banner_bg_mask_opacity;
  162. this._alignType = info.align_type ? info.align_type : this._alignType;
  163. this.banner_close_showAd_interval = info.banner_close_showAd_interval ? info.banner_close_showAd_interval : this.banner_close_showAd_interval;
  164. }
  165. toStrong() {
  166. 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}`;
  167. }
  168. }
  169. @ccclass("CustomAdInfo")
  170. export class CustomAdInfo {
  171. /**
  172. * 广告条的位置
  173. * 1:Home-首页
  174. * 2:Level-选关
  175. * 3:Skin-皮肤
  176. * 4:Game-游戏
  177. * 5:Pause-暂停
  178. * 6:Over-结算
  179. * 其中选项没有的话,可以自定义
  180. */
  181. location: BannerLocation = BannerLocation.None;
  182. /**
  183. * 是否显示结算大banner
  184. */
  185. is_show_ad: string = "true";
  186. /**
  187. * 距离顶部的距离
  188. */
  189. top: number = -1;
  190. /**
  191. * 距离左边的距离
  192. */
  193. left: number = -1;
  194. /**
  195. * 距离右边的距离
  196. */
  197. right: number = -1;
  198. /**
  199. * 距离底部的距离
  200. */
  201. bottom: number = -1;
  202. /**
  203. * 广告ID
  204. */
  205. id: string = "";
  206. /**
  207. * 刷新时间
  208. */
  209. refresh_time: number = -1;
  210. /**
  211. * 广告宽度
  212. */
  213. width: number = 0;
  214. /**
  215. * 广告高度
  216. */
  217. height: number = 0;
  218. /**
  219. * 显示成功后是否隐藏banner
  220. */
  221. hide_banner: string = "false";
  222. /**
  223. * 是否居中显示
  224. * about:左右居中
  225. * updown:上下
  226. * all:上下和左右居中
  227. */
  228. is_center: string = "false";
  229. /**
  230. * 改变位置的时候是否刷新广告
  231. */
  232. change_location_refresh_ad = "true";
  233. //当前obj对象
  234. customAdObj: any = null;
  235. /**
  236. * 初始化
  237. * @param location 位置
  238. * @param info 配置
  239. */
  240. init(location: BannerLocation, info: any) {
  241. this.location = location;
  242. this.top = "top" in info ? info.top : -1;
  243. this.right = "right" in info ? info.right : -1;
  244. this.left = "left" in info ? info.left : -1;
  245. this.bottom = "bottom" in info ? info.bottom : -1;
  246. this.id = "id" in info ? info.id : "";
  247. this.refresh_time = "refresh_time" in info ? info.refresh_time : -1;
  248. this.is_show_ad = "is_show_ad" in info ? info.is_show_ad : "true";
  249. this.width = "width" in info ? info.width : 0;
  250. this.height = "height" in info ? info.height : 0;
  251. this.hide_banner = "hide_banner" in info ? info.hide_banner : "false";
  252. this.change_location_refresh_ad = "change_location_refresh_ad" in info ? info.change_location_refresh_ad : "false";
  253. this.is_center = "is_center" in info ? info.is_center : "all";
  254. }
  255. toStrong() {
  256. 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}`;
  257. }
  258. }
  259. @ccclass("WechatConfig")
  260. export class WechatConfig {
  261. appID: string = "";
  262. bannerIds: BannerIdInfo[] = [];
  263. videoId: string = "";
  264. insertId: string = "";
  265. jumpId: string = "";
  266. appBoxId: string = "";
  267. boxId: string = "";
  268. bannerBoxId: string = "";
  269. customAdInfos: CustomAdInfo[] = [];
  270. isAttributed: boolean = false;
  271. version: string = "";
  272. nativeBannerId: string = "";
  273. nativeInsertIds: string = "";
  274. /**
  275. * 根据位置获取bannerId
  276. * @param location BannerLocation
  277. */
  278. public getBannerId(location: BannerLocation) {
  279. for (let i = 0; i < this.bannerIds.length; i++) {
  280. if (this.bannerIds[i].location == location) {
  281. return this.bannerIds[i].bannerId;
  282. }
  283. }
  284. if (this.bannerIds.length > 0) {
  285. return this.bannerIds[0].bannerId;
  286. }
  287. return "";
  288. }
  289. /**
  290. * 设定原生模版配置
  291. * @param location 位置
  292. * @param bannerInfo 配置
  293. */
  294. public setCustomAdInfo(location, custInfo: any) {
  295. let nativeCustomAd = new CustomAdInfo();
  296. nativeCustomAd.init(location, custInfo);
  297. this.customAdInfos.push(nativeCustomAd);
  298. }
  299. /**
  300. * 根据位置获取原生模版配置
  301. * @param location BannerLocation
  302. */
  303. public getCustomAdInfoInfo(location: BannerLocation) {
  304. utils.showLog("根据位置获取原生模版配置>>location=", location);
  305. for (let i = 0; i < this.customAdInfos.length; i++) {
  306. if (this.customAdInfos[i].location == location) {
  307. utils.showLog("根据位置获取原生模版配置>>info=", this.customAdInfos[i].toStrong());
  308. return this.customAdInfos[i];
  309. }
  310. }
  311. return null;
  312. }
  313. /**
  314. * 设定bannerId
  315. * @param location BannerLocation
  316. * @param bannerId
  317. */
  318. public setBannerId(location: BannerLocation, bannerId: string) {
  319. for (let i = 0; i < this.bannerIds.length; i++) {
  320. if (this.bannerIds[i].location == location) {
  321. this.bannerIds[i].bannerId = bannerId;
  322. return;
  323. }
  324. }
  325. }
  326. }
  327. @ccclass("QQConfig")
  328. export class QQConfig {
  329. QQ: boolean = true;
  330. appID: string = "";
  331. bannerId: string = "";
  332. insertId: string = "";
  333. videoId: string = "";
  334. boxId: string = "";
  335. version: string = "";
  336. bannerBoxId: string = "";
  337. }
  338. @ccclass("OppoConfig")
  339. export class OppoConfig {
  340. public appID: string = "";
  341. public channel: string = "oppo";
  342. bannerId: string = "";
  343. insertId: string = "";
  344. videoId: string = "";
  345. nativeBannerIds: string[] = [];
  346. nativeTryGameIds: string[] = [];
  347. nativeInsertIds: string[] = [];
  348. nativeSingleAdIds: string[] = [];
  349. packageName: string = "";
  350. nativeBannerInfos: NativeBannerInfo[] = [];
  351. recGameBannerId: string = "";
  352. recPortalId: string = "";
  353. version: string = "";
  354. recGameDrawerId: string = "";
  355. umengId: String = ""; //友盟ID
  356. intersitialAdConfigs: any[] = []; //插屏ID配置
  357. bannerAdConfigs: any[] = []; //Banner配置
  358. /**
  359. * 根据位置获取原生banner配置
  360. * @param location BannerLocation
  361. */
  362. public getNativeBannerInfo(location: BannerLocation) {
  363. utils.showLog("根据位置获取原生banner配置>>location=", location);
  364. for (let i = 0; i < this.nativeBannerInfos.length; i++) {
  365. if (this.nativeBannerInfos[i].location == location) {
  366. utils.showLog("根据位置获取原生banner配置>>info=", this.nativeBannerInfos[i].toStrong());
  367. return this.nativeBannerInfos[i];
  368. }
  369. }
  370. return new NativeBannerInfo();
  371. }
  372. /**
  373. * 设定原生banner配置
  374. * @param location 位置
  375. * @param bannerInfo 配置
  376. */
  377. public setNativeBannerInfo(location, bannerInfo: any) {
  378. let nativeBannerInfo: NativeBannerInfo = new NativeBannerInfo();
  379. nativeBannerInfo.init(location, bannerInfo);
  380. this.nativeBannerInfos.push(nativeBannerInfo);
  381. }
  382. }
  383. @ccclass("VivoConfig")
  384. export class VivoConfig {
  385. showAd: boolean = true;
  386. appID: string = "";
  387. bannerId: string = "";
  388. insertId: string = "";
  389. videoId: string = ""
  390. nativeTryGameIds: string[] = [];
  391. nativeBannerIds: string[] = [];
  392. nativeInsertIds: string[] = [];
  393. nativeBannerInfos: NativeBannerInfo[] = [];
  394. customAdInfos: CustomAdInfo[] = [];
  395. nativeSingleAdIds: string[] = [];
  396. recGameBannerId: string = "";
  397. recPortalId: string = "";
  398. version: string = "";
  399. umengId: String = ""; //友盟ID
  400. /**
  401. * 根据位置获取原生banner配置
  402. * @param location BannerLocation
  403. */
  404. public getNativeBannerInfo(location: BannerLocation) {
  405. utils.showLog("根据位置获取原生banner配置>>location=", location);
  406. for (let i = 0; i < this.nativeBannerInfos.length; i++) {
  407. if (this.nativeBannerInfos[i].location == location) {
  408. utils.showLog("根据位置获取原生banner配置>>info=", this.nativeBannerInfos[i].toStrong());
  409. return this.nativeBannerInfos[i];
  410. }
  411. }
  412. return new NativeBannerInfo();
  413. }
  414. /**
  415. * 根据位置获取原生模版配置
  416. * @param location BannerLocation
  417. */
  418. public getCustomAdInfoInfo(location: BannerLocation) {
  419. utils.showLog("根据位置获取原生模版配置>>location=", location);
  420. for (let i = 0; i < this.customAdInfos.length; i++) {
  421. if (this.customAdInfos[i].location == location) {
  422. utils.showLog("根据位置获取原生模版配置>>info=", this.customAdInfos[i].toStrong());
  423. return this.customAdInfos[i];
  424. }
  425. }
  426. return new CustomAdInfo();
  427. }
  428. /**
  429. * 设定原生banner配置
  430. * @param location 位置
  431. * @param bannerInfo 配置
  432. */
  433. public setNativeBannerInfo(location, bannerInfo: any) {
  434. let nativeBannerInfo: NativeBannerInfo = new NativeBannerInfo();
  435. nativeBannerInfo.init(location, bannerInfo);
  436. this.nativeBannerInfos.push(nativeBannerInfo);
  437. }
  438. /**
  439. * 设定原生模版配置
  440. * @param location 位置
  441. * @param bannerInfo 配置
  442. */
  443. public setCustomAdInfo(location, custInfo: any) {
  444. let nativeCustomAd = new CustomAdInfo();
  445. nativeCustomAd.init(location, custInfo);
  446. this.customAdInfos.push(nativeCustomAd);
  447. }
  448. }
  449. @ccclass("YzRedBagInfo")
  450. export class YzRedBagInfo {
  451. private _progress: number = 0; //当前进度
  452. private _totalProgress: number = 5; //总进度
  453. private _balance: number = 0.00; //余额
  454. private _totalMoeny: number = 0;
  455. private _lastOpenFreeRedBagTime: string = "";
  456. private _progressInfos: any = null;
  457. private _lastOpenLevel: string = "-1";
  458. private _freeRedBagCount: number = 0; //现金红包次数
  459. public withdrawaMoneys = [5, 20, 45, 50]
  460. constructor() {
  461. if (PlatUtils.IsTest) {
  462. this._progressInfos = [
  463. {
  464. level: 0,
  465. min_money: 0.1,
  466. max_money: 5,
  467. type: 1
  468. },
  469. {
  470. level: 4,
  471. min_money: 0.1,
  472. max_money: 3,
  473. type: 3
  474. },
  475. {
  476. level: 5,
  477. min_money: 0.001,
  478. max_money: 0.005,
  479. type: 2
  480. }
  481. ]
  482. }
  483. this._progress = YZ_LocalStorage.getItem(YZ_Constant.ST_RED_BAG_PROGRESS) ? YZ_LocalStorage.getItem(YZ_Constant.ST_RED_BAG_PROGRESS) : 0;
  484. this._totalProgress = YZ_LocalStorage.getItem(YZ_Constant.ST_RED_BAG_TOTAL_PROGRESS) ? YZ_LocalStorage.getItem(YZ_Constant.ST_RED_BAG_TOTAL_PROGRESS) : 5;
  485. this._balance = YZ_LocalStorage.getItem(YZ_Constant.ST_RED_BAG_BALANCE) ? parseFloat(YZ_LocalStorage.getItem(YZ_Constant.ST_RED_BAG_BALANCE)) : 0.00;
  486. 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;
  487. this._lastOpenFreeRedBagTime = YZ_LocalStorage.getItem(YZ_Constant.ST_FREE_RED_BAG_TIME) ? YZ_LocalStorage.getItem(YZ_Constant.ST_FREE_RED_BAG_TIME) : "";
  488. this._lastOpenLevel = YZ_LocalStorage.getItem(YZ_Constant.ST_LAST_OPEN_LEVEL) ? YZ_LocalStorage.getItem(YZ_Constant.ST_LAST_OPEN_LEVEL) : "-1";
  489. }
  490. public get freeRedBagCount() {
  491. return this._freeRedBagCount;
  492. }
  493. public set freeRedBagCount(value: number) {
  494. this._freeRedBagCount = value;
  495. }
  496. public get lastOpenLevel() {
  497. return this._lastOpenLevel;
  498. }
  499. public set lastOpenLevel(value: string) {
  500. this._lastOpenLevel = value;
  501. YZ_LocalStorage.setItem(YZ_Constant.ST_LAST_OPEN_LEVEL, value);
  502. }
  503. public get progress() {
  504. return this._progress;
  505. }
  506. public set progress(value: number) {
  507. this._progress = value;
  508. if (this._progress > this._totalProgress) {
  509. this._progress = this._totalProgress;
  510. } else {
  511. utils._rewardRedBagPanelShowCount = -1;
  512. }
  513. YZ_LocalStorage.setItem(YZ_Constant.ST_RED_BAG_PROGRESS, this._progress + '');
  514. cc.game.emit("YZ_RED_BAG_PROGRESS_CHANGE");
  515. }
  516. public get totalProgress() {
  517. return this._totalProgress;
  518. }
  519. public set totalProgress(value: number) {
  520. this._totalProgress = value;
  521. YZ_LocalStorage.setItem(YZ_Constant.ST_RED_BAG_TOTAL_PROGRESS, value + '');
  522. }
  523. public get totalMoney() {
  524. return this._totalMoeny;
  525. }
  526. public set totalMoney(value: number) {
  527. this._totalMoeny = value;
  528. YZ_LocalStorage.setItem(YZ_Constant.ST_RED_BAG_TOTAL_MONEY, value + '');
  529. }
  530. public set progressInfos(values: []) {
  531. this._progressInfos = values;
  532. }
  533. public get progressInfos() {
  534. return this._progressInfos;
  535. }
  536. public get curProgressInfo() {
  537. if (this._progressInfos && this._progressInfos.length > 0) {
  538. if (parseInt(this.lastOpenLevel) > 0 && parseInt(this.lastOpenLevel) >= utils.currentLevel) {
  539. return this._progressInfos[this._progressInfos.length - 1];
  540. }
  541. let temp = this.lastOpenLevel ? this._progressInfos[0] : this._progressInfos[1];
  542. for (let i = 0; i < this._progressInfos.length; i++) {
  543. //@ts-ignore
  544. if (utils.currentLevel <= this._progressInfos[i].level) {
  545. temp = this._progressInfos[i];
  546. break;
  547. }
  548. }
  549. console.log("curInfo " + JSON.stringify(temp));
  550. return temp;
  551. }
  552. return null;
  553. }
  554. public get balance() {
  555. return this._balance;
  556. }
  557. public set balance(value: number) {
  558. this._balance = value;
  559. YZ_LocalStorage.setItem(YZ_Constant.ST_RED_BAG_BALANCE, value + '');
  560. cc.game.emit("YZ_RED_BAG_BALANCE_CHANGE");
  561. }
  562. public get lastOpenFreeRedBagTime() {
  563. return this._lastOpenFreeRedBagTime;
  564. }
  565. public set lastOpenFreeRedBagTime(value: string) {
  566. this._lastOpenFreeRedBagTime = value;
  567. YZ_LocalStorage.setItem(YZ_Constant.ST_FREE_RED_BAG_TIME, value + '');
  568. }
  569. /**
  570. * 今天是否有免费的红包
  571. */
  572. public get isFreeRedBag(): boolean {
  573. cc.log("是否有免费红包:" + new Date().toDateString() != this._lastOpenFreeRedBagTime);
  574. return new Date().toDateString() != this._lastOpenFreeRedBagTime;
  575. }
  576. }
  577. @ccclass("HuaWeiConfig")
  578. export class HuaWeiConfig {
  579. appID: string = "";
  580. bannerId: string = "";
  581. insertId: string = "";
  582. videoId: string = "";
  583. nativeSplashId: string = "";
  584. nativeTryGameIds: string[] = [];
  585. nativeBannerIds: string[] = [];
  586. nativeInsertIds: string[] = [];
  587. nativeBannerInfos: NativeBannerInfo[] = [];
  588. version: string = "";
  589. umengId: string = "";
  590. /**
  591. * 根据位置获取原生banner配置
  592. * @param location BannerLocation
  593. */
  594. public getNativeBannerInfo(location: BannerLocation) {
  595. utils.showLog("根据位置获取原生banner配置>>location=", location);
  596. for (let i = 0; i < this.nativeBannerInfos.length; i++) {
  597. if (this.nativeBannerInfos[i].location == location) {
  598. utils.showLog("根据位置获取原生banner配置>>info=", this.nativeBannerInfos[i].toStrong());
  599. return this.nativeBannerInfos[i];
  600. }
  601. }
  602. return new NativeBannerInfo();
  603. }
  604. /**
  605. * 设定原生banner配置
  606. * @param location 位置
  607. * @param bannerInfo 配置
  608. */
  609. public setNativeBannerInfo(location, bannerInfo: any) {
  610. let nativeBannerInfo: NativeBannerInfo = new NativeBannerInfo();
  611. nativeBannerInfo.init(location, bannerInfo);
  612. this.nativeBannerInfos.push(nativeBannerInfo);
  613. }
  614. }
  615. @ccclass("NativeAndroidConfig")
  616. export class NativeAndroidConfig {
  617. appID: string = "";
  618. channel: string = "";
  619. version: string = "";
  620. }
  621. @ccclass("BaiduConfig")
  622. export class BaiduConfig {
  623. appID: string = "";
  624. appSID: string = "";
  625. bannerId: string = "";
  626. videoId: string = "";
  627. version: string = "";
  628. }
  629. @ccclass("WiFiConfig")
  630. export class WiFiConfig {
  631. appID: string = "";
  632. bannerId: string = "";
  633. videoId: string = "";
  634. version: string = "";
  635. }
  636. @ccclass("KwaiConfig")
  637. export class KwaiConfig {
  638. appID: string = "";
  639. videoId: string = "";
  640. insertId: string = "";
  641. version: string = "";
  642. }
  643. @ccclass("HagoConfig")
  644. export class HagoConfig {
  645. appID: string = "";
  646. videoId: string = "";
  647. version: string = "";
  648. }
  649. @ccclass("NativeIosConfig")
  650. export class NativeIosConfig {
  651. appID: string = "";
  652. bannerId: string = "";
  653. insertId: string = "";
  654. videoId: string = "";
  655. version: string = "";
  656. }
  657. @ccclass("DouyinConfig")
  658. export class DouyinConfig {
  659. Douyin: boolean = true;
  660. appID: string = "";
  661. bannerId: string = "";
  662. insertId: string = "";
  663. videoId: string = "";
  664. version: string = "";
  665. }
  666. @ccclass("QuTouTiaoConfig")
  667. export class QTTConfig {
  668. QuTouTiao: boolean = true;
  669. showAd: boolean = true;
  670. gamename: string = "";
  671. appID: string = "";
  672. appKey: string = "";
  673. }
  674. @ccclass("UCConfig")
  675. export class UCConfig {
  676. appID: string = "";
  677. appKey: string = "";
  678. version: string = "";
  679. }
  680. @ccclass("CocosConfig")
  681. export class CocosConfig {
  682. appID: string = "";
  683. appKey: string = "";
  684. appSecret: string = "";
  685. bannerId: string = "";
  686. videoId: string = "";
  687. insertId: string = "";
  688. }
  689. @ccclass("XiaoMiConfig")
  690. export class XiaoMiConfig {
  691. appID: string = "";
  692. bannerId: string = "";
  693. videoId: string = "";
  694. insertId: string = "";
  695. nativeSplashId: string = "";
  696. nativeTryGameIds: string[] = [];
  697. nativeBannerIds: string[] = [];
  698. nativeInsertIds: string[] = [];
  699. nativeBannerInfos: NativeBannerInfo[] = [];
  700. version: string = "";
  701. /**
  702. * 根据位置获取原生banner配置
  703. * @param location BannerLocation
  704. */
  705. public getNativeBannerInfo(location: BannerLocation) {
  706. utils.showLog("根据位置获取原生banner配置>>location=", location);
  707. for (let i = 0; i < this.nativeBannerInfos.length; i++) {
  708. if (this.nativeBannerInfos[i].location == location) {
  709. utils.showLog("根据位置获取原生banner配置>>info=", this.nativeBannerInfos[i].toStrong());
  710. return this.nativeBannerInfos[i];
  711. }
  712. }
  713. return new NativeBannerInfo();
  714. }
  715. /**
  716. * 设定原生banner配置
  717. * @param location 位置
  718. * @param bannerInfo 配置
  719. */
  720. public setNativeBannerInfo(location, bannerInfo: any) {
  721. let nativeBannerInfo: NativeBannerInfo = new NativeBannerInfo();
  722. nativeBannerInfo.init(location, bannerInfo);
  723. this.nativeBannerInfos.push(nativeBannerInfo);
  724. }
  725. }
  726. @ccclass("BiliConfig")
  727. export class BiliConfig {
  728. appID: string = "";
  729. bannerId: string = "";
  730. videoId: string = "";
  731. }
  732. @ccclass("FaceBookConfig")
  733. export class FaceBookConfig {
  734. appID: string = "";
  735. bannerId: string = "";
  736. insertId: string = "";
  737. videoId: string = "";
  738. version: string = "";
  739. }
  740. @ccclass("OtherConfig")
  741. export class OtherConfig {
  742. shareTitle: string = "";
  743. shareImgUrl: string = "";
  744. shareIcon: string = "";
  745. shareDesc: string = "";
  746. @property({ type: cc.JsonAsset, displayName: "本地配置文件", tooltip: "将Common/Config/下面的配置文件拖放到此处" })
  747. localConfig: cc.JsonAsset = null;
  748. @property({ type: cc.Prefab, displayName: "日志输出组件", tooltip: "将Common/Prefabs/LogoutView拖放到此处" })
  749. logoutView: cc.Prefab = null;
  750. @property({ type: cc.Prefab, tooltip: "原生广告条组件,将Common/Prefabs/NativeBanner拖到此处", displayName: "原生广告条组件" })
  751. nativeBanner: cc.Prefab = null;
  752. @property({ type: cc.Prefab, tooltip: "原生插屏组件,将Common/Prefabs/NativeInsert拖到此处", displayName: "原生插屏组件" })
  753. nativeInsert: cc.Prefab = null;
  754. @property({ type: cc.Prefab, tooltip: "原生插屏组件,将Common/Prefabs/nativeSplashView拖到此处", displayName: "原生开屏组件" })
  755. nativeSplashView: cc.Prefab = null;
  756. @property({ type: cc.Prefab, tooltip: "底部推荐游戏广告Banner, 将Common/Prefabs/RecommendGamesBanner拖到此处" })
  757. recommendGamesBanner: cc.Prefab = null;
  758. @property({ type: cc.Prefab, tooltip: "推荐游戏横条,将Common/Prefabs/RecommendGamesBar拖到此处" })
  759. recommendGamesBar: cc.Prefab = null;
  760. @property({ type: cc.Prefab, tooltip: "推荐游戏圆形挂件,将Common/Prefabs/TryGamesWidget拖到此处" })
  761. tryGamesWidget: cc.Prefab = null;
  762. @property({ type: cc.Prefab, tooltip: "侧边更多游戏面板挂件,将Common/Prefabs/MoreGamesWidget拖到此处" })
  763. moreGamesWidget: cc.Prefab = null;
  764. @property({ type: cc.Prefab, tooltip: "录屏按钮组件,将Common/Prefabs/RecordWidget拖到此处" })
  765. recordWidget: cc.Prefab = null;
  766. @property({ type: cc.Prefab, tooltip: "快捷方式按钮,将Common/Prefabs/ShortcutWidget拖到此处 " })
  767. shortcutWidget: cc.Prefab = null;
  768. // @property({ type: cc.Prefab, tooltip: "游戏盒子,将Common/Prefabs/GameBox拖到此处 " })
  769. gameBox: cc.Prefab = null;
  770. @property({ type: cc.Prefab, tooltip: "6元素交叉推广组件,将Common/Prefabs/CrossWidget6拖到此处" })
  771. crossWidget6: cc.Prefab = null;
  772. // @property({ type: cc.Prefab, tooltip: "激励插屏推广组件,将Common/Prefabs/RewardInsert拖到此处" })
  773. rewardInsert: cc.Prefab = null;
  774. @property({ type: cc.Prefab, tooltip: "结算页面推广组件,将Common/Prefabs/StatementRecomment拖到此处" })
  775. statementRecomment: cc.Prefab = null;
  776. @property({ type: cc.Prefab, tooltip: "单个原生广告,将Common/Prefabs/SingleNativeAd拖到此处" })
  777. singleNativeAd: cc.Prefab = null;
  778. @property({ type: cc.Prefab, tooltip: "分享录屏弹窗,将Common/Prefabs/ShareRecordPanel拖到此处" })
  779. shareRecordPanel: cc.Prefab = null;
  780. // @property({ type: cc.Prefab, tooltip: "原生退出游戏弹窗,将Common/Prefabs/GameExitDialog拖到此处" })
  781. gameExitDialog: cc.Prefab = null;
  782. @property({ type: cc.Prefab, tooltip: "五倍奖励宝箱弹窗,将Common/Prefabs/RewardBoxPanel拖到此处" })
  783. rewardBoxPanel: cc.Prefab = null;
  784. @property({ type: cc.Prefab, tooltip: "奖励转盘抽奖弹窗,将Common/Prefabs/RewardTurntablePanel拖到此处" })
  785. rewardTurnTablePanel: cc.Prefab = null;
  786. @property({ type: cc.Prefab, tooltip: "添加桌面激励弹窗,将Common/Prefabs/RewardShortCutPanel拖到此处" })
  787. rewardShortCutPanel: cc.Prefab = null;
  788. @property({ type: cc.Prefab, tooltip: "原生抖动试玩,将Common/Prefabs/NativeTryGameWidget拖到此处", displayName: "原生抖动组件" })
  789. nativeTryGameWidget: cc.Prefab = null;
  790. @property({ type: cc.Prefab, tooltip: "结算前互推面板,将Common/Prefabs/BeforGameOverRecGamesPanel拖到此处", displayName: "结算前互推面板" })
  791. beforGameOverRecGamesPanel: cc.Prefab = null;
  792. // @property({ type: cc.Prefab, tooltip: "红包提现框,将Common/Prefabs/WithdrawalWidget拖到此处", displayName: "红包提现框挂件" })
  793. withdrawalWidget: cc.Prefab = null;
  794. // @property({ type: cc.Prefab, tooltip: "红包提现弹窗,将Common/Prefabs/WithdrawalPanel拖到此处", displayName: "红包提现弹窗" })
  795. withdrawalPanel: cc.Prefab = null;
  796. // @property({ type: cc.Prefab, tooltip: "红包进度挂件,将Common/Prefabs/RedBagProgressWidget拖到此处", displayName: "红包进度挂件" })
  797. redBagProgressWidget: cc.Prefab = null;
  798. // @property({ type: cc.Prefab, tooltip: "拆红包弹窗,将Common/Prefabs/OpenRedBagPanel拖到此处", displayName: "拆红包弹窗" })
  799. openRedBagPanel: cc.Prefab = null;
  800. // @property({ type: cc.Prefab, tooltip: "恭喜获得红包弹窗,将Common/Prefabs/RewardRedBagPanel拖到此处", displayName: "恭喜获得红包弹窗" })
  801. rewardRedBagPanel: cc.Prefab = null;
  802. @property({ type: cc.Prefab, tooltip: "幸运宝箱弹窗,将Common/Prefabs/RewardLuckBoxPanel拖到此处", displayName: "幸运宝箱弹窗" })
  803. rewardLuckBoxPanel: cc.Prefab = null;
  804. @property({ type: cc.Prefab, tooltip: "竖状互推窗口,将Common/Prefabs/VerticalRecommentPanel拖到此处", displayName: "竖状互推窗口" })
  805. verticalRecommentPanel: cc.Prefab = null;
  806. @property({ type: cc.Prefab, tooltip: "隐私协议挂件,将Common/Prefabs/PrivacyWidget拖到此处", displayName: "隐私协议挂件" })
  807. privacyWidget: cc.Prefab = null;
  808. @property({ type: cc.Prefab, tooltip: "隐私协议弹窗,将Common/Prefabs/PrivacyPanel拖到此处", displayName: "隐私协议弹窗" })
  809. privacyPanel: cc.Prefab = null;
  810. @property({ type: cc.Prefab, tooltip: "指引的手势,将Common/Prefabs/HandPrefab拖到此处", displayName: "指引的手势" })
  811. handPrefab: cc.Prefab = null;
  812. @property({ type: cc.Prefab, tooltip: "实名制认证弹窗,将Common/Prefabs/YzRealNameAuthPanel拖到此处", displayName: "实名制认证弹窗" })
  813. yzRealNameAuthPanel: cc.Prefab = null;
  814. @property({ type: cc.Prefab, tooltip: "模版广告推荐弹窗,将Common/Prefabs/YzCustomAdPanel拖到此处", displayName: "模版广告推荐弹窗" })
  815. yzCustomAdPanel: cc.Prefab = null;
  816. @property({ type: cc.Prefab, tooltip: "登录弹窗,将Common/Prefabs/YzLoginPanel拖到此处", displayName: "登录弹窗" })
  817. yzLoginPanel: cc.Prefab = null;
  818. //游玩统计SDK:ID
  819. yw_app_id: string = "";
  820. }
  821. @ccclass("CommonConfig")
  822. export default class CommonConfig {
  823. wechatconfig: WechatConfig = new WechatConfig();
  824. oppoconfig: OppoConfig = new OppoConfig();
  825. vivoconfig: VivoConfig = new VivoConfig();
  826. nativeAndroidConfig: NativeAndroidConfig = new NativeAndroidConfig();
  827. baiduconfig: BaiduConfig = new BaiduConfig();
  828. douyinconfig: DouyinConfig = new DouyinConfig();
  829. wifiConfig: WiFiConfig = new WiFiConfig();
  830. qqconfig: QQConfig = new QQConfig();
  831. qttconfig: QTTConfig = new QTTConfig();
  832. xiaomiConfig: XiaoMiConfig = new XiaoMiConfig();
  833. ucConfig: UCConfig = new UCConfig();
  834. cocosConfig: CocosConfig = new CocosConfig();
  835. biliConfig: BiliConfig = new BiliConfig();
  836. kwaiConfig: KwaiConfig = new KwaiConfig();
  837. nativeIoSConfig: NativeIosConfig = new NativeIosConfig();
  838. hagoConfig: HagoConfig = new HagoConfig();
  839. huaweiConfig: HuaWeiConfig = new HuaWeiConfig();
  840. faceBookConfig: FaceBookConfig = new FaceBookConfig();
  841. @property({ type: OtherConfig, tooltip: "其他配置", displayName: "其他配置" })
  842. otherconfig: OtherConfig = new OtherConfig();
  843. public init(data: string) {
  844. this._init_other(data);
  845. if (PlatUtils.IsWechat) {
  846. return this._init_wechat(data);
  847. } else if (PlatUtils.IsOPPO) {
  848. return this._init_oppo(data);
  849. } else if (PlatUtils.IsVIVO) {
  850. return this._init_vivo(data);
  851. } else if (PlatUtils.IsDouyin) {
  852. return this._init_douyin(data);
  853. } else if (PlatUtils.IsQQ) {
  854. return this._init_qq(data);
  855. } else if (PlatUtils.IsBaidu) {
  856. return this._init_baidu(data);
  857. } else if (PlatUtils.IsQTT) {
  858. return this._init_qtt(data);
  859. } else if (PlatUtils.IsXiaoMi) {
  860. return this._init_xiaomi(data);
  861. } else if (PlatUtils.ISUC) {
  862. return this._init_uc(data);
  863. } else if (PlatUtils.ISCocos) {
  864. return this._init_cocos(data);
  865. } else if (PlatUtils.IsNativeAndroid) {
  866. return this._init_native_android();;
  867. } else if (PlatUtils.IsNativeIOS) {
  868. return this._init_native_ios(data);;
  869. } else if (PlatUtils.IsBili) {
  870. return this._init_bili(data);;
  871. } else if (PlatUtils.IsKwai) {
  872. return this._init_kwai(data);;
  873. } else if (PlatUtils.IsWiFi) {
  874. return this._init_wifi(data);;
  875. } else if (PlatUtils.IsHago) {
  876. return this._init_hago(data);;
  877. } else if (PlatUtils.IsHuaWei) {
  878. return this._init_huawei(data);;
  879. } else if (PlatUtils.IsFaceBook) {
  880. return this._init_facebook(data);;
  881. } else {
  882. return true;
  883. }
  884. }
  885. private _init_other(data: string) {
  886. if (!data) return false;
  887. let configObj: any = JSON.parse(data);
  888. if (configObj) {
  889. if (configObj.other) {
  890. if (configObj.other.yw_app_id) {
  891. this.otherconfig.yw_app_id = configObj.other.yw_app_id;
  892. } else {
  893. utils.showLog("warn:" + "本地配置数据不包含‘yw_app_id’字段!");
  894. }
  895. }
  896. }
  897. }
  898. private _init_wechat(data: string) {
  899. if (!data) return false;
  900. utils.showLog("本地配置数据:", data);
  901. let configObj: any = JSON.parse(data);
  902. if (configObj) {
  903. if (configObj.wechat) {
  904. if (configObj.wechat.app_id) {
  905. this.wechatconfig.appID = configObj.wechat.app_id;
  906. } else {
  907. utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
  908. return false;
  909. }
  910. if (configObj.wechat.intersititia_pos_id) {
  911. this.wechatconfig.insertId = configObj.wechat.intersititia_pos_id;
  912. } else {
  913. utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
  914. return false;
  915. }
  916. if (configObj.wechat.video_pos_id) {
  917. this.wechatconfig.videoId = configObj.wechat.video_pos_id;
  918. } else {
  919. utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
  920. return false;
  921. }
  922. if (configObj.wechat.app_box_pos_id) {
  923. this.wechatconfig.appBoxId = configObj.wechat.app_box_pos_id;
  924. } else {
  925. utils.showLog("本地配置数据不包含‘app_box_pos_id’字段!");
  926. // return false;
  927. }
  928. if (configObj.wechat.version) {
  929. this.wechatconfig.version = configObj.wechat.version;
  930. } else {
  931. utils.showLog("本地配置数据不包含‘version’字段!");
  932. }
  933. if (configObj.wechat.is_attributed) {
  934. this.wechatconfig.isAttributed = configObj.wechat.is_attributed;
  935. }
  936. if (configObj.wechat.banner_pos_id) {
  937. for (let key in configObj.wechat.banner_pos_id) {
  938. let bannerInfo: BannerIdInfo = new BannerIdInfo();
  939. bannerInfo.location = this._bannerLocationStringToEnum(key);
  940. bannerInfo.bannerId = configObj.wechat.banner_pos_id[key];
  941. this.wechatconfig.bannerIds.push(bannerInfo);
  942. }
  943. } else {
  944. utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
  945. return false;
  946. }
  947. if (configObj.wechat.shares) {
  948. if (configObj.wechat.shares.sy_title) {
  949. this.otherconfig.shareTitle = configObj.wechat.shares.sy_title;
  950. } else {
  951. utils.showLog("error" + "本地配置数据不包含‘shares.shareTitle’字段!");
  952. return false;
  953. }
  954. if (configObj.wechat.shares.sy_img) {
  955. this.otherconfig.shareImgUrl = configObj.wechat.shares.sy_img;
  956. } else {
  957. utils.showLog("error" + "本地配置数据不包含‘shares.shareImgUrl’字段!");
  958. return false;
  959. }
  960. } else {
  961. utils.showLog("error" + "本地配置数据不包含‘shares’字段!");
  962. return false;
  963. }
  964. if (configObj.wechat.banner_box_pos_id) {
  965. this.wechatconfig.bannerBoxId = configObj.wechat.banner_box_pos_id;
  966. } else {
  967. utils.showLog("error" + "本地配置中不包含 ‘banner_box_pos_id’ 字段");
  968. }
  969. if (configObj.wechat.native_banner_pos_id) {
  970. this.wechatconfig.nativeBannerId = configObj.wechat.native_banner_pos_id;
  971. } else {
  972. utils.showLog("error" + "本地配置中不包含 native_banner_pos_id 字段");
  973. }
  974. if (configObj.wechat.native_intersititial_pos_id) {
  975. this.wechatconfig.nativeInsertIds = configObj.wechat.native_intersititial_pos_id;
  976. } else {
  977. utils.showLog("error" + "本地配置中不包含 native_intersititial_pos_id 字段");
  978. }
  979. } else {
  980. utils.showLog("error" + "本地配置数据不包含‘wechat’字段!");
  981. return false;
  982. }
  983. } else {
  984. utils.showLog("error" + "本地配置数据不是合法的json数据!");
  985. return false;
  986. }
  987. return true;
  988. }
  989. private _init_oppo(data: string) {
  990. if (!data) return false;
  991. utils.showLog("本地配置数据:", data);
  992. let configObj: any = JSON.parse(data);
  993. if (configObj) {
  994. if (configObj.oppo) {
  995. if (configObj.oppo.app_id) {
  996. this.oppoconfig.appID = configObj.oppo.app_id;
  997. } else {
  998. utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
  999. return false;
  1000. }
  1001. if (configObj.oppo.package_name) {
  1002. this.oppoconfig.packageName = configObj.oppo.package_name;
  1003. } else {
  1004. utils.showLog("error" + "本地配置数据不包含‘package_name’字段!");
  1005. return false;
  1006. }
  1007. if (configObj.oppo.banner_pos_id) {
  1008. this.oppoconfig.bannerId = configObj.oppo.banner_pos_id;
  1009. }
  1010. // else {
  1011. // utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
  1012. // return false;
  1013. // }
  1014. if (configObj.oppo.rec_game_drawer_id) {
  1015. this.oppoconfig.recGameDrawerId = configObj.oppo.rec_game_drawer_id;
  1016. } else {
  1017. utils.showLog("error" + "rec_game_drawer_id");
  1018. }
  1019. // if (configObj.oppo.intersititia_pos_id) {
  1020. // this.oppoconfig.insertId = configObj.oppo.intersititia_pos_id;
  1021. // } else {
  1022. // utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
  1023. // // return false;
  1024. // }
  1025. if (configObj.oppo.video_pos_id) {
  1026. this.oppoconfig.videoId = configObj.oppo.video_pos_id;
  1027. } else {
  1028. utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
  1029. return false;
  1030. }
  1031. if (configObj.oppo.native_banner_pos_id) {
  1032. this.oppoconfig.nativeBannerIds = configObj.oppo.native_banner_pos_id;
  1033. }
  1034. // else {
  1035. // utils.showLog("error" + "本地配置数据不包含‘native_banner_pos_id’字段!");
  1036. // return false;
  1037. // }
  1038. if (configObj.oppo.native_trygame_pos_id) {
  1039. this.oppoconfig.nativeTryGameIds = configObj.oppo.native_trygame_pos_id;
  1040. } else {
  1041. utils.showLog("error" + "本地配置数据不包含‘native_trygame_pos_id’字段!");
  1042. // return false;
  1043. }
  1044. if (configObj.oppo.intersitial_configs) {
  1045. this.oppoconfig.intersitialAdConfigs = configObj.oppo.intersitial_configs;
  1046. } else {
  1047. utils.showLog("error" + "本地配置数据不包含‘intersitial_configs’字段!");
  1048. return false;
  1049. }
  1050. if (configObj.oppo.banner_configs) {
  1051. this.oppoconfig.bannerAdConfigs = configObj.oppo.banner_configs;
  1052. } else {
  1053. utils.showLog("error" + "本地配置数据不包含‘banner_configs’字段!");
  1054. return false;
  1055. }
  1056. // if (configObj.oppo.native_intersititial_pos_id) {
  1057. // this.oppoconfig.nativeInsertIds = configObj.oppo.native_intersititial_pos_id;
  1058. // } else {
  1059. // utils.showLog("error" + "本地配置数据不包含‘native_intersititial_pos_id’字段!");
  1060. // return false;
  1061. // }
  1062. if (configObj.oppo.native_single_pos_id) {
  1063. this.oppoconfig.nativeSingleAdIds = configObj.oppo.native_single_pos_id;
  1064. } else {
  1065. utils.showLog("error" + "本地配置数据不包含‘native_single_pos_id’字段!");
  1066. return false;
  1067. }
  1068. if (configObj.oppo.rec_portal_id) {
  1069. this.oppoconfig.recPortalId = configObj.oppo.rec_portal_id;
  1070. } else {
  1071. utils.showLog("error" + "本地配置数据不包含‘rec_portal_id’字段!");
  1072. }
  1073. if (configObj.oppo.rec_game_banner_id) {
  1074. this.oppoconfig.recGameBannerId = configObj.oppo.rec_game_banner_id;
  1075. } else {
  1076. utils.showLog("error" + "本地配置数据不包含‘rec_game_banner_id’字段!");
  1077. }
  1078. if (configObj.oppo.version) {
  1079. //@ts-ignore
  1080. if (window.new_version) {
  1081. //@ts-ignore
  1082. this.oppoconfig.version = window.new_version;
  1083. utils.showLog("获取到注入的版本号:" + this.oppoconfig.version);
  1084. } else {
  1085. this.oppoconfig.version = configObj.oppo.version;
  1086. }
  1087. } else {
  1088. utils.showLog("error" + "本地配置数据不包含‘version’字段!");
  1089. return false;
  1090. }
  1091. if (configObj.oppo.umeng_id) {
  1092. this.oppoconfig.umengId = configObj.oppo.umeng_id;
  1093. } else {
  1094. utils.showLog("error" + "本地配置数据不包含‘umeng_id’字段!");
  1095. }
  1096. } else {
  1097. utils.showLog("error" + "本地配置数据不包含‘oppo’字段!");
  1098. return false;
  1099. }
  1100. } else {
  1101. utils.showLog("error" + "本地配置数据不是合法的json数据!");
  1102. return false;
  1103. }
  1104. return true;
  1105. }
  1106. private _init_vivo(data: string) {
  1107. if (!data) return false;
  1108. utils.showLog("本地配置数据:", data);
  1109. let configObj: any = JSON.parse(data);
  1110. if (configObj) {
  1111. if (configObj.vivo) {
  1112. if (configObj.vivo.app_id) {
  1113. this.vivoconfig.appID = configObj.vivo.app_id;
  1114. } else {
  1115. utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
  1116. return false;
  1117. }
  1118. if (configObj.vivo.intersititia_pos_id) {
  1119. this.vivoconfig.insertId = configObj.vivo.intersititia_pos_id;
  1120. } else {
  1121. utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
  1122. return false;
  1123. }
  1124. if (configObj.vivo.video_pos_id) {
  1125. this.vivoconfig.videoId = configObj.vivo.video_pos_id;
  1126. } else {
  1127. utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
  1128. return false;
  1129. }
  1130. if (configObj.vivo.banner_pos_id) {
  1131. this.vivoconfig.bannerId = configObj.vivo.banner_pos_id;
  1132. } else {
  1133. utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
  1134. return false;
  1135. }
  1136. if (configObj.vivo.native_banner_pos_id) {
  1137. this.vivoconfig.nativeBannerIds = configObj.vivo.native_banner_pos_id;
  1138. } else {
  1139. utils.showLog("error" + "本地配置数据不包含‘native_banner_pos_id’字段!");
  1140. return false;
  1141. }
  1142. if (configObj.vivo.native_trygame_pos_id) {
  1143. this.vivoconfig.nativeTryGameIds = configObj.vivo.native_trygame_pos_id;
  1144. } else {
  1145. utils.showLog("error" + "本地配置数据不包含‘native_trygame_pos_id’字段!");
  1146. // return false;
  1147. }
  1148. if (configObj.vivo.native_intersititial_pos_id) {
  1149. this.vivoconfig.nativeInsertIds = configObj.vivo.native_intersititial_pos_id;
  1150. } else {
  1151. utils.showLog("error" + "本地配置数据不包含‘native_intersititial_pos_id’字段!");
  1152. return false;
  1153. }
  1154. if (configObj.vivo.rec_portal_id) {
  1155. this.vivoconfig.recPortalId = configObj.vivo.rec_portal_id;
  1156. } else {
  1157. utils.showLog("warn" + "本地配置数据不包含‘rec_portal_id’字段!");
  1158. }
  1159. if (configObj.vivo.rec_game_banner_id) {
  1160. this.vivoconfig.recGameBannerId = configObj.vivo.rec_game_banner_id;
  1161. } else {
  1162. utils.showLog("warn" + "本地配置数据不包含‘rec_game_banner_id’字段!");
  1163. }
  1164. if (configObj.vivo.native_single_pos_id) {
  1165. this.vivoconfig.nativeSingleAdIds = configObj.vivo.native_single_pos_id;
  1166. } else {
  1167. utils.showLog("warn" + "本地配置数据不包含‘native_single_pos_id’字段!");
  1168. }
  1169. if (configObj.vivo.umeng_id) {
  1170. this.vivoconfig.umengId = configObj.vivo.umeng_id;
  1171. } else {
  1172. utils.showLog("error" + "本地配置数据不包含‘umeng_id’字段,不启用友盟统计!");
  1173. }
  1174. if (configObj.vivo.version) {
  1175. this.vivoconfig.version = configObj.vivo.version;
  1176. } else {
  1177. utils.showLog("warn:" + "本地配置数据不包含‘version’字段!");
  1178. }
  1179. } else {
  1180. utils.showLog("error" + "本地配置数据不包含‘vivo’字段!");
  1181. return false;
  1182. }
  1183. } else {
  1184. utils.showLog("error" + "本地配置数据不是合法的json数据!");
  1185. return false;
  1186. }
  1187. return true;
  1188. }
  1189. private _init_baidu(data: string) {
  1190. if (!data) return false;
  1191. utils.showLog("本地配置数据:", data);
  1192. let configObj: any = JSON.parse(data);
  1193. if (configObj) {
  1194. if (configObj.baidu) {
  1195. if (configObj.baidu.app_id) {
  1196. this.baiduconfig.appID = configObj.baidu.app_id;
  1197. } else {
  1198. utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
  1199. return false;
  1200. }
  1201. if (configObj.baidu.app_sid) {
  1202. this.baiduconfig.appSID = configObj.baidu.app_sid;
  1203. } else {
  1204. utils.showLog("error" + "本地配置数据不包含‘app_sid’字段!")
  1205. }
  1206. if (configObj.baidu.video_pos_id) {
  1207. this.baiduconfig.videoId = configObj.baidu.video_pos_id;
  1208. } else {
  1209. utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
  1210. return false;
  1211. }
  1212. if (configObj.baidu.banner_pos_id) {
  1213. this.baiduconfig.bannerId = configObj.baidu.banner_pos_id;
  1214. } else {
  1215. utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
  1216. return false;
  1217. }
  1218. if (configObj.baidu.version) {
  1219. this.baiduconfig.version = configObj.baidu.version;
  1220. } else {
  1221. utils.showLog("error" + "本地配置数据不包含‘version’字段!");
  1222. return false;
  1223. }
  1224. if (configObj.baidu.shares) {
  1225. if (configObj.baidu.shares.sy_title) {
  1226. this.otherconfig.shareTitle = configObj.baidu.shares.sy_title;
  1227. } else {
  1228. utils.showLog("error" + "本地配置数据不包含‘shares.sy_title’字段!");
  1229. return false;
  1230. }
  1231. if (configObj.baidu.shares.sy_img) {
  1232. this.otherconfig.shareImgUrl = configObj.baidu.shares.sy_img;
  1233. } else {
  1234. utils.showLog("error" + "本地配置数据不包含‘shares.sy_img’字段!");
  1235. return false;
  1236. }
  1237. } else {
  1238. utils.showLog("error" + "本地配置数据不包含‘shares’字段!");
  1239. return false;
  1240. }
  1241. } else {
  1242. utils.showLog("error" + "本地配置数据不包含‘baidu’字段!");
  1243. return false;
  1244. }
  1245. } else {
  1246. utils.showLog("error" + "本地配置数据不是合法的json数据!");
  1247. return false;
  1248. }
  1249. return true;
  1250. }
  1251. private _init_wifi(data: string) {
  1252. if (!data) return false;
  1253. utils.showLog("本地配置数据:", data);
  1254. let configObj: any = JSON.parse(data);
  1255. if (configObj) {
  1256. if (configObj.wifi) {
  1257. if (configObj.wifi.app_id) {
  1258. this.wifiConfig.appID = configObj.wifi.app_id;
  1259. } else {
  1260. utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
  1261. return false;
  1262. }
  1263. if (configObj.wifi.version) {
  1264. this.wifiConfig.version = configObj.wifi.version;
  1265. } else {
  1266. utils.showLog("error" + "本地配置数据不包含‘version’字段!");
  1267. return false;
  1268. }
  1269. } else {
  1270. utils.showLog("error" + "本地配置数据不包含‘baidu’字段!");
  1271. return false;
  1272. }
  1273. } else {
  1274. utils.showLog("error" + "本地配置数据不是合法的json数据!");
  1275. return false;
  1276. }
  1277. return true;
  1278. }
  1279. private _init_douyin(data: string) {
  1280. if (!data) return false;
  1281. let configObj: any = JSON.parse(data);
  1282. if (configObj) {
  1283. if (configObj.toutiao) {
  1284. if (configObj.toutiao.app_id) {
  1285. this.douyinconfig.appID = configObj.toutiao.app_id;
  1286. } else {
  1287. utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
  1288. return false;
  1289. }
  1290. if (configObj.toutiao.banner_pos_id) {
  1291. this.douyinconfig.bannerId = configObj.toutiao.banner_pos_id;
  1292. } else {
  1293. utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
  1294. return false;
  1295. }
  1296. if (configObj.toutiao.video_pos_id) {
  1297. this.douyinconfig.videoId = configObj.toutiao.video_pos_id;
  1298. } else {
  1299. utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
  1300. return false;
  1301. }
  1302. if (configObj.toutiao.intersititia_pos_id) {
  1303. this.douyinconfig.insertId = configObj.toutiao.intersititia_pos_id;
  1304. } else {
  1305. utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
  1306. return false;
  1307. }
  1308. if (configObj.toutiao.version) {
  1309. this.douyinconfig.version = configObj.toutiao.version;
  1310. } else {
  1311. utils.showLog("error" + "本地配置数据不包含‘version’字段!");
  1312. return false;
  1313. }
  1314. if (configObj.toutiao.shares) {
  1315. if (configObj.toutiao.shares.sy_title) {
  1316. this.otherconfig.shareTitle = configObj.toutiao.shares.sy_title;
  1317. } else {
  1318. utils.showLog("error" + "本地配置数据不包含‘shares.sy_title’字段!");
  1319. return false;
  1320. }
  1321. if (configObj.toutiao.shares.sy_img) {
  1322. this.otherconfig.shareImgUrl = configObj.toutiao.shares.sy_img;
  1323. } else {
  1324. utils.showLog("error" + "本地配置数据不包含‘shares.sy_img’字段!");
  1325. return false;
  1326. }
  1327. } else {
  1328. utils.showLog("error" + "本地配置数据不包含‘shares’字段!");
  1329. return false;
  1330. }
  1331. }
  1332. } else {
  1333. utils.showLog("warn:" + "本地配置数据不是合法的json数据!");
  1334. return false;
  1335. }
  1336. return true;
  1337. }
  1338. private _init_qq(data: string) {
  1339. if (!data) return false;
  1340. utils.showLog("本地配置数据:", data);
  1341. let configObj: any = JSON.parse(data);
  1342. if (configObj) {
  1343. if (configObj.qq) {
  1344. if (configObj.qq.app_id) {
  1345. this.qqconfig.appID = configObj.qq.app_id;
  1346. } else {
  1347. utils.showMsg("error" + "本地配置数据不包含‘app_id’字段!");
  1348. return false;
  1349. }
  1350. if (configObj.qq.video_pos_id) {
  1351. this.qqconfig.videoId = configObj.qq.video_pos_id;
  1352. } else {
  1353. utils.showMsg("error" + "本地配置数据不包含‘video_pos_id’字段!");
  1354. return false;
  1355. }
  1356. if (configObj.qq.banner_pos_id) {
  1357. this.qqconfig.bannerId = configObj.qq.banner_pos_id;
  1358. } else {
  1359. utils.showMsg("error" + "本地配置数据不包含‘banner_pos_id’字段!");
  1360. return false;
  1361. }
  1362. if (configObj.qq.intersititia_pos_id) {
  1363. this.qqconfig.insertId = configObj.qq.intersititia_pos_id;
  1364. } else {
  1365. utils.showMsg("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
  1366. return false;
  1367. }
  1368. if (configObj.qq.box_pos_id) {
  1369. this.qqconfig.boxId = configObj.qq.box_pos_id;
  1370. } else {
  1371. utils.showMsg("error" + "本地配置数据不包含‘box_pos_id’字段!");
  1372. return false;
  1373. }
  1374. if (configObj.qq.banner_box_pos_id) {
  1375. this.qqconfig.bannerBoxId = configObj.qq.banner_box_pos_id;
  1376. } else {
  1377. utils.showMsg("error" + "本地配置数据不包含‘banner_box_pos_id’字段!");
  1378. return false;
  1379. }
  1380. if (configObj.qq.shares) {
  1381. if (configObj.qq.shares.sy_title) {
  1382. this.otherconfig.shareTitle = configObj.qq.shares.sy_title;
  1383. } else {
  1384. utils.showMsg("error" + "本地配置数据不包含‘shares.shareTitle’字段!");
  1385. return false;
  1386. }
  1387. if (configObj.qq.shares.sy_img) {
  1388. this.otherconfig.shareImgUrl = configObj.qq.shares.sy_img;
  1389. } else {
  1390. utils.showMsg("error" + "本地配置数据不包含‘shares.shareImgUrl’字段!");
  1391. return false;
  1392. }
  1393. } else {
  1394. utils.showMsg("error" + "本地配置数据不包含‘shares’字段!");
  1395. return false;
  1396. }
  1397. if (configObj.qq.version) {
  1398. this.qqconfig.version = configObj.qq.version;
  1399. } else {
  1400. utils.showMsg("error" + "本地配置数据不包含‘version’字段!");
  1401. return false;
  1402. }
  1403. } else {
  1404. utils.showMsg("error" + "本地配置数据不包含‘qq’字段!");
  1405. return false;
  1406. }
  1407. } else {
  1408. utils.showMsg("error" + "本地配置数据不是合法的json数据!");
  1409. return false;
  1410. }
  1411. return true;
  1412. }
  1413. /**
  1414. * 初始化趣头条
  1415. * 这里只输出配置不做任何处理
  1416. * @param data 数据
  1417. */
  1418. private _init_qtt(data: string): boolean {
  1419. if (!data) return false;
  1420. utils.showLog("本地配置数据:", data);
  1421. let configObj: any = JSON.parse(data);
  1422. if (configObj) {
  1423. if (configObj.qutoutiao) {
  1424. if (configObj.qutoutiao.app_id) {
  1425. this.qttconfig.appID = configObj.qutoutiao.app_id;
  1426. utils.showLog("this.qttconfig.appID:", this.qttconfig.appID);
  1427. utils.showLog("configObj.qutoutiao.app_id:", configObj.qutoutiao.app_id);
  1428. } else {
  1429. utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
  1430. return false;
  1431. }
  1432. if (configObj.qutoutiao.app_key) {
  1433. this.qttconfig.appKey = configObj.qutoutiao.app_key;
  1434. } else {
  1435. utils.showLog("error" + "本地配置数据不包含‘app_key’字段!");
  1436. return false;
  1437. }
  1438. if (configObj.qutoutiao.game_name) {
  1439. this.qttconfig.gamename = configObj.qutoutiao.game_name;
  1440. } else {
  1441. utils.showLog("error" + "本地配置数据不包含‘app_key’字段!");
  1442. return false;
  1443. }
  1444. }
  1445. }
  1446. return true;
  1447. }
  1448. private _bannerLocationStringToEnum(str: string) {
  1449. switch (str) {
  1450. case "home": {
  1451. return BannerLocation.Home;
  1452. }
  1453. case "game": {
  1454. return BannerLocation.Game;
  1455. }
  1456. case "level": {
  1457. return BannerLocation.Level;
  1458. }
  1459. case "skin": {
  1460. return BannerLocation.Skin;
  1461. }
  1462. case "pause": {
  1463. return BannerLocation.Pause;
  1464. }
  1465. case "over": {
  1466. return BannerLocation.Over;
  1467. }
  1468. default:
  1469. return BannerLocation.None;
  1470. }
  1471. }
  1472. /**
  1473. * 初始化小米
  1474. * @param data 配置
  1475. */
  1476. private _init_xiaomi(data: string) {
  1477. if (!data) return false;
  1478. utils.showLog("本地配置数据:", data);
  1479. let configObj: any = JSON.parse(data);
  1480. if (configObj) {
  1481. if (configObj.xiaomi) {
  1482. if (configObj.xiaomi.app_id) {
  1483. this.xiaomiConfig.appID = configObj.xiaomi.app_id;
  1484. } else {
  1485. utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
  1486. return false;
  1487. }
  1488. if (configObj.xiaomi.intersititia_pos_id) {
  1489. this.xiaomiConfig.insertId = configObj.xiaomi.intersititia_pos_id;
  1490. } else {
  1491. utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
  1492. return false;
  1493. }
  1494. if (configObj.xiaomi.video_pos_id) {
  1495. this.xiaomiConfig.videoId = configObj.xiaomi.video_pos_id;
  1496. } else {
  1497. utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
  1498. return false;
  1499. }
  1500. if (configObj.xiaomi.banner_pos_id) {
  1501. this.xiaomiConfig.bannerId = configObj.xiaomi.banner_pos_id;
  1502. } else {
  1503. utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
  1504. return false;
  1505. }
  1506. if (configObj.xiaomi.native_banner_pos_id) {
  1507. this.xiaomiConfig.nativeBannerIds = configObj.xiaomi.native_banner_pos_id;
  1508. } else {
  1509. utils.showLog("error" + "本地配置数据不包含‘native_banner_pos_id’字段!");
  1510. return false;
  1511. }
  1512. if (configObj.xiaomi.native_trygame_pos_id) {
  1513. this.xiaomiConfig.nativeTryGameIds = configObj.xiaomi.native_trygame_pos_id;
  1514. } else {
  1515. utils.showLog("error" + "本地配置数据不包含‘native_trygame_pos_id’字段!");
  1516. // return false;
  1517. }
  1518. if (configObj.xiaomi.native_intersititial_pos_id) {
  1519. this.xiaomiConfig.nativeInsertIds = configObj.xiaomi.native_intersititial_pos_id;
  1520. } else {
  1521. utils.showLog("error" + "本地配置数据不包含‘native_intersititial_pos_id’字段!");
  1522. return false;
  1523. }
  1524. } else {
  1525. utils.showLog("error" + "本地配置数据不包含‘xiaomi’字段!");
  1526. return false;
  1527. }
  1528. } else {
  1529. utils.showLog("error" + "本地配置数据不是合法的json数据!");
  1530. return false;
  1531. }
  1532. return true;
  1533. }
  1534. /**
  1535. * 初始化uc
  1536. * @param data 配置
  1537. */
  1538. private _init_uc(data: string) {
  1539. if (!data) return false;
  1540. utils.showLog("本地配置数据:", data);
  1541. let configObj: any = JSON.parse(data);
  1542. if (configObj) {
  1543. if (configObj.uc) {
  1544. if (configObj.uc.app_id) {
  1545. this.ucConfig.appID = configObj.uc.app_id;
  1546. } else {
  1547. utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
  1548. return false;
  1549. }
  1550. if (configObj.uc.version) {
  1551. this.ucConfig.version = configObj.uc.version;
  1552. } else {
  1553. utils.showLog("error" + "本地配置数据不包含‘version’字段!");
  1554. return false;
  1555. }
  1556. if (configObj.uc.shares) {
  1557. if (configObj.uc.shares.sy_title) {
  1558. this.otherconfig.shareTitle = configObj.uc.shares.sy_title;
  1559. } else {
  1560. utils.showLog("error" + "本地配置数据不包含‘shares.shareTitle’字段!");
  1561. return false;
  1562. }
  1563. if (configObj.uc.shares.sy_img) {
  1564. this.otherconfig.shareImgUrl = configObj.uc.shares.sy_img;
  1565. } else {
  1566. utils.showLog("error" + "本地配置数据不包含‘shares.shareImgUrl’字段!");
  1567. return false;
  1568. }
  1569. } else {
  1570. utils.showLog("error" + "本地配置数据不包含‘shares’字段!");
  1571. return false;
  1572. }
  1573. } else {
  1574. utils.showLog("error" + "本地配置数据不包含‘uc’字段!");
  1575. return false;
  1576. }
  1577. } else {
  1578. utils.showLog("error" + "本地配置数据不是合法的json数据!");
  1579. return false;
  1580. }
  1581. return true;
  1582. }
  1583. /**
  1584. * 初始化uc
  1585. * @param data 配置
  1586. */
  1587. private _init_cocos(data: string) {
  1588. if (!data) return false;
  1589. utils.showLog("本地配置数据:", data);
  1590. let configObj: any = JSON.parse(data);
  1591. if (configObj) {
  1592. if (configObj.cocos) {
  1593. if (configObj.cocos.app_id) {
  1594. this.cocosConfig.appID = configObj.cocos.app_id;
  1595. } else {
  1596. utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
  1597. return false;
  1598. }
  1599. if (configObj.cocos.video_pos_id) {
  1600. this.cocosConfig.videoId = configObj.cocos.video_pos_id;
  1601. } else {
  1602. utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
  1603. return false;
  1604. }
  1605. if (configObj.cocos.banner_pos_id) {
  1606. this.cocosConfig.bannerId = configObj.cocos.banner_pos_id;
  1607. } else {
  1608. utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
  1609. return false;
  1610. }
  1611. if (configObj.cocos.intersititia_pos_id) {
  1612. this.cocosConfig.insertId = configObj.cocos.intersititia_pos_id;
  1613. } else {
  1614. utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
  1615. return false;
  1616. }
  1617. if (configObj.cocos.shares) {
  1618. if (configObj.cocos.shares.sy_title) {
  1619. this.otherconfig.shareTitle = configObj.cocos.shares.sy_title;
  1620. } else {
  1621. utils.showLog("error" + "本地配置数据不包含‘shares.shareTitle’字段!");
  1622. return false;
  1623. }
  1624. if (configObj.cocos.shares.sy_img) {
  1625. this.otherconfig.shareImgUrl = configObj.cocos.shares.sy_img;
  1626. } else {
  1627. utils.showLog("error" + "本地配置数据不包含‘shares.shareImgUrl’字段!");
  1628. return false;
  1629. }
  1630. } else {
  1631. utils.showLog("error" + "本地配置数据不包含‘shares’字段!");
  1632. return false;
  1633. }
  1634. } else {
  1635. utils.showLog("error" + "本地配置数据不包含‘cocos’字段!");
  1636. return false;
  1637. }
  1638. } else {
  1639. utils.showLog("error" + "本地配置数据不是合法的json数据!");
  1640. return false;
  1641. }
  1642. return true;
  1643. }
  1644. /**
  1645. * 初始化原生安卓平台
  1646. * @param data 配置
  1647. */
  1648. private _init_native_android() {
  1649. if (!utils.Tool_Native) {
  1650. return false;
  1651. }
  1652. let data = utils.Tool_Native.getNativeData()
  1653. utils.showLog("原生安卓平台本地配置数据:", data);
  1654. if (!data) {
  1655. utils.showLog("error : 安卓本地配置数据配置错误!")
  1656. return false;
  1657. }
  1658. let configObj: any = JSON.parse(data);
  1659. if (configObj) {
  1660. if (configObj.app_id) {
  1661. this.nativeAndroidConfig.appID = configObj.app_id;
  1662. } else {
  1663. utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
  1664. return false;
  1665. }
  1666. if (configObj.version) {
  1667. this.nativeAndroidConfig.version = configObj.version;
  1668. } else {
  1669. utils.showMsg("error" + "本地配置数据不包含‘version’字段!");
  1670. return false;
  1671. }
  1672. if (configObj.channel) {
  1673. this.nativeAndroidConfig.channel = configObj.channel;
  1674. utils.showLog("原生平台渠道号 channel=" + configObj.channel);
  1675. } else {
  1676. utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
  1677. return false;
  1678. }
  1679. } else {
  1680. utils.showLog("error" + "本地配置数据不是合法的json数据!");
  1681. return false;
  1682. }
  1683. return true;
  1684. }
  1685. /**
  1686. * 初始化原生IOS
  1687. */
  1688. private _init_native_ios(data: string) {
  1689. if (!data) return false;
  1690. utils.showLog("本地配置数据:", data);
  1691. let configObj: any = JSON.parse(data);
  1692. if (configObj) {
  1693. if (configObj.ios.app_id) {
  1694. this.nativeIoSConfig.appID = configObj.ios.app_id;
  1695. } else {
  1696. utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
  1697. return false;
  1698. }
  1699. if (configObj.ios.video_pos_id) {
  1700. this.nativeIoSConfig.videoId = configObj.ios.video_pos_id;
  1701. } else {
  1702. utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
  1703. return false;
  1704. }
  1705. if (configObj.ios.version) {
  1706. this.nativeIoSConfig.version = configObj.ios.version;
  1707. } else {
  1708. utils.showLog("error" + "本地配置数据不包含‘version’字段!");
  1709. return false;
  1710. }
  1711. if (configObj.ios.banner_pos_id) {
  1712. this.nativeIoSConfig.bannerId = configObj.ios.banner_pos_id;
  1713. } else {
  1714. utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
  1715. return false;
  1716. }
  1717. if (configObj.ios.intersititia_pos_id) {
  1718. this.nativeIoSConfig.insertId = configObj.ios.intersititia_pos_id;
  1719. } else {
  1720. utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
  1721. return false;
  1722. }
  1723. } else {
  1724. utils.showLog("error" + "本地配置数据不是合法的json数据!");
  1725. return false;
  1726. }
  1727. return true;
  1728. }
  1729. /**
  1730. * 初始化bili
  1731. * @param data 配置
  1732. */
  1733. private _init_bili(data: string) {
  1734. if (!data) return false;
  1735. utils.showLog("本地配置数据:", data);
  1736. let configObj: any = JSON.parse(data);
  1737. if (configObj) {
  1738. if (configObj.bili.shares.sy_title) {
  1739. this.otherconfig.shareTitle = configObj.bili.shares.sy_title;
  1740. } else {
  1741. utils.showLog("error" + "本地配置数据不包含‘shares.sy_title’字段!");
  1742. return false;
  1743. }
  1744. if (configObj.bili.shares.sy_img) {
  1745. this.otherconfig.shareImgUrl = configObj.bili.shares.sy_img;
  1746. } else {
  1747. utils.showLog("error" + "本地配置数据不包含‘shares.sy_img’字段!");
  1748. return false;
  1749. }
  1750. } else {
  1751. utils.showLog("error" + "本地配置数据不是合法的json数据!");
  1752. return false;
  1753. }
  1754. return true;
  1755. }
  1756. /**
  1757. * 初始化快手
  1758. * @param data 配置
  1759. */
  1760. private _init_kwai(data: string) {
  1761. if (!data) return false;
  1762. utils.showLog("本地配置数据:", data);
  1763. let configObj: any = JSON.parse(data);
  1764. if (configObj) {
  1765. if (configObj.kwai.app_id) {
  1766. this.kwaiConfig.appID = configObj.kwai.app_id;
  1767. } else {
  1768. utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
  1769. return false;
  1770. }
  1771. if (configObj.kwai.video_pos_id) {
  1772. this.kwaiConfig.videoId = configObj.kwai.video_pos_id;
  1773. } else {
  1774. utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
  1775. return false;
  1776. }
  1777. if (configObj.kwai.intersititia_pos_id) {
  1778. this.kwaiConfig.insertId = configObj.kwai.intersititia_pos_id;
  1779. } else {
  1780. utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
  1781. }
  1782. if (configObj.kwai.version) {
  1783. this.kwaiConfig.version = configObj.kwai.version;
  1784. } else {
  1785. utils.showLog("error" + "本地配置数据不包含‘version’字段!");
  1786. return false;
  1787. }
  1788. if (configObj.kwai.shares) {
  1789. if (configObj.kwai.shares.sy_title) {
  1790. this.otherconfig.shareTitle = configObj.kwai.shares.sy_title;
  1791. } else {
  1792. utils.showLog("error" + "本地配置数据不包含‘shares.sy_title’字段!");
  1793. return false;
  1794. }
  1795. if (configObj.kwai.shares.sy_img) {
  1796. this.otherconfig.shareImgUrl = configObj.kwai.shares.sy_img;
  1797. } else {
  1798. utils.showLog("error" + "本地配置数据不包含‘shares.sy_img’字段!");
  1799. return false;
  1800. }
  1801. if (configObj.kwai.shares.sy_icon) {
  1802. this.otherconfig.shareIcon = configObj.kwai.shares.sy_icon;
  1803. } else {
  1804. utils.showLog("error" + "本地配置数据不包含‘shares.sy_icon");
  1805. return false;
  1806. }
  1807. if (configObj.kwai.shares.sy_desc) {
  1808. this.otherconfig.shareDesc = configObj.kwai.shares.sy_desc;
  1809. } else {
  1810. utils.showLog("error" + "本地配置数据不包含‘shares.sy_desc’字段!");
  1811. return false;
  1812. }
  1813. } else {
  1814. utils.showLog("error" + "本地配置数据不包含‘shares’字段!");
  1815. return false;
  1816. }
  1817. } else {
  1818. utils.showLog("error" + "本地配置数据不是合法的json数据!");
  1819. return false;
  1820. }
  1821. return true;
  1822. }
  1823. /**
  1824. * 初始化facebook
  1825. * @param data 配置
  1826. */
  1827. private _init_facebook(data: string) {
  1828. if (!data) return false;
  1829. utils.showLog("本地配置数据:", data);
  1830. let configObj: any = JSON.parse(data);
  1831. if (configObj) {
  1832. if (configObj.faceBook.app_id) {
  1833. this.faceBookConfig.appID = configObj.faceBook.app_id;
  1834. } else {
  1835. utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
  1836. return false;
  1837. }
  1838. if (configObj.faceBook.video_pos_id) {
  1839. this.faceBookConfig.videoId = configObj.faceBook.video_pos_id;
  1840. } else {
  1841. utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
  1842. return false;
  1843. }
  1844. if (configObj.faceBook.intersititia_pos_id) {
  1845. this.faceBookConfig.insertId = configObj.faceBook.intersititia_pos_id;
  1846. } else {
  1847. utils.showLog("error" + "本地配置数据不包含‘intersititia_pos_id’字段!");
  1848. return false;
  1849. }
  1850. if (configObj.faceBook.banner_pos_id) {
  1851. this.faceBookConfig.bannerId = configObj.faceBook.banner_pos_id;
  1852. } else {
  1853. utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
  1854. return false;
  1855. }
  1856. if (configObj.faceBook.version) {
  1857. this.faceBookConfig.version = configObj.faceBook.version;
  1858. } else {
  1859. utils.showLog("error" + "本地配置数据不包含‘version’字段!");
  1860. return false;
  1861. }
  1862. } else {
  1863. utils.showLog("error" + "本地配置数据不是合法的json数据!");
  1864. return false;
  1865. }
  1866. utils.showLog("success" + "本地配置数据验证完成!");
  1867. return true;
  1868. }
  1869. /**
  1870. * 初始化Hago
  1871. * @param data 配置
  1872. */
  1873. private _init_hago(data: string) {
  1874. if (!data) return false;
  1875. utils.showLog("本地配置数据:", data);
  1876. let configObj: any = JSON.parse(data);
  1877. if (configObj) {
  1878. if (configObj.hago.app_id) {
  1879. this.hagoConfig.appID = configObj.hago.app_id;
  1880. } else {
  1881. utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
  1882. return false;
  1883. }
  1884. if (configObj.hago.video_pos_id) {
  1885. this.hagoConfig.videoId = configObj.hago.video_pos_id;
  1886. } else {
  1887. utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
  1888. return false;
  1889. }
  1890. if (configObj.hago.version) {
  1891. this.hagoConfig.version = configObj.hago.version;
  1892. } else {
  1893. utils.showLog("error" + "本地配置数据不包含‘version’字段!");
  1894. return false;
  1895. }
  1896. } else {
  1897. utils.showLog("error" + "本地配置数据不是合法的json数据!");
  1898. return false;
  1899. }
  1900. return true;
  1901. }
  1902. /**
  1903. * 初始化Huawei
  1904. * @param data 配置
  1905. */
  1906. private _init_huawei(data: string) {
  1907. if (!data) return false;
  1908. utils.showLog("本地配置数据:", data);
  1909. let configObj: any = JSON.parse(data);
  1910. if (configObj) {
  1911. if (configObj.huawei.app_id) {
  1912. this.huaweiConfig.appID = configObj.huawei.app_id;
  1913. } else {
  1914. utils.showLog("error" + "本地配置数据不包含‘app_id’字段!");
  1915. return false;
  1916. }
  1917. if (configObj.huawei.video_pos_id) {
  1918. this.huaweiConfig.videoId = configObj.huawei.video_pos_id;
  1919. } else {
  1920. utils.showLog("error" + "本地配置数据不包含‘video_pos_id’字段!");
  1921. return false;
  1922. }
  1923. if (configObj.huawei.banner_pos_id) {
  1924. this.huaweiConfig.bannerId = configObj.huawei.banner_pos_id;
  1925. } else {
  1926. utils.showLog("error" + "本地配置数据不包含‘banner_pos_id’字段!");
  1927. return false;
  1928. }
  1929. if (configObj.huawei.native_banner_pos_id) {
  1930. this.huaweiConfig.nativeBannerIds = configObj.huawei.native_banner_pos_id;
  1931. } else {
  1932. utils.showLog("error" + "本地配置数据不包含‘native_banner_pos_id’字段!");
  1933. }
  1934. if (configObj.huawei.native_intersititial_pos_id) {
  1935. this.huaweiConfig.nativeInsertIds = configObj.huawei.native_intersititial_pos_id;
  1936. } else {
  1937. utils.showLog("error" + "本地配置数据不包含‘native_intersititial_pos_id’字段!");
  1938. }
  1939. if (configObj.huawei.native_trygame_pos_id) {
  1940. this.huaweiConfig.nativeTryGameIds = configObj.huawei.native_trygame_pos_id;
  1941. } else {
  1942. utils.showLog("error" + "本地配置数据不包含‘native_trygame_pos_id’字段!");
  1943. }
  1944. if (configObj.huawei.native_splash_id) {
  1945. this.huaweiConfig.nativeSplashId = configObj.huawei.native_splash_id;
  1946. }
  1947. else {
  1948. utils.showLog("error" + "本地配置数据不包含‘native_splash_id’字段!")
  1949. }
  1950. if (configObj.huawei.umeng_id) {
  1951. this.huaweiConfig.umengId = configObj.huawei.umeng_id;
  1952. } else {
  1953. utils.showLog("error" + "本地配置数据不包含‘umeng_id’字段,不启用友盟统计!");
  1954. }
  1955. if (configObj.huawei.version) {
  1956. this.huaweiConfig.version = configObj.huawei.version;
  1957. } else {
  1958. utils.showLog("error" + "本地配置数据不包含‘version’字段!");
  1959. return false;
  1960. }
  1961. } else {
  1962. utils.showLog("error" + "本地配置数据不是合法的json数据!");
  1963. return false;
  1964. }
  1965. return true;
  1966. }
  1967. }