8af0d3b5-9a75-4ffc-824c-767c8c3b8fe3.js 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590
  1. "use strict";
  2. cc._RF.push(module, '8af0dO1mnVP/IJMdnyMO4/j', 'uma.min');
  3. // common-plugin/Scripts/UMengSDK/quickGame/uma.min.js
  4. "use strict";
  5. exports.__esModule = true;
  6. exports["default"] = void 0;
  7. var e = "[UMENG] -- ",
  8. t = function () {
  9. var t = null,
  10. n = !1;
  11. function i() {
  12. this.setDebug = function (e) {
  13. n = e;
  14. };
  15. this.d = function () {
  16. if (n) try {
  17. "string" == typeof arguments[0] && (arguments[0] = e + arguments[0]);
  18. console.log.apply(console, arguments);
  19. } catch (e) {}
  20. };
  21. this.i = function () {
  22. try {
  23. if (n) try {
  24. "string" == typeof arguments[0] && (arguments[0] = e + arguments[0]);
  25. console.log.apply(console, arguments);
  26. } catch (e) {}
  27. } catch (e) {}
  28. };
  29. this.e = function () {
  30. if (n) try {
  31. "string" == typeof arguments[0] && (arguments[0] = e + arguments[0]);
  32. console.log.apply(console, arguments);
  33. } catch (e) {}
  34. };
  35. this.w = function () {
  36. if (n) try {
  37. "string" == typeof arguments[0] && (arguments[0] = e + arguments[0]);
  38. console.log.apply(console, arguments);
  39. } catch (e) {}
  40. };
  41. this.v = function () {
  42. if (n) try {
  43. "string" == typeof arguments[0] && (arguments[0] = e + arguments[0]);
  44. console.log.apply(console, arguments);
  45. } catch (e) {}
  46. };
  47. this.t = function () {
  48. if (n) try {
  49. console.log.apply(console, arguments);
  50. } catch (e) {}
  51. };
  52. this.tip = function () {
  53. try {
  54. "string" == typeof arguments[0] && (arguments[0] = e + arguments[0]);
  55. console.log.apply(console, arguments);
  56. } catch (e) {}
  57. };
  58. this.tip_w = function (e) {
  59. try {
  60. console.log("%c [UMENG] -- " + e, "background:red; padding: 4px; padding-right: 8px; border-radius: 4px; color: #fff;");
  61. } catch (e) {}
  62. };
  63. this.err = function () {
  64. try {
  65. "string" == typeof arguments[0] && (arguments[0] = e + arguments[0]);
  66. console.log.apply(console, arguments);
  67. } catch (e) {}
  68. };
  69. this.repeat = function (e) {
  70. for (var t = e; t.length < 86;) {
  71. t += e;
  72. }
  73. return t;
  74. };
  75. }
  76. return function () {
  77. null === t && (t = new i());
  78. return t;
  79. };
  80. }(),
  81. n = function () {
  82. var e = null;
  83. function t() {
  84. var e = {};
  85. this.useOpenid = function () {
  86. return !!e.useOpenid;
  87. };
  88. this.useSwanid = function () {
  89. return !!e.useSwanid;
  90. };
  91. this.autoGetOpenid = function () {
  92. return !!e.autoGetOpenid;
  93. };
  94. this.appKey = function () {
  95. return e.appKey;
  96. };
  97. this.uploadUserInfo = function () {
  98. return e.uploadUserInfo;
  99. };
  100. this.enableVerify = function () {
  101. return e.enableVerify;
  102. };
  103. this.set = function (t) {
  104. e = t;
  105. };
  106. this.get = function () {
  107. return e;
  108. };
  109. this.setItem = function (t, n) {
  110. e[t] = n;
  111. };
  112. this.getItem = function (t) {
  113. return e[t];
  114. };
  115. }
  116. return function () {
  117. e || (e = new t());
  118. return e;
  119. };
  120. }();
  121. function i() {}
  122. i.prototype = {
  123. on: function on(e, t, n) {
  124. var i = this.e || (this.e = {});
  125. (i[e] || (i[e] = [])).push({
  126. fn: t,
  127. ctx: n
  128. });
  129. return this;
  130. },
  131. once: function once(e, t, n) {
  132. var i = this;
  133. function r() {
  134. i.off(e, r);
  135. t.apply(n, arguments);
  136. }
  137. r._ = t;
  138. return this.on(e, r, n);
  139. },
  140. emit: function emit(e) {
  141. for (var t = [].slice.call(arguments, 1), n = ((this.e || (this.e = {}))[e] || []).slice(), i = 0, r = n.length; i < r; i++) {
  142. n[i].fn.apply(n[i].ctx, t);
  143. }
  144. return this;
  145. },
  146. off: function off(e, t) {
  147. var n = this.e || (this.e = {}),
  148. i = n[e],
  149. r = [];
  150. if (i && t) for (var o = 0, s = i.length; o < s; o++) {
  151. i[o].fn !== t && i[o].fn._ !== t && r.push(i[o]);
  152. }
  153. r.length ? n[e] = r : delete n[e];
  154. return this;
  155. }
  156. };
  157. var r = new i();
  158. r.messageType = {
  159. CONFIG_LOADED: 0,
  160. UMA_LIB_INITED: 1
  161. };
  162. function o() {
  163. return cc ? cc.sys && cc.sys.platform && cc.sys.platform <= 111 && cc.sys.platform >= 108 ? qg || hbs : void 0 : qg || hbs;
  164. }
  165. var s = o();
  166. var a = new (function () {
  167. function e() {}
  168. e.prototype.setStorage = function (e, t, n) {
  169. if (s.setStorage) s.setStorage({
  170. key: e,
  171. value: t,
  172. success: function success() {
  173. "function" == typeof n && n(!0);
  174. },
  175. fail: function fail() {
  176. "function" == typeof n && n(!1);
  177. }
  178. });else {
  179. localStorage.setItem(e, t);
  180. "function" == typeof n && n(!0);
  181. }
  182. };
  183. e.prototype.getStorage = function (e, n) {
  184. if (s.getStorage) s.getStorage({
  185. key: e,
  186. success: function success(e) {
  187. "function" == typeof n && n(e);
  188. },
  189. fail: function fail(i, r) {
  190. t().w(e + "code = : " + r);
  191. "function" == typeof n && n();
  192. }
  193. });else if (localStorage) {
  194. var i = localStorage.getItem(e);
  195. "function" == typeof n && n(i);
  196. }
  197. };
  198. e.prototype.removeStorage = function (e, t) {
  199. if (s.deleteStorage) s.deleteStorage({
  200. key: e,
  201. success: function success() {
  202. "function" == typeof t && t(!0);
  203. },
  204. fail: function fail() {
  205. "function" == typeof t && t(!1);
  206. }
  207. });else if (localStorage) {
  208. localStorage.removeItem(e);
  209. "function" == typeof t && t(!0);
  210. }
  211. };
  212. e.prototype.getSystemInfo = function (e) {
  213. s.getSystemInfo({
  214. success: function success(t) {
  215. var n = {
  216. model: t.model,
  217. brand: t.brand,
  218. screenWidth: t.screenWidth,
  219. screenHeight: t.screenHeight,
  220. platform: t.osType,
  221. pixelRatio: t.pixelRatio,
  222. platformVersion: t.platformVersionCode,
  223. language: t.language,
  224. deviceName: t.model,
  225. OSVersion: t.osVersionName,
  226. resolution: "",
  227. statusBarHeight: t.statusBarHeight
  228. };
  229. if (t.system) {
  230. var i = t.system.split(" ");
  231. if (Array.isArray(i)) {
  232. !n.platform && (n.platform = i[0]);
  233. !n.OSVersion && (n.OSVersion = i[1]);
  234. }
  235. }
  236. var r = Math.round(t.screenWidth * t.pixelRatio),
  237. o = Math.round(t.screenHeight * t.pixelRatio);
  238. n.resolution = r > o ? r + "*" + o : o + "*" + r;
  239. "function" == typeof e && e(n);
  240. },
  241. fail: function fail() {
  242. "function" == typeof e && e();
  243. }
  244. });
  245. };
  246. e.prototype.getDeviceInfo = function (e) {
  247. "function" == typeof e && e("");
  248. };
  249. e.prototype.getNetworkInfo = function (e) {
  250. s.getNetworkType({
  251. success: function success(t) {
  252. "function" == typeof e && e({
  253. networkAvailable: "none" !== t.networkType,
  254. networkType: t.networkType
  255. });
  256. },
  257. fail: function fail() {
  258. "function" == typeof e && e();
  259. }
  260. });
  261. };
  262. e.prototype.request = function (e) {
  263. var t = e.success,
  264. n = e.fail,
  265. i = !1,
  266. r = null;
  267. e.success = function (e) {
  268. if (!i) {
  269. r && clearTimeout(r);
  270. "function" == typeof t && t(e);
  271. }
  272. };
  273. e.fail = function () {
  274. if (!i) {
  275. r && clearTimeout(r);
  276. "function" == typeof n && n(!1);
  277. }
  278. };
  279. s.request ? s.request(e) : XMLHttpRequest && function (e, t) {
  280. void 0 === t && (t = !0);
  281. (e = e || {}).method = e.method || "GET";
  282. e.url = e.url || "";
  283. e.success = e.success || function () {};
  284. e.fail = e.fail || function () {};
  285. var n,
  286. i,
  287. r = new XMLHttpRequest(),
  288. o = [];
  289. if ("object" == typeof e.data) {
  290. for (var s in e.data) {
  291. o.push(s + "=" + encodeURIComponent(e.data[s]));
  292. }
  293. n = JSON.stringify(e.data || {});
  294. i = o.join("&");
  295. } else if ("string" == typeof e.data) {
  296. n = e.data;
  297. i = e.data;
  298. }
  299. "POST" === e.method ? r.open(e.method, e.url, t) : r.open(e.method, e.url + "?" + i || "", t);
  300. if (e.header && "object" == typeof e.header) {
  301. for (var a in e.header) {
  302. r.setRequestHeader(a, e.header[a]);
  303. }
  304. e.header["content-type"] || e.header["Content-Type"] || r.setRequestHeader("content-type", "text/plain");
  305. }
  306. t && (r.timeout = e.timeout || 3e4);
  307. r.onreadystatechange = function () {
  308. if (4 == r.readyState && 200 == r.status) {
  309. var t = {};
  310. try {
  311. t = JSON.parse(r.responseText);
  312. } catch (e) {}
  313. e.success({
  314. data: t,
  315. status: r.status
  316. });
  317. } else 4 == r.readyState && e.fail({
  318. data: null,
  319. status: r.status
  320. });
  321. };
  322. "POST" === e.method ? r.send(n || "") : r.send();
  323. }(e, !0);
  324. r = setTimeout(function () {
  325. r && clearTimeout(r);
  326. i = !0;
  327. "function" == typeof n && n(i);
  328. }, e.timeout || 3e4);
  329. };
  330. e.prototype.getSdkType = function () {
  331. return this.getPlatform() + "mp";
  332. };
  333. e.prototype.getPlatform = function () {
  334. return "quickgame";
  335. };
  336. e.prototype.getUserInfo = function (e) {
  337. e && e();
  338. };
  339. e.prototype.getAppInfoSync = function () {
  340. return {};
  341. };
  342. e.prototype.onShareAppMessage = function (e) {};
  343. e.prototype.shareAppMessage = function (e) {};
  344. e.prototype.getContext = function () {
  345. return o();
  346. };
  347. e.prototype.getLaunchOptionsSync = function () {
  348. var e = null;
  349. if (e) return e;
  350. if (!s.getLaunchOptionsSync) return {};
  351. try {
  352. e = s.getLaunchOptionsSync();
  353. } catch (t) {
  354. e = null;
  355. }
  356. return e || {};
  357. };
  358. return e;
  359. }())(),
  360. _u = function u(e, t) {
  361. return (_u = Object.setPrototypeOf || {
  362. __proto__: []
  363. } instanceof Array && function (e, t) {
  364. e.__proto__ = t;
  365. } || function (e, t) {
  366. for (var n in t) {
  367. t.hasOwnProperty(n) && (e[n] = t[n]);
  368. }
  369. })(e, t);
  370. };
  371. function c(e, t) {
  372. _u(e, t);
  373. function n() {
  374. this.constructor = e;
  375. }
  376. e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, new n());
  377. }
  378. var f = {
  379. SESSION_INTERVAL: 3e4,
  380. LOG_URL: "/quickgamem_logs",
  381. GET_OPENID_URL: "",
  382. USERINFO_URL: "/uminiprogram_logs/comm/uif",
  383. ENDPOINT: "https://umini.shujupie.com",
  384. ENDPOINTB: "https://ulogs.umeng.com",
  385. DEVICE_INFO_KEY: "device_info",
  386. ADVERTISING_ID: "mobile_ad_id",
  387. ANDROID_ID: "android_id",
  388. CURRENT_SESSION: "current_session",
  389. SESSION_PAUSE_TIME: "session_pause_time",
  390. EVENT_SEND_DEFAULT_INTERVAL: 15e3,
  391. EVENT_LAST_SEND_TIME: "last_send_time",
  392. MAX_EVENTID_LENGTH: 128,
  393. MAX_PROPERTY_KEY_LENGTH: 256,
  394. MAX_PROPERTY_KEYS_COUNT: 100,
  395. REPORT_POLICY: "report_policy",
  396. REPORT_INTERVAL_TIME: "report_interval_time",
  397. REPORT_POLICY_START_SEND: "1",
  398. REPORT_POLICY_INTERVAL: "6",
  399. IMPRINT: "imprint",
  400. SEED_VERSION: "1.0.0",
  401. IMPL_VERSION: "2.7.2-beta.17928427",
  402. ALIPAY_AVAILABLE_VERSION: "10.1.52",
  403. SHARE_PATH: "um_share_path",
  404. SHARES: "shares",
  405. REQUESTS: "requests",
  406. UUID: "um_uuid",
  407. UUID_SUFFIX: "ud",
  408. OPENID: "um_od",
  409. UNIONID: "um_unid",
  410. ALIPAYID: "um_alipayid",
  411. USERID: "um_userid",
  412. PROVIDER: "um_provider",
  413. SWANID: "um_swanid",
  414. ANONYMOUSID: "um_anonymousid",
  415. LAUNCH_OPTIONS: "LAUNCH_OPTIONS",
  416. UM_SSRC: "_um_ssrc",
  417. USER_INFO: "user_info",
  418. IS_ALIYUN: !1
  419. };
  420. var p,
  421. l = {
  422. isNumber: function isNumber(e) {
  423. return !Number.isNaN(parseInt(e, 10));
  424. },
  425. compareVersion: function compareVersion(e, t) {
  426. for (var n = String(e).split("."), i = String(t).split("."), r = 0; r < Math.max(n.length, i.length); r++) {
  427. var o = parseInt(n[r] || 0, 10),
  428. s = parseInt(i[r] || 0, 10);
  429. if (o > s) return 1;
  430. if (o < s) return -1;
  431. }
  432. return 0;
  433. },
  434. getRandomStr: function getRandomStr(e) {
  435. for (var t = "", n = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"], i = 0; i < Number(e); i++) {
  436. t += n[Math.round(Math.random() * (n.length - 1))];
  437. }
  438. return t;
  439. },
  440. clone: function clone(e) {
  441. return JSON.parse(JSON.stringify(e));
  442. },
  443. startsWith: function startsWith(e, t) {
  444. return !(!e || !t || 0 === t.length || t.length > e.length) && e.substr(0, t.length) === t;
  445. },
  446. endsWith: function endsWith(e, t) {
  447. return !(!t || 0 === e.length || t.length > e.length) && e.substring(e.length - t.length) === t;
  448. },
  449. assign: function assign(e) {
  450. if (null == e) throw new TypeError("Cannot convert undefined or null to object");
  451. for (var t = Object(e), n = 1; n < arguments.length; n++) {
  452. var i = arguments[n];
  453. if (i) for (var r in i) {
  454. Object.prototype.hasOwnProperty.call(i, r) && (t[r] = i[r]);
  455. }
  456. }
  457. return t;
  458. },
  459. deepEqual: function e(t, n) {
  460. if (t === n) return !0;
  461. if (t && "object" == typeof t && n && "object" == typeof n) {
  462. if (Object.keys(t).length !== Object.keys(n).length) return !1;
  463. for (var i in t) {
  464. if (Object.prototype.hasOwnProperty.call(n, i)) return !1;
  465. if (!e(t[i], n[i])) return !1;
  466. }
  467. return !0;
  468. }
  469. return !1;
  470. },
  471. trimStart: function trimStart(e, t) {
  472. if (!e) return "";
  473. if ("string" == typeof t && t.length) {
  474. var n = new RegExp("^" + t + "*");
  475. e = e.replace(n, "");
  476. } else e = e.replace(/^s*/, "");
  477. return e;
  478. },
  479. trimEnd: function trimEnd(e, t) {
  480. if (!e) return "";
  481. var n, i;
  482. if ("string" == typeof t && t.length) {
  483. n = new RegExp(t);
  484. i = e.length;
  485. for (; n.test(e.charAt(i));) {
  486. i -= 1;
  487. }
  488. return e.slice(0, i + 1);
  489. }
  490. n = /s/;
  491. i = e.length - 1;
  492. for (; n.test(e.charAt(i));) {
  493. i -= 1;
  494. }
  495. return e.slice(0, i + 1);
  496. },
  497. isFunction: function isFunction(e) {
  498. return "function" == typeof e;
  499. }
  500. },
  501. d = function (e) {
  502. c(n, e);
  503. function n() {
  504. var t = null !== e && e.apply(this, arguments) || this;
  505. t._openid = "";
  506. t._unionid = "";
  507. t._useOpenid = !1;
  508. return t;
  509. }
  510. n.prototype.initID = function (e) {
  511. var n = this;
  512. n._idType = n._useOpenid ? "openid" : "uuid";
  513. t().v("id type: ", n._idType);
  514. a.getStorage(f.UNIONID, function (e) {
  515. n._unionid = e;
  516. });
  517. this._useOpenid ? a.getStorage(f.OPENID, function (t) {
  518. n._openid = t;
  519. e && e();
  520. }) : e && e();
  521. };
  522. n.prototype.setUseOpenid = function (e) {
  523. this._useOpenid = e;
  524. };
  525. n.prototype.setOpenid = function (e) {
  526. if (!this._openid && e) {
  527. this._openid = e;
  528. a.setStorage(f.OPENID, e);
  529. }
  530. };
  531. n.prototype.setUnionid = function (e) {
  532. if (!this._unionid && e) {
  533. this._unionid = e;
  534. a.setStorage(f.UNIONID, e);
  535. }
  536. };
  537. n.prototype.getIdTracking = function () {
  538. var t = e.prototype.getIdTracking.call(this);
  539. this._openid && (t.openid = this._openid);
  540. this._unionid && (t.unionid = this._unionid);
  541. this._userid && (t.userid = this._userid);
  542. return t;
  543. };
  544. n.prototype.getId = function () {
  545. return this._useOpenid ? this._openid : this._uuid;
  546. };
  547. return n;
  548. }(function () {
  549. function e() {
  550. this._uuid = "";
  551. this._userid = "";
  552. this._provider = "";
  553. this._idType = "";
  554. }
  555. e.prototype.createUUID = function () {
  556. return l.getRandomStr(10) + Date.now() + l.getRandomStr(7) + f.UUID_SUFFIX;
  557. };
  558. e.prototype.initUUID = function (e) {
  559. var t = this;
  560. a.getStorage(f.UUID, function (n) {
  561. if (n) t._uuid = n;else {
  562. t._uuid = t.createUUID();
  563. a.setStorage(f.UUID, t._uuid);
  564. }
  565. e && e(n);
  566. });
  567. };
  568. e.prototype.initUserid = function () {
  569. var e = this;
  570. a.getStorage(f.USERID, function (n) {
  571. if (!e._userid && n) {
  572. e._userid = n;
  573. t().v("userId is ", n);
  574. }
  575. });
  576. a.getStorage(f.PROVIDER, function (n) {
  577. if (!e._provider && n) {
  578. e._provider = n;
  579. t().v("provider is ", n);
  580. }
  581. });
  582. };
  583. e.prototype.init = function (e) {
  584. var t = this;
  585. t.initUUID(function () {
  586. t.initUserid();
  587. t.initID(e);
  588. });
  589. };
  590. e.prototype.setUserid = function (e, t) {
  591. if (!this._userid && e) {
  592. this._userid = e;
  593. this._provider = t;
  594. a.setStorage(f.USERID, e);
  595. a.setStorage(f.PROVIDER, t);
  596. }
  597. };
  598. e.prototype.getUserId = function () {
  599. return this._userid;
  600. };
  601. e.prototype.getProvider = function () {
  602. return this._provider;
  603. };
  604. e.prototype.getIdType = function () {
  605. return this._idType;
  606. };
  607. e.prototype.getIdTracking = function () {
  608. var e = {};
  609. this._uuid && (e.uuid = this._uuid);
  610. this._userid && (e.userid = this._userid);
  611. return e;
  612. };
  613. return e;
  614. }()),
  615. h = o(),
  616. g = function (e) {
  617. c(n, e);
  618. function n() {
  619. return null !== e && e.apply(this, arguments) || this;
  620. }
  621. n.prototype.getOpenIdAsync = function (e, n) {
  622. var i = this;
  623. h.login({
  624. success: function success(r) {
  625. r.code ? a.request({
  626. url: f.ENDPOINT + f.GET_OPENID_URL,
  627. method: "GET",
  628. data: {
  629. key: e,
  630. code: r.code
  631. },
  632. success: function success(e) {
  633. if (e && 200 === e.statusCode && e.data && e.data.data) {
  634. var t = e.data.data;
  635. i.setOpenid(t.oid);
  636. i.setUnionid(t.uid);
  637. return n && n(!0);
  638. }
  639. n && n();
  640. },
  641. fail: function fail(e) {
  642. t().v("wx request failed...", e);
  643. n && n();
  644. }
  645. }) : n && n();
  646. },
  647. fail: function fail() {
  648. n && n();
  649. }
  650. });
  651. };
  652. return n;
  653. }(d),
  654. v = (p = null, function () {
  655. p || (p = new g());
  656. return p;
  657. }),
  658. _ = function () {
  659. var e = null;
  660. function t() {
  661. var e = !1,
  662. t = null,
  663. n = [];
  664. this.addPageStart = function (n) {
  665. if (n && !e) {
  666. t = {
  667. ts: Date.now(),
  668. path: n,
  669. page_name: n
  670. };
  671. e = !0;
  672. }
  673. };
  674. this.addPageEnd = function (i) {
  675. if (e && i && t && i === t.page_name) {
  676. var r = Date.now() - t.ts;
  677. t.duration = Math.abs(r);
  678. n.push(t);
  679. t = null;
  680. e = !1;
  681. }
  682. };
  683. this.get = function () {
  684. return n;
  685. };
  686. this.getCurrentPage = function () {
  687. return t;
  688. };
  689. this.clear = function () {
  690. n.length = 0;
  691. };
  692. }
  693. return function () {
  694. e || (e = new t());
  695. return e;
  696. };
  697. }(),
  698. y = {};
  699. var m = function () {
  700. var e = null,
  701. n = [],
  702. i = "";
  703. function r() {
  704. return {
  705. add: function add(e, r) {
  706. t().v("share origin: %o", e);
  707. var o = {
  708. title: e && e.title,
  709. path: e && e.path && e.path.split("?")[0],
  710. _um_sts: Date.now()
  711. };
  712. o.path && o.path.length > 1 && l.startsWith(o.path, "/") && (o.path = l.trimStart(o.path, "/"));
  713. var s = e.path || "",
  714. a = v().getId();
  715. if (a) {
  716. var u = i.split(","),
  717. c = (u = u.filter(function (e) {
  718. return e.length > 0;
  719. })).indexOf(a);
  720. c >= 0 && (u = u.slice(0, c));
  721. u.length < 3 && u.push(a);
  722. var f = u.join(",");
  723. -1 !== s.indexOf("?") ? s += "&_um_ssrc=" + f : s += "?_um_ssrc=" + f;
  724. var p = Date.now();
  725. s += "&_um_sts=" + p;
  726. if (r) {
  727. var d = function (e) {
  728. var t = [];
  729. for (var n in e) {
  730. "_um_ssrc" !== n && "_um_sts" !== n && t.push(n + "=" + e[n]);
  731. }
  732. return t.join("&");
  733. }(y),
  734. h = d ? d + "&_um_ssrc=" + f + "&_um_sts=" + p : "_um_ssrc=" + f + "&_um_sts=" + p;
  735. e.query = e.query ? e.query + "&_um_ssrc=" + f + "&_um_sts=" + p : h;
  736. } else e.path = s;
  737. o._um_ssrc = f;
  738. o._um_sts = p;
  739. }
  740. n.push(o);
  741. t().v("share: %o", e);
  742. return e;
  743. },
  744. setShareSource: function setShareSource(e) {
  745. i = e;
  746. },
  747. clear: function clear() {
  748. n.length = 0;
  749. },
  750. get: function get() {
  751. return n;
  752. }
  753. };
  754. }
  755. return function () {
  756. e || (e = new r());
  757. return e;
  758. };
  759. }(),
  760. S = function S(e) {
  761. if (e) try {
  762. return JSON.stringify(e);
  763. } catch (e) {}
  764. return "";
  765. },
  766. I = function I(e) {
  767. if (e) try {
  768. return JSON.parse(e);
  769. } catch (e) {}
  770. return null;
  771. },
  772. O = function () {
  773. var e = null,
  774. t = "",
  775. i = null,
  776. r = !1;
  777. function o() {
  778. this.load = function (e) {
  779. if (i) {
  780. a.removeStorage(t);
  781. e();
  782. } else {
  783. t = "um_cache_" + n().appKey();
  784. a.getStorage(t, function (n) {
  785. i = I(n) || {};
  786. r = !0;
  787. a.removeStorage(t);
  788. e();
  789. });
  790. }
  791. };
  792. this.save = function () {
  793. i && a.setStorage(t, S(i));
  794. };
  795. this.set = function (e, t) {
  796. i && (i[e] = t);
  797. };
  798. this.get = function (e) {
  799. return (i || {})[e];
  800. };
  801. this.remove = function (e) {
  802. i && i[e] && delete i[e];
  803. };
  804. this.getAll = function () {
  805. return i;
  806. };
  807. this.clear = function () {
  808. i = null;
  809. };
  810. this.has = function (e) {
  811. return !!this.get(e);
  812. };
  813. this.isLoaded = function () {
  814. return r;
  815. };
  816. }
  817. return function () {
  818. e || (e = new o());
  819. return e;
  820. };
  821. }(),
  822. E = function () {
  823. var e,
  824. n,
  825. i = [],
  826. r = [];
  827. function o() {
  828. if (i.length) {
  829. var e = O().get("ekvs");
  830. if (function (e) {
  831. var t = 0;
  832. for (var n in e) {
  833. Array.isArray(e[n]) && (t += e[n].length);
  834. }
  835. return t;
  836. }(e) + i.length <= 1e4) {
  837. e = s(e, i);
  838. O().set("ekvs", e);
  839. }
  840. }
  841. }
  842. function s(e, t) {
  843. var i = (e = e || {})[n];
  844. Array.isArray(i) && i.length ? e[n] = i.concat(t) : e[n] = [].concat(t);
  845. return e;
  846. }
  847. return function () {
  848. e || (e = {
  849. addEvent: function addEvent(e) {
  850. if (n) {
  851. i.unshift(e);
  852. if (i.length > 1) {
  853. o();
  854. i.length = 0;
  855. }
  856. } else {
  857. t().w("session id is null: ", n);
  858. r.unshift(e);
  859. }
  860. },
  861. setSessionId: function setSessionId(e) {
  862. n = e;
  863. t().v("setSessionId: ", n);
  864. if (Array.isArray(r) && r.length && n) {
  865. for (var i = 0; i < r.length; i++) {
  866. this.addEvent(r[i]);
  867. }
  868. r.length = 0;
  869. }
  870. },
  871. getEkvs: function getEkvs() {
  872. var e = O().get("ekvs");
  873. i && i.length && (e = s(e, i));
  874. return e;
  875. },
  876. clear: function clear() {
  877. O().remove("ekvs");
  878. i.length = 0;
  879. }
  880. });
  881. return e;
  882. };
  883. }(),
  884. T = "2g",
  885. N = "3g",
  886. A = "4g",
  887. b = "half_session",
  888. k = "close_session",
  889. D = "ekv",
  890. w = ["access", "access_subtype"],
  891. R = function () {
  892. var e = null;
  893. function t() {
  894. var e = !1,
  895. t = {};
  896. function i(e) {
  897. var i = O().get(f.IMPRINT);
  898. i && (t.imprint = i);
  899. t.device_type = "Phone";
  900. t.sdk_version = f.IMPL_VERSION;
  901. t.appkey = n().appKey();
  902. a.getDeviceInfo(function (e) {
  903. t.device_info = e || "";
  904. });
  905. var r = a.getAppInfoSync();
  906. t.appid = r.appId;
  907. t.app_env = r.appEnv;
  908. t.app_version = r.appVersion;
  909. a.getSystemInfo(function (n) {
  910. a.getNetworkInfo(function (i) {
  911. var r = function (e, t) {
  912. var n = {};
  913. (e = e || {}).safeArea = e.safeArea || {};
  914. var i = (t = t || {}).networkType;
  915. "none" === i && (i = "unknown");
  916. var r = e.model || "",
  917. o = e.platform || "",
  918. s = e.brand || "",
  919. u = s.toLowerCase();
  920. n.sdk_type = a.getSdkType();
  921. n.platform = a.getPlatform();
  922. n.platform_sdk_version = e.platformSDKVersion;
  923. n.platform_version = e.platformVersion;
  924. n.resolution = e.resolution;
  925. n.pixel_ratio = e.pixelRatio;
  926. n.os = o;
  927. n.font_size_setting = e.fontSizeSetting;
  928. n.device_model = r;
  929. n.device_brand = s;
  930. n.device_manufacturer = u;
  931. n.device_manuid = r;
  932. n.device_name = r;
  933. n.os_version = e.OSVersion;
  934. n.language = e.language;
  935. n.theme = e.theme;
  936. n.benchmark_level = e.benchmarkLevel;
  937. n.status_bar_height = e.statusBarHeight;
  938. n.safe_area_top = e.safeArea.top;
  939. n.safe_area_left = e.safeArea.left;
  940. n.safe_area_right = e.safeArea.right;
  941. n.safe_area_bottom = e.safeArea.bottom;
  942. n.safe_area_height = e.safeArea.height;
  943. n.safe_area_width = e.safeArea.width;
  944. n.storage = e.storage;
  945. n.screen_width = e.screenWidth;
  946. n.screen_height = e.screenHeight;
  947. n.host = e.host;
  948. switch (i = i ? i.toLowerCase() : "") {
  949. case A:
  950. n.access_subtype = "LTE";
  951. n.access = "4G";
  952. break;
  953. case N:
  954. n.access_subtype = "CDMA";
  955. n.access = "3G";
  956. break;
  957. case T:
  958. n.access_subtype = "GRPS";
  959. n.access = "2G";
  960. break;
  961. default:
  962. n.access = i;
  963. delete n.access_subtype;
  964. }
  965. return n;
  966. }(n, i);
  967. l.assign(t, r);
  968. e && e();
  969. });
  970. });
  971. }
  972. return {
  973. init: function init() {
  974. i(function () {
  975. e = !0;
  976. });
  977. },
  978. isLoaded: function isLoaded() {
  979. return e;
  980. },
  981. get: function get() {
  982. return t;
  983. },
  984. getRealtimeFields: function getRealtimeFields() {
  985. var e = {};
  986. w.forEach(function (n) {
  987. e[n] = t[n];
  988. });
  989. return e;
  990. },
  991. setIdTracking: function setIdTracking(e) {
  992. this.setItem("id_tracking", e);
  993. },
  994. setIdType: function setIdType(e) {
  995. this.setItem("id_type", e);
  996. },
  997. setAppVersion: function setAppVersion(e) {
  998. this.setItem("app_version", e);
  999. },
  1000. setSuperProperty: function setSuperProperty(e) {
  1001. t.sp || (t.sp = {});
  1002. t.sp.isv = e;
  1003. },
  1004. getSuperProperty: function getSuperProperty() {
  1005. return t && t.sp ? t.sp.isv : "";
  1006. },
  1007. setItem: function setItem(e, n) {
  1008. t[e] = n;
  1009. },
  1010. getItem: function getItem(e) {
  1011. return t[e];
  1012. }
  1013. };
  1014. }
  1015. return {
  1016. instance: function instance() {
  1017. e || (e = t());
  1018. return e;
  1019. }
  1020. };
  1021. }(),
  1022. U = function () {
  1023. var e = null,
  1024. n = null,
  1025. i = null;
  1026. function r() {
  1027. return {
  1028. resume: function resume(e) {
  1029. var r = !1;
  1030. i || (i = O().get(f.CURRENT_SESSION));
  1031. var o = new Date();
  1032. n = o.getTime();
  1033. if (!i || !i.end_time || n - i.end_time > f.SESSION_INTERVAL) {
  1034. r = !0;
  1035. !function (e) {
  1036. try {
  1037. var n = (i || {}).options || {},
  1038. r = l.assign({}, function (e) {
  1039. var n = {};
  1040. for (var i in e) {
  1041. 0 === i.indexOf("_um_") && (n[i] = e[i]);
  1042. }
  1043. t().v("query: ", e);
  1044. t().v("_um_params: ", n);
  1045. return n;
  1046. }(e.query));
  1047. r.path = e.path || n.path;
  1048. r.scene = e.scene ? a.getPlatform() + "_" + e.scene : n.scene;
  1049. var o = e.referrerInfo;
  1050. o && (r.referrerAppId = o.appId);
  1051. t().v("session options: ", r);
  1052. var s = r[f.UM_SSRC];
  1053. s && m().setShareSource(s);
  1054. var u = Date.now();
  1055. i = {
  1056. id: l.getRandomStr(10) + u,
  1057. start_time: u,
  1058. options: r
  1059. };
  1060. } catch (e) {
  1061. t().e("生成新session失败: ", e);
  1062. }
  1063. }(e);
  1064. t().v("开始新的session(%s): ", i.id, i);
  1065. } else t().v("延续上一次session(%s): %s ", i.id, o.toLocaleTimeString(), i);
  1066. return r;
  1067. },
  1068. pause: function pause() {
  1069. !function () {
  1070. if (i) {
  1071. var e = new Date();
  1072. i.end_time = e.getTime();
  1073. "number" != typeof i.duration && (i.duration = 0);
  1074. i.duration = i.end_time - n;
  1075. O().set(f.CURRENT_SESSION, i);
  1076. t().v("退出会话(%s): %s ", i.id, e.toLocaleTimeString(), i);
  1077. }
  1078. }();
  1079. },
  1080. getCurrentSessionId: function getCurrentSessionId() {
  1081. return (i || {}).id;
  1082. },
  1083. getCurrentSession: function getCurrentSession() {
  1084. return i;
  1085. },
  1086. cloneCurrentSession: function cloneCurrentSession() {
  1087. return l.clone(i);
  1088. }
  1089. };
  1090. }
  1091. return function () {
  1092. e || (e = r());
  1093. return e;
  1094. };
  1095. }();
  1096. function P(e) {
  1097. var t = null;
  1098. switch (e) {
  1099. case b:
  1100. t = function () {
  1101. var e = null,
  1102. t = U().cloneCurrentSession();
  1103. t && (e = {
  1104. header: {
  1105. st: "1"
  1106. },
  1107. analytics: {
  1108. sessions: [t]
  1109. }
  1110. });
  1111. return e;
  1112. }();
  1113. break;
  1114. case k:
  1115. t = function () {
  1116. var e = null,
  1117. t = {},
  1118. n = U().cloneCurrentSession();
  1119. if (n) {
  1120. var i = _().get(),
  1121. r = m().get();
  1122. Array.isArray(i) && i.length && (n.pages = l.clone(i));
  1123. Array.isArray(r) && r.length && (n.shares = l.clone(r));
  1124. _().clear();
  1125. m().clear();
  1126. t.sessions = [n];
  1127. }
  1128. var o = E().getEkvs();
  1129. if (o) {
  1130. t.ekvs = l.clone(o);
  1131. E().clear();
  1132. }
  1133. (t.sessions || t.ekvs) && (e = {
  1134. analytics: t
  1135. });
  1136. return e;
  1137. }();
  1138. break;
  1139. case D:
  1140. t = function () {
  1141. var e = null,
  1142. t = E().getEkvs();
  1143. if (t) {
  1144. e = {
  1145. analytics: {
  1146. ekvs: l.clone(t)
  1147. }
  1148. };
  1149. E().clear();
  1150. }
  1151. return e;
  1152. }();
  1153. }
  1154. return t;
  1155. }
  1156. var C = {
  1157. sessions: "sn",
  1158. ekvs: "e",
  1159. active_user: "active_user"
  1160. },
  1161. L = {
  1162. sdk_type: "sdt",
  1163. access: "ac",
  1164. access_subtype: "acs",
  1165. device_model: "dm",
  1166. language: "lang",
  1167. device_type: "dt",
  1168. device_manufacturer: "dmf",
  1169. device_name: "dn",
  1170. platform_version: "pv",
  1171. id_type: "it",
  1172. font_size_setting: "fss",
  1173. os_version: "ov",
  1174. device_manuid: "did",
  1175. platform_sdk_version: "psv",
  1176. device_brand: "db",
  1177. appkey: "ak",
  1178. _id: "id",
  1179. id_tracking: "itr",
  1180. imprint: "imp",
  1181. sdk_version: "sv",
  1182. resolution: "rl",
  1183. testToken: "ttn",
  1184. theme: "t5",
  1185. benchmark_level: "bml",
  1186. screen_width: "sw",
  1187. screen_height: "sh",
  1188. status_bar_height: "sbh",
  1189. safe_area_top: "sat",
  1190. safe_area_left: "sal",
  1191. safe_area_right: "sar",
  1192. safe_area_bottom: "sab",
  1193. safe_area_height: "sah",
  1194. safe_area_width: "saw",
  1195. pixel_ratio: "pr",
  1196. storage: "s7",
  1197. host: "hs"
  1198. },
  1199. M = {
  1200. uuid: "ud",
  1201. unionid: "und",
  1202. openid: "od",
  1203. anonymousid: "nd",
  1204. alipay_id: "ad",
  1205. device_id: "dd",
  1206. userid: "puid"
  1207. };
  1208. function j(e, t) {
  1209. var n = V(e, t);
  1210. e && e.id_tracking && (n[t.id_tracking || "id_tracking"] = V(e.id_tracking, M));
  1211. return n;
  1212. }
  1213. function V(e, t) {
  1214. var n = {};
  1215. for (var i in e) {
  1216. t[i] ? n[t[i]] = e[i] : n[i] = e[i];
  1217. }
  1218. return n;
  1219. }
  1220. function x(e, t) {
  1221. var n = {};
  1222. if (e) for (var i in e) {
  1223. e[i] && (n[t[i]] = e[i]);
  1224. }
  1225. return n;
  1226. }
  1227. var q = "";
  1228. function G() {
  1229. return q;
  1230. }
  1231. var F = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
  1232. H = function (e) {
  1233. for (var t = {}, n = 0, i = e.length; n < i; n++) {
  1234. t[e.charAt(n)] = n;
  1235. }
  1236. return t;
  1237. }(F),
  1238. K = String.fromCharCode,
  1239. Y = function Y(e) {
  1240. if (e.length < 2) {
  1241. return (t = e.charCodeAt(0)) < 128 ? e : t < 2048 ? K(192 | t >>> 6) + K(128 | 63 & t) : K(224 | t >>> 12 & 15) + K(128 | t >>> 6 & 63) + K(128 | 63 & t);
  1242. }
  1243. var t = 65536 + 1024 * (e.charCodeAt(0) - 55296) + (e.charCodeAt(1) - 56320);
  1244. return K(240 | t >>> 18 & 7) + K(128 | t >>> 12 & 63) + K(128 | t >>> 6 & 63) + K(128 | 63 & t);
  1245. },
  1246. J = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,
  1247. X = function X(e) {
  1248. var t = [0, 2, 1][e.length % 3],
  1249. n = e.charCodeAt(0) << 16 | (e.length > 1 ? e.charCodeAt(1) : 0) << 8 | (e.length > 2 ? e.charCodeAt(2) : 0);
  1250. return [F.charAt(n >>> 18), F.charAt(n >>> 12 & 63), t >= 2 ? "=" : F.charAt(n >>> 6 & 63), t >= 1 ? "=" : F.charAt(63 & n)].join("");
  1251. },
  1252. B = function B(e) {
  1253. return function (e) {
  1254. return e.replace(J, Y);
  1255. }(e).replace(/[\s\S]{1,3}/g, X);
  1256. },
  1257. W = new RegExp(["[À-ß][€-¿]", "[à-ï][€-¿]{2}", "[ð-÷][€-¿]{3}"].join("|"), "g"),
  1258. z = function z(e) {
  1259. switch (e.length) {
  1260. case 4:
  1261. var t = ((7 & e.charCodeAt(0)) << 18 | (63 & e.charCodeAt(1)) << 12 | (63 & e.charCodeAt(2)) << 6 | 63 & e.charCodeAt(3)) - 65536;
  1262. return K(55296 + (t >>> 10)) + K(56320 + (1023 & t));
  1263. case 3:
  1264. return K((15 & e.charCodeAt(0)) << 12 | (63 & e.charCodeAt(1)) << 6 | 63 & e.charCodeAt(2));
  1265. default:
  1266. return K((31 & e.charCodeAt(0)) << 6 | 63 & e.charCodeAt(1));
  1267. }
  1268. },
  1269. Q = function Q(e) {
  1270. var t = e.length,
  1271. n = t % 4,
  1272. i = (t > 0 ? H[e.charAt(0)] << 18 : 0) | (t > 1 ? H[e.charAt(1)] << 12 : 0) | (t > 2 ? H[e.charAt(2)] << 6 : 0) | (t > 3 ? H[e.charAt(3)] : 0),
  1273. r = [K(i >>> 16), K(i >>> 8 & 255), K(255 & i)];
  1274. r.length -= [0, 0, 2, 1][n];
  1275. return r.join("");
  1276. },
  1277. Z = function Z(e) {
  1278. return function (e) {
  1279. return e.replace(/[\s\S]{1,4}/g, Q);
  1280. }(e).replace(W, z);
  1281. },
  1282. $ = function $(e, t) {
  1283. return t ? B(String(e)).replace(/[+\/]/g, function (e) {
  1284. return "+" == e ? "-" : "_";
  1285. }).replace(/=/g, "") : B(String(e));
  1286. },
  1287. ee = function ee(e) {
  1288. return Z(String(e).replace(/[-_]/g, function (e) {
  1289. return "-" == e ? "+" : "/";
  1290. }).replace(/[^A-Za-z0-9\+\/]/g, ""));
  1291. };
  1292. var te = new function () {
  1293. var e = "",
  1294. t = this;
  1295. this.set = function (t) {
  1296. e = t;
  1297. };
  1298. this.get = function () {
  1299. return e;
  1300. };
  1301. this.getImpObj = function () {
  1302. return I(ee(e));
  1303. };
  1304. this.getItem = function (e) {
  1305. var n = t.getImpObj();
  1306. return n && n[e] || "";
  1307. };
  1308. this.load = function () {
  1309. e = O().get(f.IMPRINT);
  1310. };
  1311. this.save = function () {
  1312. e && O().set(f.IMPRINT, e);
  1313. };
  1314. }();
  1315. function ne(e, n, i, r) {
  1316. R.instance().setIdType(v().getIdType());
  1317. R.instance().setIdTracking(v().getIdTracking());
  1318. var o = v().getUserId();
  1319. o && e.analytics && (e.analytics.active_user = {
  1320. puid: o,
  1321. provider: v().getProvider()
  1322. });
  1323. var s = l.clone(R.instance().get());
  1324. e.header = l.assign(s, e.header, {
  1325. ts: Date.now(),
  1326. testToken: G(),
  1327. traceId: l.getRandomStr(10) + Date.now() + l.getRandomStr(9)
  1328. });
  1329. var u = function (e) {
  1330. return {
  1331. h: j(e.header, L),
  1332. a: x(e.analytics, C)
  1333. };
  1334. }(e),
  1335. c = S(u),
  1336. p = {
  1337. url: f.ENDPOINT + f.LOG_URL,
  1338. method: "POST",
  1339. data: $(c),
  1340. success: function success(r) {
  1341. var o = r.code || r.status || r.statusCode;
  1342. if (200 === o || 413 === o) {
  1343. t().i("数据发送成功: ", e, c);
  1344. !function (e) {
  1345. if (e) {
  1346. R.instance().setItem(f.IMPRINT, e);
  1347. te.set(e);
  1348. te.save();
  1349. t().v("imprint: ", te.getImpObj());
  1350. te.getItem("ttn_invalid") && (q = "");
  1351. }
  1352. }((r.data || {}).imprint);
  1353. "function" == typeof n && n(r);
  1354. } else {
  1355. t().w("数据发送失败: ", c);
  1356. "function" == typeof i && i();
  1357. }
  1358. },
  1359. fail: function fail(e) {
  1360. t().w("超时: ", c);
  1361. "function" == typeof i && i();
  1362. },
  1363. complete: function complete() {
  1364. "function" == typeof r && r();
  1365. }
  1366. };
  1367. a.request(l.assign(p, {
  1368. header: {
  1369. "content-type": "text/plain",
  1370. "Msg-Type": a.getSdkType() + "/json"
  1371. }
  1372. }));
  1373. }
  1374. function ie(e) {
  1375. var t = e,
  1376. n = [];
  1377. this.enqueue = function (e) {
  1378. "number" == typeof t && this.size() >= t && this.dequeue();
  1379. n.push(e);
  1380. };
  1381. this.dequeue = function () {
  1382. return n.shift();
  1383. };
  1384. this.front = function () {
  1385. return n[0];
  1386. };
  1387. this.isEmpty = function () {
  1388. return 0 === n.length;
  1389. };
  1390. this.clear = function () {
  1391. n.length = 0;
  1392. };
  1393. this.size = function () {
  1394. return n.length;
  1395. };
  1396. this.items = function () {
  1397. return n;
  1398. };
  1399. this.print = function () {
  1400. console.log(n.toString());
  1401. };
  1402. }
  1403. var re = function () {
  1404. var e = null,
  1405. n = !1,
  1406. i = [],
  1407. r = new ie(50);
  1408. function o(e, t, n) {
  1409. if (R.instance().isLoaded()) {
  1410. t = t || {};
  1411. var i = P(e);
  1412. if (i) {
  1413. var s = R.instance().getRealtimeFields();
  1414. i.header = l.assign({}, i.header, s);
  1415. i.noCache = t.noCache;
  1416. r.enqueue(i);
  1417. }
  1418. "function" == typeof n && n();
  1419. } else setTimeout(function () {
  1420. o(e, t, n);
  1421. }, 100);
  1422. }
  1423. function s(e) {
  1424. var t = r.front();
  1425. if (t) ne(t, function () {
  1426. r.dequeue();
  1427. s(e);
  1428. }, function () {
  1429. var t = r.dequeue();
  1430. t && !t.noCache && i.push(t);
  1431. s(e);
  1432. });else {
  1433. !function () {
  1434. i.forEach(function (e) {
  1435. r.enqueue(e);
  1436. });
  1437. i.length = 0;
  1438. }();
  1439. e();
  1440. }
  1441. }
  1442. function a(e) {
  1443. if (v().getId()) {
  1444. if (n) t().i("队列正在发送中");else {
  1445. n = !0;
  1446. s(function () {
  1447. n = !1;
  1448. "function" == typeof e && e();
  1449. });
  1450. }
  1451. } else {
  1452. t().i("获取id标识失败,暂缓发送");
  1453. "function" == typeof e && e();
  1454. }
  1455. }
  1456. function u() {
  1457. this.send = function (e, t, n) {
  1458. e ? this.add(e, t, function () {
  1459. a(n);
  1460. }) : a(n);
  1461. };
  1462. this.add = function (e, t, n) {
  1463. o(e, t, n);
  1464. };
  1465. this.load = function () {
  1466. var e = O().get(f.REQUESTS);
  1467. e && e.length && e.forEach(function (e) {
  1468. r.enqueue(e);
  1469. });
  1470. O().remove(f.REQUESTS);
  1471. };
  1472. this.save = function () {
  1473. O().set(f.REQUESTS, l.clone(r.items()));
  1474. r.clear();
  1475. };
  1476. }
  1477. return function () {
  1478. e || (e = new u());
  1479. return e;
  1480. };
  1481. }(),
  1482. oe = function () {
  1483. var e = null,
  1484. i = null;
  1485. function r() {
  1486. this.setUserInfo = function (e) {
  1487. i = e;
  1488. };
  1489. this.update = function () {
  1490. e(i) || a.getUserInfo(function (t) {
  1491. e(t);
  1492. });
  1493. };
  1494. function e(e) {
  1495. if (e && "object" == typeof e) {
  1496. var i = O().get(f.USER_INFO);
  1497. i && l.deepEqual(e, i) || function (e, i) {
  1498. var r = n().appKey(),
  1499. o = a.getSdkType(),
  1500. s = v().getId(),
  1501. u = v().getIdType();
  1502. if (!(r && o && s && u)) return;
  1503. var c = {
  1504. ak: n().appKey(),
  1505. sdt: a.getSdkType(),
  1506. uin: e.nickName,
  1507. uia: e.avatar || e.avatarUrl,
  1508. uig: e.gender,
  1509. uit: e.country,
  1510. uip: e.province,
  1511. uic: e.city,
  1512. uil: e.language,
  1513. id: v().getId(),
  1514. it: v().getIdType(),
  1515. age: e.age,
  1516. cln: e.constellation
  1517. },
  1518. p = JSON.stringify(c);
  1519. p = $(p);
  1520. a.request({
  1521. url: f.ENDPOINT + f.USERINFO_URL,
  1522. method: "POST",
  1523. header: {
  1524. "content-type": "application/x-www-form-urlencoded"
  1525. },
  1526. data: "ui=" + p,
  1527. success: function success(n) {
  1528. t().v("用户信息上传成功: ", e);
  1529. i && i(n && n.data && 200 === n.data.code);
  1530. },
  1531. fail: function fail() {
  1532. t().e("用户信息上传失败: ", e);
  1533. i && i(!1);
  1534. }
  1535. });
  1536. }(e, function (t) {
  1537. t && O().set(f.USER_INFO, e);
  1538. });
  1539. return !0;
  1540. }
  1541. return !1;
  1542. }
  1543. }
  1544. return function () {
  1545. e || (e = new r());
  1546. return e;
  1547. };
  1548. }();
  1549. function se(e, t) {
  1550. this.id = e;
  1551. this.ts = Date.now();
  1552. var n = typeof t;
  1553. if ("string" === n && t) this[e] = t;else if ("object" === n) for (var i in t) {
  1554. ({}).hasOwnProperty.call(t, i) && (this[i] = t[i]);
  1555. }
  1556. }
  1557. function ae() {
  1558. var e = !1,
  1559. i = !1,
  1560. r = 0;
  1561. this.init = function (i) {
  1562. t().v("sdk version: " + f.IMPL_VERSION);
  1563. e ? t().v("Lib重复实例化") : O().load(function () {
  1564. t().v("cache初始化成功: ", O().getAll());
  1565. !function () {
  1566. v().setUseOpenid && v().setUseOpenid(n().useOpenid());
  1567. v().init(function () {
  1568. R.instance().init();
  1569. t().v("Header初始化成功");
  1570. });
  1571. }();
  1572. e = !0;
  1573. "function" == typeof i && i();
  1574. t().tip("SDK集成成功");
  1575. });
  1576. };
  1577. this.resume = function (r) {
  1578. if (e && !i) {
  1579. t().v("showOptions: ", r);
  1580. var o;
  1581. i = !0;
  1582. n().enableVerify() && r && r.query && (o = r.query._ttn, q = o || q);
  1583. this._resume(r);
  1584. }
  1585. };
  1586. this._resume = function (e) {
  1587. re().load();
  1588. var i = U().resume(e),
  1589. r = U().getCurrentSessionId();
  1590. E().setSessionId(r);
  1591. i && re().add(b, {}, function () {
  1592. v().setUseOpenid && v().setUseOpenid(n().useOpenid());
  1593. if (n().useOpenid() && n().autoGetOpenid() && !v().getId()) {
  1594. t().v("get id async");
  1595. o(10, 3e3);
  1596. } else {
  1597. t().v("session auto send");
  1598. re().send();
  1599. }
  1600. });
  1601. function o(e, i) {
  1602. v().getId() || e <= 0 || v().getOpenIdAsync(n().appKey(), function (n) {
  1603. if (n) {
  1604. t().v("获取id成功");
  1605. re().send();
  1606. } else {
  1607. t().v("获取openid失败,启动重试,剩余可用次数", e - 1);
  1608. setTimeout(function () {
  1609. o(e - 1, i);
  1610. }, i);
  1611. }
  1612. });
  1613. }
  1614. };
  1615. this.pause = function (o) {
  1616. if (e) {
  1617. i = !1;
  1618. r = 0;
  1619. U().pause();
  1620. n().uploadUserInfo() && oe().update();
  1621. re().send(k, {}, function () {
  1622. re().save();
  1623. O().save();
  1624. t().v("cache save success");
  1625. "function" == typeof o && o();
  1626. });
  1627. }
  1628. };
  1629. this.setOpenid = function (e) {
  1630. t().v("setOpenId: %s", e);
  1631. v().setOpenid(e);
  1632. re().send();
  1633. };
  1634. this.setUnionid = function (e) {
  1635. t().v("setUnionid: %s", e);
  1636. v().setUnionid(e);
  1637. };
  1638. this.setUserid = function (e, n) {
  1639. t().v("setUserid: %s", e, n);
  1640. v().setUserid(e, n);
  1641. };
  1642. this.setUserInfo = function (e) {
  1643. t().v("setUserInfo: %s", e);
  1644. oe().setUserInfo(e);
  1645. };
  1646. this.setAnonymousid = function (e) {
  1647. t().v("setAnonymousId: %s", e);
  1648. v().setAnonymousid(e);
  1649. re().send();
  1650. };
  1651. this.setAppVersion = function (e) {
  1652. e && "string" != typeof e ? t().w("setAppVersion方法只接受字符串类型参数") : R.instance().setAppVersion(e);
  1653. };
  1654. this.setAlipayUserid = function (e) {
  1655. if (e && "string" != typeof e) t().w("setAlipayUserid方法只接受字符串类型参数");else {
  1656. t().v("setAlipayUserid: %s", e);
  1657. v().setAlipayUserid(e);
  1658. }
  1659. };
  1660. this.setDeviceId = function (e) {
  1661. if ("string" == typeof e) {
  1662. v().setDeviceId(e);
  1663. return e;
  1664. }
  1665. };
  1666. this.setSuperProperty = function (e) {
  1667. if (e && "string" != typeof e) t().w("超级属性只支持字符串类型");else {
  1668. var n = this;
  1669. if (R.instance().getSuperProperty() !== e) {
  1670. R.instance().setSuperProperty(e);
  1671. n.pause(function () {
  1672. n.resume();
  1673. });
  1674. }
  1675. }
  1676. };
  1677. this.trackEvent = function (n, i) {
  1678. if (e) {
  1679. t().v("event: ", n, i);
  1680. if (function (e, n) {
  1681. if (!e || "string" != typeof e) {
  1682. t().e('please check trackEvent id. id should be "string" and not null');
  1683. return !1;
  1684. }
  1685. var i = ["id", "ts", "du"],
  1686. r = {};
  1687. i.forEach(function (e) {
  1688. r[e] = 1;
  1689. });
  1690. if (r[e]) {
  1691. t().e("eventId不能与以下保留字冲突: " + i.join(","));
  1692. return !1;
  1693. }
  1694. if (e.length > f.MAX_EVENTID_LENGTH) {
  1695. t().e("The maximum length of event id shall not exceed " + f.MAX_EVENTID_LENGTH);
  1696. return !1;
  1697. }
  1698. if (n && ("object" != typeof n || Array.isArray(n)) && "string" != typeof n) {
  1699. t().e("please check trackEvent properties. properties should be string or object(not include Array)");
  1700. return !1;
  1701. }
  1702. if ("object" == typeof n) {
  1703. var o = 0;
  1704. for (var s in n) {
  1705. if ({}.hasOwnProperty.call(n, s)) {
  1706. if (s.length > f.MAX_PROPERTY_KEY_LENGTH) {
  1707. t().e("The maximum length of property key shall not exceed " + f.MAX_PROPERTY_KEY_LENGTH);
  1708. return !1;
  1709. }
  1710. if (o >= f.MAX_PROPERTY_KEYS_COUNT) {
  1711. t().e("The maximum count of properties shall not exceed " + f.MAX_PROPERTY_KEYS_COUNT);
  1712. return !1;
  1713. }
  1714. if (r[s]) {
  1715. t().e("属性中的key不能与以下保留字冲突: " + i.join(","));
  1716. return !1;
  1717. }
  1718. o += 1;
  1719. }
  1720. }
  1721. }
  1722. return !0;
  1723. }(n, i)) {
  1724. var o = new se(n, i);
  1725. E().addEvent(o);
  1726. var s = !!G(),
  1727. a = s ? 0 : f.EVENT_SEND_DEFAULT_INTERVAL,
  1728. u = Date.now();
  1729. if (function (e, t) {
  1730. return "number" != typeof r || "number" != typeof t || r <= 0 || e - r > t;
  1731. }(u, a)) {
  1732. r = u;
  1733. re().send(D, {
  1734. noCache: s
  1735. }, function () {});
  1736. }
  1737. }
  1738. }
  1739. };
  1740. this.trackShare = function (n) {
  1741. if (e) try {
  1742. if (a.getSdkType().indexOf("game") > -1) {
  1743. n = m().add(n, !0);
  1744. t().v("shareQuery: ", n);
  1745. } else {
  1746. n = m().add(n, !1);
  1747. t().v("sharePath: ", n.path);
  1748. }
  1749. } catch (e) {
  1750. t().v("shareAppMessage: ", e);
  1751. }
  1752. return n;
  1753. };
  1754. this.trackPageStart = function (t) {
  1755. e && _().addPageStart(t);
  1756. };
  1757. this.trackPageEnd = function (t) {
  1758. e && _().addPageEnd(t);
  1759. };
  1760. this.onShareAppMessage = function (e) {
  1761. var t = this;
  1762. a.onShareAppMessage(function () {
  1763. return t.trackShare(e());
  1764. });
  1765. };
  1766. this.shareAppMessage = function (e) {
  1767. this.trackShare(e);
  1768. a.shareAppMessage(e);
  1769. };
  1770. }
  1771. var ue = [];
  1772. function ce() {}
  1773. ce.prototype = {
  1774. createMethod: function createMethod(e, n, i) {
  1775. try {
  1776. e[n] = i && i[n] ? function () {
  1777. return i[n].apply(i, arguments);
  1778. } : function () {
  1779. ue.push([n, [].slice.call(arguments)]);
  1780. };
  1781. } catch (e) {
  1782. t().v("create method errror: ", e);
  1783. }
  1784. },
  1785. installApi: function installApi(e, n) {
  1786. try {
  1787. var i,
  1788. r,
  1789. o = "resume,pause,trackEvent,trackPageStart,trackPageEnd,trackShare,setUserid,setOpenid,setUnionid,onShareAppMessage,shareAppMessage,setUserInfo".split(",");
  1790. for (i = 0, r = o.length; i < r; i++) {
  1791. this.createMethod(e, o[i], n);
  1792. }
  1793. if (n) for (i = 0, r = ue.length; i < r; i++) {
  1794. var s = ue[i];
  1795. try {
  1796. n[s[0]].apply(n, s[1]);
  1797. } catch (e) {
  1798. t().v("impl[v[0]].apply error: ", s[0], e);
  1799. }
  1800. }
  1801. } catch (e) {
  1802. t().v("install api errror: ", e);
  1803. }
  1804. }
  1805. };
  1806. var fe = [f.ENDPOINT, f.ENDPOINTB];
  1807. function pe(e, n) {
  1808. var i, r;
  1809. 0 === e || 1 === e && n ? i = f.ENDPOINT : 2 === e && n ? i = f.ENDPOINTB : n && (i = fe[e]);
  1810. if (e >= fe.length || n) {
  1811. n && (r = i, f.ENDPOINT = r);
  1812. n && t().v("命中可用服务", i);
  1813. !n && t().tip_w("未命中可用服务");
  1814. return !1;
  1815. }
  1816. a.request({
  1817. url: f.ENDPOINT + "/uminiprogram_logs/ckdh",
  1818. success: function success(t) {
  1819. 200 === (t.code || t.status || t.statusCode) && t.data && 200 === t.data.code ? pe(e + 1, !0) : pe(e + 1, !1);
  1820. },
  1821. fail: function fail() {
  1822. pe(e + 1, !1);
  1823. }
  1824. });
  1825. }
  1826. var le = {
  1827. init: function init(e) {
  1828. f.ENDPOINTB && setTimeout(function () {
  1829. pe(0, !1);
  1830. }, e);
  1831. }
  1832. },
  1833. de = new ce(),
  1834. he = {
  1835. _inited: !1,
  1836. _log: t(),
  1837. preinit: function preinit(e) {
  1838. if (e && "object" == typeof e) for (var t in e) {
  1839. f[t] = e[t];
  1840. }
  1841. return f;
  1842. },
  1843. use: function use(e, t) {
  1844. e && l.isFunction(e.install) ? e.install(he, t) : l.isFunction(e) && e(he, t);
  1845. return he;
  1846. },
  1847. messager: r,
  1848. init: function init(e) {
  1849. if (this._inited) t().v("已经实例过,请避免重复初始化");else if (e) {
  1850. if (e.appKey) {
  1851. "boolean" != typeof e.useOpenid && (e.useOpenid = !0);
  1852. n().set(e);
  1853. t().setDebug(e.debug);
  1854. this._inited = !0;
  1855. var i = this;
  1856. r.emit(r.messageType.CONFIG_LOADED, e);
  1857. try {
  1858. var o = new ae();
  1859. t().v("成功创建Lib对象");
  1860. if (!a.getContext()) return;
  1861. o.init(function () {
  1862. t().v("Lib对象初始化成功");
  1863. de.installApi(i, o);
  1864. t().v("安装Lib接口成功");
  1865. r.emit(r.messageType.UMA_LIB_INITED, e);
  1866. });
  1867. le.init(3e3);
  1868. } catch (e) {
  1869. t().w("创建Lib对象异常: " + e);
  1870. }
  1871. } else t().err("请确保传入正确的appkey");
  1872. } else t().err("请正确设置相关信息!");
  1873. }
  1874. };
  1875. try {
  1876. de.installApi(he, null);
  1877. } catch (e) {
  1878. t().w("uma赋值异常: ", e);
  1879. }
  1880. var ge = "https://ucc.umeng.com/v1/mini/fetch",
  1881. ve = "https://pslog.umeng.com/mini_ablog",
  1882. _e = "2.7.2-beta.17928427",
  1883. ye = "none",
  1884. me = {},
  1885. Se = Array.isArray;
  1886. me.isArray = Se || function (e) {
  1887. return "[object Array]" === toString.call(e);
  1888. };
  1889. me.isObject = function (e) {
  1890. return e === Object(e) && !me.isArray(e);
  1891. };
  1892. me.isEmptyObject = function (e) {
  1893. if (me.isObject(e)) {
  1894. for (var t in e) {
  1895. if (hasOwnProperty.call(e, t)) return !1;
  1896. }
  1897. return !0;
  1898. }
  1899. return !1;
  1900. };
  1901. me.isUndefined = function (e) {
  1902. return void 0 === e;
  1903. };
  1904. me.isString = function (e) {
  1905. return "[object String]" === toString.call(e);
  1906. };
  1907. me.isDate = function (e) {
  1908. return "[object Date]" === toString.call(e);
  1909. };
  1910. me.isNumber = function (e) {
  1911. return "[object Number]" === toString.call(e);
  1912. };
  1913. me.each = function (e, t, n) {
  1914. if (null != e) {
  1915. var i = {},
  1916. r = Array.prototype.forEach;
  1917. if (r && e.forEach === r) e.forEach(t, n);else if (e.length === +e.length) {
  1918. for (var o = 0, s = e.length; o < s; o++) {
  1919. if (o in e && t.call(n, e[o], o, e) === i) return;
  1920. }
  1921. } else for (var a in e) {
  1922. if (hasOwnProperty.call(e, a) && t.call(n, e[a], a, e) === i) return;
  1923. }
  1924. }
  1925. };
  1926. me.buildQuery = function (e, t) {
  1927. var n,
  1928. i,
  1929. r = [];
  1930. void 0 === t && (t = "&");
  1931. me.each(e, function (e, t) {
  1932. n = encodeURIComponent(e.toString());
  1933. i = encodeURIComponent(t);
  1934. r[r.length] = i + "=" + n;
  1935. });
  1936. return r.join(t);
  1937. };
  1938. me.JSONDecode = function (e) {
  1939. if (e) {
  1940. try {
  1941. return JSON.parse(e);
  1942. } catch (e) {
  1943. console.error("JSONDecode error", e);
  1944. }
  1945. return null;
  1946. }
  1947. };
  1948. me.JSONEncode = function (e) {
  1949. try {
  1950. return JSON.stringify(e);
  1951. } catch (e) {
  1952. console.error("JSONEncode error", e);
  1953. }
  1954. };
  1955. var Ie = Object.create(null);
  1956. function Oe(e) {
  1957. t().v("开始构建 fetch body");
  1958. a.getSystemInfo(function (t) {
  1959. a.getNetworkInfo(function (i) {
  1960. var r = (i = i || {}).networkType;
  1961. r = r === ye ? "unknown" : r.toUpperCase();
  1962. Ie.access = r;
  1963. !function (e, t) {
  1964. var i = e.brand || "";
  1965. Ie.deviceType = "Phone";
  1966. Ie.sdkVersion = _e;
  1967. Ie.appkey = n().appKey();
  1968. Ie.sdkType = a.getSdkType();
  1969. Ie.umid = v().getId();
  1970. if (e) {
  1971. Ie.language = e.language || "";
  1972. Ie.os = e.OS;
  1973. Ie.osVersion = e.OSVersion;
  1974. Ie.deviceName = e.deviceName;
  1975. Ie.platformVersion = e.platformVersion;
  1976. Ie.platformSdkVersion = e.platformSDKVersion;
  1977. Ie.deviceBrand = i;
  1978. var r = e.resolution.split("*");
  1979. if (me.isArray(r)) {
  1980. Ie.resolutionHeight = Number(r[0]);
  1981. Ie.resolutionWidth = Number(r[1]);
  1982. }
  1983. }
  1984. !function (e) {
  1985. if (e) {
  1986. Ie.installTime = e.install_datetime && Date.parse(e.install_datetime);
  1987. Ie.scene = e.install_scene;
  1988. Ie.channel = e.install_channel;
  1989. Ie.campaign = e.install_campaign;
  1990. }
  1991. }(te.getImpObj());
  1992. t && t(Ie);
  1993. }(t, e);
  1994. });
  1995. });
  1996. }
  1997. var Ee = Object.create(null),
  1998. Te = null,
  1999. Ne = !1,
  2000. Ae = {
  2001. minFetchIntervalSeconds: 43200
  2002. };
  2003. function be(e) {
  2004. e && me.each(e, function (e) {
  2005. Ee[e.k] = e;
  2006. });
  2007. }
  2008. function ke() {
  2009. var e = this;
  2010. this.STORAGE_NAME = null;
  2011. r.once(r.messageType.CONFIG_LOADED, function (n) {
  2012. t().v("云配初始化开始...");
  2013. e.init(n);
  2014. });
  2015. }
  2016. ke.prototype = {
  2017. setDefaultValues: function setDefaultValues(e) {
  2018. Ne && me.isObject(e) && me.each(e, function (e, t) {
  2019. Ee[t] && Ee[t].v || (Ee[t] = {
  2020. v: e
  2021. });
  2022. });
  2023. },
  2024. getValue: function getValue(e) {
  2025. t().v("从配置项中读取 value, 当前配置为: ", Ee);
  2026. t().v("待读取的 key : ", e);
  2027. try {
  2028. if (!Ne) return;
  2029. var i = Ee[e] || {};
  2030. t().v("读取相应配置ing..., 结果为: ", i);
  2031. if (me.isNumber(i.e) && me.isNumber(i.g)) {
  2032. t().v("读取到相应配置, 开始数据上报...");
  2033. !function (e) {
  2034. var i = {
  2035. appkey: n().appKey(),
  2036. sdkType: a.getSdkType(),
  2037. expId: e && e.e,
  2038. groupId: e && e.g,
  2039. clientTs: Date.now(),
  2040. key: e && e.k,
  2041. value: e && e.v,
  2042. umid: v().getId()
  2043. };
  2044. try {
  2045. a.request({
  2046. url: ve,
  2047. method: "POST",
  2048. data: [i],
  2049. success: function success(e) {
  2050. e && 200 === e.statusCode ? t().v("上传数据成功", i) : t().w("ablog 请求成功, 返回结果异常 ", e);
  2051. },
  2052. fail: function fail(e) {
  2053. t().w("ablog 请求数据错误 ", i, e);
  2054. }
  2055. });
  2056. } catch (e) {
  2057. t().w("urequest 调用错误", e);
  2058. }
  2059. }(i);
  2060. }
  2061. return i.v;
  2062. } catch (n) {
  2063. t().w("getValue error, key: ", e);
  2064. }
  2065. },
  2066. active: function active(e) {
  2067. try {
  2068. if (!Ne) return;
  2069. var n, i;
  2070. e && e.params && (n = e.params);
  2071. e && e.callback && (i = e.callback);
  2072. t().v("激活配置项: ", n);
  2073. if (n) {
  2074. t().v("本地已缓存的配置项: ", Ee);
  2075. be(n);
  2076. t().v("合并后的配置项: ", Ee);
  2077. i && i(Ee);
  2078. t().v("active 结束");
  2079. } else {
  2080. t().v("配置项为空!! 读取本地配置...");
  2081. a.getStorage(this.STORAGE_NAME, function (e) {
  2082. if (e) {
  2083. be((e = me.JSONDecode(e) || {}).params);
  2084. t().v("当前本地配置项为: ", Ee);
  2085. i && i(Ee);
  2086. t().v("active 结束");
  2087. } else t().v("当前本地配置项为空, 退出激活");
  2088. });
  2089. }
  2090. } catch (e) {
  2091. t().w("SDK active 错误", e);
  2092. }
  2093. },
  2094. init: function init(e) {
  2095. if (e.appKey) {
  2096. Te = e.appKey;
  2097. this.STORAGE_NAME = "um_remote_config_{{" + Te + "}}";
  2098. }
  2099. if (Te) {
  2100. if (Ne) t().w("SDK 已经初始化, 请避免重复初始化");else {
  2101. Ne = !0;
  2102. this.setOptions(e);
  2103. this.active();
  2104. }
  2105. } else t().err("请检查您的小程序 appKey, appKey 不能为空");
  2106. },
  2107. setOptions: function setOptions(e) {
  2108. if (me.isObject(e)) {
  2109. var t = e.minFetchIntervalSeconds;
  2110. me.isNumber(t) && (Ae.minFetchIntervalSeconds = Math.max(t, 5));
  2111. }
  2112. },
  2113. fetch: function fetch(e) {
  2114. if (Ne && this.STORAGE_NAME) {
  2115. var n, i;
  2116. e && e.active && (n = e.active);
  2117. e && e.callback && (i = e.callback);
  2118. var r = this;
  2119. a.getStorage(this.STORAGE_NAME, function (e) {
  2120. t().v("开始读缓存 data is ", e);
  2121. if ((e = me.JSONDecode(e) || {}).params && e.ts && Date.now() - e.ts < 1e3 * Ae.minFetchIntervalSeconds) {
  2122. t().v("缓存数据存在, 并且本次触发时间距离上次fetch触发时间未超过 fetch 时间间隔, 无需 fetch");
  2123. i && i(e.params);
  2124. } else Oe(function (e) {
  2125. t().v("缓存数据不存在, 构建 fetch body :", e);
  2126. try {
  2127. a.request({
  2128. url: ge,
  2129. method: "POST",
  2130. data: e,
  2131. success: function success(e) {
  2132. if (e && 200 === e.statusCode && e.data && e.data.cc) {
  2133. t().v("fetch 请求成功, 响应数据: ", e.data);
  2134. var o = Object.create(null);
  2135. me.each(e.data.cc, function (e) {
  2136. o[e.k] = e;
  2137. });
  2138. var s = {
  2139. ts: Date.now(),
  2140. params: o
  2141. };
  2142. t().v("开始缓存 fetch 请求的云配置结果...");
  2143. a.setStorage(r.STORAGE_NAME, me.JSONEncode(s), function (e) {
  2144. t().v("缓存云配置成功, 缓存数据为: ", s);
  2145. t().v("缓存云配置成功, 成功消息为: ", e);
  2146. t().v("云配拉取数据是否自动激活: ", n);
  2147. if (e && n) {
  2148. t().v("激活云配置...");
  2149. r.active({
  2150. params: o,
  2151. callback: i
  2152. });
  2153. }
  2154. });
  2155. } else {
  2156. t().w("fetch 请求成功,返回结果异常 ", e.data);
  2157. i && i();
  2158. }
  2159. },
  2160. fail: function fail(n) {
  2161. t().w("fetch请求数据错误 ", e, n);
  2162. i && i();
  2163. }
  2164. });
  2165. } catch (e) {
  2166. t().w("urequest调用错误", e);
  2167. }
  2168. });
  2169. });
  2170. }
  2171. }
  2172. };
  2173. var De = {
  2174. install: function install(e, t) {
  2175. e.rc || (e.rc = new ke());
  2176. e.messager.once(e.messager.messageType.CONFIG_LOADED, function () {
  2177. e._log.v("plugin rc installed");
  2178. });
  2179. return e.rc;
  2180. }
  2181. },
  2182. we = "_um",
  2183. Re = "revenue",
  2184. Ue = "stage",
  2185. Pe = "level",
  2186. Ce = "running",
  2187. Le = "end",
  2188. Me = "init",
  2189. je = "set",
  2190. Ve = [we, Ue, "start"].join(".");
  2191. function xe(e) {
  2192. var t = {};
  2193. for (var n in e) {
  2194. var i = e[n];
  2195. if ("object" == typeof i) for (var r in i) {
  2196. t[n + "." + r] = i[r];
  2197. } else t[n] = i;
  2198. }
  2199. return t;
  2200. }
  2201. var qe = {
  2202. install: function install(e, t) {
  2203. e.revenue = function (t) {
  2204. e.trackEvent([we, Re, t.group].join("."), xe(t));
  2205. };
  2206. var n = 0;
  2207. e.stage = {
  2208. onStart: function onStart(t) {
  2209. n = Date.now();
  2210. e.trackEvent(Ve, xe(t));
  2211. },
  2212. onEnd: function onEnd(t) {
  2213. "number" != typeof t._um_sdu && (t._um_sdu = 0 !== n ? Date.now() - n : 0);
  2214. e.trackEvent([we, Ue, Le, t.event].join("."), xe(t));
  2215. },
  2216. onRunning: function onRunning(t) {
  2217. e.trackEvent([we, Ue, Ce, t.event].join("."), xe(t));
  2218. }
  2219. };
  2220. e.level = {
  2221. onInitLevel: function onInitLevel(t) {
  2222. e.trackEvent([we, Pe, Me].join("."), xe(t));
  2223. },
  2224. onSetLevel: function onSetLevel(t) {
  2225. e.trackEvent([we, Pe, je].join("."), xe(t));
  2226. }
  2227. };
  2228. e.messager.once(e.messager.messageType.CONFIG_LOADED, function () {
  2229. e._log.v("plugin game-ext installed");
  2230. });
  2231. return e;
  2232. }
  2233. },
  2234. Ge = a.getContext();
  2235. if (void 0 !== Ge) {
  2236. Ge.onShow(function (e) {
  2237. t().v("game onShow: ", e);
  2238. n = e.query, y = n;
  2239. var n;
  2240. he.resume(e, !0);
  2241. });
  2242. Ge.onHide(function () {
  2243. t().v("game onHide");
  2244. he.pause();
  2245. });
  2246. }
  2247. var Fe = he.init;
  2248. he.init = function (e) {
  2249. if (e && e.useOpenid) {
  2250. t().tip_w(t().repeat("!"));
  2251. t().tip_w("您选择了使用openid进行统计,请确保使用setOpenid回传openid或通过设置autoGetOpenid为true,并在友盟后台设置secret由友盟帮您获取");
  2252. t().tip_w(t().repeat("!"));
  2253. }
  2254. he.resume({});
  2255. Fe.call(he, e);
  2256. };
  2257. he.use(De);
  2258. he.use(qe);
  2259. Ge && (Ge.uma = he);
  2260. var _default = he;
  2261. exports["default"] = _default;
  2262. module.exports = exports["default"];
  2263. cc._RF.pop();