wxsdk_v3.17.js 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850
  1. var t = require;
  2. var e = module;
  3. var i,
  4. s,
  5. o,
  6. a,
  7. r,
  8. l,
  9. h,
  10. c,
  11. d,
  12. n,
  13. u,
  14. p,
  15. f,
  16. g,
  17. m,
  18. _,
  19. y,
  20. v,
  21. U,
  22. Z,
  23. C,
  24. b,
  25. S,
  26. T,
  27. I =
  28. "function" == typeof Symbol && "symbol" == typeof Symbol.iterator
  29. ? function (t) {
  30. return typeof t;
  31. }
  32. : function (t) {
  33. return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype
  34. ? "symbol"
  35. : typeof t;
  36. };
  37. function w(t, s) {
  38. 0 < t.length
  39. ? wx.request({
  40. url: l + "/api/wx/wx_subscribe",
  41. method: "POST",
  42. data: {tmpid: t, appid: p, openid: f, sign: g, platform: y},
  43. success: function (t) {
  44. var e,
  45. i = t.data.data;
  46. for (e in i) wx.setStorageSync(e, i[e]);
  47. s({code: 1, msg: "订阅成功", tem_ids: i});
  48. },
  49. fail: function (t) {
  50. console.log(t, "rrrrrrrrrr");
  51. }
  52. })
  53. : s({code: 0, msg: "拒绝订阅"});
  54. }
  55. function M(e) {
  56. wx.checkSession({
  57. success: function () {
  58. var t;
  59. console.log("重新获取 success-" + f),
  60. f
  61. ? ((t = {user: {openid: f, sign: g}, shareInfo: _.query}), e(t))
  62. : T.login(function (t) {
  63. f ? e(t) : wx.showModal({title: "提示", content: "登录异常,请重新打开小游戏4"});
  64. });
  65. },
  66. fail: function () {
  67. "develop" == h && console.log("重新获取openid fail"),
  68. T.login(function (t) {
  69. f ? e(t) : wx.showModal({title: "提示", content: "登录异常,请重新打开小游戏3"});
  70. });
  71. }
  72. });
  73. }
  74. function D(t) {
  75. new Array();
  76. for (var e = t.split("&"), i = 0; i < e.length; i++) {
  77. if ("" == e[i]) return;
  78. var s = t.split("=");
  79. if ("chid" == s[0] || "subchid" == s[0] || "shareid" == s[0] || "sharetype" == s[0]) return;
  80. }
  81. return 1;
  82. }
  83. "function" == typeof Symbol && I(Symbol.iterator),
  84. (t = t("config")),
  85. (r = "v3.17"),
  86. (h = "develop"),
  87. (d = "test_sub_channel_id"),
  88. (m = {}),
  89. (_ = {}),
  90. (U = 120),
  91. (C = Z = y = g = f = p = n = c = l = ""),
  92. (S = b = v = u = 0),
  93. (T = {
  94. getDybUserInfo: function (e) {
  95. (v = +new Date()),
  96. "develop" == h && console.log("----------getDybUserInfo-------------"),
  97. M(function (t) {
  98. T.initData(function () {}), e(t);
  99. });
  100. },
  101. login: function (s) {
  102. "develop" == h && console.log(f + "======login========"),
  103. wx.login({
  104. success: function (t) {
  105. t = {
  106. code: t.code,
  107. game_appid: p,
  108. channel_id: c,
  109. sub_channel_id: d,
  110. shareid: u,
  111. sharetype: n,
  112. version: r,
  113. gdt: "",
  114. platform: y,
  115. clue_token: Z,
  116. click_id: C,
  117. ad_id: b,
  118. creative_id: S
  119. };
  120. "develop" == h && console.log(t, "初始化登陆logins数据"),
  121. wx.request({
  122. url: l + "/api/wx/get_wx_userinfo",
  123. header: {"content-type": "application/x-www-form-urlencoded"},
  124. method: "POST",
  125. data: t,
  126. dataType: "json",
  127. success: function (t) {
  128. var e, i;
  129. t.data.code
  130. ? ((i = {
  131. user: (e = {openid: t.data.data.openid, sign: t.data.data.sign}),
  132. shareInfo: _.query
  133. }),
  134. (f = t.data.data.openid),
  135. (g = t.data.data.sign),
  136. (m = e),
  137. wx.setStorageSync("sop_user", e),
  138. s(i))
  139. : wx.showModal({title: "提示", content: t.data.msg});
  140. },
  141. fail: function (t) {
  142. console.log("调用失败", t),
  143. wx.showModal({title: "提示", content: "登录异常,请重新打开小游戏1"});
  144. }
  145. });
  146. },
  147. fail: function (t) {
  148. console.log("调用失败", t),
  149. wx.showModal({title: "提示", content: "登录异常,请重新打开小游戏2"});
  150. }
  151. });
  152. },
  153. initData: function () {
  154. "develop" == h && console.log("----------init_Data-------------");
  155. var t = {};
  156. (t.openid = f),
  157. (t.sign = g),
  158. (t.game_appid = p),
  159. (t.channel_id = c),
  160. (t.sub_channel_id = d),
  161. (t.version = r),
  162. (t.platform = y),
  163. (t.clue_token = Z),
  164. (t.click_id = C),
  165. wx.request({
  166. url: l + "/api/wx/init_data",
  167. data: t,
  168. method: "post",
  169. header: {"content-type": "application/x-www-form-urlencoded"},
  170. success: function (t) {
  171. "develop" == h && console.log(t.data, "init_data_success"),
  172. 1 == t.data.code && (U = t.data.data.online_time || 60);
  173. }
  174. });
  175. },
  176. createRole: function (t, i) {
  177. console.log("获取字节创角clue_token", Z),
  178. "develop" == h && console.log("----------roleData-------------"),
  179. M(function () {
  180. var e = {openid: f, game_appid: p, sign: g, gdt: "", version: r, platform: y};
  181. return null == I(t.server_id) && "" == String(t.server_id) && "undefined" == String(t.server_id)
  182. ? void i({code: 0, msg: "服务器ID不正确"})
  183. : ((e.server_id = t.server_id),
  184. null != I(t.server_name) ||
  185. "" != String(t.server_name) ||
  186. "undefined" != String(t.server_name)
  187. ? (e.server_name = t.server_name)
  188. : (e.server_name = "默认区服"),
  189. null == I(t.role_name) && "" == String(t.role_name) && "undefined" == String(t.role_name)
  190. ? void i({code: 0, msg: "角色名称不正确"})
  191. : ((e.role_name = t.role_name),
  192. void wx.request({
  193. url: l + "/api/wx/create_role",
  194. data: e,
  195. method: "post",
  196. header: {"content-type": "application/x-www-form-urlencoded"},
  197. success: function (t) {
  198. i(t.data),
  199. 1 == t.data.code
  200. ? wx.request({
  201. url: l + "/api/wx/role_login",
  202. data: e,
  203. method: "post",
  204. header: {"content-type": "application/x-www-form-urlencoded"},
  205. complete: function () {}
  206. })
  207. : i(t.data);
  208. },
  209. complete: function () {
  210. console.log("finshshow-----"), wx.reportAnalytics("finishShow");
  211. }
  212. })));
  213. });
  214. },
  215. submitOrder: function (t, a) {
  216. var n = +new Date();
  217. console.log("开始时间:", n),
  218. "develop" == h && console.log("----------提交订单-------------支付环境"),
  219. M(function () {
  220. var e, o;
  221. null != I(t.server_name) && "" != String(t.server_name) && "undefined" != String(t.server_name)
  222. ? null != I(t.role_name) && "" != String(t.role_name) && "undefined" != String(t.role_name)
  223. ? ((e = {
  224. game_appid: p,
  225. extra_info: t.extra_info,
  226. goods_count: t.goods_count,
  227. goods_name: t.goods_name,
  228. pay_amount: t.pay_amount,
  229. account_id: f,
  230. redirect_uri: t.redirect_uri,
  231. role_name: t.role_name,
  232. server_name: t.server_name,
  233. channel_id: c,
  234. sub_channel_id: d,
  235. order_sn: t.order_sn,
  236. sign: g,
  237. gdt: "",
  238. version: r,
  239. platform: y
  240. }),
  241. (o = +new Date() - n),
  242. console.log("request_before", o),
  243. wx.request({
  244. url: l + "/api/wx/wxgame_create",
  245. method: "POST",
  246. header: {"content-type": "application/x-www-form-urlencoded"},
  247. data: e,
  248. success: function (s) {
  249. var t,
  250. i = +new Date() - n;
  251. "develop" == h && console.log(s.data, "支付接口返回", i),
  252. s.data.code
  253. ? 2 == s.data.data.pay_type
  254. ? wx.openCustomerServiceConversation({
  255. showMessageCard: !0,
  256. sendMessageTitle: s.data.data.order_sn,
  257. sendMessagePath: JSON.stringify(e),
  258. sendMessageImg: l + "/kefuIcon.png",
  259. success: function (t) {
  260. wx.hideLoading(),
  261. a({code: 1, msg: "支付success 客服回调"}),
  262. console.log(t, "客服回调");
  263. },
  264. fail: function (t) {
  265. wx.hideLoading(),
  266. a({code: 0, msg: "取消支付"}),
  267. console.log(t, "客服回调fail");
  268. }
  269. })
  270. : 1 == s.data.data.pay_type
  271. ? (wx.hideLoading(),
  272. wx.navigateToMiniProgram({
  273. appId: "wxab2e839b6578e72c",
  274. path: "pages/come/come?scene=" + s.data.data.id,
  275. extraData: {game_appid: p, openid: f},
  276. envVersion: "release",
  277. success: function (t) {
  278. wx.hideLoading(),
  279. a({code: 1, msg: "支付success "}),
  280. console.log(t, "res");
  281. },
  282. fail: function (t) {
  283. wx.hideLoading(),
  284. a({code: 0, msg: "支付dail"}),
  285. console.log(t, "fff");
  286. },
  287. complete: function () {
  288. wx.hideLoading();
  289. }
  290. }))
  291. : 3 == s.data.data.pay_type
  292. ? wx.request({
  293. url: l + "/api/wx/native_pay",
  294. method: "POST",
  295. data: {id: s.data.data.id},
  296. header: {"content-type": "application/json"},
  297. success: function (t) {
  298. console.log(t, "sss"),
  299. t.data.code &&
  300. ((t = l + "/" + t.data.data.url),
  301. console.log(t),
  302. wx.previewImage({
  303. current: t,
  304. urls: [t, t],
  305. success: function () {
  306. wx.hideLoading();
  307. },
  308. fail: function (t) {
  309. wx.hideLoading(), console.log(t, "prf");
  310. },
  311. complete: function (t) {
  312. wx.hideLoading(), console.log(t, "com");
  313. }
  314. }));
  315. }
  316. })
  317. : 4 == s.data.data.pay_type
  318. ? wx.request({
  319. url: l + "/api/mini/getUnlimit",
  320. method: "POST",
  321. data: {scene: s.data.data.id, appid: "wxab2e839b6578e72c"},
  322. header: {"content-type": "application/json"},
  323. success: function (t) {
  324. console.log(t, "sss"),
  325. t.data.code &&
  326. (console.log(l + "/" + t.data.data.url),
  327. wx.previewImage({
  328. current: l + "/" + t.data.data.url,
  329. urls: [l + "/" + t.data.data.url],
  330. success: function () {
  331. wx.hideLoading();
  332. },
  333. fail: function (t) {
  334. wx.hideLoading(), console.log(t, "prf");
  335. }
  336. }));
  337. }
  338. })
  339. : "android" == y || "windows" == y
  340. ? wx.requestMidasPayment({
  341. mode: s.data.data.param.mode,
  342. offerId: s.data.data.param.offerId,
  343. currencyType: s.data.data.param.currencyType,
  344. platform: s.data.data.param.platform,
  345. buyQuantity: s.data.data.param.buyQuantity,
  346. success: function () {
  347. a({code: 1, msg: "支付成功"}),
  348. "develop" == h && console.log("支付成功回调函数");
  349. var e = 0,
  350. t = s.data.data.order_sn,
  351. i = setInterval(function () {
  352. wx.request({
  353. url: l + "/api/wx/wxgame_notify",
  354. method: "POST",
  355. header: {
  356. "content-type":
  357. "application/x-www-form-urlencoded"
  358. },
  359. data: {
  360. bill_no: t,
  361. game_appid: p,
  362. account_id: f,
  363. sign: g
  364. },
  365. success: function (t) {
  366. "develop" == h &&
  367. console.log(t.data, "支付成功查询回调"),
  368. (1 == t.data.code || 10 < e) &&
  369. clearInterval(i),
  370. e++;
  371. },
  372. complete: function () {
  373. 30 < e && clearInterval(i);
  374. }
  375. });
  376. }, 2e3);
  377. },
  378. fail: function (t) {
  379. "develop" == h && console.log("支付失败", t),
  380. wx.hideLoading(),
  381. a({code: 0, msg: "支付失败"});
  382. var e = +new Date() - n;
  383. console.log("fail_time", e),
  384. (t.request_before = o),
  385. (t.req_success = i),
  386. (t.failTime = e),
  387. (t.appid = p),
  388. (t.openid = f),
  389. wx.request({
  390. url: l + "/api/wx/fail_pay",
  391. method: "POST",
  392. header: {
  393. "content-type":
  394. "application/x-www-form-urlencoded"
  395. },
  396. data: t,
  397. success: function () {}
  398. });
  399. }
  400. })
  401. : (wx.hideLoading(),
  402. wx.showModal({
  403. title: "提示",
  404. content: "请使用手机完成支付",
  405. showCancel: !1,
  406. cancelColor: "cancelColor"
  407. }))
  408. : (wx.hideLoading(),
  409. (t = s.data.data.data) &&
  410. 90011 == t.errcode &&
  411. ((f = ""), wx.removeStorageSync("sop_user")),
  412. a({code: 0, msg: s.data.msg}));
  413. },
  414. fail: function () {
  415. a({code: 0, msg: "请求失败"});
  416. }
  417. }))
  418. : a({code: 0, msg: "缺少角色名"})
  419. : a({code: 0, msg: "缺少服务器名"});
  420. });
  421. },
  422. toGameClub: function (t, e) {
  423. wx.openPage({
  424. openlink: t,
  425. success: function (t) {
  426. e(t.errMsg);
  427. },
  428. fail: function (t) {
  429. e({code: 0, msg: "open gameclub fail!", res: t.errMsg});
  430. }
  431. });
  432. },
  433. getUserData: function (e) {
  434. M(function () {
  435. wx.request({
  436. url: l + "/api/wx/get_userInfo_data",
  437. method: "POST",
  438. header: {"content-type": "application/x-www-form-urlencoded"},
  439. data: {game_appid: p, account_id: f, sign: g},
  440. success: function (t) {
  441. t = t.data;
  442. e(1 == t.code ? t.data : t);
  443. },
  444. fail: function (t) {
  445. console.log("getUserData", t);
  446. }
  447. });
  448. });
  449. },
  450. transfer: function () {
  451. wx.request({
  452. url: l + "/api/wx/transfer",
  453. method: "POST",
  454. header: {"content-type": "application/x-www-form-urlencoded"},
  455. data: {game_appid: p, account_id: f, sign: g, platform: y},
  456. success: function (t) {
  457. t = t.data;
  458. console.log(t, "ssssssss"),
  459. 1 == t.code &&
  460. wx.showModal({
  461. title: "转移大福利",
  462. content:
  463. "大大您好,这里看到您近期游戏体验较为活跃,作为我们的忠实玩家,现推出app版本,诚邀您参与体验,切换微信不再会影响游戏进程,游戏体验更流畅,app微信实现双登录,更有专属福利活动等着您,如有疑问,请联系官方客服QQ:800821618",
  464. confirmText: "立即前往",
  465. cancelText: "暂时跳过",
  466. success: function (t) {
  467. t.confirm
  468. ? (console.log("用户点击确定"),
  469. wx.openCustomerServiceConversation({
  470. showMessageCard: !0,
  471. sendMessageTitle: "转移",
  472. sendMessagePath: y,
  473. success: function (t) {
  474. console.log(t, "客服回调");
  475. },
  476. fail: function (t) {
  477. console.log(t, "客服回调fail"),
  478. wx.showModal({
  479. title: "转移大福利",
  480. content:
  481. "大大您好,这里看到您近期游戏体验较为活跃,作为我们的忠实玩家,现推出app版本,诚邀您参与体验,切换微信不再会影响游戏进程,游戏体验更流畅,app微信实现双登录,更有专属福利活动等着您,如有疑问,请联系官方客服QQ:800821618",
  482. confirmText: "立即前往",
  483. cancelText: "暂时跳过",
  484. success: function (t) {
  485. t.confirm
  486. ? (console.log("用户点击确定"),
  487. wx.openCustomerServiceConversation({
  488. showMessageCard: !0,
  489. sendMessageTitle: "转移",
  490. sendMessagePath: y,
  491. success: function (t) {
  492. console.log(t, "客服回调");
  493. },
  494. fail: function (t) {
  495. console.log(t, "客服回调fail");
  496. }
  497. }))
  498. : console.log("用户点击取消");
  499. }
  500. });
  501. }
  502. }))
  503. : console.log("用户点击取消");
  504. }
  505. });
  506. },
  507. fail: function (t) {
  508. console.log("transfer", t);
  509. }
  510. });
  511. },
  512. subscribeMsg: function (t, s) {
  513. var e,
  514. o = [],
  515. a = [];
  516. for (e in t) wx.getStorageSync(t[e]) || o.push(t[e]);
  517. if (0 == o.length) return console.log("已经订阅"), void s({code: 2, msg: "已经订阅"});
  518. var n = [];
  519. wx.requestSubscribeMessage({
  520. tmplIds: o,
  521. success: function (t) {
  522. if ((console.log(t, "success-ssssssss"), "requestSubscribeMessage:ok" == t.errMsg)) {
  523. for (var e in o)
  524. wx.getStorageSync(o[e]) ||
  525. ("accept" == t[o[e]]
  526. ? (a.push(o[e]), console.log(a, "upppppppp"))
  527. : (n.push(o[e]),
  528. wx.showModal({
  529. title: "订阅",
  530. content: "为了及时了解游戏动态,请订阅通知",
  531. cancelColor: "cancelColor",
  532. success: function (t) {
  533. t.confirm
  534. ? wx.openSetting({
  535. withSubscriptions: !0,
  536. success: function (t) {
  537. console.log(t, "openSetting");
  538. var e,
  539. i = t.subscriptionsSetting.itemSettings;
  540. for (e in n)
  541. wx.getStorageSync(n[e]) ||
  542. ("accept" == i[n[e]] && (a[o[e]] = o[e]));
  543. }
  544. })
  545. : s({code: 0, msg: "拒绝订阅"});
  546. }
  547. })));
  548. w(a, s);
  549. }
  550. },
  551. fail: function (t) {
  552. console.log(t, "fail"),
  553. wx.openSetting({
  554. withSubscriptions: !0,
  555. success: function (t) {
  556. console.log(t, "openSetting");
  557. var e,
  558. i = t.subscriptionsSetting.itemSettings;
  559. for (e in o) wx.getStorageSync(o[e]) || ("accept" == i[o[e]] && a.push(o[e]));
  560. w(a, s);
  561. },
  562. fail: function () {
  563. s({code: 0, msg: "拒绝订阅"});
  564. }
  565. });
  566. }
  567. });
  568. },
  569. onShare: function (t) {
  570. "develop" == h && console.log("----------设置转发-------------"),
  571. !t.query || D(t.query)
  572. ? (wx.showShareMenu({showShareItems: ["shareAppMessage", "shareTimeline"], withShareTicket: !0}),
  573. wx.onShareAppMessage(function () {
  574. return {
  575. title: t.title,
  576. imageUrl: t.imageUrl,
  577. query: "subchid=" + d + "&sharetype=onshare&shareid=" + f + "&" + t.query
  578. };
  579. }))
  580. : console.log("query error");
  581. },
  582. share: function (t) {
  583. "develop" == h && console.log("----------主动转发-------------"),
  584. M(function () {
  585. !t.query || D(t.query)
  586. ? (wx.showShareMenu({
  587. showShareItems: ["shareAppMessage", "shareTimeline"],
  588. withShareTicket: !0
  589. }),
  590. wx.shareAppMessage({
  591. title: t.title,
  592. imageUrl: t.imageUrl,
  593. query: "subchid=" + d + "&sharetype=share&shareid=" + f + "&" + t.query
  594. }))
  595. : console.log("query error");
  596. });
  597. },
  598. dot: function (t, e) {
  599. wx.request({
  600. url: l + "/api/wx/dot_record",
  601. method: "POST",
  602. header: {"content-type": "application/x-www-form-urlencoded"},
  603. data: {game_appid: p, account_id: f, step: t, sign: g, version: r, platform: y},
  604. success: function (t) {
  605. e(t.data);
  606. },
  607. fail: function (t) {
  608. e({code: 0, msg: "网络请求失败", res: t});
  609. }
  610. });
  611. },
  612. createVideoAd: function (t, i) {
  613. var e;
  614. "develop" == h && console.log(void 0 === s ? "undefined" : I(s), "typeof(video)"),
  615. "object" != (void 0 === s ? "undefined" : I(s))
  616. ? ("develop" == h && console.log(o, "typeof(adUnitId11)"),
  617. (o = t),
  618. (s = wx.createRewardedVideoAd({adUnitId: t})).onError(function (t) {
  619. var e = {};
  620. "develop" == h && console.log(t, "----------onError-------------"),
  621. (e.msg = t.errMsg),
  622. (e.state = "error"),
  623. (e.isEnded = !1),
  624. (e.res = t),
  625. i(e);
  626. }),
  627. s.onClose(function (t) {
  628. var e = {};
  629. T.advertisement("close", function () {}),
  630. (e.state = "close"),
  631. (e.isEnded = t.isEnded),
  632. (e.msg = "视频广告关闭"),
  633. i(e);
  634. }),
  635. s
  636. .load()
  637. .then(function () {
  638. console.log("激励视频加载成功"),
  639. s
  640. .show()
  641. .then(function () {
  642. T.advertisement("show", function () {}),
  643. i({state: "show", msg: "视频展示成功", isEnded: !1});
  644. })
  645. .catch(function (t) {
  646. var e = {code: 2, state: "error"};
  647. (e.msg = t.errMsg), (e.isEnded = !1), i(t);
  648. });
  649. })
  650. .catch(function (t) {
  651. console.log("激励视频加载失败", t);
  652. }))
  653. : o != t
  654. ? ("develop" == h && console.log(o, t, "typeof(new)"),
  655. (o = t),
  656. (e = wx.createRewardedVideoAd({adUnitId: t}))
  657. .load()
  658. .then(function () {
  659. e.show()
  660. .then(function () {
  661. T.advertisement("show", function () {}),
  662. i({state: "show", msg: "视频展示成功", isEnded: !1});
  663. })
  664. .catch(function (t) {
  665. var e = {code: 2, state: "error"};
  666. (e.msg = t.errMsg), (e.isEnded = !1), i(t);
  667. });
  668. })
  669. .catch(function (t) {
  670. console.log("激励视频加载失败", t);
  671. }))
  672. : ("develop" == h && console.log(s, "----------createVideoAd-------------"),
  673. s
  674. .show()
  675. .then(function () {
  676. T.advertisement("show", function () {}),
  677. i({state: "show", msg: "视频展示成功", isEnded: !1});
  678. })
  679. .catch(function (t) {
  680. var e = {code: 2, state: "error"};
  681. (e.msg = t.errMsg), (e.isEnded = !1), i(t);
  682. }));
  683. },
  684. advertisement: function (e, i) {
  685. "develop" == h && console.log(e, "----------上报广告-------------"),
  686. M(function () {
  687. var t = "";
  688. "show" == e
  689. ? (t = l + "/api/wx/videoClick")
  690. : "close" == e
  691. ? (t = l + "/api/wx/watch")
  692. : "share" == e && (t = l + "/api/wx/share"),
  693. wx.request({
  694. url: t,
  695. data: {openid: f, game_appid: p, sign: g, version: r, platform: y},
  696. method: "post",
  697. header: {"content-type": "application/x-www-form-urlencoded"},
  698. complete: function (t) {
  699. i(t.data);
  700. }
  701. });
  702. });
  703. },
  704. gameLevel: function (t, e) {
  705. var i = {};
  706. (i.openid = f),
  707. (i.appid = p),
  708. (i.sign = g),
  709. (i.level = t),
  710. (i.version = r),
  711. (i.platform = y),
  712. wx.request({
  713. url: l + "/api/wx/game_level",
  714. data: i,
  715. method: "post",
  716. header: {"content-type": "application/x-www-form-urlencoded"},
  717. complete: function (t) {
  718. e(t.data);
  719. }
  720. });
  721. },
  722. msg_check: function (t, e) {
  723. var i = {};
  724. (i.content = t),
  725. (i.appid = p),
  726. (i.openid = f),
  727. (i.version = r),
  728. wx.request({
  729. url: l + "/api/wx/msg_sec_check",
  730. data: i,
  731. method: "post",
  732. header: {"content-type": "application/x-www-form-urlencoded"},
  733. success: function (t) {
  734. e(t.data);
  735. }
  736. });
  737. },
  738. img_check: function (t, e) {
  739. wx.uploadFile({
  740. url: l + "/api/v2/img_sec_check",
  741. filePath: t,
  742. name: "media",
  743. formData: {appid: p, openid: f},
  744. success: function (t) {
  745. e(t.data);
  746. }
  747. });
  748. },
  749. media_check: function (t, e, i) {
  750. wx.request({
  751. url: l + "/api/v2/media_check",
  752. data: {appid: p, media_url: t, type: e},
  753. method: "post",
  754. header: {"content-type": "application/x-www-form-urlencoded"},
  755. success: function (t) {
  756. i(t.data);
  757. }
  758. });
  759. }
  760. }),
  761. cc.sys.platform === cc.sys.WECHAT_GAME &&
  762. ((m = wx.getStorageSync("sop_user")),
  763. (f = m.openid),
  764. (g = m.sign),
  765. console.log("==wxsdk version==", r),
  766. (h = t.env),
  767. (l = t.url),
  768. (p = t.appid),
  769. (function () {
  770. (_ = wx.getLaunchOptionsSync()), "develop" == h && console.log(_, "wx.getLaunchOptionsSync(111)");
  771. var t = _.query;
  772. (c = _.scene),
  773. (C = t.gdt_vid || ""),
  774. console.log("来源广告的广告id是: " + C),
  775. (Z = t.clue_token || ""),
  776. (b = t.ad_id || ""),
  777. (S = t.creative_id || "");
  778. var e = _.referrerInfo;
  779. t.via
  780. ? ((d = t.via || "test_sub_channel_id"), (u = t.shareid || 0), (n = t.sharetype || ""))
  781. : t.subchid
  782. ? ((d = t.subchid || "test_sub_channel_id"), (u = t.shareid || 0), (n = t.sharetype || ""))
  783. : e &&
  784. "string" == typeof e.extraData &&
  785. ((e.extraData = JSON.parse(e.extraData)),
  786. (d = e.extraData.subchid),
  787. (u = e.extraData.shareid || 0),
  788. (n = e.extraData.sharetype || "")),
  789. (i = wx.getSystemInfoSync()),
  790. (y = i.platform),
  791. (a = i.SDKVersion);
  792. })(),
  793. wx.onHide(function () {
  794. var t;
  795. console.log("onhide", v),
  796. (t = Math.floor((+new Date() - v) / 1e3)),
  797. "develop" == h && console.log("----------timing-------------:", t, U, v),
  798. !f ||
  799. t < U ||
  800. wx.request({
  801. url: l + "/api/wx/online_time",
  802. data: {openid: f, game_appid: p, timing: t, sign: g, version: r, platform: y},
  803. method: "post",
  804. header: {"content-type": "application/x-www-form-urlencoded"},
  805. success: function () {
  806. v = +new Date();
  807. }
  808. }),
  809. (v = +new Date());
  810. }),
  811. wx.onShow(function (t) {
  812. (v = +new Date()), console.log(JSON.stringify(t), "show");
  813. var e = t.referrerInfo;
  814. console.log(e, "refer"),
  815. e.extraData &&
  816. ((t = e.extraData),
  817. console.log("data-----------", e.appId),
  818. "wxab2e839b6578e72c" == e.appId &&
  819. ("success" == t.pay
  820. ? wx.showToast({
  821. title: "成功",
  822. icon: "success",
  823. duration: 2e3,
  824. fail: function (t) {
  825. console.log(t, "eeeeeee");
  826. }
  827. })
  828. : wx.showToast({
  829. title: "支付失败",
  830. icon: "error",
  831. duration: 2e3,
  832. fail: function (t) {
  833. console.log(t, "eeeeeee");
  834. }
  835. })));
  836. }),
  837. 0 <=
  838. (function (t, e) {
  839. (t = t.split(".")), (e = e.split("."));
  840. for (var i = Math.max(t.length, e.length); t.length < i; ) t.push("0");
  841. for (; e.length < i; ) e.push("0");
  842. for (var s = 0; s < i; s++) {
  843. var o = parseInt(t[s]),
  844. a = parseInt(e[s]);
  845. if (a < o) return 1;
  846. if (o < a) return -1;
  847. }
  848. return 0;
  849. })(a, "2.10.3") && wx.onAddToFavorites(function () {}),
  850. (window.dyb = T));