30bc39b7-83f8-49ff-940c-540a3f8f40b3.js 176 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404
  1. "use strict";
  2. cc._RF.push(module, '30bc3m3g/hJ/5QMVAo/j0Cz', 'Utils');
  3. // common-plugin/Scripts/Utils.ts
  4. "use strict";
  5. var __extends = (this && this.__extends) || (function () {
  6. var extendStatics = function (d, b) {
  7. extendStatics = Object.setPrototypeOf ||
  8. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10. return extendStatics(d, b);
  11. };
  12. return function (d, b) {
  13. extendStatics(d, b);
  14. function __() { this.constructor = d; }
  15. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16. };
  17. })();
  18. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  19. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23. };
  24. var __spreadArrays = (this && this.__spreadArrays) || function () {
  25. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  26. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  27. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  28. r[k] = a[j];
  29. return r;
  30. };
  31. Object.defineProperty(exports, "__esModule", { value: true });
  32. exports.utils = void 0;
  33. var AdManager_1 = require("./AdManager");
  34. var CommonConfig_1 = require("./CommonConfig");
  35. var WechatTool_1 = require("./WechatTool");
  36. var PlatUtils_1 = require("./PlatUtils");
  37. var YZ_Tool_Oppo_1 = require("./YZ_Tool_Oppo");
  38. var YZ_Tool_Baidu_1 = require("./YZ_Tool_Baidu");
  39. var YZ_Tool_Native_1 = require("./YZ_Tool_Native");
  40. var YZ_Tool_Vivo_1 = require("./YZ_Tool_Vivo");
  41. var YZ_Tool_Douyin_1 = require("./YZ_Tool_Douyin");
  42. var YZ_Constant_1 = require("./YZ_Constant");
  43. var YZ_Tool_QQ_1 = require("./YZ_Tool_QQ");
  44. var YZ_Tool_QTT_1 = require("./YZ_Tool_QTT");
  45. var YZ_Tool_Xiaomi_1 = require("./YZ_Tool_Xiaomi");
  46. var AldUtils_1 = require("./AldUtils");
  47. var YZ_Tool_UC_1 = require("./YZ_Tool_UC");
  48. var YZ_Tool_Cocosplay_1 = require("./YZ_Tool_Cocosplay");
  49. var YZ_Tool_4399_1 = require("./YZ_Tool_4399");
  50. var YZ_Tool_IOS_1 = require("./YZ_Tool_IOS");
  51. var YZ_Tool_Bili_1 = require("./YZ_Tool_Bili");
  52. var YZ_Tool_Kwai_1 = require("./YZ_Tool_Kwai");
  53. var YZ_Tool_Broswer_1 = require("./YZ_Tool_Broswer");
  54. var YZ_Tool_Wifi_1 = require("./YZ_Tool_Wifi");
  55. var YZ_Tool_Hago_1 = require("./YZ_Tool_Hago");
  56. var RedBagProgressWidget_1 = require("./RedBagProgressWidget");
  57. var CompatibleTool_1 = require("./CompatibleTool");
  58. var YZ_Tool_HuaWei_1 = require("./YZ_Tool_HuaWei");
  59. var OpenRedBagPanel_1 = require("./OpenRedBagPanel");
  60. var YZ_Tool_FaceBook_1 = require("./YZ_Tool_FaceBook");
  61. var YzRealNameAuthPanel_1 = require("./YzRealNameAuthPanel");
  62. var YzUserPrivacyPanel_1 = require("./YzUserPrivacyPanel");
  63. var YZ_LocalStorage_1 = require("./YZ_LocalStorage");
  64. var YZ_Tool_GoogleWeb_1 = require("./YZ_Tool_GoogleWeb");
  65. //@ts-ignore
  66. var CryptoJS = require("./Encrypt/CryptoJS");
  67. var secretKey = "youzhixx12345678";
  68. //@ts-ignore
  69. // var uma = require('./UMengSDK/uma.js');
  70. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  71. exports.utils = null;
  72. var UTILSVERSION = "1.6.6";
  73. var Utils = /** @class */ (function (_super) {
  74. __extends(Utils, _super);
  75. function Utils() {
  76. var _this = _super !== null && _super.apply(this, arguments) || this;
  77. _this.DebugLoacalConfig = false;
  78. _this.showLogView = false;
  79. _this.config = null;
  80. /**
  81. * 红包信息
  82. */
  83. _this.yzRedBagInfo = null;
  84. _this.adManager = null;
  85. _this._wechatTool = null;
  86. /**
  87. * 当前关卡
  88. */
  89. _this.currentLevel = 0;
  90. /**
  91. * 是否在录屏中
  92. */
  93. _this.isRecording = false;
  94. /**
  95. * 激励组件成功回调
  96. */
  97. _this.rewardCallFunc = null;
  98. /**
  99. * 激励组件关闭回调
  100. */
  101. _this.rewardCloseFunc = null;
  102. /**
  103. * 激励组件原始奖励
  104. */
  105. _this.rewardValue = 0;
  106. /**
  107. *
  108. * 幸运宝箱显示次数
  109. */
  110. _this.luckBoxShowCount = -1;
  111. /**
  112. * 原生插屏展示的次数
  113. */
  114. _this.nativeInsertShowCount = 0;
  115. /**
  116. *
  117. * 原生插屏满足关闭按钮设置大小条件后显示的次数,用来判断间隔多少次使用服务器大小
  118. */
  119. _this.nativeInsertResizeCloseBtnShowCount = 0;
  120. /**
  121. * 原生Banner展示的次数
  122. */
  123. _this.nativeBannerShowCount = 0;
  124. /**
  125. *
  126. * 原生banner满足关闭按钮设置大小条件后显示的次数,用来判断间隔多少次使用服务器大小
  127. */
  128. _this.nativeBannerResizeCloseBtnShowCount = 0;
  129. /**
  130. * 转盘抽奖关闭回调
  131. */
  132. _this.turnTablePanelCloseFunc = null;
  133. /**
  134. * 分享录屏组件关闭回调
  135. */
  136. _this.shareRecordPanelCloseFunc = null;
  137. /**
  138. * 宝箱关闭回调
  139. */
  140. _this.rewardBoxPanelCloseFunc = null;
  141. /**
  142. * 添加快捷桌面组件关闭回调
  143. */
  144. _this.rewardShortCutPanelCloseFunc = null;
  145. /**
  146. * 推荐游戏组件关闭回调
  147. */
  148. _this.rewardRecGamePanelCloseFunc = null;
  149. /**
  150. * 幸运宝箱组件关闭回调
  151. */
  152. _this.rewardLuckBoxPanelCloseFunc = null;
  153. //Banner广告关闭的时间
  154. _this._bannerCloseTime = 0;
  155. /**
  156. * 其他配置:包含分组的信息
  157. */
  158. _this._other_config = null;
  159. _this._oppoTool = null;
  160. _this._tool_Kwai = null;
  161. _this._tool_Wifi = null;
  162. _this._tool_Hago = null;
  163. _this._tool_Baidu = null;
  164. _this._tool_Native = null;
  165. _this._tool_Vivo = null;
  166. _this._tool_Douyin = null;
  167. _this._tool_QQ = null;
  168. _this._tool_XiaoMi = null;
  169. _this._tool_QTT = null;
  170. _this._tool_UC = null;
  171. _this._tool_Cocosplay = null;
  172. _this._tool_4399 = null;
  173. _this._tool_Ios = null;
  174. _this._tool_bili = null;
  175. _this._tool_Broswer = null;
  176. _this._tool_Huawei = null;
  177. _this._tool_Facebook = null;
  178. _this._tool_GoogleWeb = null;
  179. // 本地配置是否初始化
  180. _this._isConfigInit = false;
  181. // 服务器配置是否初始化
  182. _this._isServerInit = false;
  183. /**
  184. * 游戏进入时间
  185. */
  186. _this._gameEntryTime = 0;
  187. _this._isServerLoadSuccess = false;
  188. _this._recommendGamesBanner = null;
  189. _this._recommendGamesList = null;
  190. _this._tryGamesWidget = null;
  191. _this._moreGamesSidePanel = null;
  192. _this._moreGamesSidePanelBaidu = null;
  193. _this._recordWidget = null;
  194. _this._shortcutWidget = null;
  195. _this._gameBox = null;
  196. _this._nativeTryGameNode = null;
  197. _this.tryGameDate = [];
  198. _this.nativeNeedChange = true;
  199. _this._cur_tool = null;
  200. _this.serverShowLog = false;
  201. /**
  202. * 显示日志到控制台
  203. */
  204. _this.showLogToConsole = false;
  205. _this.overPageShowTime = 0;
  206. _this.overPageInsertAdIsTouch = false; // 结算页面的插屏广告是否被点击过
  207. /**
  208. * 分享成功次数
  209. */
  210. _this.recored_share_count = 0;
  211. _this.shareRecordPanel = null;
  212. _this._withdrawalWidget = null;
  213. _this._redBagProgressWidget = null;
  214. _this._withdrawalPanel = null;
  215. _this._openRedBagPanel = null;
  216. _this._rewardRedBagPanel = null;
  217. _this._rewardRedBagPanelShowCount = 0;
  218. _this._privacyWidget = null;
  219. _this._privacyPanel = null;
  220. _this.minScale = 1;
  221. _this.maxScale = 1.3;
  222. _this.runTime = 0.3;
  223. //原生广告最后上报时间
  224. _this._lastReportAdTime = 0;
  225. /**
  226. * 显示VIVO九宫格挂件
  227. * @param params
  228. * ```
  229. * {
  230. * top:number // 距离屏幕顶部的距离
  231. * }
  232. * ```
  233. */
  234. _this._curVivoGamePortalLocation = "";
  235. _this._curGameDrawerAdLocation = "";
  236. _this._isRealNameAuth = false;
  237. _this._yzRealNameAuthPanel = null;
  238. _this._yzLoginPanel = null;
  239. return _this;
  240. }
  241. Object.defineProperty(Utils.prototype, "utilsVersion", {
  242. get: function () {
  243. return UTILSVERSION;
  244. },
  245. enumerable: false,
  246. configurable: true
  247. });
  248. Object.defineProperty(Utils.prototype, "wechatTool", {
  249. get: function () {
  250. if (!this._wechatTool) {
  251. exports.utils.showLog("wechat tool is null");
  252. }
  253. return this._wechatTool;
  254. },
  255. enumerable: false,
  256. configurable: true
  257. });
  258. Object.defineProperty(Utils.prototype, "oppoTool", {
  259. get: function () {
  260. if (!this._oppoTool) {
  261. exports.utils.showLog("oppo tool is null");
  262. }
  263. return this._oppoTool;
  264. },
  265. enumerable: false,
  266. configurable: true
  267. });
  268. Object.defineProperty(Utils.prototype, "kwaiTool", {
  269. get: function () {
  270. if (!this._tool_Kwai) {
  271. exports.utils.showLog("Kwai tool is null");
  272. }
  273. return this._tool_Kwai;
  274. },
  275. enumerable: false,
  276. configurable: true
  277. });
  278. Object.defineProperty(Utils.prototype, "wifiTool", {
  279. get: function () {
  280. if (!this._tool_Wifi) {
  281. exports.utils.showLog("Wifi tool is null");
  282. }
  283. return this._tool_Wifi;
  284. },
  285. enumerable: false,
  286. configurable: true
  287. });
  288. Object.defineProperty(Utils.prototype, "hagoTool", {
  289. get: function () {
  290. if (!this._tool_Hago) {
  291. exports.utils.showLog("Hago tool is null");
  292. }
  293. return this._tool_Hago;
  294. },
  295. enumerable: false,
  296. configurable: true
  297. });
  298. Object.defineProperty(Utils.prototype, "Tool_Baidu", {
  299. get: function () {
  300. if (!this._tool_Baidu) {
  301. exports.utils.showLog("tool baidu is null");
  302. }
  303. return this._tool_Baidu;
  304. },
  305. enumerable: false,
  306. configurable: true
  307. });
  308. Object.defineProperty(Utils.prototype, "Tool_Native", {
  309. get: function () {
  310. if (!this._tool_Native) {
  311. exports.utils.showLog("tool native is null");
  312. }
  313. return this._tool_Native;
  314. },
  315. enumerable: false,
  316. configurable: true
  317. });
  318. Object.defineProperty(Utils.prototype, "Tool_Vivo", {
  319. get: function () {
  320. if (!this._tool_Vivo) {
  321. exports.utils.showLog("tool vivo is null");
  322. }
  323. return this._tool_Vivo;
  324. },
  325. enumerable: false,
  326. configurable: true
  327. });
  328. Object.defineProperty(Utils.prototype, "Tool_Douyin", {
  329. get: function () {
  330. if (!this._tool_Douyin) {
  331. exports.utils.showLog("tool douyin is null");
  332. }
  333. return this._tool_Douyin;
  334. },
  335. enumerable: false,
  336. configurable: true
  337. });
  338. Object.defineProperty(Utils.prototype, "Tool_QQ", {
  339. get: function () {
  340. if (!this._tool_QQ) {
  341. exports.utils.showLog("tool qq is null");
  342. }
  343. return this._tool_QQ;
  344. },
  345. enumerable: false,
  346. configurable: true
  347. });
  348. Object.defineProperty(Utils.prototype, "Tool_XiaoMi", {
  349. get: function () {
  350. if (!this._tool_XiaoMi) {
  351. exports.utils.showLog("tool xiaomi is null");
  352. }
  353. return this._tool_XiaoMi;
  354. },
  355. enumerable: false,
  356. configurable: true
  357. });
  358. Object.defineProperty(Utils.prototype, "Tool_QTT", {
  359. get: function () {
  360. if (!this._tool_QTT) {
  361. exports.utils.showLog("tool qtt is null");
  362. }
  363. return this._tool_QTT;
  364. },
  365. enumerable: false,
  366. configurable: true
  367. });
  368. Object.defineProperty(Utils.prototype, "Tool_UC", {
  369. get: function () {
  370. if (!this._tool_UC) {
  371. exports.utils.showLog("tool uc is null");
  372. }
  373. return this._tool_UC;
  374. },
  375. enumerable: false,
  376. configurable: true
  377. });
  378. Object.defineProperty(Utils.prototype, "Tool_Cocosplay", {
  379. get: function () {
  380. if (!this._tool_Cocosplay) {
  381. exports.utils.showLog("tool cocos is null");
  382. }
  383. return this._tool_Cocosplay;
  384. },
  385. enumerable: false,
  386. configurable: true
  387. });
  388. Object.defineProperty(Utils.prototype, "Tool_4399", {
  389. get: function () {
  390. if (!this._tool_4399) {
  391. exports.utils.showLog("tool 4399 is null");
  392. }
  393. return this._tool_4399;
  394. },
  395. enumerable: false,
  396. configurable: true
  397. });
  398. Object.defineProperty(Utils.prototype, "Tool_IOS", {
  399. get: function () {
  400. if (!this._tool_Ios) {
  401. exports.utils.showLog("tool ios is null");
  402. }
  403. return this._tool_Ios;
  404. },
  405. enumerable: false,
  406. configurable: true
  407. });
  408. Object.defineProperty(Utils.prototype, "Tool_Bili", {
  409. get: function () {
  410. if (!this._tool_Ios) {
  411. exports.utils.showLog("tool ios is null");
  412. }
  413. return this._tool_bili;
  414. },
  415. enumerable: false,
  416. configurable: true
  417. });
  418. Object.defineProperty(Utils.prototype, "Tool_Broswer", {
  419. get: function () {
  420. if (!this._tool_Broswer) {
  421. // cc.log("tool qtt is null");
  422. }
  423. return this._tool_Broswer;
  424. },
  425. enumerable: false,
  426. configurable: true
  427. });
  428. Object.defineProperty(Utils.prototype, "Tool_Huawei", {
  429. get: function () {
  430. if (!this._tool_Huawei) {
  431. exports.utils.showLog("huawei tool is null");
  432. }
  433. return this._tool_Huawei;
  434. },
  435. enumerable: false,
  436. configurable: true
  437. });
  438. Object.defineProperty(Utils.prototype, "Tool_Facebook", {
  439. get: function () {
  440. if (!this._tool_Facebook) {
  441. exports.utils.showLog("facebook tool is null");
  442. }
  443. return this._tool_Facebook;
  444. },
  445. enumerable: false,
  446. configurable: true
  447. });
  448. Object.defineProperty(Utils.prototype, "Tool_GoogleWeb", {
  449. get: function () {
  450. if (!this._tool_GoogleWeb) {
  451. exports.utils.showLog("googleWeb tool is null");
  452. }
  453. return this._tool_GoogleWeb;
  454. },
  455. enumerable: false,
  456. configurable: true
  457. });
  458. /**
  459. * 初始化配置数据
  460. * @param data 配置数据
  461. */
  462. Utils.prototype._initConfig = function () {
  463. var _this = this;
  464. if (this._isConfigInit) {
  465. exports.utils.showLog("warn:" + "配置数据已经初始化,请勿重复初始化!");
  466. return;
  467. }
  468. if (this.config.otherconfig.localConfig) {
  469. var data = JSON.stringify(this.config.otherconfig.localConfig.json);
  470. exports.utils.showLog("本地数据:" + data);
  471. if (data) {
  472. if (PlatUtils_1.default.IsNativeAndroid) {
  473. // 安卓需要先获取JNI,再取本地数据
  474. this.initTools(data);
  475. this._isConfigInit = this._initLoacalConfig(data);
  476. if (this._isConfigInit) {
  477. exports.utils.Tool_Native.init();
  478. }
  479. }
  480. else {
  481. this._isConfigInit = this._initLoacalConfig(data);
  482. // 这个必须在广告组件之前初始化
  483. this.initTools(data);
  484. }
  485. this._other_config = this.config.otherconfig.localConfig.json.other;
  486. this.adManager = new AdManager_1.default();
  487. this.adManager.Init();
  488. if (this._oppoTool) {
  489. this._oppoTool.hideDefaultLoadingPage();
  490. }
  491. if (PlatUtils_1.default.IsKwai) {
  492. //@ts-ignore
  493. kwaigame.readyGo();
  494. }
  495. exports.utils.yzRedBagInfo = new CommonConfig_1.YzRedBagInfo();
  496. exports.utils.registerServerInitEvent(function () {
  497. if (exports.utils.ServerConfig) {
  498. _this.serverShowLog = _this.getConfigByKey("is_show_log_view") == "true";
  499. _this.showLogToConsole = _this.getConfigByKey("show_log_to_console") == "true";
  500. if (_this.getConfigByKey("red_bag_total_progress")) {
  501. exports.utils.yzRedBagInfo.totalProgress = _this.getConfigByKey("red_bag_total_progress");
  502. }
  503. if (_this.getConfigByKey("red_bag_progress_infos")) {
  504. exports.utils.yzRedBagInfo.progressInfos = _this.getConfigByKey("red_bag_progress_infos");
  505. }
  506. if (_this.getConfigByKey("red_bag_moneys")) {
  507. exports.utils.yzRedBagInfo.withdrawaMoneys = _this.getConfigByKey("red_bag_moneys");
  508. }
  509. }
  510. if (PlatUtils_1.default.IsHago) {
  511. //@ts-ignore
  512. hg.gameLoadResult && hg.gameLoadResult({ code: 0 });
  513. }
  514. // if (PlatUtils.IsHuaWei) {
  515. // utils.showMsg("华为小游戏要用华为单独的组件对接!!!!!!!!!")
  516. // }
  517. }, this);
  518. }
  519. else {
  520. exports.utils.showLog("warn:" + "本地配置文件不是合法的json文件!");
  521. }
  522. }
  523. else {
  524. exports.utils.showLog("warn:" + "本地配置文件未找到,请检查 CommonUtils 组件上是否存在!");
  525. }
  526. };
  527. Utils.prototype._initLoacalConfig = function (data) {
  528. if (this.config) {
  529. return this.config.init(data);
  530. }
  531. else {
  532. return false;
  533. }
  534. };
  535. Utils.prototype.onLoad = function () {
  536. cc.game.addPersistRootNode(this.node);
  537. exports.utils = this;
  538. exports.utils.showLog("广告组件版本:" + this.utilsVersion);
  539. if (!CC_DEBUG) {
  540. // 正式包关闭此选项
  541. this.DebugLoacalConfig = false;
  542. }
  543. this._gameEntryTime = new Date().getTime();
  544. // 初始化本地配置
  545. this._initConfig();
  546. };
  547. Utils.prototype.update = function (dt) {
  548. if (this._isConfigInit) {
  549. if (this.adManager) {
  550. this.adManager.OnUpdate(dt);
  551. }
  552. }
  553. };
  554. Utils.prototype.initTools = function (data) {
  555. if (!this._isConfigInit && !PlatUtils_1.default.IsNativeAndroid) {
  556. exports.utils.showLog("warn:" + "本地数据未初始化!");
  557. return;
  558. }
  559. if (PlatUtils_1.default.IsNativeAndroid) {
  560. this._tool_Native = new YZ_Tool_Native_1.default();
  561. // this._tool_Native.init(data);
  562. }
  563. else if (PlatUtils_1.default.IsWechat) {
  564. this._wechatTool = new WechatTool_1.default();
  565. this._wechatTool.init(data);
  566. }
  567. else if (PlatUtils_1.default.IsOPPO) {
  568. this._oppoTool = new YZ_Tool_Oppo_1.default();
  569. this._oppoTool.init(data);
  570. }
  571. else if (PlatUtils_1.default.IsBaidu) {
  572. this._tool_Baidu = new YZ_Tool_Baidu_1.default();
  573. this._tool_Baidu.init(data);
  574. }
  575. else if (PlatUtils_1.default.IsVIVO) {
  576. this._tool_Vivo = new YZ_Tool_Vivo_1.default();
  577. this._tool_Vivo.init(data);
  578. }
  579. else if (PlatUtils_1.default.IsDouyin) {
  580. this._tool_Douyin = new YZ_Tool_Douyin_1.default();
  581. this._tool_Douyin.init(data);
  582. }
  583. else if (PlatUtils_1.default.IsQQ) {
  584. this._tool_QQ = new YZ_Tool_QQ_1.default();
  585. this._tool_QQ.init(data);
  586. }
  587. else if (PlatUtils_1.default.IsQTT) {
  588. this._tool_QTT = new YZ_Tool_QTT_1.default();
  589. this._tool_QTT.init(data);
  590. }
  591. else if (PlatUtils_1.default.IsXiaoMi) {
  592. this._tool_XiaoMi = new YZ_Tool_Xiaomi_1.default();
  593. this._tool_XiaoMi.init(data);
  594. }
  595. else if (PlatUtils_1.default.ISUC) {
  596. this._tool_UC = new YZ_Tool_UC_1.default();
  597. this._tool_UC.init(data);
  598. }
  599. else if (PlatUtils_1.default.ISCocos) {
  600. this._tool_Cocosplay = new YZ_Tool_Cocosplay_1.default();
  601. this._tool_Cocosplay.init(data);
  602. }
  603. else if (PlatUtils_1.default.Is4399) {
  604. this._tool_4399 = new YZ_Tool_4399_1.default();
  605. this._tool_4399.init(data);
  606. }
  607. else if (PlatUtils_1.default.IsNativeIOS) {
  608. this._tool_Ios = new YZ_Tool_IOS_1.default();
  609. this._tool_Ios.init(data);
  610. }
  611. else if (PlatUtils_1.default.IsBili) {
  612. this._tool_bili = new YZ_Tool_Bili_1.default();
  613. this._tool_bili.init(data);
  614. }
  615. else if (PlatUtils_1.default.IsKwai) {
  616. this._tool_Kwai = new YZ_Tool_Kwai_1.default();
  617. this._tool_Kwai.init(data);
  618. }
  619. else if (PlatUtils_1.default.IsWiFi) {
  620. this._tool_Wifi = new YZ_Tool_Wifi_1.default();
  621. this._tool_Wifi.init(data);
  622. }
  623. else if (PlatUtils_1.default.IsHago) {
  624. this._tool_Hago = new YZ_Tool_Hago_1.default();
  625. this._tool_Hago.init(data);
  626. }
  627. else if (PlatUtils_1.default.IsHuaWei) {
  628. this._tool_Huawei = new YZ_Tool_HuaWei_1.default();
  629. this._tool_Huawei.init(data);
  630. }
  631. else if (PlatUtils_1.default.IsFaceBook) {
  632. this._tool_Facebook = new YZ_Tool_FaceBook_1.default();
  633. this._tool_Facebook.init(data);
  634. }
  635. else if (PlatUtils_1.default.IsGoogleWeb) {
  636. this._tool_GoogleWeb = new YZ_Tool_GoogleWeb_1.default();
  637. this._tool_GoogleWeb.init(data);
  638. }
  639. else if (PlatUtils_1.default.IsTest) {
  640. this._tool_Broswer = new YZ_Tool_Broswer_1.default();
  641. this._tool_Broswer.init(data);
  642. }
  643. };
  644. /**
  645. * 延时调用函数
  646. * @param callback 回调函数
  647. * @param delay 延时时间
  648. */
  649. Utils.prototype.delayCall = function (callback, delay) {
  650. this.scheduleOnce(function () {
  651. if (callback) {
  652. callback();
  653. }
  654. }, delay);
  655. };
  656. /**
  657. *
  658. * @param callback Function<ret:boolean, msg:string> 分享回调
  659. */
  660. Utils.prototype.share = function (callback) {
  661. if (callback === void 0) { callback = null; }
  662. if (!this._isConfigInit) {
  663. exports.utils.showLog("warn:" + "本地数据未初始化!");
  664. return;
  665. }
  666. this.cur_tool && this.cur_tool.share && this.cur_tool.share(callback);
  667. };
  668. /**
  669. * 注销游戏退出回调
  670. */
  671. Utils.prototype.gameExitOff = function () {
  672. if (!this._isConfigInit) {
  673. exports.utils.showLog("warn:" + "本地数据未初始化!");
  674. return;
  675. }
  676. if (PlatUtils_1.default.IsNativeAndroid) {
  677. cc.systemEvent.targetOff(this);
  678. }
  679. };
  680. /**
  681. * 开始录屏
  682. */
  683. Utils.prototype.recordStart = function () {
  684. if (!this._isConfigInit) {
  685. exports.utils.showLog("warn:" + "本地数据未初始化!");
  686. return;
  687. }
  688. this.cur_tool && this.cur_tool.recordStart && this.cur_tool.recordStart();
  689. };
  690. /**
  691. * 结束录屏
  692. */
  693. Utils.prototype.recordEnd = function () {
  694. if (!this._isConfigInit) {
  695. exports.utils.showLog("warn:" + "本地数据未初始化!");
  696. return;
  697. }
  698. this.cur_tool && this.cur_tool.recordEnd && this.cur_tool.recordEnd();
  699. };
  700. /**
  701. * 获取分享信息
  702. */
  703. Utils.prototype.getShareInfo = function () {
  704. if (!this._isConfigInit) {
  705. exports.utils.showLog("warn:" + "本地数据未初始化!");
  706. return null;
  707. }
  708. if (this.config.otherconfig.shareTitle && this.config.otherconfig.shareImgUrl) {
  709. return {
  710. title: this.config.otherconfig.shareTitle,
  711. imageUrl: this.config.otherconfig.shareImgUrl
  712. };
  713. }
  714. else {
  715. exports.utils.showLog("分享配置出错!");
  716. return null;
  717. }
  718. };
  719. /**
  720. * 获取游戏内交叉推广信息, 游戏内跳转组件使用
  721. * @returns object or null
  722. */
  723. Utils.prototype.getInnerRecommendData = function () {
  724. if (!this._isConfigInit) {
  725. exports.utils.showLog("warn:" + "本地数据未初始化!");
  726. return null;
  727. }
  728. if (this.ServerConfig && this.ServerConfig.jump_list && this.ServerConfig.jump_list.length > 0) {
  729. return {
  730. "jump_refresh_time": this.ServerConfig.icon_jump,
  731. "jump_list": this.ServerConfig.jump_list
  732. };
  733. }
  734. return null;
  735. };
  736. /**
  737. * 跳转到其他小游戏
  738. * @param data
  739. * { // 交叉推广挂件内容信息
  740. "icon": "http://xcx.youletd.com/img/icon/fgdxc.png",
  741. "name": "翻滚的香肠大冒险",
  742. "path": "",
  743. "js_jump": "true",
  744. "qr_code": "http://xcx.youletd.com/img/qrcode/q_fgdxc.jpg",
  745. "appid": "wx2c4ed4218224b042"
  746. }
  747. @param callback Function(ret) 跳转回调
  748. */
  749. Utils.prototype.navigateToMiniGame = function (data, callback) {
  750. if (callback === void 0) { callback = null; }
  751. if (!this._isConfigInit) {
  752. exports.utils.showLog("warn:" + "本地数据未初始化!");
  753. return;
  754. }
  755. if (PlatUtils_1.default.IsWechat) {
  756. if (data) {
  757. if (data.is_jump && data.is_jump == "true" && data.appid) {
  758. this.wechatTool.navigateToMiniProgram(data.appid, callback, data.path);
  759. return;
  760. }
  761. if (data.is_jump && data.is_jump == "false" && data.qr_code) {
  762. this.wechatTool.previewImage(data.qr_code);
  763. if (callback) {
  764. callback(true);
  765. }
  766. return;
  767. }
  768. }
  769. }
  770. else if (PlatUtils_1.default.IsOPPO) {
  771. if (data && data.appid) {
  772. this.oppoTool.navigateToMiniGame(data.appid, callback);
  773. }
  774. else {
  775. exports.utils.showLog("data 或者 appid 为null!");
  776. if (callback) {
  777. callback(false);
  778. }
  779. }
  780. }
  781. else if (PlatUtils_1.default.IsBaidu) {
  782. if (data && data.appid) {
  783. exports.utils.Tool_Baidu.navigateToMiniGame(data.appid, callback);
  784. }
  785. else {
  786. exports.utils.showLog("data 或者 appid 为null!");
  787. if (callback) {
  788. callback(false);
  789. }
  790. }
  791. }
  792. else if (PlatUtils_1.default.IsNativeAndroid) {
  793. if (data) {
  794. exports.utils.Tool_Native.navigateToGame(JSON.stringify(data), callback);
  795. }
  796. else {
  797. exports.utils.showLog("data 或者 appid 为null!");
  798. if (callback) {
  799. callback(false);
  800. }
  801. }
  802. }
  803. else if (PlatUtils_1.default.IsNativeIOS) {
  804. if (data && data.appid) {
  805. this.Tool_IOS.navigateToGame(data.appid, callback);
  806. }
  807. else {
  808. exports.utils.showLog("data 或者 appid 为null!");
  809. if (callback) {
  810. callback(false);
  811. }
  812. }
  813. }
  814. };
  815. /**
  816. * 当前版本是否支持跳转到其他小游戏
  817. */
  818. Utils.prototype.isSupportnavigateToMiniGame = function () {
  819. if (!this._isConfigInit) {
  820. exports.utils.showLog("warn:" + "本地数据未初始化!");
  821. return false;
  822. }
  823. if (PlatUtils_1.default.IsWechat || PlatUtils_1.default.IsNativeAndroid || PlatUtils_1.default.IsNativeIOS || PlatUtils_1.default.IsBaidu) {
  824. return true;
  825. }
  826. else if (PlatUtils_1.default.IsOPPO) {
  827. return this.oppoTool.isOverMiniVersion("1044");
  828. }
  829. else if (PlatUtils_1.default.IsDouyin) {
  830. return this.Tool_Douyin.isShowMoreGamesModal() && this.Tool_Douyin._sysInfo.appName != "live_stream";
  831. }
  832. else if (PlatUtils_1.default.IsQQ) {
  833. return this._tool_QQ.isOverMinVersion("1.7.1");
  834. }
  835. return false;
  836. };
  837. /**
  838. * 显示消息提示
  839. * @param msg 消息提示
  840. */
  841. Utils.prototype.showMsg = function (msg) {
  842. if (exports.utils.Tool_Broswer) {
  843. console.log(msg);
  844. return;
  845. }
  846. this.cur_tool && this.cur_tool.showToast && this.cur_tool.showToast(msg);
  847. };
  848. /**
  849. * 是否已经创建过快捷方式
  850. */
  851. Utils.prototype.hasShortcutInstalled = function () {
  852. if (!this._isConfigInit) {
  853. exports.utils.showLog("warn:" + "本地数据未初始化!");
  854. return true;
  855. }
  856. if (PlatUtils_1.default.IsVIVO && this.Tool_Vivo) {
  857. return this.Tool_Vivo.ShortcutCreated;
  858. }
  859. else if (PlatUtils_1.default.IsOPPO && this.oppoTool) {
  860. return this.oppoTool.ShortcutCreated;
  861. }
  862. return false;
  863. };
  864. /**
  865. * 是否可以创建桌面快捷方式,平台是否支持
  866. */
  867. Utils.prototype.canCreateShortcut = function () {
  868. if (!this._isConfigInit) {
  869. exports.utils.showLog("warn:" + "本地数据未初始化!");
  870. return false;
  871. }
  872. if (this.cur_tool && this.cur_tool.canCreateShortcut) {
  873. return this.cur_tool.canCreateShortcut();
  874. }
  875. return false;
  876. };
  877. /**
  878. * 创建桌面快捷方式
  879. */
  880. Utils.prototype.createShortcut = function (callback) {
  881. if (!this._isConfigInit) {
  882. exports.utils.showLog("warn:" + "本地数据未初始化!");
  883. return;
  884. }
  885. this.cur_tool && this.cur_tool.createShortcut && this.cur_tool.createShortcut(callback);
  886. };
  887. /**
  888. * 通用http请求,只封装了GET请求
  889. * @param url 请求的url地址
  890. * @param callback Function(ret:boolean, data:string)
  891. * 请求结束回调,成功ret为true, data为返回的数据string。 失败为ret为false, data为空
  892. */
  893. Utils.prototype.commomHttpRequest = function (url, callback) {
  894. var _this = this;
  895. if (!this._isConfigInit) {
  896. exports.utils.showLog("warn:" + "本地数据未初始化!");
  897. return;
  898. }
  899. var completeCallback = callback;
  900. var xhr = new XMLHttpRequest();
  901. xhr.timeout = 6000; // 单位毫秒
  902. var requestUrl = this._buildServerUrl(url) + ("&time_stamp=" + (new Date()).getTime() + "&reqv=" + YZ_Constant_1.default.SERVER_VERSION);
  903. exports.utils.showLog("服务器地址:" + requestUrl);
  904. xhr.open('GET', requestUrl);
  905. xhr.send();
  906. xhr.onreadystatechange = function () {
  907. exports.utils.showLog("请求状态改变, reaedyState=", xhr.readyState, "; status=", xhr.status);
  908. if (xhr.readyState == 4) {
  909. if (xhr.status == 200) {
  910. if (completeCallback) {
  911. if (requestUrl.indexOf("m=g") > -1 || requestUrl.indexOf("m=rlevelv3") > -1) {
  912. completeCallback(true, _this.aesDecrypt(xhr.responseText));
  913. }
  914. else {
  915. completeCallback(true, xhr.responseText);
  916. }
  917. }
  918. }
  919. else {
  920. if (completeCallback) {
  921. completeCallback(false, "");
  922. }
  923. }
  924. }
  925. };
  926. xhr.ontimeout = function () {
  927. exports.utils.showLog("请求超时!");
  928. if (completeCallback) {
  929. completeCallback(false, "");
  930. }
  931. };
  932. xhr.onerror = function (err) {
  933. exports.utils.showLog("请求出错! err=", JSON.stringify(err));
  934. if (completeCallback) {
  935. completeCallback(false, "");
  936. }
  937. };
  938. };
  939. Utils.prototype.aesEncrypt = function (content) {
  940. var key = CryptoJS.enc.Utf8.parse(secretKey);
  941. var srcs = CryptoJS.enc.Utf8.parse(content);
  942. var encrypted = CryptoJS.AES.encrypt(srcs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
  943. return encrypted.toString();
  944. };
  945. /**
  946. * 解密方法
  947. * @param encryptStr 密文
  948. * @returns {string} 明文
  949. */
  950. Utils.prototype.aesDecrypt = function (encryptStr) {
  951. var key = CryptoJS.enc.Utf8.parse(secretKey);
  952. var decrypt = CryptoJS.AES.decrypt(encryptStr, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
  953. return CryptoJS.enc.Utf8.stringify(decrypt).toString();
  954. };
  955. /**
  956. * 增加常用字段
  957. */
  958. Utils.prototype._buildServerUrl = function (url) {
  959. // utils.showLog(" _buildServerUrl >>>>>.");
  960. if (PlatUtils_1.default.IsOPPO) {
  961. //@ts-ignore
  962. url = url + ("&kyx=true&app_id=" + exports.utils.config.oppoconfig.packageName + "&channel=oppo&device_uid=" + exports.utils.oppoTool.uid + "&uid=" + exports.utils.oppoTool.serviceId + "&source=" + this.oppoTool._source + "&game_version=" + exports.utils.config.oppoconfig.version + "&device_id=" + exports.utils.oppoTool._device_id);
  963. }
  964. else if (PlatUtils_1.default.IsXiaoMi) {
  965. url = url + ("&kyx=true&app_id=" + exports.utils.config.xiaomiConfig.appID + "&channel=xiaomi&device_uid=" + exports.utils._tool_XiaoMi.uid + "&uid=" + exports.utils._tool_XiaoMi.serviceId);
  966. }
  967. else if (PlatUtils_1.default.IsWechat) {
  968. url = url + ("&kyx=true&app_id=" + exports.utils.config.wechatconfig.appID + "&channel=wechat&device_uid=" + exports.utils.wechatTool.uid + "&uid=" + exports.utils.wechatTool.serviceId + "&source=" + this.wechatTool._source_app_id + "&soure_type=" + this.wechatTool._luanchType + "&game_version=" + exports.utils.config.wechatconfig.version);
  969. }
  970. else if (PlatUtils_1.default.IsVIVO) {
  971. url = url + ("&kyx=true&app_id=" + exports.utils.config.vivoconfig.appID + "&channel=vivo&device_uid=" + exports.utils._tool_Vivo.uid + "&uid=" + exports.utils._tool_Vivo.serviceId + "&source=" + this._tool_Vivo._source + "&game_version=" + exports.utils.config.vivoconfig.version);
  972. }
  973. else if (PlatUtils_1.default.IsQTT) {
  974. url = url + ("&kyx=true&app_id=" + exports.utils.config.qttconfig.appID + "&channel=qutoutiao&device_uid=" + exports.utils._tool_QTT.uid + "&uid=" + exports.utils._tool_QTT.serviceId);
  975. }
  976. else if (PlatUtils_1.default.IsDouyin) {
  977. url = url + ("&kyx=true&app_id=" + exports.utils.config.douyinconfig.appID + "&channel=toutiao&device_uid=" + exports.utils.Tool_Douyin.uid + "&uid=" + exports.utils.Tool_Douyin.serviceId + "&game_version=" + exports.utils.config.douyinconfig.version);
  978. }
  979. else if (PlatUtils_1.default.IsQQ) {
  980. url = url + ("&kyx=true&app_id=" + exports.utils.config.qqconfig.appID + "&channel=qq&device_uid=" + exports.utils._tool_QQ.uid + "&uid=" + exports.utils._tool_QQ.serviceId + "&game_version=" + exports.utils.config.qqconfig.version);
  981. }
  982. else if (PlatUtils_1.default.IsBaidu) {
  983. url = url + ("&kyx=true&app_id=" + exports.utils.config.baiduconfig.appID + "&channel=baidu&device_uid=" + exports.utils._tool_Baidu.uid + "&uid=" + exports.utils._tool_Baidu.serviceId + "&game_version=" + exports.utils.config.baiduconfig.version);
  984. }
  985. else if (PlatUtils_1.default.ISUC) {
  986. url = url + ("&kyx=true&app_id=" + exports.utils.config.ucConfig.appID + "&channel=uc&device_uid=" + exports.utils._tool_UC.uid + "&uid=" + exports.utils._tool_UC.serviceId + "&game_version=" + exports.utils.config.ucConfig.version);
  987. }
  988. else if (PlatUtils_1.default.ISCocos) {
  989. url = url + ("&kyx=true&app_id=" + exports.utils.config.cocosConfig.appID + "&channel=cocos&device_uid=" + exports.utils._tool_Cocosplay.uid + "&uid=" + exports.utils._tool_Cocosplay.serviceId);
  990. }
  991. else if (PlatUtils_1.default.IsNativeAndroid) {
  992. url = url + ("&kyx=false&app_id=" + exports.utils.config.nativeAndroidConfig.appID + "&channel=" + exports.utils.config.nativeAndroidConfig.channel + "&device_uid=" + exports.utils.Tool_Native.uid + "&uid=" + exports.utils.Tool_Native.serviceId + "&game_type=2&game_version=" + exports.utils.config.nativeAndroidConfig.version);
  993. }
  994. else if (PlatUtils_1.default.IsKwai) {
  995. url = url + ("&kyx=true&app_id=" + exports.utils.config.kwaiConfig.appID + "&channel=kuaishou&device_uid=" + exports.utils._tool_Kwai.uid + "&uid=" + exports.utils._tool_Kwai.serviceId + "&game_version=" + exports.utils.config.kwaiConfig.version);
  996. }
  997. else if (PlatUtils_1.default.IsNativeIOS) {
  998. url = url + ("&kyx=false&app_id=" + exports.utils.config.nativeIoSConfig.appID + "&channel=ios&device_uid=" + exports.utils.Tool_IOS.uid + "&uid=" + exports.utils.Tool_IOS.serviceId + "&game_type=2&game_version=" + exports.utils.config.nativeIoSConfig.version);
  999. }
  1000. else if (PlatUtils_1.default.IsWiFi) {
  1001. url = url + ("&kyx=true&app_id=" + exports.utils.config.wifiConfig.appID + "&channel=wifi&device_uid=" + exports.utils._tool_Wifi.uid + "&uid=" + exports.utils._tool_Wifi.serviceId + "&game_version=" + exports.utils.config.wifiConfig.version);
  1002. }
  1003. else if (PlatUtils_1.default.IsHago) {
  1004. url = url + ("&kyx=true&app_id=" + exports.utils.config.hagoConfig.appID + "&channel=hago&device_uid=" + exports.utils._tool_Hago.uid + "&uid=" + exports.utils._tool_Hago.serviceId + "&game_version=" + exports.utils.config.hagoConfig.version);
  1005. }
  1006. else if (PlatUtils_1.default.IsHuaWei) {
  1007. url = url + ("&kyx=true&app_id=" + exports.utils.config.huaweiConfig.appID + "&channel=huawei&device_uid=" + exports.utils.Tool_Huawei.uid + "&uid=" + exports.utils.Tool_Huawei.serviceId + "&game_version=" + exports.utils.config.huaweiConfig.version);
  1008. }
  1009. else if (PlatUtils_1.default.IsFaceBook) {
  1010. url = url + ("&kyx=true&app_id=" + exports.utils.config.faceBookConfig.appID + "&channel=facebookxyx&device_uid=" + exports.utils.Tool_Facebook.uid + "&uid=" + exports.utils.Tool_Facebook.serviceId + "&game_version=" + exports.utils.config.faceBookConfig.version);
  1011. }
  1012. return url;
  1013. };
  1014. /**
  1015. * 上报小游戏跳转点击数据
  1016. */
  1017. Utils.prototype.postData = function (otherGameAppId) {
  1018. if (!this._isConfigInit) {
  1019. exports.utils.showLog("warn:" + "本地数据未初始化!");
  1020. return;
  1021. }
  1022. this.cur_tool && this.cur_tool.postData && this.cur_tool.postData(otherGameAppId);
  1023. };
  1024. /**
  1025. * 注册服务器初始化完成事件
  1026. * @param callback
  1027. * @param target
  1028. */
  1029. Utils.prototype.registerServerInitEvent = function (callback, target) {
  1030. if (!this._isConfigInit) {
  1031. exports.utils.showLog("warn:" + "本地数据未初始化!");
  1032. return;
  1033. }
  1034. if (this._isServerInit) {
  1035. if (callback) {
  1036. callback();
  1037. }
  1038. }
  1039. else {
  1040. cc.game.on(YZ_Constant_1.default.EC_ServerInit, callback, target);
  1041. }
  1042. };
  1043. /**
  1044. * 注册服务器初始化完成事件
  1045. * @param callback
  1046. * @param target
  1047. */
  1048. Utils.prototype.registerServerDataLoadSuccessEvent = function (callback, target) {
  1049. if (this._isServerLoadSuccess) {
  1050. if (callback) {
  1051. callback();
  1052. }
  1053. }
  1054. else {
  1055. cc.game.on(YZ_Constant_1.default.EC_ServerDataLoadSuccess, callback, target);
  1056. }
  1057. };
  1058. /**
  1059. * 注册隐私弹窗关闭事件
  1060. * @param callback
  1061. * @param target
  1062. */
  1063. Utils.prototype.registerPrivacyCloseEvent = function (callback, target) {
  1064. var ysxy = YZ_LocalStorage_1.default.getItem(YZ_Constant_1.default.YZ_GAME_YSXY);
  1065. if (ysxy) {
  1066. if (callback) {
  1067. callback();
  1068. }
  1069. }
  1070. else {
  1071. cc.game.on(YZ_Constant_1.default.YZ_PrivacyClose, callback, target);
  1072. }
  1073. };
  1074. /**
  1075. * 上报互推组件数据
  1076. * @param otherGameAppId 跳转的ID
  1077. * @param location 当前位置
  1078. * @param status 0:点击,1:跳转成功
  1079. */
  1080. Utils.prototype.postDataByLocation = function (otherGameAppId, location, status) {
  1081. if (status === void 0) { status = 0; }
  1082. if (!this._isConfigInit) {
  1083. exports.utils.showLog("warn:" + "本地数据未初始化!");
  1084. return;
  1085. }
  1086. if (PlatUtils_1.default.IsBaidu) {
  1087. if (this.Tool_Baidu) {
  1088. this.Tool_Baidu.postData(otherGameAppId);
  1089. }
  1090. }
  1091. else {
  1092. this.cur_tool && this.cur_tool.postDataByLocation && this.cur_tool.postDataByLocation(otherGameAppId, location, status);
  1093. }
  1094. };
  1095. /**
  1096. * 上报互推组件数据
  1097. * @param otherGameAppId 跳转的ID
  1098. * @param location 当前位置
  1099. * @param status 0:点击,1:跳转成功
  1100. */
  1101. Utils.prototype.postRecommentShowData = function (location) {
  1102. if (!this._isConfigInit) {
  1103. exports.utils.showLog("warn:" + "本地数据未初始化!");
  1104. return;
  1105. }
  1106. this.cur_tool && this.cur_tool.postRecommentShowData && this.cur_tool.postRecommentShowData(location);
  1107. };
  1108. /**
  1109. * 注销服务器初始化完成事件
  1110. * @param target
  1111. */
  1112. Utils.prototype.unregisterServerInitEvent = function (target) {
  1113. cc.game.targetOff(target);
  1114. };
  1115. /**
  1116. * 发送服务器初始化完毕事件
  1117. */
  1118. Utils.prototype.emitServerInitEvent = function () {
  1119. // if (PlatUtils.IsTest) {
  1120. // this.getConfigByKey("is_privacy_panel = "true";
  1121. // }
  1122. var _this = this;
  1123. if (this.isShowPrivacyPanel()) {
  1124. this._isServerLoadSuccess = true;
  1125. cc.game.emit(YZ_Constant_1.default.EC_ServerDataLoadSuccess);
  1126. exports.utils.registerPrivacyCloseEvent(function () {
  1127. _this._isServerInit = true;
  1128. cc.game.emit(YZ_Constant_1.default.EC_ServerInit);
  1129. cc.game.targetOff(YZ_Constant_1.default.EC_ServerDataLoadSuccess);
  1130. cc.game.targetOff(YZ_Constant_1.default.YZ_PrivacyClose);
  1131. }, this);
  1132. return;
  1133. }
  1134. this._isServerInit = true;
  1135. cc.game.emit(YZ_Constant_1.default.EC_ServerInit);
  1136. };
  1137. /**
  1138. * 注册实名制认证关闭事件
  1139. * @param callback
  1140. * @param target
  1141. */
  1142. Utils.prototype.registerRealNameAuthCloseEvent = function (callback, target) {
  1143. if (this._isServerLoadSuccess) {
  1144. if (callback) {
  1145. callback();
  1146. }
  1147. }
  1148. else {
  1149. cc.game.on(YZ_Constant_1.default.EC_RealNameAuthPanelClose, callback, target);
  1150. }
  1151. };
  1152. Utils.prototype.emitRealNameAuthCloseEvent = function () {
  1153. cc.game.emit(YZ_Constant_1.default.EC_RealNameAuthPanelClose);
  1154. };
  1155. /**
  1156. * 发送隐私确认弹窗关闭事件
  1157. */
  1158. Utils.prototype.emitPrivacyCloseEvent = function () {
  1159. this._isServerInit = true;
  1160. cc.game.emit(YZ_Constant_1.default.YZ_PrivacyClose);
  1161. };
  1162. /**
  1163. * 获取交叉推广数据
  1164. */
  1165. Utils.prototype.getRecommondGameList = function () {
  1166. if (!this._isConfigInit) {
  1167. exports.utils.showLog("warn:" + "本地数据未初始化!");
  1168. return null;
  1169. }
  1170. // if (this.cur_tool && this.cur_tool.getRecommondGameList) {
  1171. // return this.cur_tool.getRecommondGameList();
  1172. // }
  1173. if (PlatUtils_1.default.IsWechat) {
  1174. return this.wechatTool.getRecommondGameList();
  1175. }
  1176. else if (PlatUtils_1.default.IsOPPO) {
  1177. return this.oppoTool.getRecommondGameList();
  1178. }
  1179. else if (PlatUtils_1.default.IsBaidu) {
  1180. return this.Tool_Baidu.getRecommondGameList();
  1181. }
  1182. else if (PlatUtils_1.default.IsNativeAndroid) {
  1183. return this.Tool_Native.getRecommondGameList();
  1184. }
  1185. else if (PlatUtils_1.default.IsDouyin) {
  1186. return this.Tool_Douyin.getRecommondGameList();
  1187. }
  1188. else if (this.Tool_Broswer) {
  1189. return this.Tool_Broswer.getRecommondGameList();
  1190. }
  1191. else if (PlatUtils_1.default.IsNativeIOS) {
  1192. return this.Tool_IOS.getRecommondGameList();
  1193. }
  1194. return null;
  1195. };
  1196. /**
  1197. * 是否显示底部更多游戏banner列表
  1198. */
  1199. Utils.prototype.isShowRecommondGamesBanner = function () {
  1200. if (!this._isConfigInit) {
  1201. exports.utils.showLog("本地数据未初始化!");
  1202. return false;
  1203. }
  1204. if (this.Tool_Broswer)
  1205. return true;
  1206. if (exports.utils.isSupportnavigateToMiniGame()) {
  1207. if (this.ServerConfig
  1208. && this.ServerConfig.is_bottom_banner_list) {
  1209. if (this.ServerConfig.is_bottom_banner_list == "true") {
  1210. return true;
  1211. }
  1212. else {
  1213. exports.utils.showLog("is_bottom_banner_list 参数为false,底部更多游戏横幅组件不显示!");
  1214. }
  1215. }
  1216. else {
  1217. exports.utils.showLog("配置中没有 is_bottom_banner_list 参数,底部更多游戏横幅组件不显示!");
  1218. }
  1219. }
  1220. else {
  1221. exports.utils.showLog("当前平台不支持游戏内跳转,底部更多游戏横幅组件不显示!");
  1222. }
  1223. return false;
  1224. };
  1225. /**
  1226. * 显示底部推荐游戏Banner
  1227. * @param params
  1228. * 参数是一个对象.
  1229. * {
  1230. * group:string //组件所在的组。
  1231. * scale:number //组件的缩放值。
  1232. * }
  1233. */
  1234. Utils.prototype.showRecommendGamesBanner = function (params) {
  1235. if (params === void 0) { params = null; }
  1236. if (!this._isConfigInit) {
  1237. exports.utils.showLog("warn:" + "组件配置未初始化!");
  1238. return false;
  1239. }
  1240. if (this.isShowRecommondGamesBanner()) {
  1241. exports.utils.showLog("显示自定义banner!");
  1242. if (this.config.otherconfig.recommendGamesBanner) {
  1243. var bannerNode = cc.instantiate(this.config.otherconfig.recommendGamesBanner);
  1244. if (bannerNode) {
  1245. if (this._recommendGamesBanner && cc.isValid(this._recommendGamesBanner)) {
  1246. this._recommendGamesBanner.destroy();
  1247. }
  1248. this._recommendGamesBanner = bannerNode;
  1249. this._recommendGamesBanner.zIndex = 9999;
  1250. if (params) {
  1251. if (params.group) {
  1252. bannerNode.group = params.group;
  1253. }
  1254. if (params.scale) {
  1255. bannerNode.scale = params.scale;
  1256. }
  1257. }
  1258. cc.director.getScene().addChild(bannerNode, 1000);
  1259. return true;
  1260. }
  1261. }
  1262. else {
  1263. exports.utils.showLog("warn:" + "未找到预制体 RecommendGamesBanner, 请查看CommonUtils组件上是否赋值!");
  1264. }
  1265. }
  1266. return false;
  1267. };
  1268. /**
  1269. * 隐藏底部推荐游戏Banner
  1270. */
  1271. Utils.prototype.hideRecommendGamesBanner = function () {
  1272. var banner = cc.find("RecommendGamesBanner");
  1273. if (banner) {
  1274. banner.active = false;
  1275. }
  1276. };
  1277. /**
  1278. * 是否显示推荐游戏列表
  1279. */
  1280. Utils.prototype.isShowRecommondGamesList = function () {
  1281. if (!this._isConfigInit) {
  1282. exports.utils.showLog("warn:" + "组件配置未初始化!");
  1283. return false;
  1284. }
  1285. if (this.Tool_Broswer)
  1286. return true;
  1287. if (exports.utils.isSupportnavigateToMiniGame()) {
  1288. if (this.ServerConfig.is_banner_list
  1289. && this.ServerConfig.is_banner_list == "true"
  1290. && this.ServerConfig.jump_list
  1291. && this.ServerConfig.jump_list.length > 0) {
  1292. return true;
  1293. }
  1294. else {
  1295. exports.utils.showLog("请确认字段:is_banner_list、jump_list 是否达到显示自定义banner的要求!");
  1296. return false;
  1297. }
  1298. }
  1299. else {
  1300. exports.utils.showLog("当前平台不支持游戏内跳转,更多游戏列表组件不显示!");
  1301. }
  1302. return false;
  1303. };
  1304. /**
  1305. * 显示互推滚动条
  1306. * @param params
  1307. * ```
  1308. * {
  1309. * group:string // 组件所在的组
  1310. * bottom:number // 组件距离屏幕下边的距离
  1311. * left:number // 组件距离屏幕左边的距离
  1312. * scale:number // 组件的缩放比例
  1313. * parent:cc.Node // 父节点,注意:如果不传此参数,则必须接收返回值,并将其加入到父节点中,否则组件不会显示。
  1314. * }
  1315. * ```
  1316. */
  1317. Utils.prototype.showRecommendGamesList = function (params) {
  1318. if (params === void 0) { params = null; }
  1319. if (!this._isConfigInit) {
  1320. exports.utils.showLog("warn:" + "组件配置未初始化!");
  1321. return null;
  1322. }
  1323. if (this.config.otherconfig.recommendGamesBar) {
  1324. var barNode = cc.instantiate(this.config.otherconfig.recommendGamesBar);
  1325. if (barNode) {
  1326. if (this._recommendGamesList && cc.isValid(this._recommendGamesList)) {
  1327. this._recommendGamesList.destroy();
  1328. }
  1329. this._recommendGamesList = barNode;
  1330. this._recommendGamesList.zIndex = 9999;
  1331. var widget = barNode.getComponent(cc.Widget);
  1332. if (params) {
  1333. if (params.group) {
  1334. barNode.group = params.group;
  1335. }
  1336. if (params.scale != null) {
  1337. barNode.scale = params.scale;
  1338. }
  1339. if (params.top != null) {
  1340. widget.isAlignTop = true;
  1341. widget.isAlignBottom = false;
  1342. widget.top = params.top;
  1343. }
  1344. else if (params.bottom != null) {
  1345. widget.isAlignTop = false;
  1346. widget.isAlignBottom = true;
  1347. widget.bottom = params.bottom;
  1348. }
  1349. if (params.left != null) {
  1350. widget.isAlignLeft = true;
  1351. widget.isAlignRight = false;
  1352. widget.left = params.left;
  1353. }
  1354. else if (params.right != null) {
  1355. widget.isAlignLeft = false;
  1356. widget.isAlignRight = true;
  1357. widget.right = params.right;
  1358. }
  1359. if (params.parent != null) {
  1360. barNode.parent = params.parent;
  1361. }
  1362. }
  1363. widget.updateAlignment();
  1364. return barNode;
  1365. }
  1366. }
  1367. else {
  1368. exports.utils.showLog("warn:" + "未找到预制体 RecommendGamesBar, 请查看CommonUtils组件上是否赋值 !");
  1369. }
  1370. return null;
  1371. };
  1372. /**
  1373. * 隐藏互推滚动条
  1374. * @param _tryGamesWidget 更多游戏挂件
  1375. */
  1376. Utils.prototype.hideRecommendGamesList = function () {
  1377. if (this._recommendGamesList && cc.isValid(this._recommendGamesList)) {
  1378. this._recommendGamesList.destroy();
  1379. }
  1380. };
  1381. /**
  1382. * 是否显示试玩挂件
  1383. */
  1384. Utils.prototype.isShowTryGamesWidget = function () {
  1385. if (!this._isConfigInit) {
  1386. exports.utils.showLog("warn:" + "组件配置未初始化!");
  1387. return false;
  1388. }
  1389. if (this.Tool_Broswer)
  1390. return true;
  1391. if (PlatUtils_1.default.IsWechat) {
  1392. if (exports.utils.isSupportnavigateToMiniGame()) {
  1393. if (exports.utils.wechatTool
  1394. && exports.utils.wechatTool.ServerConfig
  1395. && exports.utils.wechatTool.ServerConfig.icon_jump) {
  1396. if (exports.utils.wechatTool.ServerConfig.icon_jump > 0) {
  1397. return true;
  1398. }
  1399. else {
  1400. exports.utils.showLog("warn:" + "icon_jump参数为false,试玩游戏挂件不显示!");
  1401. }
  1402. }
  1403. else {
  1404. exports.utils.showLog("warn:" + "配置中没有icon_jump参数,试玩游戏挂件不显示!");
  1405. }
  1406. }
  1407. else {
  1408. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,试玩游戏挂件不显示!");
  1409. }
  1410. }
  1411. else if (PlatUtils_1.default.IsOPPO) {
  1412. if (exports.utils.isSupportnavigateToMiniGame()) {
  1413. if (exports.utils.oppoTool
  1414. && exports.utils.oppoTool.ServerConfig
  1415. && exports.utils.oppoTool.ServerConfig.icon_jump) {
  1416. if (parseInt(exports.utils.oppoTool.ServerConfig.icon_jump) > 0) {
  1417. return true;
  1418. }
  1419. else {
  1420. exports.utils.showLog("warn:" + "icon_jump参数为false,试玩戏挂件不显示!");
  1421. }
  1422. }
  1423. else {
  1424. exports.utils.showLog("warn:" + "配置中没有icon_jump参数,试玩游戏挂件不显示!");
  1425. }
  1426. }
  1427. else {
  1428. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,试玩游戏挂件不显示!");
  1429. }
  1430. }
  1431. else if (PlatUtils_1.default.IsBaidu) {
  1432. if (exports.utils.isSupportnavigateToMiniGame()) {
  1433. if (exports.utils.Tool_Baidu
  1434. && exports.utils.Tool_Baidu.ServerConfig
  1435. && exports.utils.Tool_Baidu.ServerConfig.icon_jump) {
  1436. if (exports.utils.Tool_Baidu.ServerConfig.icon_jump > 0) {
  1437. return true;
  1438. }
  1439. else {
  1440. exports.utils.showLog("warn:" + "icon_jump参数为false,更多游戏挂件不显示!");
  1441. }
  1442. }
  1443. else {
  1444. exports.utils.showLog("warn:" + "配置中没有icon_jump参数,试玩游戏挂件不显示!");
  1445. }
  1446. }
  1447. else {
  1448. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,试玩游戏挂件不显示!");
  1449. }
  1450. }
  1451. else if (PlatUtils_1.default.IsNativeAndroid) {
  1452. if (exports.utils.Tool_Native
  1453. && exports.utils.Tool_Native.ServerConfig
  1454. && exports.utils.Tool_Native.ServerConfig.icon_jump) {
  1455. if (parseInt(exports.utils.Tool_Native.ServerConfig.icon_jump) > 0) {
  1456. return true;
  1457. }
  1458. }
  1459. else {
  1460. exports.utils.showLog("warn:" + "配置中没有jumpList参数,试玩游戏挂件不显示!");
  1461. }
  1462. }
  1463. else if (PlatUtils_1.default.IsDouyin) {
  1464. if (exports.utils.isSupportnavigateToMiniGame()) {
  1465. if (exports.utils.Tool_Douyin && exports.utils.Tool_Douyin.isShowMoreGamesModal()
  1466. && exports.utils.Tool_Douyin.ServerConfig
  1467. && exports.utils.Tool_Douyin.ServerConfig.icon_jump) {
  1468. if (exports.utils.Tool_Douyin.ServerConfig.icon_jump > 0) {
  1469. return true;
  1470. }
  1471. else {
  1472. exports.utils.showLog("warn:" + "icon_jump参数为false,试玩游戏挂件不显示!");
  1473. }
  1474. }
  1475. else {
  1476. exports.utils.showLog("warn:" + "配置中没有icon_jump参数,试玩游戏挂件不显示!");
  1477. }
  1478. }
  1479. else {
  1480. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,试玩游戏挂件不显示!");
  1481. }
  1482. }
  1483. else if (PlatUtils_1.default.IsQQ) {
  1484. if (exports.utils.isSupportnavigateToMiniGame()) {
  1485. if (exports.utils.Tool_QQ
  1486. && exports.utils.Tool_QQ.ServerConfig
  1487. && exports.utils.Tool_QQ.ServerConfig.icon_jump) {
  1488. if (exports.utils.Tool_QQ.ServerConfig.icon_jump > 0) {
  1489. return true;
  1490. }
  1491. else {
  1492. exports.utils.showLog("warn:" + "icon_jump参数为false,试玩游戏挂件不显示!");
  1493. }
  1494. }
  1495. else {
  1496. exports.utils.showLog("warn:" + "配置中没有icon_jump参数,试玩游戏挂件不显示!");
  1497. }
  1498. }
  1499. else {
  1500. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,试玩游戏挂件不显示!");
  1501. }
  1502. }
  1503. else if (PlatUtils_1.default.IsNativeIOS) {
  1504. if (exports.utils.Tool_IOS
  1505. && exports.utils.Tool_IOS.ServerConfig
  1506. && exports.utils.Tool_IOS.ServerConfig.icon_jump) {
  1507. if (exports.utils.Tool_IOS.ServerConfig.icon_jump > 0) {
  1508. return true;
  1509. }
  1510. else {
  1511. exports.utils.showLog("warn:" + "icon_jump参数为false,试玩游戏挂件不显示!");
  1512. }
  1513. }
  1514. else {
  1515. exports.utils.showLog("warn:" + "配置中没有icon_jump参数,试玩游戏挂件不显示!");
  1516. }
  1517. }
  1518. return false;
  1519. };
  1520. /**
  1521. * 显示试玩挂件
  1522. * @param params
  1523. * ```
  1524. * {
  1525. * group:string
  1526. * left:number
  1527. * bottom:number
  1528. * scale:number
  1529. * parent:cc.Node
  1530. * }
  1531. * ```
  1532. * @returns 生成的组件
  1533. */
  1534. Utils.prototype.showTryGamesWidget = function (params) {
  1535. if (params === void 0) { params = null; }
  1536. if (!this._isConfigInit) {
  1537. exports.utils.showLog("warn:" + "组件配置未初始化!");
  1538. return null;
  1539. }
  1540. if (exports.utils.isShowTryGamesWidget()) {
  1541. if (params.location && (this.getConfigByKey("try_game_widget_locations").indexOf(params.location) < 0)) {
  1542. exports.utils.showLog("当前位置服务器未配置显示试玩挂件!");
  1543. if (this._tryGamesWidget && cc.isValid(this._tryGamesWidget)) {
  1544. this._tryGamesWidget.destroy();
  1545. }
  1546. return null;
  1547. }
  1548. if (this.config.otherconfig.tryGamesWidget) {
  1549. var node = cc.instantiate(this.config.otherconfig.tryGamesWidget);
  1550. if (node) {
  1551. if (this._tryGamesWidget && cc.isValid(this._tryGamesWidget)) {
  1552. this._tryGamesWidget.destroy();
  1553. }
  1554. this._tryGamesWidget = node;
  1555. this._tryGamesWidget.zIndex = 9999;
  1556. var widget = node.getComponent(cc.Widget);
  1557. if (params) {
  1558. if (params.group) {
  1559. node.group = params.group;
  1560. }
  1561. if (params.scale != null) {
  1562. node.scale = params.scale;
  1563. }
  1564. if (params.top != null) {
  1565. widget.isAlignTop = true;
  1566. widget.isAlignBottom = false;
  1567. widget.top = params.top;
  1568. }
  1569. else if (params.bottom != null) {
  1570. widget.isAlignTop = false;
  1571. widget.isAlignBottom = true;
  1572. widget.bottom = params.bottom;
  1573. }
  1574. if (params.left != null) {
  1575. widget.isAlignLeft = true;
  1576. widget.isAlignRight = false;
  1577. widget.left = params.left;
  1578. }
  1579. else if (params.right != null) {
  1580. widget.isAlignLeft = false;
  1581. widget.isAlignRight = true;
  1582. widget.right = params.right;
  1583. }
  1584. if (params.parent != null) {
  1585. node.parent = params.parent;
  1586. }
  1587. }
  1588. widget.updateAlignment();
  1589. return node;
  1590. }
  1591. }
  1592. else {
  1593. exports.utils.showLog("warn:" + "未找到预制体 TryGamesWidget, 请查看CommonUtils组件上是否赋值 !");
  1594. }
  1595. }
  1596. else {
  1597. exports.utils.showLog("warn:" + "不支持跳转组件");
  1598. }
  1599. return null;
  1600. };
  1601. /**
  1602. * 隐藏更多游戏挂件
  1603. * @param _tryGamesWidget 更多游戏挂件
  1604. */
  1605. Utils.prototype.hideTryGamesWidget = function () {
  1606. if (this._tryGamesWidget && cc.isValid(this._tryGamesWidget)) {
  1607. this._tryGamesWidget.destroy();
  1608. }
  1609. };
  1610. /**
  1611. * 是否显示更多游戏侧边栏
  1612. */
  1613. Utils.prototype.isShowMoreGamesWidget = function () {
  1614. if (!this._isConfigInit) {
  1615. exports.utils.showLog("warn:" + "组件配置未初始化!");
  1616. return false;
  1617. }
  1618. if (this.Tool_Broswer || CC_DEBUG)
  1619. return true;
  1620. if (PlatUtils_1.default.IsWechat) {
  1621. if (exports.utils.isSupportnavigateToMiniGame()) {
  1622. if (this.getConfigByKey("is_more_game") == "true") {
  1623. return true;
  1624. }
  1625. else {
  1626. exports.utils.showLog("warn:" + "配置中没有is_more_game参数,更多游戏侧边栏组件不显示!");
  1627. }
  1628. }
  1629. else {
  1630. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,更多游戏侧边栏组件不显示!");
  1631. }
  1632. }
  1633. else if (PlatUtils_1.default.IsOPPO) {
  1634. if (exports.utils.isSupportnavigateToMiniGame()) {
  1635. if (this.getConfigByKey("is_more_game") == "true") {
  1636. if (exports.utils.oppoTool.ServerConfig.show_oppo_rec == "true") {
  1637. if (!exports.utils.oppoTool.canShowRecommend()) {
  1638. exports.utils.showLog("warn:" + "当前平台不支持官方互推,更多游戏侧边栏组件不显示!");
  1639. return false;
  1640. }
  1641. }
  1642. return true;
  1643. }
  1644. else {
  1645. exports.utils.showLog("warn:" + "配置中没有is_more_game参数,更多游戏侧边栏组件不显示!");
  1646. }
  1647. }
  1648. else {
  1649. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,更多游戏侧边栏组件不显示!");
  1650. }
  1651. }
  1652. else if (PlatUtils_1.default.IsDouyin) {
  1653. if (PlatUtils_1.default.IsAndroid
  1654. && exports.utils.isSupportnavigateToMiniGame()) {
  1655. if (this.getConfigByKey("is_more_game") == "true") {
  1656. return true;
  1657. }
  1658. else {
  1659. exports.utils.showLog("warn:" + "配置中没有is_more_game参数,更多游戏侧边栏组件不显示!");
  1660. }
  1661. }
  1662. else {
  1663. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,更多游戏侧边栏组件不显示!");
  1664. }
  1665. }
  1666. else if (PlatUtils_1.default.IsBaidu) {
  1667. if (exports.utils.isSupportnavigateToMiniGame()) {
  1668. if (this.getConfigByKey("is_more_game") == "true") {
  1669. return true;
  1670. }
  1671. else {
  1672. exports.utils.showLog("warn:" + "配置中没有is_more_game参数,更多游戏侧边栏组件不显示!");
  1673. }
  1674. }
  1675. else {
  1676. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,更多游戏侧边栏组件不显示!");
  1677. }
  1678. }
  1679. else if (PlatUtils_1.default.IsQQ) {
  1680. if (exports.utils.isSupportnavigateToMiniGame()) {
  1681. if (this.getConfigByKey("is_more_game") == "true") {
  1682. return true;
  1683. }
  1684. else {
  1685. exports.utils.showLog("warn:" + "配置中没有is_more_game参数,更多游戏侧边栏组件不显示!");
  1686. }
  1687. }
  1688. else {
  1689. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,更多游戏侧边栏组件不显示!");
  1690. }
  1691. }
  1692. else if (PlatUtils_1.default.Is4399) {
  1693. return true;
  1694. }
  1695. else if (PlatUtils_1.default.IsNativeAndroid) {
  1696. if (this.getConfigByKey("is_more_game") == "true") {
  1697. return true;
  1698. }
  1699. else {
  1700. exports.utils.showLog("warn:" + "配置中没有is_more_game参数,更多游戏侧边栏组件不显示!");
  1701. }
  1702. }
  1703. else if (PlatUtils_1.default.IsNativeIOS) {
  1704. if (this.getConfigByKey("is_more_game") == "true") {
  1705. return true;
  1706. }
  1707. else {
  1708. exports.utils.showLog("warn:" + "配置中没有is_more_game参数,更多游戏侧边栏组件不显示!");
  1709. }
  1710. }
  1711. else if (PlatUtils_1.default.IsVIVO) {
  1712. if (this.getConfigByKey("is_more_game") == "true") {
  1713. return true;
  1714. }
  1715. else {
  1716. exports.utils.showLog("warn:" + "配置中没有is_more_game参数,更多游戏侧边栏组件不显示!");
  1717. }
  1718. }
  1719. return false;
  1720. };
  1721. /**
  1722. * 显示更多游戏侧边栏
  1723. * @param params
  1724. * ```
  1725. * {
  1726. * group:string // 组件所在的组
  1727. * left:number // 组件距离屏幕左边的距离
  1728. * right:number // 组件距离屏幕右边的距离
  1729. * top:number // 距离屏幕顶部的距离
  1730. * bottom:number // 距离屏幕底部的距离
  1731. * scale:number // 缩放比例
  1732. * parent:cc.Node // 父节点
  1733. * }
  1734. * ```
  1735. */
  1736. Utils.prototype.showMoreGamesWidget = function (params) {
  1737. if (params === void 0) { params = null; }
  1738. if (!this._isConfigInit) {
  1739. exports.utils.showLog("warn:" + "组件配置未初始化!");
  1740. return null;
  1741. }
  1742. if (params.location && (this.getConfigByKey("more_game_widget_locations").indexOf(params.location) < 0)) {
  1743. exports.utils.showLog("当前位置服务器未配置显示更多游戏挂件!");
  1744. if (this._moreGamesSidePanel && cc.isValid(this._moreGamesSidePanel)) {
  1745. this._moreGamesSidePanel.destroy();
  1746. }
  1747. return null;
  1748. }
  1749. if (PlatUtils_1.default.IsDouyin) {
  1750. if (exports.utils.Tool_Douyin) {
  1751. if (exports.utils.isShowMoreGamesWidget()) {
  1752. if (exports.utils.Tool_Douyin.isShowMoreGamesModal()) {
  1753. if (this.config.otherconfig.moreGamesWidget) {
  1754. var node = cc.instantiate(this.config.otherconfig.moreGamesWidget);
  1755. if (node) {
  1756. if (this._moreGamesSidePanel && cc.isValid(this._moreGamesSidePanel)) {
  1757. this._moreGamesSidePanel.destroy();
  1758. }
  1759. this._moreGamesSidePanel = node;
  1760. this._moreGamesSidePanel.zIndex = 9999;
  1761. var widget = node.getComponent(cc.Widget);
  1762. if (params) {
  1763. if (params.group) {
  1764. node.group = params.group;
  1765. }
  1766. if (params.scale != null) {
  1767. node.scale = params.scale;
  1768. }
  1769. if (params.top != null) {
  1770. widget.isAlignTop = true;
  1771. widget.isAlignBottom = false;
  1772. widget.top = params.top;
  1773. }
  1774. else if (params.bottom != null) {
  1775. widget.isAlignTop = false;
  1776. widget.isAlignBottom = true;
  1777. widget.bottom = params.bottom;
  1778. }
  1779. if (params.left != null) {
  1780. widget.isAlignLeft = true;
  1781. widget.isAlignRight = false;
  1782. widget.left = params.left;
  1783. }
  1784. else if (params.right != null) {
  1785. widget.isAlignLeft = false;
  1786. widget.isAlignRight = true;
  1787. widget.right = params.right;
  1788. }
  1789. if (params.parent != null) {
  1790. node.parent = params.parent;
  1791. }
  1792. }
  1793. widget.updateAlignment();
  1794. return node;
  1795. }
  1796. }
  1797. else {
  1798. exports.utils.showLog("warn:" + "未找到预制体 MoreGamesWidget, 请查看CommonUtils组件上是否赋值!");
  1799. }
  1800. }
  1801. else {
  1802. var btn = exports.utils.Tool_Douyin.showMoreGamesButton(params);
  1803. if (btn) {
  1804. if (this._moreGamesSidePanel) {
  1805. this._moreGamesSidePanel.destroy();
  1806. }
  1807. this._moreGamesSidePanel = btn;
  1808. if (params) {
  1809. if (params.group) {
  1810. btn.group = params.group;
  1811. }
  1812. if (params.parent != null) {
  1813. btn.parent = params.parent;
  1814. }
  1815. }
  1816. return this._moreGamesSidePanel;
  1817. }
  1818. else {
  1819. return null;
  1820. }
  1821. }
  1822. }
  1823. else {
  1824. exports.utils.showLog("当前平台版本不支持交叉推广, 更多游戏按钮不显示!");
  1825. return null;
  1826. }
  1827. }
  1828. }
  1829. else {
  1830. if (exports.utils.isShowMoreGamesWidget()) {
  1831. if (this.config.otherconfig.moreGamesWidget) {
  1832. var node = cc.instantiate(this.config.otherconfig.moreGamesWidget);
  1833. if (node) {
  1834. if (this._moreGamesSidePanel && cc.isValid(this._moreGamesSidePanel)) {
  1835. this._moreGamesSidePanel.destroy();
  1836. }
  1837. this._moreGamesSidePanel = node;
  1838. this._moreGamesSidePanel.zIndex = 9999;
  1839. var widget = node.getComponent(cc.Widget);
  1840. if (params) {
  1841. if (params.group) {
  1842. node.group = params.group;
  1843. }
  1844. if (params.scale != null) {
  1845. node.scale = params.scale;
  1846. }
  1847. if (params.top != null) {
  1848. widget.isAlignTop = true;
  1849. widget.isAlignBottom = false;
  1850. widget.top = params.top;
  1851. }
  1852. else if (params.bottom != null) {
  1853. widget.isAlignTop = false;
  1854. widget.isAlignBottom = true;
  1855. widget.bottom = params.bottom;
  1856. }
  1857. if (params.left != null) {
  1858. widget.isAlignLeft = true;
  1859. widget.isAlignRight = false;
  1860. widget.left = params.left;
  1861. }
  1862. else if (params.right != null) {
  1863. widget.isAlignLeft = false;
  1864. widget.isAlignRight = true;
  1865. widget.right = params.right;
  1866. }
  1867. if (params.parent != null) {
  1868. node.parent = params.parent;
  1869. }
  1870. }
  1871. widget.updateAlignment();
  1872. return node;
  1873. }
  1874. }
  1875. else {
  1876. exports.utils.showLog("warn:" + "未找到预制体 MoreGamesWidget, 请查看CommonUtils组件上是否赋值!");
  1877. }
  1878. }
  1879. else {
  1880. exports.utils.showLog("warn:" + "不可显示更多游戏侧边栏");
  1881. }
  1882. }
  1883. return null;
  1884. };
  1885. /**
  1886. * 隐藏侧边栏按钮
  1887. * @param moreGameBtn 更多游戏侧边栏按钮
  1888. */
  1889. Utils.prototype.hideMoreGamesWidget = function (moreGameBtn) {
  1890. if (PlatUtils_1.default.IsDouyin) {
  1891. if (moreGameBtn && cc.isValid(moreGameBtn)) {
  1892. moreGameBtn.destroy();
  1893. }
  1894. if (this._moreGamesSidePanel) {
  1895. this._moreGamesSidePanel.destroy();
  1896. }
  1897. }
  1898. else {
  1899. if (moreGameBtn && cc.isValid(moreGameBtn)) {
  1900. moreGameBtn.destroy();
  1901. }
  1902. if (this._moreGamesSidePanel && cc.isValid(this._moreGamesSidePanel)) {
  1903. this._moreGamesSidePanel.destroy();
  1904. }
  1905. }
  1906. if (PlatUtils_1.default.IsVIVO) {
  1907. this.Tool_Vivo && this.Tool_Vivo.hideGamePortal();
  1908. }
  1909. };
  1910. Utils.prototype.showBaiduMoreGamesBtn = function (params) {
  1911. if (params === void 0) { params = null; }
  1912. if (!this._isConfigInit) {
  1913. exports.utils.showLog("warn:" + "组件配置未初始化!");
  1914. return null;
  1915. }
  1916. var isShow = false;
  1917. if (PlatUtils_1.default.IsBaidu) {
  1918. if (exports.utils.Tool_Baidu
  1919. && exports.utils.Tool_Baidu.canShowRecommendButton()) {
  1920. isShow = true;
  1921. }
  1922. else {
  1923. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,百度更多游戏侧边栏组件不显示!");
  1924. }
  1925. }
  1926. if (PlatUtils_1.default.IsBaidu) {
  1927. if (exports.utils.Tool_Baidu) {
  1928. if (isShow) {
  1929. var btn = exports.utils.Tool_Baidu.showRecommendationButton(params);
  1930. if (btn) {
  1931. if (this._moreGamesSidePanelBaidu) {
  1932. this._moreGamesSidePanelBaidu.destroy();
  1933. }
  1934. this._moreGamesSidePanelBaidu = btn;
  1935. return this._moreGamesSidePanelBaidu;
  1936. }
  1937. else {
  1938. return null;
  1939. }
  1940. }
  1941. else {
  1942. exports.utils.showLog("当前平台版本不支持交叉推广, 百度更多游戏按钮不显示!");
  1943. return null;
  1944. }
  1945. }
  1946. }
  1947. };
  1948. Utils.prototype.hideBaiduMoreGamesBtn = function (moreGameBtn) {
  1949. if (PlatUtils_1.default.IsBaidu && moreGameBtn) {
  1950. if (moreGameBtn != null) {
  1951. moreGameBtn.destroy();
  1952. }
  1953. }
  1954. };
  1955. /**
  1956. * 是否显示录屏组件
  1957. */
  1958. Utils.prototype.isShowRecordWidget = function () {
  1959. if (!this._isConfigInit) {
  1960. exports.utils.showLog("warn:" + "组件配置未初始化!");
  1961. return false;
  1962. }
  1963. if (this.Tool_Broswer)
  1964. return true;
  1965. if (PlatUtils_1.default.IsDouyin) {
  1966. if (this.getConfigByKey("show_record") == "true") {
  1967. return true;
  1968. }
  1969. exports.utils.showLog("服务器配置不显示录屏按钮!");
  1970. }
  1971. else if (PlatUtils_1.default.IsKwai) {
  1972. if (exports.utils.kwaiTool && exports.utils.kwaiTool.checkCanShowRecored() && this.getConfigByKey("show_record") == "true") {
  1973. return true;
  1974. }
  1975. exports.utils.showLog("服务器配置不显示录屏按钮!");
  1976. }
  1977. return false;
  1978. };
  1979. Utils.prototype.hideRecordWidget = function () {
  1980. if (this._recordWidget && cc.isValid(this._recordWidget)) {
  1981. this._recordWidget.destroy();
  1982. }
  1983. };
  1984. /**
  1985. * 显示录屏按钮
  1986. * @param params
  1987. */
  1988. Utils.prototype.showRecordWidget = function (params) {
  1989. if (params === void 0) { params = null; }
  1990. if (!this._isConfigInit) {
  1991. exports.utils.showLog("warn:" + "组件配置未初始化!");
  1992. return null;
  1993. }
  1994. if (!this.isShowRecordWidget())
  1995. return null;
  1996. if (this.config.otherconfig.recordWidget) {
  1997. var node = cc.instantiate(this.config.otherconfig.recordWidget);
  1998. if (node) {
  1999. if (this._recordWidget && cc.isValid(this._recordWidget)) {
  2000. this._recordWidget.destroy();
  2001. }
  2002. this._recordWidget = node;
  2003. this._recordWidget.zIndex = 9999;
  2004. var widget = node.getComponent(cc.Widget);
  2005. if (params) {
  2006. if (params.group) {
  2007. node.group = params.group;
  2008. }
  2009. if (params.scale != null) {
  2010. node.scale = params.scale;
  2011. }
  2012. if (params.top != null) {
  2013. widget.isAlignTop = true;
  2014. widget.isAlignBottom = false;
  2015. widget.top = params.top;
  2016. }
  2017. else if (params.bottom != null) {
  2018. widget.isAlignTop = false;
  2019. widget.isAlignBottom = true;
  2020. widget.bottom = params.bottom;
  2021. }
  2022. if (params.left != null) {
  2023. widget.isAlignLeft = true;
  2024. widget.isAlignRight = false;
  2025. widget.left = params.left;
  2026. }
  2027. else if (params.right != null) {
  2028. widget.isAlignLeft = false;
  2029. widget.isAlignRight = true;
  2030. widget.right = params.right;
  2031. }
  2032. if (params.parent != null) {
  2033. node.parent = params.parent;
  2034. }
  2035. }
  2036. widget.updateAlignment();
  2037. return node;
  2038. }
  2039. }
  2040. else {
  2041. exports.utils.showLog("warn:" + "未找到预制体 RecordWidget, 请查看CommonUtils组件上是否赋值!");
  2042. }
  2043. return null;
  2044. };
  2045. /**
  2046. * 是否显示创建快捷方式控件
  2047. */
  2048. Utils.prototype.isShowCreateShortcutWidget = function () {
  2049. if (!this._isConfigInit) {
  2050. exports.utils.showLog("warn:" + "本地数据未初始化!");
  2051. return false;
  2052. }
  2053. if (this.Tool_Broswer)
  2054. return true;
  2055. if (this.canCreateShortcut()) {
  2056. if (this.getConfigByKey("is_desktop") == "true") {
  2057. return true;
  2058. }
  2059. else {
  2060. exports.utils.showLog("配置数据中没有 is_desktop 字段, 创建快捷方式按钮不显示!");
  2061. }
  2062. }
  2063. else {
  2064. exports.utils.showLog("当前平台版本不支持创建桌面快捷方式, 创建快捷方式按钮不显示!");
  2065. }
  2066. return false;
  2067. };
  2068. /**
  2069. * 创建快捷方式
  2070. * @param callback 点击创建快捷方式按钮后回调函数 Function<ret:boolean>
  2071. * @param params
  2072. */
  2073. Utils.prototype.showCreateShortcutWidget = function (callback, params) {
  2074. if (callback === void 0) { callback = null; }
  2075. if (params === void 0) { params = null; }
  2076. if (!this._isConfigInit) {
  2077. exports.utils.showLog("warn:" + "组件配置未初始化!");
  2078. return null;
  2079. }
  2080. if (exports.utils.isShowCreateShortcutWidget()) {
  2081. if (this.config.otherconfig.shortcutWidget) {
  2082. var node = cc.instantiate(this.config.otherconfig.shortcutWidget);
  2083. if (node) {
  2084. if (this._shortcutWidget && cc.isValid(this._shortcutWidget)) {
  2085. this._shortcutWidget.destroy();
  2086. }
  2087. this._shortcutWidget = node;
  2088. this._shortcutWidget.zIndex = 9999;
  2089. var widget = node.getComponent(cc.Widget);
  2090. var shortcutWidget = node.getComponent("YZ_ShortcutWidget");
  2091. if (shortcutWidget) {
  2092. shortcutWidget.Callback = callback;
  2093. }
  2094. if (params) {
  2095. if (params.group) {
  2096. node.group = params.group;
  2097. }
  2098. if (params.scale != null) {
  2099. node.scale = params.scale;
  2100. }
  2101. if (params.top != null) {
  2102. widget.isAlignTop = true;
  2103. widget.isAlignBottom = false;
  2104. widget.top = params.top;
  2105. }
  2106. else if (params.bottom != null) {
  2107. widget.isAlignTop = false;
  2108. widget.isAlignBottom = true;
  2109. widget.bottom = params.bottom;
  2110. }
  2111. if (params.left != null) {
  2112. widget.isAlignLeft = true;
  2113. widget.isAlignRight = false;
  2114. widget.left = params.left;
  2115. }
  2116. else if (params.right != null) {
  2117. widget.isAlignLeft = false;
  2118. widget.isAlignRight = true;
  2119. widget.right = params.right;
  2120. }
  2121. if (params.parent != null) {
  2122. node.parent = params.parent;
  2123. }
  2124. else {
  2125. cc.director.getScene().addChild(node, 1000);
  2126. }
  2127. }
  2128. widget.updateAlignment();
  2129. return node;
  2130. }
  2131. }
  2132. else {
  2133. exports.utils.showLog("warn:" + "未找到预制体 ShortcutWidge, 请查看CommonUtils组件上是否赋值!");
  2134. }
  2135. }
  2136. else {
  2137. exports.utils.showLog("warn:" + "不显示创建桌面图标");
  2138. }
  2139. return null;
  2140. };
  2141. /**
  2142. * 隐藏快捷方式
  2143. */
  2144. Utils.prototype.hideCreateShortcutWidget = function (params) {
  2145. if (params === void 0) { params = null; }
  2146. if (this._shortcutWidget && cc.isValid(this._shortcutWidget)) {
  2147. this._shortcutWidget.destroy();
  2148. }
  2149. };
  2150. /**
  2151. * 注册事件,事件在YZ_Constant类中定义
  2152. * @param eventName : string 事件名 事件在 YZ_Constant 类中定义
  2153. * @param callback 回调函数
  2154. * @param target : cc.Node 目标对象
  2155. */
  2156. Utils.prototype.registerEvent = function (eventName, callback, target) {
  2157. if (!eventName) {
  2158. exports.utils.showLog("warn:" + "[Utils.registerEvent] param eventName is null!");
  2159. return;
  2160. }
  2161. if (!callback) {
  2162. exports.utils.showLog("warn:" + "[Utils.registerEvent] param callback is null!");
  2163. return;
  2164. }
  2165. if (!target) {
  2166. exports.utils.showLog("warn:" + "[Utils.registerEvent] param target is null!");
  2167. return;
  2168. }
  2169. cc.game.on(eventName, callback, target);
  2170. };
  2171. /**
  2172. * 取消注册事件
  2173. * @param eventName 事件名
  2174. */
  2175. Utils.prototype.unregisterEvent = function (eventName) {
  2176. cc.game.off(eventName);
  2177. };
  2178. /**
  2179. * 发送事件
  2180. * @param eventName 事件名
  2181. */
  2182. Utils.prototype.emitCommonEvent = function (eventName) {
  2183. cc.game.emit(eventName);
  2184. };
  2185. /**
  2186. * 显示游戏盒子
  2187. * @param params
  2188. */
  2189. Utils.prototype.showGameBox = function (params) {
  2190. if (params === void 0) { params = null; }
  2191. if (PlatUtils_1.default.IsWechat) {
  2192. var isShow = false;
  2193. // console.log("utils.wechatTool.ServerConfig.openBox",utils.wechatTool.ServerConfig.openBox)
  2194. if (exports.utils.wechatTool.ServerConfig && exports.utils.wechatTool.ServerConfig.openBox) {
  2195. if (exports.utils.wechatTool.ServerConfig.openBox != "true") {
  2196. exports.utils.showLog("服务器游戏盒子配置为关闭状态!");
  2197. return;
  2198. }
  2199. exports.utils.showLog("服务器配置游戏盒子为打开状态");
  2200. isShow = true;
  2201. }
  2202. else {
  2203. var showTime = new Date().getTime() - new Date("2019-10-23").getTime();
  2204. if (showTime > 0) {
  2205. isShow = true;
  2206. exports.utils.showLog("当前时间大于指定时间,可以显示游戏盒子");
  2207. }
  2208. }
  2209. if (!isShow) {
  2210. exports.utils.showLog("warn:" + "当前条件不满足要求,游戏盒子不显示!");
  2211. return;
  2212. }
  2213. var node = cc.instantiate(this.config.otherconfig.gameBox);
  2214. if (node) {
  2215. if (this._gameBox && cc.isValid(this._gameBox)) {
  2216. this._gameBox.destroy();
  2217. }
  2218. this._gameBox = node;
  2219. this._gameBox.zIndex = 9999;
  2220. if (params.parent != null) {
  2221. node.parent = params.parent;
  2222. }
  2223. }
  2224. else {
  2225. exports.utils.showLog("warn:" + "未找到预制体 GameBox, 请查看CommonUtils组件上是否赋值!");
  2226. }
  2227. }
  2228. };
  2229. Utils.prototype.isShowNativeTryGamesWidget = function () {
  2230. if (!this._isConfigInit) {
  2231. exports.utils.showLog("warn:" + "组件配置未初始化!");
  2232. return false;
  2233. }
  2234. if (this.Tool_Broswer)
  2235. return true;
  2236. if (this.ServerConfig
  2237. && this.ServerConfig.icon_jump_native
  2238. && parseInt(this.ServerConfig.icon_jump_native) > 0) {
  2239. return true;
  2240. }
  2241. else {
  2242. exports.utils.showLog("warn:" + "配置中没有icon_jump_native参数,原生试玩游戏挂件不显示!");
  2243. }
  2244. return false;
  2245. };
  2246. /**
  2247. * 是否能显示6个元素的交叉推广组件
  2248. */
  2249. Utils.prototype.canShowCrossWidget6 = function () {
  2250. if (!this._isConfigInit) {
  2251. exports.utils.showLog("组件配置未初始化!");
  2252. return false;
  2253. }
  2254. if (this.Tool_Broswer)
  2255. return true;
  2256. if (PlatUtils_1.default.IsWechat || PlatUtils_1.default.IsOPPO || PlatUtils_1.default.IsBaidu || PlatUtils_1.default.IsNativeAndroid || PlatUtils_1.default.IsNativeIOS) {
  2257. if (exports.utils.isSupportnavigateToMiniGame()) {
  2258. if (this.getConfigByKey("is_cross_game") == "true") {
  2259. return true;
  2260. }
  2261. else {
  2262. exports.utils.showLog("warn:" + "配置中没有is_cross_game参数,6元素交叉推广组件不显示!");
  2263. }
  2264. }
  2265. else {
  2266. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,6元素交叉推广组件不显示!");
  2267. }
  2268. }
  2269. else if (PlatUtils_1.default.IsDouyin) {
  2270. if (exports.utils.isSupportnavigateToMiniGame() && exports.utils.Tool_Douyin.isShowMoreGamesModal()) {
  2271. if (this.getConfigByKey("is_cross_game") == "true") {
  2272. return true;
  2273. }
  2274. else {
  2275. exports.utils.showLog("warn:" + "is_cross_game参数为false,6元素交叉推广组件不显示!");
  2276. }
  2277. }
  2278. else {
  2279. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,6元素交叉推广组件不显示!");
  2280. }
  2281. }
  2282. return false;
  2283. };
  2284. /**
  2285. * 显示6元素交叉推广组件
  2286. */
  2287. Utils.prototype.showCrossWidget6 = function () {
  2288. if (!this._isConfigInit) {
  2289. exports.utils.showLog("warn:" + "组件配置未初始化!");
  2290. return null;
  2291. }
  2292. if (this.canShowCrossWidget6()) {
  2293. if (this.config.otherconfig.crossWidget6) {
  2294. return cc.instantiate(this.config.otherconfig.crossWidget6);
  2295. }
  2296. else {
  2297. exports.utils.showLog("warn:" + "未找到预制体 CrossWidget6, 请查看CommonUtils组件上是否赋值!");
  2298. }
  2299. }
  2300. return null;
  2301. };
  2302. /**
  2303. * 显示添加到我的小程序引导
  2304. * @param param 参数值:
  2305. * type: bar(一直展示)/tip(3秒展示)
  2306. */
  2307. Utils.prototype.showFavoriteGuide = function (param) {
  2308. if (PlatUtils_1.default.IsBaidu) {
  2309. if (exports.utils._tool_Baidu.canShowFavoriteGuide()) {
  2310. //@ts-ignore
  2311. swan.showFavoriteGuide({
  2312. type: param ? param.type : 'tip',
  2313. content: '一键添加到我的小程序',
  2314. success: function (res) {
  2315. exports.utils.showLog('添加成功:', res);
  2316. },
  2317. fail: function (err) {
  2318. exports.utils.showLog('添加失败:', err);
  2319. }
  2320. });
  2321. exports.utils.showLog("显示我的小程序引导成功!");
  2322. }
  2323. else {
  2324. exports.utils.showLog("当前平台不支持显示添加我的小程序引导");
  2325. }
  2326. }
  2327. };
  2328. /**
  2329. * 验证是否自动弹出签到
  2330. * true : 自动弹出,false : 不自动弹出
  2331. */
  2332. Utils.prototype.checkAutoSign = function () {
  2333. if (this.getConfigByKey("auto_sign") == "true") {
  2334. return true;
  2335. }
  2336. return false;
  2337. };
  2338. Object.defineProperty(Utils.prototype, "ServerConfig", {
  2339. /**
  2340. * 获取当前平台的配置文件
  2341. */
  2342. get: function () {
  2343. if (this.cur_tool) {
  2344. return this.cur_tool.ServerConfig ? this.cur_tool.ServerConfig : {};
  2345. }
  2346. return {};
  2347. },
  2348. enumerable: false,
  2349. configurable: true
  2350. });
  2351. Object.defineProperty(Utils.prototype, "cur_tool", {
  2352. /**
  2353. * 获取当前平台的配置文件
  2354. */
  2355. get: function () {
  2356. if (this._cur_tool)
  2357. return this._cur_tool;
  2358. if (PlatUtils_1.default.IsWechat) {
  2359. this._cur_tool = exports.utils.wechatTool;
  2360. }
  2361. else if (PlatUtils_1.default.IsOPPO) {
  2362. this._cur_tool = exports.utils.oppoTool;
  2363. }
  2364. else if (PlatUtils_1.default.IsVIVO) {
  2365. this._cur_tool = exports.utils.Tool_Vivo;
  2366. }
  2367. else if (PlatUtils_1.default.IsQQ) {
  2368. this._cur_tool = exports.utils.Tool_QQ;
  2369. }
  2370. else if (PlatUtils_1.default.IsDouyin) {
  2371. this._cur_tool = exports.utils.Tool_Douyin;
  2372. }
  2373. else if (PlatUtils_1.default.IsBaidu) {
  2374. this._cur_tool = exports.utils.Tool_Baidu;
  2375. }
  2376. else if (PlatUtils_1.default.IsQTT) {
  2377. this._cur_tool = exports.utils.Tool_QTT;
  2378. }
  2379. else if (PlatUtils_1.default.IsXiaoMi) {
  2380. this._cur_tool = exports.utils.Tool_XiaoMi;
  2381. }
  2382. else if (PlatUtils_1.default.ISUC) {
  2383. this._cur_tool = exports.utils.Tool_UC;
  2384. }
  2385. else if (PlatUtils_1.default.ISCocos) {
  2386. this._cur_tool = exports.utils.Tool_Cocosplay;
  2387. }
  2388. else if (PlatUtils_1.default.IsNativeAndroid) {
  2389. this._cur_tool = exports.utils.Tool_Native;
  2390. }
  2391. else if (PlatUtils_1.default.Is4399) {
  2392. this._cur_tool = exports.utils.Tool_4399;
  2393. }
  2394. else if (PlatUtils_1.default.IsKwai) {
  2395. this._cur_tool = exports.utils._tool_Kwai;
  2396. }
  2397. else if (PlatUtils_1.default.IsNativeIOS) {
  2398. this._cur_tool = exports.utils.Tool_IOS;
  2399. }
  2400. else if (PlatUtils_1.default.IsWiFi) {
  2401. this._cur_tool = exports.utils._tool_Wifi;
  2402. }
  2403. else if (PlatUtils_1.default.IsHago) {
  2404. this._cur_tool = exports.utils._tool_Hago;
  2405. }
  2406. else if (PlatUtils_1.default.IsHuaWei) {
  2407. this._cur_tool = exports.utils.Tool_Huawei;
  2408. }
  2409. else if (PlatUtils_1.default.IsFaceBook) {
  2410. this._cur_tool = exports.utils.Tool_Facebook;
  2411. }
  2412. else if (PlatUtils_1.default.IsGoogleWeb) {
  2413. this._cur_tool = exports.utils.Tool_Facebook;
  2414. }
  2415. else {
  2416. this._cur_tool = exports.utils._tool_Broswer;
  2417. }
  2418. return this._cur_tool;
  2419. },
  2420. enumerable: false,
  2421. configurable: true
  2422. });
  2423. Utils.prototype.showLog = function (msg) {
  2424. var _a;
  2425. if (msg === void 0) { msg = ""; }
  2426. var any = [];
  2427. for (var _i = 1; _i < arguments.length; _i++) {
  2428. any[_i - 1] = arguments[_i];
  2429. }
  2430. // if (true) {
  2431. // console.log(msg, ...any);
  2432. // return;
  2433. // }
  2434. if (this.showLogView || this.serverShowLog) {
  2435. if (this.config.otherconfig.logoutView) {
  2436. if (cc.director.getScene()) {
  2437. var logooutView = cc.director.getScene().getChildByName("LogoutView");
  2438. if (!logooutView) {
  2439. logooutView = cc.instantiate(this.config.otherconfig.logoutView);
  2440. cc.director.getScene().addChild(logooutView, 1000);
  2441. }
  2442. (_a = logooutView.getComponent("LogOutView")).addLog.apply(_a, __spreadArrays([msg], any));
  2443. }
  2444. }
  2445. else {
  2446. exports.utils.showLog("warn:" + "未找到预制体 LogOutView, 请查看CommonUtils组件上是否赋值!");
  2447. }
  2448. }
  2449. else {
  2450. if (this.showLogToConsole) {
  2451. console.log.apply(console, __spreadArrays([msg], any));
  2452. }
  2453. else {
  2454. cc.log.apply(cc, __spreadArrays([msg], any));
  2455. }
  2456. }
  2457. };
  2458. /**
  2459. * 屏幕震动功能
  2460. * @param type 震动类型 传递枚举:VibrateType
  2461. */
  2462. Utils.prototype.vibrate = function (type) {
  2463. if (type === void 0) { type = YZ_Constant_1.VibrateType.Short; }
  2464. if (PlatUtils_1.default.IsWechat) {
  2465. if (type == YZ_Constant_1.VibrateType.Short) {
  2466. //@ts-ignore
  2467. //使手机发生较短时间的振动(15 ms)。仅在 iPhone 7 / 7 Plus 以上及 Android 机型生效
  2468. wx.vibrateShort({ success: function (res) { }, fail: function (res) { } });
  2469. }
  2470. else {
  2471. //@ts-ignore
  2472. wx.vibrateLong({ success: function (res) { }, fail: function (res) { } }); //400 ms
  2473. }
  2474. }
  2475. else if (PlatUtils_1.default.IsOPPO) {
  2476. if (type == YZ_Constant_1.VibrateType.Short) {
  2477. //@ts-ignore
  2478. qg.vibrateShort({ success: function (res) { }, fail: function (res) { } }); //(20 ms)
  2479. }
  2480. else {
  2481. //@ts-ignore
  2482. qg.vibrateLong({ success: function (res) { }, fail: function (res) { } }); //400 ms
  2483. }
  2484. }
  2485. else if (PlatUtils_1.default.IsVIVO) {
  2486. if (type == YZ_Constant_1.VibrateType.Short) {
  2487. //@ts-ignore
  2488. qg.vibrateShort(); //(15 ms)
  2489. }
  2490. else {
  2491. //@ts-ignore
  2492. qg.vibrateLong(); //400 ms
  2493. }
  2494. }
  2495. else if (PlatUtils_1.default.IsQQ) {
  2496. if (type == YZ_Constant_1.VibrateType.Short) {
  2497. //@ts-ignore
  2498. //(15 ms),仅在 iPhone 7/7 Plus 以上及 Android 机型生效。
  2499. qq.vibrateShort({ success: function (res) { }, fail: function (res) { } });
  2500. }
  2501. else {
  2502. //@ts-ignore
  2503. qq.vibrateLong({ success: function (res) { }, fail: function (res) { } }); //400 ms
  2504. }
  2505. }
  2506. else if (PlatUtils_1.default.IsDouyin) {
  2507. if (type == YZ_Constant_1.VibrateType.Short) {
  2508. //@ts-ignore
  2509. tt.vibrateShort({ success: function (res) { }, fail: function (res) { } });
  2510. }
  2511. else {
  2512. //@ts-ignore
  2513. tt.vibrateLong({ success: function (res) { }, fail: function (res) { } }); //400 ms
  2514. }
  2515. }
  2516. else if (PlatUtils_1.default.IsBaidu) {
  2517. if (type == YZ_Constant_1.VibrateType.Short) {
  2518. //@ts-ignore
  2519. //(15 ms),仅在 iPhone 7/7 Plus 以上及 Android 机型生效。
  2520. swan.vibrateShort({ success: function (res) { }, fail: function (res) { } });
  2521. }
  2522. else {
  2523. //@ts-ignore
  2524. swan.vibrateLong({ success: function (res) { }, fail: function (res) { } }); //400 ms
  2525. }
  2526. }
  2527. else if (PlatUtils_1.default.IsWiFi) {
  2528. if (type == YZ_Constant_1.VibrateType.Short) {
  2529. //@ts-ignore
  2530. //(15 ms),仅在 iPhone 7/7 Plus 以上及 Android 机型生效。
  2531. wuji.vibrateShort({ success: function (res) { }, fail: function (res) { } });
  2532. }
  2533. else {
  2534. //@ts-ignore
  2535. wuji.vibrateLong({ success: function (res) { }, fail: function (res) { } }); //400 ms
  2536. }
  2537. }
  2538. else if (PlatUtils_1.default.IsNativeAndroid) {
  2539. if (type == YZ_Constant_1.VibrateType.Short) {
  2540. //@ts-ignore
  2541. jsb.reflection.callStaticMethod(exports.utils.Tool_Native.jniClassName, "vibrateShort", "()V");
  2542. }
  2543. else {
  2544. //@ts-ignore
  2545. jsb.reflection.callStaticMethod(exports.utils.Tool_Native.jniClassName, "vibrateLong", "()V");
  2546. }
  2547. }
  2548. };
  2549. /**
  2550. * 游戏开始上报
  2551. * @param level 当前关卡
  2552. * @param model 当前模式: 没有则省略
  2553. */
  2554. Utils.prototype.StartGame = function (level, model) {
  2555. AldUtils_1.default.StartGame(level, model);
  2556. exports.utils.cur_tool && exports.utils.cur_tool.umaOnStart && exports.utils.cur_tool.umaOnStart(level);
  2557. if (PlatUtils_1.default.IsDouyin || PlatUtils_1.default.IsKwai) {
  2558. this.AutoStartRecord(level);
  2559. }
  2560. };
  2561. /**
  2562. * 游戏胜利上报,显示结算广告
  2563. * @param level 当前关卡
  2564. * @param star 获得星星: 默认为0
  2565. * @param model 当前模式: 没有则省略
  2566. * @param isShowAd 是否调用广告,默认开启调用
  2567. * @returns json{ type:(1:6元素互推、2:单个原生广告),node:节点}
  2568. *
  2569. */
  2570. Utils.prototype.GameWin = function (level, star, model, isShowAd) {
  2571. if (star === void 0) { star = 0; }
  2572. if (isShowAd === void 0) { isShowAd = true; }
  2573. AldUtils_1.default.GameWin(level, star, model);
  2574. exports.utils.cur_tool && exports.utils.cur_tool.umaReportedLevel && exports.utils.cur_tool.umaReportedLevel(level, YZ_Constant_1.LevelStatus.GameWin);
  2575. if (PlatUtils_1.default.IsKwai) {
  2576. exports.utils.kwaiTool.isClickEnd = false;
  2577. }
  2578. // if (PlatUtils.IsDouyin || PlatUtils.IsKwai) {
  2579. this.recordEnd();
  2580. // }
  2581. return this.AutoShowStatement(level, true, isShowAd);
  2582. };
  2583. /**
  2584. * 游戏失败上报,显示结算广告
  2585. * @param level 当前关卡
  2586. * @param model 当前模式: 没有则省略
  2587. * @param isShowAd 是否调用广告,默认开启调用
  2588. * @returns json{ type:(1:6元素互推、2:单个原生广告),node:节点}
  2589. */
  2590. Utils.prototype.GameFail = function (level, model, isShowAd) {
  2591. if (isShowAd === void 0) { isShowAd = true; }
  2592. AldUtils_1.default.GameFail(level, model);
  2593. exports.utils.cur_tool && exports.utils.cur_tool.umaReportedLevel && exports.utils.cur_tool.umaReportedLevel(level, YZ_Constant_1.LevelStatus.GameFail);
  2594. // if (PlatUtils.IsDouyin || PlatUtils.IsKwai) {
  2595. this.recordEnd();
  2596. // }
  2597. return this.AutoShowStatement(level, false, isShowAd);
  2598. };
  2599. /**
  2600. * 跳过关卡上报
  2601. * @param level 当前关卡
  2602. * @param model 当前模式: 没有则省略
  2603. */
  2604. Utils.prototype.GameSkip = function (level, model) {
  2605. AldUtils_1.default.GameSkip(level, model);
  2606. };
  2607. /**
  2608. * 事件上报
  2609. * @param eventName 事件名称
  2610. */
  2611. Utils.prototype.SendEvent = function (eventName) {
  2612. AldUtils_1.default.SendEvent(eventName);
  2613. };
  2614. /**
  2615. * 友盟自定义事件上报
  2616. * @param eventID 事件ID
  2617. * @param params 事件内容 Type: obj
  2618. */
  2619. Utils.prototype.umaEvent = function (eventID, params) {
  2620. exports.utils.showLog("\u4E8B\u4EF6\u4E0A\u62A5:" + eventID + "\uFF1A" + params);
  2621. if (PlatUtils_1.default.IsNativeAndroid) {
  2622. exports.utils.cur_tool && exports.utils.cur_tool.umaTrackEvent && exports.utils.cur_tool.umaTrackEvent("custom", eventID, params);
  2623. }
  2624. else {
  2625. exports.utils.cur_tool && exports.utils.cur_tool.umaTrackEvent && exports.utils.cur_tool.umaTrackEvent(eventID, params);
  2626. }
  2627. };
  2628. Utils.prototype.reportOverPageTouchEvent = function (overPage) {
  2629. var _this = this;
  2630. exports.utils.showLog("reportOverPageTouchEvent >>>>>>>");
  2631. this.overPageInsertAdIsTouch = false;
  2632. this.overPageShowTime = new Date().getTime();
  2633. var node = new cc.Node();
  2634. node.width = overPage.width * 2;
  2635. node.height = overPage.height * 2;
  2636. node.on(cc.Node.EventType.TOUCH_START, function () {
  2637. var time = (new Date().getTime() - _this.overPageShowTime) / 1000;
  2638. var json = {};
  2639. json.data = time;
  2640. exports.utils.SendEventNew("\u7ED3\u7B97\u9875\u9762\u70B9\u51FB\u65F6\u95F4", "overPageTouch", JSON.stringify(json));
  2641. node.destroy();
  2642. node.removeFromParent();
  2643. }, overPage);
  2644. node['_touchListener']['swallowTouches'] = false;
  2645. overPage.addChild(node, cc.macro.MAX_ZINDEX);
  2646. };
  2647. /**
  2648. * 自定义事件上报
  2649. * @param eventName 事件名称
  2650. */
  2651. Utils.prototype.SendEventNew = function (eventName, eventId, eventData, isCallBack) {
  2652. if (eventId === void 0) { eventId = "default"; }
  2653. if (isCallBack === void 0) { isCallBack = true; }
  2654. exports.utils.showLog("\u81EA\u5B9A\u4E49\u4E8B\u4EF6\u4E0A\u62A5:" + eventName + "\uFF0C" + eventId + "," + eventData);
  2655. exports.utils.cur_tool && exports.utils.cur_tool.SendEventNew && exports.utils.cur_tool.SendEventNew(eventName, eventId, eventData, isCallBack);
  2656. };
  2657. /**
  2658. * 游戏中使用道具上报
  2659. * @param level 当前关卡
  2660. * @param tooName 道具名称
  2661. * @param model 当前模式: 没有则省略
  2662. */
  2663. Utils.UseTool = function (level, toolName, model) {
  2664. AldUtils_1.default.UseTool(level, toolName, model);
  2665. };
  2666. /**
  2667. * 判断算界面是否能显示自动分享 自动强弹视频 自动弹插屏
  2668. * type 1自动分享 2自动强弹视频 3自动弹插屏 4自动弹互推插屏
  2669. */
  2670. Utils.prototype.checkResultShow = function (type) {
  2671. var level = exports.utils.currentLevel;
  2672. var isSuccess = exports.utils.isSuccess;
  2673. var config = exports.utils.ServerConfig;
  2674. if (!config) {
  2675. exports.utils.showLog("warn:" + "服务器配置不存在,只显示结算广告");
  2676. return type == 3;
  2677. }
  2678. if (PlatUtils_1.default.IsDouyin) {
  2679. if (config.auto_record_share_count) {
  2680. var recoredCount = config.auto_record_share_count;
  2681. if (recoredCount != 0 && exports.utils.recored_share_count >= recoredCount) {
  2682. exports.utils.showLog("\u670D\u52A1\u5668\u914D\u7F6E\u5206\u4EAB\u6B21\u6570\uFF1A" + recoredCount + " ,\u5DF2\u5230\u4E0A\u9650");
  2683. }
  2684. else {
  2685. var record_cap = config.auto_record_interval;
  2686. var checkShow_1 = false;
  2687. if (level > 0 && record_cap != 0) {
  2688. if (record_cap.indexOf(",") == -1) {
  2689. if (level % Number(record_cap) == 0) {
  2690. checkShow_1 = true;
  2691. }
  2692. }
  2693. else {
  2694. exports.utils.showLog("\u6307\u5B9A\u5173\u5361" + config.auto_record_interval + "\u5206\u4EAB\u5F55\u5C4F\uFF0C\u5F53\u524D\u5173\u5361\u4E3A\uFF1A" + level);
  2695. var record_cap_arr = record_cap.split(",");
  2696. record_cap_arr.forEach(function (str) {
  2697. if (level == Number(str)) {
  2698. checkShow_1 = true;
  2699. }
  2700. });
  2701. }
  2702. if (checkShow_1) {
  2703. if (config.auto_record_share_type == "all") {
  2704. return type == 1;
  2705. }
  2706. if (config.auto_record_share_type == "success") {
  2707. if (exports.utils.isSuccess == true) {
  2708. return type == 1;
  2709. }
  2710. }
  2711. if (config.auto_record_share_type == "fail") {
  2712. if (exports.utils.isSuccess == false) {
  2713. return type == 1;
  2714. }
  2715. }
  2716. }
  2717. }
  2718. }
  2719. }
  2720. }
  2721. exports.utils.showLog("\u4E0D\u80FD\u81EA\u52A8\u5206\u4EAB\u5F55\u5C4F \u5206\u4EAB\u5F55\u5C4F\u95F4\u9694\u4E3A\uFF1A" + config.auto_record_interval + " \u5206\u4EAB\u7C7B\u578B\u4E3A\uFF1A" + config.auto_record_share_type);
  2722. if (config.auto_video_interval && config.auto_video_interval != 0) {
  2723. var space = config.auto_video_interval;
  2724. var showType = config.auto_video_show_type;
  2725. if (level % space == 0) {
  2726. if (showType == "all") {
  2727. return type == 2;
  2728. }
  2729. if (showType == "success") {
  2730. if (isSuccess == true) {
  2731. return type == 2;
  2732. }
  2733. }
  2734. if (showType == "fail") {
  2735. if (isSuccess == false) {
  2736. return type == 2;
  2737. }
  2738. }
  2739. }
  2740. }
  2741. exports.utils.showLog("\u4E0D\u80FD\u81EA\u52A8\u5F39\u89C6\u9891\u5F39\u89C6\u9891\u95F4\u9694\u4E3A\uFF1A" + config.auto_video_interval + " \u5F39\u89C6\u9891\u7C7B\u578B\u4E3A\uFF1A" + config.auto_video_show_type);
  2742. if (config.auto_rec_insert_interval && config.auto_rec_insert_interval != 0) {
  2743. var space = config.auto_rec_insert_interval;
  2744. var showType = config.auto_rec_insert_type;
  2745. if (level % space == 0) {
  2746. if (showType == "all") {
  2747. return type == 4;
  2748. }
  2749. if (showType == "success") {
  2750. if (isSuccess == true) {
  2751. return type == 4;
  2752. }
  2753. }
  2754. if (showType == "fail") {
  2755. if (isSuccess == false) {
  2756. return type == 4;
  2757. }
  2758. }
  2759. }
  2760. }
  2761. exports.utils.showLog("\u4E0D\u80FD\u81EA\u52A8\u5F39\u4E92\u63A8\u63D2\u5C4F\u95F4\u9694\u4E3A\uFF1A" + config.auto_rec_insert_interval + " \u5F39\u89C6\u9891\u7C7B\u578B\u4E3A\uFF1A" + config.auto_rec_insert_type);
  2762. return type == 3;
  2763. };
  2764. /**
  2765. * 结算广告控制
  2766. * level 当前关卡 isSuccess是否胜利
  2767. * qq 若判断2通过弹游戏盒子 判断3通过弹插屏
  2768. * 抖音 若判断2通过则弹视频 判断3过弹插屏
  2769. * 趣头条 若判断2通过弹视频 判断3通过弹互动直弹
  2770. * 其他平台若判断2通过则服务器配置有问题,联系运营修改
  2771. *服务器控制 结算界面自动弹出视频
  2772. */
  2773. Utils.prototype.AutoShowStatement = function (level, isSuccess, isShowAd) {
  2774. exports.utils.currentLevel = level;
  2775. exports.utils.isSuccess = isSuccess;
  2776. var res = { "type": -1, "node": null };
  2777. if (!isShowAd) {
  2778. exports.utils.showLog("isShowAd为false,只上报不显示广告");
  2779. return res;
  2780. }
  2781. var isShowVideo = false;
  2782. if (this.checkResultShow(2)) {
  2783. if (this.getConfigByKey("result_auto_show_video") == "false")
  2784. return;
  2785. if (PlatUtils_1.default.IsDouyin) {
  2786. exports.utils.showLog("服务器版本:", exports.utils.config.douyinconfig.version, "当前版本:", this.getConfigByKey("version"));
  2787. if (exports.utils.config.douyinconfig.version != this.getConfigByKey("version")) {
  2788. exports.utils.showLog("版本不一致,自动播放视频!");
  2789. exports.utils.adManager.ShowVideo(function () { });
  2790. isShowVideo = true;
  2791. }
  2792. }
  2793. else if (PlatUtils_1.default.IsQQ) {
  2794. if (exports.utils.config.qqconfig.version != this.getConfigByKey("version")) {
  2795. exports.utils.showLog("版本不一致,自动播放视频!");
  2796. exports.utils.adManager.ShowVideo(function () { });
  2797. isShowVideo = true;
  2798. }
  2799. }
  2800. else if (PlatUtils_1.default.IsWiFi) {
  2801. if (exports.utils.config.wifiConfig.version != this.getConfigByKey("version")) {
  2802. exports.utils.showLog("版本不一致,自动播放视频!");
  2803. exports.utils.adManager.ShowVideo(function () { });
  2804. isShowVideo = true;
  2805. }
  2806. }
  2807. else if (PlatUtils_1.default.IsBaidu) {
  2808. if (exports.utils.config.baiduconfig.version != this.getConfigByKey("version")) {
  2809. exports.utils.showLog("版本不一致,自动播放视频!");
  2810. exports.utils.adManager.ShowVideo(function () { });
  2811. isShowVideo = true;
  2812. }
  2813. }
  2814. else if (PlatUtils_1.default.IsKwai) {
  2815. if (exports.utils.config.kwaiConfig.version != this.getConfigByKey("version")) {
  2816. exports.utils.showLog("版本不一致,自动播放视频!");
  2817. exports.utils.adManager.ShowVideo(function () { });
  2818. isShowVideo = true;
  2819. }
  2820. }
  2821. else if (PlatUtils_1.default.IsHago) {
  2822. if (exports.utils.config.hagoConfig.version != this.getConfigByKey("version")) {
  2823. exports.utils.showLog("版本不一致,自动播放视频!");
  2824. exports.utils.adManager.ShowVideo(function () { });
  2825. isShowVideo = true;
  2826. }
  2827. }
  2828. else if (PlatUtils_1.default.IsNativeAndroid) {
  2829. if (exports.utils.config.nativeAndroidConfig.version != this.getConfigByKey("version")) {
  2830. exports.utils.showLog("版本不一致,自动播放视频!");
  2831. if (exports.utils.ServerConfig && this.getConfigByKey("auto_video_type") == "reward_video") {
  2832. exports.utils.adManager.ShowVideo(function () { });
  2833. }
  2834. else {
  2835. exports.utils.adManager.showFullScreenVideo();
  2836. }
  2837. isShowVideo = true;
  2838. }
  2839. else {
  2840. exports.utils.showLog("与服务器版本一致,不自动播放视频!");
  2841. }
  2842. }
  2843. else if (PlatUtils_1.default.IsNativeIOS) {
  2844. if (exports.utils.config.nativeIoSConfig.version != this.getConfigByKey("version")) {
  2845. exports.utils.showLog("版本不一致,自动播放视频!");
  2846. if (exports.utils.ServerConfig && this.getConfigByKey("auto_video_type") == "reward_video") {
  2847. exports.utils.adManager.ShowVideo(function () { });
  2848. }
  2849. else {
  2850. exports.utils.adManager.showFullScreenVideo();
  2851. }
  2852. isShowVideo = true;
  2853. }
  2854. }
  2855. else if (PlatUtils_1.default.IsVIVO) {
  2856. exports.utils.showLog("服务器配置当前显示强弹视频,但当前平台不支持。需修改服务器配置");
  2857. exports.utils.adManager.showStatementAds();
  2858. }
  2859. else {
  2860. isShowVideo = true;
  2861. exports.utils.adManager.ShowVideo(function () { });
  2862. }
  2863. if (isShowVideo && (PlatUtils_1.default.IsDouyin || PlatUtils_1.default.IsQQ || PlatUtils_1.default.IsNativeAndroid || PlatUtils_1.default.IsNativeIOS)) {
  2864. exports.utils.showLog("当前强弹了视频,不显示插屏!");
  2865. }
  2866. else {
  2867. res = exports.utils.adManager.showStatementAds();
  2868. }
  2869. }
  2870. // if (this.canShowRedBag() && this.yzRedBagInfo.progress >= this.yzRedBagInfo.totalProgress) {
  2871. // utils.showLog("当前红包进度已满,显示获得红包窗口!");
  2872. // // this.showOpenRedBagPanel({ showType: 2 });
  2873. // }
  2874. if (this.checkResultShow(3)) {
  2875. res = exports.utils.adManager.showStatementAds();
  2876. // console.log(" this.checkResultShow(3)", res.node);
  2877. }
  2878. if (PlatUtils_1.default.IsDouyin || PlatUtils_1.default.IsNativeIOS || PlatUtils_1.default.IsBaidu || PlatUtils_1.default.IsNativeAndroid) {
  2879. //抖音平台判断是否需要6元素互推
  2880. res.type = 1;
  2881. res.node = exports.utils.showCrossWidget6();
  2882. }
  2883. return res;
  2884. };
  2885. /**
  2886. * 获得一次现金红包
  2887. */
  2888. Utils.prototype.addRedBagCount = function (callFun) {
  2889. this.yzRedBagInfo.freeRedBagCount++;
  2890. if (callFun) {
  2891. this.rewardCloseFunc = callFun;
  2892. }
  2893. this.showOpenRedBagPanel({ showType: 3 });
  2894. exports.utils.showLog("获得一个现金红包");
  2895. };
  2896. /**
  2897. * 开始游戏自动录屏
  2898. * 暂时只有头条平台有
  2899. * 默认为0 表示不开启,例如3 表示每三关会自动录屏,例如3,6,9 表示只有第3,6,9指定的关卡会自动录屏
  2900. */
  2901. Utils.prototype.AutoStartRecord = function (level) {
  2902. if (this.getConfigByKey("auto_record_interval") > 0) {
  2903. exports.utils.recordStart();
  2904. }
  2905. else {
  2906. exports.utils.showLog("warn:" + "服务器配置不存在auto_record_interva");
  2907. }
  2908. };
  2909. /**
  2910. * 显示录屏分享窗口
  2911. * @param params
  2912. */
  2913. Utils.prototype.showShareRecordPanel = function (params) {
  2914. if (params === void 0) { params = null; }
  2915. if (!this._isConfigInit) {
  2916. exports.utils.showLog("warn:" + "组件配置未初始化!");
  2917. return null;
  2918. }
  2919. if (this.config.otherconfig.shareRecordPanel) {
  2920. var node = cc.instantiate(this.config.otherconfig.shareRecordPanel);
  2921. if (node) {
  2922. if (this.shareRecordPanel && cc.isValid(this.shareRecordPanel)) {
  2923. this.shareRecordPanel.destroy();
  2924. }
  2925. this.shareRecordPanel = node;
  2926. this.shareRecordPanel.zIndex = 9999;
  2927. var widget = node.getComponent(cc.Widget);
  2928. if (params) {
  2929. if (params.group) {
  2930. node.group = params.group;
  2931. }
  2932. if (params.scale != null) {
  2933. node.scale = params.scale;
  2934. }
  2935. if (params.top != null) {
  2936. widget.isAlignTop = true;
  2937. widget.isAlignBottom = false;
  2938. widget.top = params.top;
  2939. }
  2940. else if (params.bottom != null) {
  2941. widget.isAlignTop = false;
  2942. widget.isAlignBottom = true;
  2943. widget.bottom = params.bottom;
  2944. }
  2945. if (params.left != null) {
  2946. widget.isAlignLeft = true;
  2947. widget.isAlignRight = false;
  2948. widget.left = params.left;
  2949. }
  2950. else if (params.right != null) {
  2951. widget.isAlignLeft = false;
  2952. widget.isAlignRight = true;
  2953. widget.right = params.right;
  2954. }
  2955. if (params.parent != null) {
  2956. node.parent = params.parent;
  2957. }
  2958. else {
  2959. cc.director.getScene().addChild(this.shareRecordPanel, 1000);
  2960. }
  2961. }
  2962. else {
  2963. cc.director.getScene().addChild(this.shareRecordPanel, 1000);
  2964. }
  2965. widget.updateAlignment();
  2966. return node;
  2967. }
  2968. }
  2969. else {
  2970. exports.utils.showLog("未找到预制体 ShareRecordPanel, 请查看CommonUtils组件上是否赋值!");
  2971. }
  2972. return null;
  2973. };
  2974. Object.defineProperty(Utils.prototype, "otherConfig", {
  2975. /**
  2976. * 获取其他辅助配置
  2977. */
  2978. get: function () {
  2979. if (!this._other_config) {
  2980. this._other_config = this.config.otherconfig.localConfig.json.other;
  2981. }
  2982. return this._other_config;
  2983. },
  2984. enumerable: false,
  2985. configurable: true
  2986. });
  2987. /**
  2988. * 获取试用皮肤关卡间隔
  2989. * 默认为每5关显示一次
  2990. *
  2991. */
  2992. Utils.prototype.isShowTrySkin = function (curLevel) {
  2993. var count = 5;
  2994. if (exports.utils.ServerConfig && this.getConfigByKey("try_skin_level_count")) {
  2995. count = this.getConfigByKey("try_skin_level_count");
  2996. }
  2997. if (curLevel % count == 0) {
  2998. if (exports.utils.ServerConfig && this.getConfigByKey("try_skin_show_ad_interval") != undefined) {
  2999. if (curLevel % this.getConfigByKey("try_skin_show_ad_interval") == 0) {
  3000. exports.utils.showLog("\u670D\u52A1\u5668\u914D\u7F6E\u95F4\u9694" + this.getConfigByKey("try_skin_show_ad_interval") + "\u5173\u8BD5\u7528\u76AE\u80A4\u5C55\u793A\u63D2\u5C4F\uFF01");
  3001. exports.utils.adManager.ShowInterstitial();
  3002. }
  3003. }
  3004. return true;
  3005. }
  3006. return false;
  3007. };
  3008. /**
  3009. * 延迟显示跳过或者关闭按钮
  3010. * @param btn 延迟显示按钮的节点
  3011. * @param isCloseBtn 是否返回或者关闭按钮
  3012. * @param location 按钮所在的页面位置
  3013. */
  3014. Utils.prototype.showSkipBtn = function (btn, isCloseBtn, location) {
  3015. if (isCloseBtn === void 0) { isCloseBtn = false; }
  3016. if (location === void 0) { location = YZ_Constant_1.BannerLocation.None; }
  3017. if (btn) {
  3018. var delayShowBtn = PlatUtils_1.default.IsNativeAndroid ? 3 : 0;
  3019. if (this.getConfigByKey("skip_btn_show_delay")) {
  3020. delayShowBtn = this.getConfigByKey("skip_btn_show_delay");
  3021. }
  3022. if (isCloseBtn) {
  3023. if (this.getConfigByKey("special_skip_btn_show_delay")) {
  3024. delayShowBtn = this.getConfigByKey("special_skip_btn_show_delay");
  3025. }
  3026. }
  3027. if (PlatUtils_1.default.IsTest) {
  3028. this.ServerConfig.over_page_skip_btn_show_delay = 3;
  3029. }
  3030. if (location == YZ_Constant_1.BannerLocation.Over) {
  3031. if (this.getConfigByKey("over_page_skip_btn_show_delay")) {
  3032. delayShowBtn = this.getConfigByKey("over_page_skip_btn_show_delay");
  3033. }
  3034. }
  3035. if (delayShowBtn > 0) {
  3036. btn.opacity = 0;
  3037. btn.active = false;
  3038. this.scheduleOnce(function () {
  3039. if (btn && cc.isValid(btn)) {
  3040. btn.active = true;
  3041. btn.runAction(cc.fadeIn(0.3));
  3042. }
  3043. }, delayShowBtn);
  3044. }
  3045. else {
  3046. if (!btn.active) {
  3047. btn.active = true;
  3048. }
  3049. }
  3050. }
  3051. };
  3052. /**
  3053. * 抖音按钮延迟显示
  3054. * 默认为0秒
  3055. */
  3056. Utils.prototype.delayShowNode = function (btn) {
  3057. if (btn) {
  3058. btn.opacity = 0;
  3059. btn.active = true;
  3060. var delayShowBtn = 0;
  3061. if (this.getConfigByKey("next_btn_show_delay")) {
  3062. delayShowBtn = this.getConfigByKey("next_btn_show_delay");
  3063. }
  3064. this.scheduleOnce(function () {
  3065. if (btn && cc.isValid(btn)) {
  3066. btn.runAction(cc.fadeIn(0.3));
  3067. }
  3068. }, delayShowBtn);
  3069. }
  3070. };
  3071. /**
  3072. * 宝箱界面是否自动勾选
  3073. */
  3074. Utils.prototype.isBoxAutoSelectToggle = function () {
  3075. var cap_level = 0;
  3076. var level = exports.utils.currentLevel;
  3077. if (this.getConfigByKey("box_auto_select_level")) {
  3078. cap_level = Number(this.getConfigByKey("box_auto_select_level"));
  3079. }
  3080. else {
  3081. exports.utils.showLog("服务器配置不存在,不自动勾选");
  3082. }
  3083. if (cap_level != 0 && (level % cap_level) == 0) {
  3084. return true;
  3085. }
  3086. return false;
  3087. };
  3088. /**
  3089. * 结算界面是否自动勾选
  3090. */
  3091. Utils.prototype.isResultAutoSelectToggle = function () {
  3092. var cap_level = 0;
  3093. var level = exports.utils.currentLevel;
  3094. if (this.getConfigByKey("result_auto_select_level")) {
  3095. cap_level = Number(this.getConfigByKey("result_auto_select_level"));
  3096. }
  3097. else {
  3098. exports.utils.showLog("服务器配置不存在,不自动勾选");
  3099. }
  3100. if (cap_level != 0 && (level % cap_level) == 0) {
  3101. return true;
  3102. }
  3103. return false;
  3104. };
  3105. /**
  3106. * 试用皮肤界面是否自动勾选
  3107. */
  3108. Utils.prototype.isTrySkinAutoSelectToggle = function () {
  3109. var cap_level = 0;
  3110. var level = exports.utils.currentLevel;
  3111. if (this.getConfigByKey("skin_auto_select_level")) {
  3112. cap_level = Number(this.getConfigByKey("skin_auto_select_level"));
  3113. }
  3114. else {
  3115. exports.utils.showLog("服务器配置不存在,不自动勾选");
  3116. }
  3117. if (cap_level != 0 && (level % cap_level) == 0) {
  3118. return true;
  3119. }
  3120. return false;
  3121. };
  3122. Object.defineProperty(Utils.prototype, "gameVersion", {
  3123. /**
  3124. * 游戏当前版本
  3125. */
  3126. get: function () {
  3127. if (this.cur_tool && this.cur_tool.gameVersion)
  3128. return this.cur_tool.gameVersion();
  3129. return "-1";
  3130. },
  3131. enumerable: false,
  3132. configurable: true
  3133. });
  3134. /**
  3135. * 界面控制
  3136. * @param view
  3137. * 界面类型:皮肤试用界面 宝箱界面
  3138. *
  3139. * 返回值类型
  3140. * @param callback isSelect:按钮是否自动勾选上
  3141. * @param callback msg:文字提示
  3142. * @param callback btnType:初始按钮类型 true为看广告的文本 false为不看广告的文本
  3143. */
  3144. Utils.prototype.controView = function (view) {
  3145. var result = { "isSelect": true, "msg": "观看视频获得奖励", "btnType": true, "is_open": false };
  3146. var adTipsType;
  3147. var selectType;
  3148. if (!exports.utils.ServerConfig) {
  3149. exports.utils.showLog("服务器配置不存在");
  3150. return result;
  3151. }
  3152. //验证服务器是否开启勾选策略
  3153. if (this.getConfigByKey("open_check_btn") == "false") {
  3154. exports.utils.showLog("服务器配置不开启勾选!");
  3155. return result;
  3156. }
  3157. result.is_open = true;
  3158. switch (view) {
  3159. case YZ_Constant_1.ViewLocation.sign:
  3160. selectType = this.getConfigByKey("sign_auto_select_level") ? this.getConfigByKey("sign_auto_select_level") : 0;
  3161. if (this.getConfigByKey("ad_tip_sign_random") == "true") {
  3162. adTipsType = Math.random() >= 0.5 ? true : false;
  3163. }
  3164. else {
  3165. adTipsType = true;
  3166. }
  3167. if (adTipsType) {
  3168. result.msg = "查看视频获得双倍奖励";
  3169. }
  3170. else {
  3171. result.msg = "不需要视频奖励";
  3172. }
  3173. break;
  3174. case YZ_Constant_1.ViewLocation.trySkin:
  3175. selectType = this.getConfigByKey("tryskin_auto_select_level") ? this.getConfigByKey("tryskin_auto_select_level") : 0;
  3176. if (this.getConfigByKey("ad_tip_tryskin_random") == "true") {
  3177. adTipsType = Math.random() >= 0.5 ? true : false;
  3178. }
  3179. else {
  3180. adTipsType = true;
  3181. }
  3182. if (adTipsType) {
  3183. result.msg = "查看视频试用皮肤";
  3184. }
  3185. else {
  3186. result.msg = "不需要视频试用皮肤";
  3187. }
  3188. break;
  3189. case YZ_Constant_1.ViewLocation.box:
  3190. selectType = this.getConfigByKey("box_auto_select_level") ? this.getConfigByKey("box_auto_select_level") : 0;
  3191. if (this.getConfigByKey("ad_tip_box_random") == "true") {
  3192. adTipsType = Math.random() >= 0.5 ? true : false;
  3193. }
  3194. else {
  3195. adTipsType = true;
  3196. }
  3197. if (adTipsType) {
  3198. result.msg = "查看视频获得五倍奖励";
  3199. }
  3200. else {
  3201. result.msg = "不需要视频奖励";
  3202. }
  3203. break;
  3204. case YZ_Constant_1.ViewLocation.successBox:
  3205. selectType = this.getConfigByKey("success_box_auto_select_level") ? this.getConfigByKey("success_box_auto_select_level") : 0;
  3206. break;
  3207. case YZ_Constant_1.ViewLocation.failBox:
  3208. selectType = this.getConfigByKey("fail_box_auto_select_level") ? this.getConfigByKey("fail_box_auto_select_level") : 0;
  3209. break;
  3210. case YZ_Constant_1.ViewLocation.winPanel:
  3211. selectType = this.getConfigByKey("win_panel_auto_select_level") ? this.getConfigByKey("win_panel_auto_select_level") : 0;
  3212. break;
  3213. case YZ_Constant_1.ViewLocation.turntable:
  3214. selectType = this.getConfigByKey("turntable_auto_select_level") ? this.getConfigByKey("turntable_auto_select_level") : 0;
  3215. break;
  3216. }
  3217. if (selectType == 0) {
  3218. result.isSelect = false;
  3219. }
  3220. else if (selectType == 1) {
  3221. result.isSelect = true;
  3222. }
  3223. else if (selectType == 2) {
  3224. result.isSelect = Math.random() >= 0.5 ? true : false;
  3225. }
  3226. result.btnType = adTipsType == result.isSelect;
  3227. return result;
  3228. };
  3229. /**
  3230. * 是否能再下一关开始的时候强弹视频
  3231. */
  3232. Utils.prototype.canShowNextVideo = function (level) {
  3233. if (exports.utils.ServerConfig && this.getConfigByKey("next_auto_video_interval")) {
  3234. var cap = Number(this.getConfigByKey("next_auto_video_interval"));
  3235. if (cap && cap != 0) {
  3236. if (level % cap == 0) {
  3237. if (PlatUtils_1.default.IsDouyin) {
  3238. if (this.getConfigByKey("version") != exports.utils.config.douyinconfig.version) {
  3239. return true;
  3240. }
  3241. }
  3242. else if (PlatUtils_1.default.IsBaidu) {
  3243. if (this.getConfigByKey("version") != exports.utils.config.baiduconfig.version) {
  3244. return true;
  3245. }
  3246. }
  3247. else if (PlatUtils_1.default.ISUC) {
  3248. if (this.getConfigByKey("version") != exports.utils.config.ucConfig.version) {
  3249. return true;
  3250. }
  3251. }
  3252. else {
  3253. return true;
  3254. }
  3255. }
  3256. else {
  3257. if (PlatUtils_1.default.Is4399) {
  3258. cap = 3; //4399不能读取服务器配置写死间隔
  3259. if (cap != 0 && level % cap == 0) {
  3260. return this.true;
  3261. }
  3262. }
  3263. }
  3264. }
  3265. }
  3266. return false;
  3267. };
  3268. /**
  3269. * 是否显示红包
  3270. */
  3271. Utils.prototype.canShowRedBag = function () {
  3272. if (!this._isConfigInit) {
  3273. exports.utils.showLog("warn:" + "组件配置未初始化!");
  3274. return false;
  3275. }
  3276. if (this.Tool_Broswer)
  3277. return true;
  3278. if (this.ServerConfig && this.yzRedBagInfo && this.ServerConfig.show_red_bag && this.ServerConfig.show_red_bag == "true") {
  3279. return true;
  3280. }
  3281. exports.utils.showLog("服务器配置不显示红包组件!");
  3282. return false;
  3283. };
  3284. /**
  3285. * 隐藏提现框挂件
  3286. */
  3287. Utils.prototype.hideWithdrawalWidget = function () {
  3288. if (this._withdrawalWidget && cc.isValid(this._withdrawalWidget)) {
  3289. this._withdrawalWidget.destroy();
  3290. }
  3291. };
  3292. /**
  3293. * 显示提现框挂件
  3294. * @param params
  3295. */
  3296. Utils.prototype.showWithdrawalWidget = function (params) {
  3297. if (params === void 0) { params = null; }
  3298. if (!this._isConfigInit) {
  3299. exports.utils.showLog("warn:" + "组件配置未初始化!");
  3300. return null;
  3301. }
  3302. if (!this.canShowRedBag())
  3303. return null;
  3304. if (this.config.otherconfig.withdrawalWidget) {
  3305. var node = cc.instantiate(this.config.otherconfig.withdrawalWidget);
  3306. if (node) {
  3307. if (this._withdrawalWidget && cc.isValid(this._withdrawalWidget)) {
  3308. this._withdrawalWidget.destroy();
  3309. }
  3310. this._withdrawalWidget = node;
  3311. this._withdrawalWidget.zIndex = 9999;
  3312. var widget = node.getComponent(cc.Widget);
  3313. if (params) {
  3314. if (params.group) {
  3315. node.group = params.group;
  3316. }
  3317. if (params.scale != null) {
  3318. node.scale = params.scale;
  3319. }
  3320. if (params.top != null) {
  3321. widget.isAlignTop = true;
  3322. widget.isAlignBottom = false;
  3323. widget.top = params.top;
  3324. }
  3325. else if (params.bottom != null) {
  3326. widget.isAlignTop = false;
  3327. widget.isAlignBottom = true;
  3328. widget.bottom = params.bottom;
  3329. }
  3330. if (params.left != null) {
  3331. widget.isAlignLeft = true;
  3332. widget.isAlignRight = false;
  3333. widget.left = params.left;
  3334. }
  3335. else if (params.right != null) {
  3336. widget.isAlignLeft = false;
  3337. widget.isAlignRight = true;
  3338. widget.right = params.right;
  3339. }
  3340. if (params.parent != null) {
  3341. node.parent = params.parent;
  3342. }
  3343. }
  3344. widget.updateAlignment();
  3345. return node;
  3346. }
  3347. }
  3348. else {
  3349. exports.utils.showLog("warn:" + "未找到预制体 WithdrawalWidget, 请查看CommonUtils组件上是否赋值!");
  3350. }
  3351. return null;
  3352. };
  3353. /**
  3354. * 隐藏红包进度挂件
  3355. */
  3356. Utils.prototype.hideRedBagProgressWidget = function () {
  3357. if (this._redBagProgressWidget && cc.isValid(this._redBagProgressWidget)) {
  3358. this._redBagProgressWidget.destroy();
  3359. }
  3360. };
  3361. /**
  3362. * 显示红包进度挂件
  3363. * @param params
  3364. */
  3365. Utils.prototype.showRedBagProgressWidget = function (params) {
  3366. if (params === void 0) { params = null; }
  3367. if (!this._isConfigInit) {
  3368. exports.utils.showLog("warn:" + "组件配置未初始化!");
  3369. return null;
  3370. }
  3371. if (!this.canShowRedBag())
  3372. return null;
  3373. if (this.config.otherconfig.redBagProgressWidget) {
  3374. var node = cc.instantiate(this.config.otherconfig.redBagProgressWidget);
  3375. if (node) {
  3376. if (this._redBagProgressWidget && cc.isValid(this._redBagProgressWidget)) {
  3377. this._redBagProgressWidget.destroy();
  3378. }
  3379. this._redBagProgressWidget = node;
  3380. this._redBagProgressWidget.zIndex = 9999;
  3381. var widget = node.getComponent(cc.Widget);
  3382. if (params) {
  3383. if (params.location) {
  3384. node.getComponent(RedBagProgressWidget_1.default).init(params);
  3385. }
  3386. if (params.group) {
  3387. node.group = params.group;
  3388. }
  3389. if (params.scale != null) {
  3390. node.scale = params.scale;
  3391. }
  3392. if (params.top != null) {
  3393. widget.isAlignTop = true;
  3394. widget.isAlignBottom = false;
  3395. widget.top = params.top;
  3396. }
  3397. else if (params.bottom != null) {
  3398. widget.isAlignTop = false;
  3399. widget.isAlignBottom = true;
  3400. widget.bottom = params.bottom;
  3401. }
  3402. if (params.left != null) {
  3403. widget.isAlignLeft = true;
  3404. widget.isAlignRight = false;
  3405. widget.left = params.left;
  3406. }
  3407. else if (params.right != null) {
  3408. widget.isAlignLeft = false;
  3409. widget.isAlignRight = true;
  3410. widget.right = params.right;
  3411. }
  3412. if (params.parent != null) {
  3413. node.parent = params.parent;
  3414. }
  3415. }
  3416. widget.updateAlignment();
  3417. return node;
  3418. }
  3419. }
  3420. else {
  3421. exports.utils.showLog("warn:" + "未找到预制体 RedBagProgressWidget, 请查看CommonUtils组件上是否赋值!");
  3422. }
  3423. return null;
  3424. };
  3425. /**
  3426. * 显示提现弹窗
  3427. * @param params
  3428. */
  3429. Utils.prototype.showWithdrawalPanel = function (params) {
  3430. if (params === void 0) { params = null; }
  3431. if (!this._isConfigInit) {
  3432. exports.utils.showLog("warn:" + "组件配置未初始化!");
  3433. return null;
  3434. }
  3435. if (!this.canShowRedBag())
  3436. return null;
  3437. if (this.config.otherconfig.withdrawalPanel) {
  3438. var node = cc.instantiate(this.config.otherconfig.withdrawalPanel);
  3439. if (node) {
  3440. if (this._withdrawalPanel && cc.isValid(this._withdrawalPanel)) {
  3441. this._withdrawalPanel.destroy();
  3442. }
  3443. this._withdrawalPanel = node;
  3444. cc.director.getScene().addChild(this._withdrawalPanel, 9999);
  3445. }
  3446. else {
  3447. exports.utils.showLog("warn:" + "未找到预制体 WithdrawalPanel, 请查看CommonUtils组件上是否赋值!");
  3448. }
  3449. return null;
  3450. }
  3451. };
  3452. /**
  3453. * 显示开红包弹窗
  3454. * @param params
  3455. */
  3456. Utils.prototype.showOpenRedBagPanel = function (params) {
  3457. if (params === void 0) { params = null; }
  3458. if (params && params.closeCallFunc) {
  3459. this.rewardCloseFunc = params.closeCallFunc;
  3460. }
  3461. if (!this._isConfigInit) {
  3462. exports.utils.showLog("warn:" + "组件配置未初始化!");
  3463. this.rewardCloseFunc && this.rewardCloseFunc();
  3464. return null;
  3465. }
  3466. if (!this.canShowRedBag()) {
  3467. this.rewardCloseFunc && this.rewardCloseFunc();
  3468. return null;
  3469. }
  3470. if (params && params.location && params.location === YZ_Constant_1.BannerLocation.Home) {
  3471. if (this.yzRedBagInfo.progress < this.yzRedBagInfo.totalProgress && !this.yzRedBagInfo.isFreeRedBag) {
  3472. exports.utils.showLog("当前红包进度不满足条件且没有免费红包领取,首页不显示拆红包窗口");
  3473. this.rewardCloseFunc && this.rewardCloseFunc();
  3474. return null;
  3475. }
  3476. else if (!this.yzRedBagInfo.isFreeRedBag) {
  3477. params.showType = 2;
  3478. }
  3479. }
  3480. if (this.config.otherconfig.openRedBagPanel) {
  3481. var node = cc.instantiate(this.config.otherconfig.openRedBagPanel);
  3482. if (node) {
  3483. if (this._openRedBagPanel && cc.isValid(this._openRedBagPanel)) {
  3484. this._openRedBagPanel.destroy();
  3485. }
  3486. this._openRedBagPanel = node;
  3487. if (params && params.showType) {
  3488. this._openRedBagPanel.getComponent(OpenRedBagPanel_1.default).initData(params.showType);
  3489. }
  3490. cc.director.getScene().addChild(node, 9999);
  3491. }
  3492. else {
  3493. exports.utils.showLog("warn:" + "未找到预制体 OpenRedBagPanel, 请查看CommonUtils组件上是否赋值!");
  3494. }
  3495. return null;
  3496. }
  3497. };
  3498. /**
  3499. * 显示获得红包弹窗
  3500. * @param params
  3501. */
  3502. Utils.prototype.showRewardRedBagPanel = function (params) {
  3503. if (params === void 0) { params = null; }
  3504. if (!this._isConfigInit) {
  3505. exports.utils.showLog("warn:" + "组件配置未初始化!");
  3506. return null;
  3507. }
  3508. if (!this.canShowRedBag())
  3509. return null;
  3510. this._rewardRedBagPanelShowCount++;
  3511. // if (this.ServerConfig && this.ServerConfig.show_reward_red_bag_interval) {
  3512. if (this._rewardRedBagPanelShowCount % 3 != 0) {
  3513. exports.utils.showLog("获得红包弹窗未达到服务器配置的间隔限制!");
  3514. return;
  3515. }
  3516. // }
  3517. if (this.config.otherconfig.rewardRedBagPanel) {
  3518. var node = cc.instantiate(this.config.otherconfig.rewardRedBagPanel);
  3519. if (node) {
  3520. if (this._rewardRedBagPanel && cc.isValid(this._rewardRedBagPanel)) {
  3521. this._rewardRedBagPanel.destroy();
  3522. }
  3523. this._rewardRedBagPanel = node;
  3524. cc.director.getScene().addChild(this._rewardRedBagPanel, 9999);
  3525. }
  3526. else {
  3527. exports.utils.showLog("warn:" + "未找到预制体 OpenRedBagPanel, 请查看CommonUtils组件上是否赋值!");
  3528. }
  3529. return null;
  3530. }
  3531. };
  3532. /**
  3533. * 是否竖屏互推窗口
  3534. */
  3535. Utils.prototype.isVerticalRecommentPanel = function () {
  3536. if (!this._isConfigInit) {
  3537. exports.utils.showLog("warn:" + "组件配置未初始化!");
  3538. return false;
  3539. }
  3540. if (this.Tool_Broswer)
  3541. return true;
  3542. if (PlatUtils_1.default.IsWechat) {
  3543. if (exports.utils.isSupportnavigateToMiniGame()) {
  3544. if (exports.utils.wechatTool
  3545. && exports.utils.wechatTool.ServerConfig
  3546. && exports.utils.wechatTool.ServerConfig.is_vertical_game) {
  3547. if (exports.utils.wechatTool.ServerConfig.is_vertical_game == "true") {
  3548. return true;
  3549. }
  3550. else {
  3551. exports.utils.showLog("warn:" + "is_vertical_game参数为false,更多游戏侧边栏组件不显示!");
  3552. }
  3553. }
  3554. else {
  3555. exports.utils.showLog("warn:" + "配置中没有is_vertical_game参数,更多游戏侧边栏组件不显示!");
  3556. }
  3557. }
  3558. else {
  3559. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,更多游戏侧边栏组件不显示!");
  3560. }
  3561. }
  3562. else if (PlatUtils_1.default.IsOPPO) {
  3563. if (exports.utils.isSupportnavigateToMiniGame()) {
  3564. if (exports.utils.oppoTool
  3565. && exports.utils.oppoTool.ServerConfig
  3566. && exports.utils.oppoTool.ServerConfig.is_vertical_game) {
  3567. if (exports.utils.oppoTool.ServerConfig.is_vertical_game == "true") {
  3568. return true;
  3569. }
  3570. else {
  3571. exports.utils.showLog("warn:" + "is_vertical_game参数为false,更多游戏侧边栏组件不显示!");
  3572. }
  3573. }
  3574. else {
  3575. exports.utils.showLog("warn:" + "配置中没有is_vertical_game参数,更多游戏侧边栏组件不显示!");
  3576. }
  3577. }
  3578. else {
  3579. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,更多游戏侧边栏组件不显示!");
  3580. }
  3581. }
  3582. else if (PlatUtils_1.default.IsDouyin) {
  3583. if (PlatUtils_1.default.IsAndroid
  3584. && exports.utils.isSupportnavigateToMiniGame()) {
  3585. if (exports.utils.Tool_Douyin
  3586. && exports.utils.Tool_Douyin.ServerConfig
  3587. && exports.utils.Tool_Douyin.ServerConfig.is_vertical_game) {
  3588. if (exports.utils.Tool_Douyin.ServerConfig.is_vertical_game == "true") {
  3589. return true;
  3590. }
  3591. else {
  3592. exports.utils.showLog("warn:" + "is_vertical_game参数为false,更多游戏侧边栏组件不显示!");
  3593. }
  3594. }
  3595. else {
  3596. exports.utils.showLog("warn:" + "配置中没有is_vertical_game参数,更多游戏侧边栏组件不显示!");
  3597. }
  3598. }
  3599. else {
  3600. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,更多游戏侧边栏组件不显示!");
  3601. }
  3602. }
  3603. else if (PlatUtils_1.default.IsBaidu) {
  3604. if (exports.utils.isSupportnavigateToMiniGame()) {
  3605. if (exports.utils.Tool_Baidu
  3606. && exports.utils.Tool_Baidu.ServerConfig
  3607. && exports.utils.Tool_Baidu.ServerConfig.is_vertical_game) {
  3608. if (exports.utils.Tool_Baidu.ServerConfig.is_vertical_game == "true") {
  3609. return true;
  3610. }
  3611. else {
  3612. exports.utils.showLog("warn:" + "is_vertical_game参数为false,更多游戏侧边栏组件不显示!");
  3613. }
  3614. }
  3615. else {
  3616. exports.utils.showLog("warn:" + "配置中没有is_vertical_game参数,更多游戏侧边栏组件不显示!");
  3617. }
  3618. }
  3619. else {
  3620. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,更多游戏侧边栏组件不显示!");
  3621. }
  3622. }
  3623. else if (PlatUtils_1.default.IsQQ) {
  3624. if (exports.utils.isSupportnavigateToMiniGame()) {
  3625. if (exports.utils.Tool_QQ
  3626. && exports.utils.Tool_QQ.ServerConfig
  3627. && exports.utils.Tool_QQ.ServerConfig.is_vertical_game) {
  3628. if (exports.utils.Tool_QQ.ServerConfig.is_vertical_game == "true") {
  3629. return true;
  3630. }
  3631. else {
  3632. exports.utils.showLog("warn:" + "is_vertical_game参数为false,更多游戏侧边栏组件不显示!");
  3633. }
  3634. }
  3635. else {
  3636. exports.utils.showLog("warn:" + "配置中没有is_vertical_game参数,更多游戏侧边栏组件不显示!");
  3637. }
  3638. }
  3639. else {
  3640. exports.utils.showLog("warn:" + "当前平台不支持游戏内跳转,更多游戏侧边栏组件不显示!");
  3641. }
  3642. }
  3643. else if (PlatUtils_1.default.Is4399) {
  3644. return true;
  3645. }
  3646. else if (PlatUtils_1.default.IsNativeAndroid) {
  3647. if (exports.utils.Tool_Native
  3648. && exports.utils.Tool_Native.ServerConfig
  3649. && exports.utils.Tool_Native.ServerConfig.is_vertical_game) {
  3650. if (exports.utils.Tool_Native.ServerConfig.is_vertical_game == "true") {
  3651. return true;
  3652. }
  3653. else {
  3654. exports.utils.showLog("warn:" + "is_vertical_game参数为false,更多游戏侧边栏组件不显示!");
  3655. }
  3656. }
  3657. else {
  3658. exports.utils.showLog("warn:" + "配置中没有is_vertical_game参数,更多游戏侧边栏组件不显示!");
  3659. }
  3660. }
  3661. else if (PlatUtils_1.default.IsNativeIOS) {
  3662. if (exports.utils.Tool_IOS
  3663. && exports.utils.Tool_IOS.ServerConfig
  3664. && exports.utils.Tool_IOS.ServerConfig.is_vertical_game) {
  3665. if (exports.utils.Tool_IOS.ServerConfig.is_vertical_game == "true") {
  3666. return true;
  3667. }
  3668. else {
  3669. exports.utils.showLog("warn:" + "is_vertical_game参数为false,更多游戏侧边栏组件不显示!");
  3670. }
  3671. }
  3672. else {
  3673. exports.utils.showLog("warn:" + "配置中没有is_vertical_game参数,更多游戏侧边栏组件不显示!");
  3674. }
  3675. }
  3676. return false;
  3677. };
  3678. /**
  3679. * 显示红包进度挂件
  3680. * @param params
  3681. */
  3682. Utils.prototype.showVerticalRecommentPanel = function (params) {
  3683. if (params === void 0) { params = null; }
  3684. if (!this._isConfigInit) {
  3685. exports.utils.showLog("warn:" + "组件配置未初始化!");
  3686. return null;
  3687. }
  3688. if (!this.isVerticalRecommentPanel())
  3689. return null;
  3690. if (this.config.otherconfig.verticalRecommentPanel) {
  3691. var node = cc.instantiate(this.config.otherconfig.verticalRecommentPanel);
  3692. if (node) {
  3693. // if (this._redBagProgressWidget && cc.isValid(this._redBagProgressWidget)) {
  3694. // this._redBagProgressWidget.destroy();
  3695. // }
  3696. node.zIndex = 9999;
  3697. var widget = node.getComponent(cc.Widget);
  3698. if (params) {
  3699. if (params.group) {
  3700. node.group = params.group;
  3701. }
  3702. if (params.scale != null) {
  3703. node.scale = params.scale;
  3704. }
  3705. if (params.top != null) {
  3706. widget.isAlignTop = true;
  3707. widget.isAlignBottom = false;
  3708. widget.top = params.top;
  3709. }
  3710. else if (params.bottom != null) {
  3711. widget.isAlignTop = false;
  3712. widget.isAlignBottom = true;
  3713. widget.bottom = params.bottom;
  3714. }
  3715. if (params.left != null) {
  3716. widget.isAlignLeft = true;
  3717. widget.isAlignRight = false;
  3718. widget.left = params.left;
  3719. }
  3720. else if (params.right != null) {
  3721. widget.isAlignLeft = false;
  3722. widget.isAlignRight = true;
  3723. widget.right = params.right;
  3724. }
  3725. if (params.parent != null) {
  3726. node.parent = params.parent;
  3727. }
  3728. if (params.position != null) {
  3729. node.setPosition(CompatibleTool_1.default.position(params.position.x, params.position.y));
  3730. }
  3731. }
  3732. widget.updateAlignment();
  3733. return node;
  3734. }
  3735. }
  3736. else {
  3737. exports.utils.showLog("warn:" + "未找到预制体 verticalRecommentPanel, 请查看CommonUtils组件上是否赋值!");
  3738. }
  3739. return null;
  3740. };
  3741. /**
  3742. * 是否显示用户协议挂件
  3743. */
  3744. Utils.prototype.isShowPrivacyWidget = function () {
  3745. if (this.Tool_Broswer)
  3746. return true;
  3747. if (this.getConfigByKey("is_privacy") == "true") {
  3748. return true;
  3749. }
  3750. else {
  3751. exports.utils.showLog("warn:" + "配置中没有is_privacy参数,更用户协议挂件组件不显示!");
  3752. }
  3753. return false;
  3754. };
  3755. /**
  3756. * 显示用户协议挂件
  3757. * @param params
  3758. */
  3759. Utils.prototype.showPrivacyWidget = function (params) {
  3760. if (params === void 0) { params = null; }
  3761. if (exports.utils.isShowPrivacyWidget()) {
  3762. if (this.config.otherconfig.privacyWidget) {
  3763. if (this._privacyWidget && cc.isValid(this._privacyWidget)) {
  3764. this._privacyWidget.destroy();
  3765. }
  3766. var node_1 = cc.instantiate(this.config.otherconfig.privacyWidget);
  3767. this._privacyWidget = node_1;
  3768. this._privacyWidget.zIndex = 9999;
  3769. var widget = node_1.getComponent(cc.Widget);
  3770. if (params) {
  3771. if (params.color) {
  3772. node_1.children[0].color = params.color;
  3773. }
  3774. if (params.group) {
  3775. node_1.group = params.group;
  3776. }
  3777. if (params.scale != null) {
  3778. node_1.scale = params.scale;
  3779. }
  3780. if (params.top != null) {
  3781. widget.isAlignTop = true;
  3782. widget.isAlignBottom = false;
  3783. widget.top = params.top;
  3784. }
  3785. else if (params.bottom != null) {
  3786. widget.isAlignTop = false;
  3787. widget.isAlignBottom = true;
  3788. widget.bottom = params.bottom;
  3789. }
  3790. if (params.left != null) {
  3791. widget.isAlignLeft = true;
  3792. widget.isAlignRight = false;
  3793. widget.left = params.left;
  3794. }
  3795. else if (params.right != null) {
  3796. widget.isAlignLeft = false;
  3797. widget.isAlignRight = true;
  3798. widget.right = params.right;
  3799. }
  3800. if (params.parent != null) {
  3801. node_1.parent = params.parent;
  3802. }
  3803. }
  3804. widget.updateAlignment();
  3805. node_1.on(cc.Node.EventType.TOUCH_END, function () {
  3806. if (PlatUtils_1.default.IsNativeAndroid) {
  3807. exports.utils.Tool_Native && exports.utils.Tool_Native.showPrivacyAgreement();
  3808. }
  3809. else {
  3810. exports.utils.showPrivacyPanel({ is_widget_click: "true", group: node_1.group });
  3811. }
  3812. }, this);
  3813. return node_1;
  3814. }
  3815. else {
  3816. exports.utils.showLog("warn:" + "隐私政策挂件预制体不存在!");
  3817. }
  3818. }
  3819. else {
  3820. exports.utils.showLog("warn:" + "不可显示更多游戏侧边栏");
  3821. }
  3822. return null;
  3823. };
  3824. /**
  3825. * 隐藏隐私政策
  3826. */
  3827. Utils.prototype.hidePrivacyWidget = function () {
  3828. if (this._privacyWidget && cc.isValid(this._privacyWidget)) {
  3829. this._privacyWidget.destroy();
  3830. }
  3831. };
  3832. /**
  3833. * 是否显示用户隐私协议弹窗
  3834. */
  3835. Utils.prototype.isShowPrivacyPanel = function () {
  3836. if (PlatUtils_1.default.IsHuaWei || PlatUtils_1.default.IsXiaoMi) {
  3837. return true;
  3838. }
  3839. if (this.getConfigByKey("is_privacy_panel")) {
  3840. if (this.getConfigByKey("is_privacy_panel") == "true") {
  3841. return true;
  3842. }
  3843. else {
  3844. exports.utils.showLog("warn:" + "is_privacy_panel参数为false,用户隐私政策弹窗组件不显示!");
  3845. }
  3846. }
  3847. return false;
  3848. };
  3849. /**
  3850. * 显示用户协议弹窗
  3851. * @param params
  3852. */
  3853. Utils.prototype.showPrivacyPanel = function (params) {
  3854. var _this = this;
  3855. if (params === void 0) { params = null; }
  3856. exports.utils.showLog("showPrivacyPanel>>>");
  3857. var showPanel = function (showDesc) {
  3858. if (_this.config.otherconfig.privacyPanel) {
  3859. if (_this._privacyPanel && cc.isValid(_this._privacyPanel)) {
  3860. _this._privacyPanel.destroy();
  3861. }
  3862. var node = cc.instantiate(_this.config.otherconfig.privacyPanel);
  3863. var yzUserPrivacyPanel = node.getComponent(YzUserPrivacyPanel_1.default);
  3864. yzUserPrivacyPanel.showDesc = showDesc;
  3865. _this._privacyPanel = node;
  3866. _this._privacyPanel.zIndex = 9999;
  3867. var widget = node.getComponent(cc.Widget);
  3868. var subject = "深圳市优智信息技术有限公司";
  3869. if (params && params.subject) {
  3870. subject = params.subject;
  3871. }
  3872. var content = cc.find("Panel/subject", node).getComponent(cc.Label).string;
  3873. content = content.replace('subject', subject);
  3874. cc.find("Panel/subject", node).getComponent(cc.Label).string = content;
  3875. if (params) {
  3876. if (params.group) {
  3877. node.group = params.group;
  3878. }
  3879. if (params.scale != null) {
  3880. node.scale = params.scale;
  3881. }
  3882. if (params.top != null) {
  3883. widget.isAlignTop = true;
  3884. widget.isAlignBottom = false;
  3885. widget.top = params.top;
  3886. }
  3887. else if (params.bottom != null) {
  3888. widget.isAlignTop = false;
  3889. widget.isAlignBottom = true;
  3890. widget.bottom = params.bottom;
  3891. }
  3892. if (params.left != null) {
  3893. widget.isAlignLeft = true;
  3894. widget.isAlignRight = false;
  3895. widget.left = params.left;
  3896. }
  3897. else if (params.right != null) {
  3898. widget.isAlignLeft = false;
  3899. widget.isAlignRight = true;
  3900. widget.right = params.right;
  3901. }
  3902. if (params.parent != null) {
  3903. node.parent = params.parent;
  3904. }
  3905. else {
  3906. cc.find("Canvas").addChild(node, cc.macro.MAX_ZINDEX);
  3907. }
  3908. }
  3909. else {
  3910. cc.find("Canvas").addChild(node, cc.macro.MAX_ZINDEX);
  3911. }
  3912. widget.updateAlignment();
  3913. }
  3914. else {
  3915. exports.utils.showLog("warn:" + "隐私政策弹窗预制体不存在!");
  3916. }
  3917. };
  3918. if (params && params.is_widget_click) {
  3919. showPanel(true);
  3920. }
  3921. else {
  3922. var ysxy = YZ_LocalStorage_1.default.getItem(YZ_Constant_1.default.YZ_GAME_YSXY);
  3923. if (ysxy) {
  3924. exports.utils.emitPrivacyCloseEvent();
  3925. exports.utils.showLog("已经同意过隐私协议,不显示隐私协议弹窗!");
  3926. return;
  3927. }
  3928. exports.utils.registerServerDataLoadSuccessEvent(function () {
  3929. showPanel();
  3930. }, this);
  3931. }
  3932. };
  3933. /**
  3934. * 显示放大缩小动态
  3935. * @param videoBtn 视频播放按钮
  3936. * @param normalBtn 普通按钮
  3937. * @param changeBtn 是否变换按钮位置
  3938. * @param showHand 是否显示手势
  3939. * @param location 按钮所属的页面位置
  3940. * @returns
  3941. */
  3942. Utils.prototype.showScaleAction = function (videoBtn, normalBtn, changeBtn, showHand, location) {
  3943. if (normalBtn === void 0) { normalBtn = null; }
  3944. if (changeBtn === void 0) { changeBtn = true; }
  3945. if (showHand === void 0) { showHand = true; }
  3946. if (location === void 0) { location = YZ_Constant_1.BannerLocation.None; }
  3947. if (changeBtn) {
  3948. if (!cc.isValid(normalBtn) || !cc.isValid(videoBtn))
  3949. return;
  3950. }
  3951. else {
  3952. if (!cc.isValid(videoBtn))
  3953. return;
  3954. }
  3955. if (CC_DEBUG) {
  3956. this.ServerConfig.btn_show_scale = "true";
  3957. this.ServerConfig.change_btn_position = "true";
  3958. this.ServerConfig.over_page_change_btn = "false";
  3959. this.ServerConfig.over_page_scale_btn = "false";
  3960. }
  3961. var scaleNode = videoBtn;
  3962. if (this.getConfigByKey("change_btn_position") == "true" && changeBtn == true) {
  3963. var changePosition = true;
  3964. if (location == YZ_Constant_1.BannerLocation.Over) {
  3965. if (this.getConfigByKey("over_page_change_btn") == "false") {
  3966. changePosition = false;
  3967. exports.utils.showLog("结算页面按钮配置不切换位置!");
  3968. }
  3969. }
  3970. if (changePosition) {
  3971. var rand = Math.floor(Math.random() * 2 + 1);
  3972. var videoPos = videoBtn.position;
  3973. var normalPos = normalBtn.position;
  3974. if (rand % 2 == 0) {
  3975. normalBtn.position = videoPos;
  3976. videoBtn.position = normalPos;
  3977. }
  3978. else {
  3979. scaleNode = videoBtn;
  3980. normalBtn.position = normalPos;
  3981. videoBtn.position = videoPos;
  3982. }
  3983. scaleNode = normalBtn.position.y > videoBtn.position.y ? normalBtn : videoBtn;
  3984. }
  3985. }
  3986. if (this.getConfigByKey("btn_show_scale") == "true") {
  3987. if (location == YZ_Constant_1.BannerLocation.Over &&
  3988. this.getConfigByKey("over_page_scale_btn") == "false") {
  3989. exports.utils.showLog("结算页面按钮配置不缩放按钮!");
  3990. return;
  3991. }
  3992. if (videoBtn) {
  3993. videoBtn.stopAllActions();
  3994. videoBtn.scale = 1;
  3995. }
  3996. if (normalBtn) {
  3997. normalBtn.stopAllActions();
  3998. normalBtn.scale = 1;
  3999. }
  4000. var action = cc.sequence(cc.scaleTo(this.runTime, this.maxScale), cc.scaleTo(this.runTime, this.minScale));
  4001. scaleNode.runAction(action.repeatForever());
  4002. if (showHand) {
  4003. if (videoBtn) {
  4004. var child = videoBtn.parent.getChildByName("hand");
  4005. if (child) {
  4006. child.destroy();
  4007. child.removeFromParent();
  4008. }
  4009. }
  4010. if (normalBtn) {
  4011. var child = normalBtn.parent.getChildByName("hand");
  4012. if (child) {
  4013. child.destroy();
  4014. child.removeFromParent();
  4015. }
  4016. }
  4017. if (this.config.otherconfig.handPrefab) {
  4018. var hand = cc.instantiate(this.config.otherconfig.handPrefab);
  4019. hand.x = scaleNode.x + scaleNode.width / 2;
  4020. hand.y = scaleNode.y - 135;
  4021. scaleNode.parent.addChild(hand, cc.macro.MAX_ZINDEX + 1, "hand");
  4022. }
  4023. }
  4024. }
  4025. };
  4026. /**
  4027. * 上报原生广告点击
  4028. */
  4029. Utils.prototype.reportNativeAdClick = function () {
  4030. if ((new Date().getTime() - this._lastReportAdTime) / 1000 > 3) {
  4031. this._lastReportAdTime = new Date().getTime();
  4032. cc.game.emit(YZ_Constant_1.default.YZ_NativeAdClick);
  4033. this.showLog("上报原生广告点击!");
  4034. }
  4035. else {
  4036. this.showLog("上报原生广告点击间隔时间小于3秒!");
  4037. }
  4038. };
  4039. /**
  4040. * 是否显示结算页面广告点击按钮
  4041. */
  4042. Utils.prototype.canShowOverPageAdBtn = function () {
  4043. if (this.ServerConfig && this.ServerConfig.show_over_page_ad_btn && this.ServerConfig.show_over_page_ad_btn == "true") {
  4044. return true;
  4045. }
  4046. return false;
  4047. };
  4048. /**
  4049. * 显示小游戏官方互推banner
  4050. */
  4051. Utils.prototype.showRecBanner = function () {
  4052. if (!exports.utils.adManager.checkShowAdTime()) {
  4053. exports.utils.showLog("显示广告条时间未达限制!");
  4054. return;
  4055. }
  4056. this.cur_tool && this.cur_tool.showRecBanner && this.cur_tool.showRecBanner();
  4057. };
  4058. /**
  4059. * 显示小游戏官方互推九宫格
  4060. */
  4061. Utils.prototype.showGamePortal = function () {
  4062. if (!exports.utils.adManager.checkShowAdTime()) {
  4063. exports.utils.showLog("显示广告条时间未达限制!");
  4064. return;
  4065. }
  4066. this.cur_tool && this.cur_tool.showGamePortal && this.cur_tool.showGamePortal();
  4067. };
  4068. Utils.prototype.showVivoGamePortalWidget = function (params) {
  4069. if (params === void 0) { params = null; }
  4070. if (!this._isConfigInit) {
  4071. exports.utils.showLog("warn:" + "组件配置未初始化!");
  4072. return;
  4073. }
  4074. if (!PlatUtils_1.default.IsVIVO)
  4075. return;
  4076. if (!exports.utils.adManager.checkShowAdTime()) {
  4077. exports.utils.showLog("显示广告条时间未达限制!");
  4078. return;
  4079. }
  4080. if (this.getConfigByKey("vivo_game_protal") === "true") {
  4081. if (params && params.location && (this.getConfigByKey("vivo_game_protal_locations").indexOf(params.location) < 0)) {
  4082. exports.utils.showLog("当前位置服务器未配置显示VIVO九宫格挂件!");
  4083. this.Tool_Vivo && this.Tool_Vivo.hideGamePortal();
  4084. return;
  4085. }
  4086. this.Tool_Vivo && this.Tool_Vivo.showGamePortal(params.top);
  4087. }
  4088. else {
  4089. exports.utils.showLog("服务器未配置显示VIVO九宫格挂件!");
  4090. }
  4091. };
  4092. /**
  4093. * 隐藏VIVO九宫格挂件
  4094. * @param params
  4095. */
  4096. Utils.prototype.hideVivoGamePortalWidget = function () {
  4097. this.Tool_Vivo && this.Tool_Vivo.hideGamePortal();
  4098. };
  4099. /*
  4100. **
  4101. * 显示OPPO互推抽屉盒子广告:
  4102. * 只能显示在左侧,设置top值
  4103. * @param params
  4104. * ```
  4105. * {
  4106. * top:number // 距离屏幕顶部的距离
  4107. * }
  4108. * ```
  4109. */
  4110. Utils.prototype.showOppoGameDrawerAdWidget = function (params) {
  4111. if (params === void 0) { params = null; }
  4112. if (!this._isConfigInit) {
  4113. exports.utils.showLog("warn:" + "组件配置未初始化!");
  4114. return;
  4115. }
  4116. if (!PlatUtils_1.default.IsOPPO)
  4117. return;
  4118. if (!exports.utils.adManager.checkShowAdTime()) {
  4119. exports.utils.showLog("显示广告条时间未达限制!");
  4120. return;
  4121. }
  4122. if (CC_DEBUG) {
  4123. this.ServerConfig.oppo_game_drawer = "true";
  4124. this.ServerConfig.oppo_game_drawer_locations = "1, 2, 3, 4,5,6";
  4125. }
  4126. if (this.getConfigByKey("oppo_game_drawer") === "true") {
  4127. if (params && params.location && (this.getConfigByKey("oppo_game_drawer_locations").indexOf(params.location) < 0)) {
  4128. exports.utils.showLog("当前位置服务器未配置显示OPPO互推抽屉盒子!");
  4129. this.oppoTool && this.oppoTool.hideGameDrawerAd();
  4130. return;
  4131. }
  4132. // if (params && params.location && this._curGameDrawerAdLocation && this._curGameDrawerAdLocation != params.location) {
  4133. // this.oppoTool && this.oppoTool.hideGameDrawerAd();
  4134. // }
  4135. this.oppoTool && this.oppoTool.showGameDrawerAd(params);
  4136. }
  4137. else {
  4138. exports.utils.showLog("服务器未配置显示OPPO互推抽屉盒子!");
  4139. }
  4140. };
  4141. /**
  4142. * 隐藏OPPO互推抽屉盒子广告
  4143. * @param params
  4144. */
  4145. Utils.prototype.hideOppoGameDrawerAdWidget = function () {
  4146. this.oppoTool && this.oppoTool.hideGameDrawerAd();
  4147. };
  4148. /*
  4149. **
  4150. * 显示OPPO互推横幅广告:
  4151. * @param params
  4152. * ```
  4153. * {
  4154. * top:number // 距离屏幕顶部的距离
  4155. * }
  4156. * ```
  4157. */
  4158. Utils.prototype.showOppoRecBanner = function (params) {
  4159. if (params === void 0) { params = null; }
  4160. if (!this._isConfigInit) {
  4161. exports.utils.showLog("warn:" + "组件配置未初始化!");
  4162. return;
  4163. }
  4164. if (!PlatUtils_1.default.IsOPPO)
  4165. return;
  4166. if (!exports.utils.adManager.checkShowAdTime()) {
  4167. exports.utils.showLog("显示广告条时间未达限制!");
  4168. return;
  4169. }
  4170. if (CC_DEBUG) {
  4171. this.ServerConfig.oppo_rec_banner = "true";
  4172. this.ServerConfig.oppo_rec_banner_locations = "1, 2, 3, 4";
  4173. }
  4174. if (this.getConfigByKey("oppo_rec_banner") === "true") {
  4175. if (params && params.location && (this.getConfigByKey("oppo_rec_banner_locations").indexOf(params.location) < 0)) {
  4176. exports.utils.showLog("当前位置服务器未配置显示OPPO互推Banner!");
  4177. this.oppoTool && this.oppoTool.hideOppoRecBanner();
  4178. return;
  4179. }
  4180. this.oppoTool && this.oppoTool.showOppoNewRecBanner(params);
  4181. }
  4182. else {
  4183. exports.utils.showLog("服务器未配置显示OPPO互推Banner!");
  4184. }
  4185. };
  4186. /**
  4187. * 隐藏OPPO互推横幅广告
  4188. * @param params
  4189. */
  4190. Utils.prototype.hideOppoRecBanner = function () {
  4191. this.oppoTool && this.oppoTool.hideOppoRecBanner();
  4192. };
  4193. /**
  4194. * 实名认证
  4195. */
  4196. Utils.prototype.realNameAuth = function (code, name, callBack) {
  4197. exports.utils.showLog("\u8FDB\u884C\u5B9E\u540D\u5236\u8BA4\u8BC1\uFF1A#code=" + code + " #name=" + name);
  4198. exports.utils.cur_tool && exports.utils.cur_tool.realNameAuth && exports.utils.cur_tool.realNameAuth(code, name, callBack);
  4199. };
  4200. /**
  4201. * 退出游戏
  4202. */
  4203. Utils.prototype.GameExit = function () {
  4204. this.cur_tool && this.cur_tool.GameExit && this.cur_tool.GameExit();
  4205. };
  4206. /**
  4207. * 显示实名制认证弹窗
  4208. * @param params
  4209. */
  4210. Utils.prototype.showYzRealNameAuthPanel = function (params) {
  4211. if (params === void 0) { params = null; }
  4212. exports.utils.showLog("显示实名制认证弹窗!");
  4213. if (!this._isConfigInit) {
  4214. exports.utils.showLog("warn:" + "组件配置未初始化!");
  4215. return;
  4216. }
  4217. if (this.getRealNameAuthLocalData() && this.getRealNameAuthLocalData() == "1") {
  4218. this._isRealNameAuth = true;
  4219. }
  4220. if (this._isRealNameAuth) {
  4221. exports.utils.showLog("已经进行过实名制认证,不显示弹窗!");
  4222. this.emitRealNameAuthCloseEvent();
  4223. return;
  4224. }
  4225. var showTime = -1;
  4226. if (PlatUtils_1.default.IsNativeAndroid || PlatUtils_1.default.IsNativeIOS) {
  4227. showTime = 0;
  4228. }
  4229. if (this.getConfigByKey("show_real_name_auth")) {
  4230. showTime = parseInt(this.getConfigByKey("show_real_name_auth"));
  4231. }
  4232. if (showTime == -1) {
  4233. exports.utils.showLog("服务器控制不显示实名制弹窗!");
  4234. this.emitRealNameAuthCloseEvent();
  4235. return;
  4236. }
  4237. if (PlatUtils_1.default.IsNativeAndroid) {
  4238. this.scheduleOnce(function () {
  4239. exports.utils.Tool_Native.showRealNameAuthPanel(showTime + "");
  4240. }, showTime);
  4241. return;
  4242. }
  4243. if (this.config.otherconfig.yzRealNameAuthPanel) {
  4244. if (this._yzRealNameAuthPanel && cc.isValid(this._yzRealNameAuthPanel)) {
  4245. this._yzRealNameAuthPanel.destroy();
  4246. }
  4247. var node_2 = cc.instantiate(this.config.otherconfig.yzRealNameAuthPanel);
  4248. if (showTime == -2) {
  4249. //达到防沉迷要求,直接提示下线
  4250. node_2.getComponent(YzRealNameAuthPanel_1.default)._isOffLine = true;
  4251. showTime = 0;
  4252. }
  4253. this._yzRealNameAuthPanel = node_2;
  4254. this._yzRealNameAuthPanel.zIndex = 9999;
  4255. if (params) {
  4256. if (params.group) {
  4257. node_2.group = params.group;
  4258. }
  4259. if (params.scale != null) {
  4260. node_2.scale = params.scale;
  4261. }
  4262. this.scheduleOnce(function () {
  4263. if (params.parent != null) {
  4264. node_2.parent = params.parent;
  4265. }
  4266. else {
  4267. cc.find("Canvas").addChild(node_2);
  4268. }
  4269. }, showTime * 1000);
  4270. }
  4271. else {
  4272. this.scheduleOnce(function () {
  4273. cc.find("Canvas").addChild(node_2);
  4274. }, showTime * 1000);
  4275. }
  4276. return node_2;
  4277. }
  4278. exports.utils.showLog("warn:" + "实名制认证弹窗预制体不存在!");
  4279. return null;
  4280. };
  4281. Utils.prototype.setRealNameAuthLocalData = function (value) {
  4282. YZ_LocalStorage_1.default.setItem('yz_game_real_name', "" + value);
  4283. };
  4284. Utils.prototype.getRealNameAuthLocalData = function () {
  4285. var realName = YZ_LocalStorage_1.default.getItem('yz_game_real_name');
  4286. if (!realName) {
  4287. realName = 0;
  4288. }
  4289. return realName;
  4290. };
  4291. /**
  4292. * 通过字段名称获取服务器对应的配置
  4293. * @param key 字段名称
  4294. * @returns 服务器有配置则返回该配置,无则返回空字符串
  4295. */
  4296. Utils.prototype.getConfigByKey = function (key) {
  4297. if (!this._isConfigInit) {
  4298. exports.utils.showLog("warn:" + "本地数据未初始化!");
  4299. return "";
  4300. }
  4301. if (key && this.ServerConfig && key in this.ServerConfig) {
  4302. return this.ServerConfig[key];
  4303. }
  4304. this.showLog("warn:\u5B57\u6BB5\uFF1A" + key + " \u672A\u914D\u7F6E\uFF01");
  4305. return "";
  4306. };
  4307. /**
  4308. * 登录
  4309. * @param successCallFunc 成功回调
  4310. * @param failCallFunc 失败回调
  4311. */
  4312. Utils.prototype.login = function (successCallFunc, failCallFunc) {
  4313. var _this = this;
  4314. this.showLog("=====login====");
  4315. if (successCallFunc) {
  4316. if (PlatUtils_1.default.IsDouyin) {
  4317. // if (YZ_LocalStorage.getItem("yz_login", "false") == "true") {
  4318. // successCallFunc && successCallFunc();
  4319. // return;
  4320. // }
  4321. }
  4322. cc.game.targetOff(YZ_Constant_1.default.ST_LOGIN_SUCCESS);
  4323. cc.game.on(YZ_Constant_1.default.ST_LOGIN_SUCCESS, successCallFunc, this);
  4324. }
  4325. if (failCallFunc) {
  4326. var newFailFunc = function () {
  4327. failCallFunc();
  4328. _this.showLoginPanel();
  4329. };
  4330. cc.game.targetOff(YZ_Constant_1.default.ST_LOGIN_FAIL);
  4331. cc.game.on(YZ_Constant_1.default.ST_LOGIN_FAIL, newFailFunc, this);
  4332. }
  4333. else {
  4334. var newFailFunc = function () {
  4335. _this.showLoginPanel();
  4336. };
  4337. cc.game.targetOff(YZ_Constant_1.default.ST_LOGIN_FAIL);
  4338. cc.game.on(YZ_Constant_1.default.ST_LOGIN_FAIL, newFailFunc, this);
  4339. }
  4340. if (this.cur_tool && this.cur_tool.login) {
  4341. this.cur_tool.login();
  4342. }
  4343. else {
  4344. cc.game.targetOff(YZ_Constant_1.default.ST_LOGIN_SUCCESS);
  4345. cc.game.targetOff(YZ_Constant_1.default.ST_LOGIN_FAIL);
  4346. successCallFunc && successCallFunc();
  4347. }
  4348. };
  4349. /**
  4350. * 显示登录弹窗
  4351. */
  4352. Utils.prototype.showLoginPanel = function () {
  4353. if (this.config.otherconfig.yzLoginPanel) {
  4354. var node = cc.instantiate(this.config.otherconfig.yzLoginPanel);
  4355. if (node) {
  4356. if (this._yzLoginPanel && cc.isValid(this._yzLoginPanel)) {
  4357. this._yzLoginPanel.destroy();
  4358. }
  4359. this._yzLoginPanel = node;
  4360. cc.find("Canvas").addChild(node, cc.macro.MAX_ZINDEX);
  4361. return node;
  4362. }
  4363. }
  4364. else {
  4365. exports.utils.showLog("warn:" + "未找到预制体 YzLoginPanel, 请查看CommonUtils组件上是否赋值!");
  4366. }
  4367. };
  4368. /**
  4369. * 生成UUID
  4370. * @returns uuid
  4371. */
  4372. Utils.prototype.generateUUID = function () {
  4373. var d = new Date().getTime();
  4374. if (window.performance && typeof window.performance.now === "function") {
  4375. d += performance.now(); //use high-precision timer if available
  4376. }
  4377. var uuid = 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  4378. var r = (d + Math.random() * 16) % 16 | 0;
  4379. d = Math.floor(d / 16);
  4380. return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
  4381. });
  4382. return uuid;
  4383. };
  4384. __decorate([
  4385. property({ displayName: "组件版本", readonly: true })
  4386. ], Utils.prototype, "utilsVersion", null);
  4387. __decorate([
  4388. property({ displayName: "测试本地数据", tooltip: "勾选此选项则使用本地配置,否则会请求服务器配置!" })
  4389. ], Utils.prototype, "DebugLoacalConfig", void 0);
  4390. __decorate([
  4391. property({ displayName: "显示日志框", tooltip: "勾选此选项则会显示日志框,用于调试!" })
  4392. ], Utils.prototype, "showLogView", void 0);
  4393. __decorate([
  4394. property({ type: CommonConfig_1.default, displayName: "配置信息" })
  4395. ], Utils.prototype, "config", void 0);
  4396. Utils = __decorate([
  4397. ccclass
  4398. ], Utils);
  4399. return Utils;
  4400. }(cc.Component));
  4401. exports.default = Utils;
  4402. cc._RF.pop();