weixin-jsapi.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. // E:/dashitech/廖明明(项目)/itsm(new)/itsm-wx-handle/node_modules/weixin-jsapi/index.js
  2. !function(a, b) {
  3. function c(b2, c2, d2) {
  4. a.WeixinJSBridge ? WeixinJSBridge.invoke(b2, e(c2), function(a2) {
  5. g(b2, a2, d2);
  6. }) : j(b2, d2);
  7. }
  8. function d(b2, c2, d2) {
  9. a.WeixinJSBridge ? WeixinJSBridge.on(b2, function(a2) {
  10. d2 && d2.trigger && d2.trigger(a2), g(b2, a2, c2);
  11. }) : d2 ? j(b2, d2) : j(b2, c2);
  12. }
  13. function e(a2) {
  14. return a2 = a2 || {}, a2.appId = z.appId, a2.verifyAppId = z.appId, a2.verifySignType = "sha1", a2.verifyTimestamp = z.timestamp + "", a2.verifyNonceStr = z.nonceStr, a2.verifySignature = z.signature, a2;
  15. }
  16. function f(a2) {
  17. return {
  18. timeStamp: a2.timestamp + "",
  19. nonceStr: a2.nonceStr,
  20. "package": a2.package,
  21. paySign: a2.paySign,
  22. signType: a2.signType || "SHA1"
  23. };
  24. }
  25. function g(a2, b2, c2) {
  26. var d2, e2, f2;
  27. switch (delete b2.err_code, delete b2.err_desc, delete b2.err_detail, d2 = b2.errMsg, d2 || (d2 = b2.err_msg, delete b2.err_msg, d2 = h(a2, d2, c2), b2.errMsg = d2), c2 = c2 || {}, c2._complete && (c2._complete(b2), delete c2._complete), d2 = b2.errMsg || "", z.debug && !c2.isInnerInvoke && alert(JSON.stringify(b2)), e2 = d2.indexOf(":"), f2 = d2.substring(e2 + 1)) {
  28. case "ok":
  29. c2.success && c2.success(b2);
  30. break;
  31. case "cancel":
  32. c2.cancel && c2.cancel(b2);
  33. break;
  34. default:
  35. c2.fail && c2.fail(b2);
  36. }
  37. c2.complete && c2.complete(b2);
  38. }
  39. function h(a2, b2) {
  40. var d2, e2, f2, g2;
  41. if (b2) {
  42. switch (d2 = b2.indexOf(":"), a2) {
  43. case o.config:
  44. e2 = "config";
  45. break;
  46. case o.openProductSpecificView:
  47. e2 = "openProductSpecificView";
  48. break;
  49. default:
  50. e2 = b2.substring(0, d2), e2 = e2.replace(/_/g, " "), e2 = e2.replace(/\b\w+\b/g, function(a3) {
  51. return a3.substring(0, 1).toUpperCase() + a3.substring(1);
  52. }), e2 = e2.substring(0, 1).toLowerCase() + e2.substring(1), e2 = e2.replace(/ /g, ""), -1 != e2.indexOf("Wcpay") && (e2 = e2.replace("Wcpay", "WCPay")), f2 = p[e2], f2 && (e2 = f2);
  53. }
  54. g2 = b2.substring(d2 + 1), "confirm" == g2 && (g2 = "ok"), "failed" == g2 && (g2 = "fail"), -1 != g2.indexOf("failed_") && (g2 = g2.substring(7)), -1 != g2.indexOf("fail_") && (g2 = g2.substring(5)), g2 = g2.replace(/_/g, " "), g2 = g2.toLowerCase(), ("access denied" == g2 || "no permission to execute" == g2) && (g2 = "permission denied"), "config" == e2 && "function not exist" == g2 && (g2 = "ok"), b2 = e2 + ":" + g2;
  55. }
  56. return b2;
  57. }
  58. function i(a2) {
  59. var b2, c2, d2, e2;
  60. if (a2) {
  61. for (b2 = 0, c2 = a2.length; c2 > b2; ++b2)
  62. d2 = a2[b2], e2 = o[d2], e2 && (a2[b2] = e2);
  63. return a2;
  64. }
  65. }
  66. function j(a2, b2) {
  67. if (!(!z.debug || b2 && b2.isInnerInvoke)) {
  68. var c2 = p[a2];
  69. c2 && (a2 = c2), b2 && b2._complete && delete b2._complete, console.log('"' + a2 + '",', b2 || "");
  70. }
  71. }
  72. function k() {
  73. if (!("6.0.2" > w || y.systemType < 0)) {
  74. var b2 = new Image();
  75. y.appId = z.appId, y.initTime = x.initEndTime - x.initStartTime, y.preVerifyTime = x.preVerifyEndTime - x.preVerifyStartTime, C.getNetworkType({
  76. isInnerInvoke: true,
  77. success: function(a2) {
  78. y.networkType = a2.networkType;
  79. var c2 = "https://open.weixin.qq.com/sdk/report?v=" + y.version + "&o=" + y.isPreVerifyOk + "&s=" + y.systemType + "&c=" + y.clientVersion + "&a=" + y.appId + "&n=" + y.networkType + "&i=" + y.initTime + "&p=" + y.preVerifyTime + "&u=" + y.url;
  80. b2.src = c2;
  81. }
  82. });
  83. }
  84. }
  85. function l() {
  86. return (/* @__PURE__ */ new Date()).getTime();
  87. }
  88. function m(b2) {
  89. t && (a.WeixinJSBridge ? b2() : q.addEventListener && q.addEventListener("WeixinJSBridgeReady", b2, false));
  90. }
  91. function n() {
  92. C.invoke || (C.invoke = function(b2, c2, d2) {
  93. a.WeixinJSBridge && WeixinJSBridge.invoke(b2, e(c2), d2);
  94. }, C.on = function(b2, c2) {
  95. a.WeixinJSBridge && WeixinJSBridge.on(b2, c2);
  96. });
  97. }
  98. var o, p, q, r, s, t, u, v, w, x, y, z, A, B, C;
  99. if (!a.jWeixin)
  100. return o = {
  101. config: "preVerifyJSAPI",
  102. onMenuShareTimeline: "menu:share:timeline",
  103. onMenuShareAppMessage: "menu:share:appmessage",
  104. onMenuShareQQ: "menu:share:qq",
  105. onMenuShareWeibo: "menu:share:weiboApp",
  106. onMenuShareQZone: "menu:share:QZone",
  107. previewImage: "imagePreview",
  108. getLocation: "geoLocation",
  109. openProductSpecificView: "openProductViewWithPid",
  110. addCard: "batchAddCard",
  111. openCard: "batchViewCard",
  112. chooseWXPay: "getBrandWCPayRequest"
  113. }, p = function() {
  114. var b2, a2 = {};
  115. for (b2 in o)
  116. a2[o[b2]] = b2;
  117. return a2;
  118. }(), q = a.document, r = q.title, s = navigator.userAgent.toLowerCase(), t = -1 != s.indexOf("micromessenger"), u = -1 != s.indexOf("android"), v = -1 != s.indexOf("iphone") || -1 != s.indexOf("ipad"), w = function() {
  119. var a2 = s.match(/micromessenger\/(\d+\.\d+\.\d+)/) || s.match(/micromessenger\/(\d+\.\d+)/);
  120. return a2 ? a2[1] : "";
  121. }(), x = { initStartTime: l(), initEndTime: 0, preVerifyStartTime: 0, preVerifyEndTime: 0 }, y = {
  122. version: 1,
  123. appId: "",
  124. initTime: 0,
  125. preVerifyTime: 0,
  126. networkType: "",
  127. isPreVerifyOk: 1,
  128. systemType: v ? 1 : u ? 2 : -1,
  129. clientVersion: w,
  130. url: encodeURIComponent(location.href)
  131. }, z = {}, A = { _completes: [] }, B = { state: 0, res: {} }, m(function() {
  132. x.initEndTime = l();
  133. }), C = {
  134. config: function(a2) {
  135. z = a2, j("config", a2);
  136. var b2 = z.check === false ? false : true;
  137. m(function() {
  138. var a3, d2, e2;
  139. if (b2)
  140. c(o.config, { verifyJsApiList: i(z.jsApiList) }, function() {
  141. A._complete = function(a5) {
  142. x.preVerifyEndTime = l(), B.state = 1, B.res = a5;
  143. }, A.success = function() {
  144. y.isPreVerifyOk = 0;
  145. }, A.fail = function(a5) {
  146. A._fail ? A._fail(a5) : B.state = -1;
  147. };
  148. var a4 = A._completes;
  149. return a4.push(function() {
  150. z.debug || k();
  151. }), A.complete = function() {
  152. for (var c2 = 0, d3 = a4.length; d3 > c2; ++c2)
  153. a4[c2]();
  154. A._completes = [];
  155. }, A;
  156. }()), x.preVerifyStartTime = l();
  157. else {
  158. for (B.state = 1, a3 = A._completes, d2 = 0, e2 = a3.length; e2 > d2; ++d2)
  159. a3[d2]();
  160. A._completes = [];
  161. }
  162. }), z.beta && n();
  163. },
  164. ready: function(a2) {
  165. 0 != B.state ? a2() : (A._completes.push(a2), !t && z.debug && a2());
  166. },
  167. error: function(a2) {
  168. "6.0.2" > w || (-1 == B.state ? a2(B.res) : A._fail = a2);
  169. },
  170. checkJsApi: function(a2) {
  171. var b2 = function(a3) {
  172. var c2, d2, b3 = a3.checkResult;
  173. for (c2 in b3)
  174. d2 = p[c2], d2 && (b3[d2] = b3[c2], delete b3[c2]);
  175. return a3;
  176. };
  177. c("checkJsApi", { jsApiList: i(a2.jsApiList) }, function() {
  178. return a2._complete = function(a3) {
  179. if (u) {
  180. var c2 = a3.checkResult;
  181. c2 && (a3.checkResult = JSON.parse(c2));
  182. }
  183. a3 = b2(a3);
  184. }, a2;
  185. }());
  186. },
  187. onMenuShareTimeline: function(a2) {
  188. d(o.onMenuShareTimeline, {
  189. complete: function() {
  190. c("shareTimeline", {
  191. title: a2.title || r,
  192. desc: a2.title || r,
  193. img_url: a2.imgUrl || "",
  194. link: a2.link || location.href
  195. }, a2);
  196. }
  197. }, a2);
  198. },
  199. onMenuShareAppMessage: function(a2) {
  200. d(o.onMenuShareAppMessage, {
  201. complete: function() {
  202. c("sendAppMessage", {
  203. title: a2.title || r,
  204. desc: a2.desc || "",
  205. link: a2.link || location.href,
  206. img_url: a2.imgUrl || "",
  207. type: a2.type || "link",
  208. data_url: a2.dataUrl || ""
  209. }, a2);
  210. }
  211. }, a2);
  212. },
  213. onMenuShareQQ: function(a2) {
  214. d(o.onMenuShareQQ, {
  215. complete: function() {
  216. c("shareQQ", {
  217. title: a2.title || r,
  218. desc: a2.desc || "",
  219. img_url: a2.imgUrl || "",
  220. link: a2.link || location.href
  221. }, a2);
  222. }
  223. }, a2);
  224. },
  225. onMenuShareWeibo: function(a2) {
  226. d(o.onMenuShareWeibo, {
  227. complete: function() {
  228. c("shareWeiboApp", {
  229. title: a2.title || r,
  230. desc: a2.desc || "",
  231. img_url: a2.imgUrl || "",
  232. link: a2.link || location.href
  233. }, a2);
  234. }
  235. }, a2);
  236. },
  237. onMenuShareQZone: function(a2) {
  238. d(o.onMenuShareQZone, {
  239. complete: function() {
  240. c("shareQZone", {
  241. title: a2.title || r,
  242. desc: a2.desc || "",
  243. img_url: a2.imgUrl || "",
  244. link: a2.link || location.href
  245. }, a2);
  246. }
  247. }, a2);
  248. },
  249. startRecord: function(a2) {
  250. c("startRecord", {}, a2);
  251. },
  252. stopRecord: function(a2) {
  253. c("stopRecord", {}, a2);
  254. },
  255. onVoiceRecordEnd: function(a2) {
  256. d("onVoiceRecordEnd", a2);
  257. },
  258. playVoice: function(a2) {
  259. c("playVoice", { localId: a2.localId }, a2);
  260. },
  261. pauseVoice: function(a2) {
  262. c("pauseVoice", { localId: a2.localId }, a2);
  263. },
  264. stopVoice: function(a2) {
  265. c("stopVoice", { localId: a2.localId }, a2);
  266. },
  267. onVoicePlayEnd: function(a2) {
  268. d("onVoicePlayEnd", a2);
  269. },
  270. uploadVoice: function(a2) {
  271. c("uploadVoice", { localId: a2.localId, isShowProgressTips: 0 == a2.isShowProgressTips ? 0 : 1 }, a2);
  272. },
  273. downloadVoice: function(a2) {
  274. c("downloadVoice", { serverId: a2.serverId, isShowProgressTips: 0 == a2.isShowProgressTips ? 0 : 1 }, a2);
  275. },
  276. translateVoice: function(a2) {
  277. c("translateVoice", { localId: a2.localId, isShowProgressTips: 0 == a2.isShowProgressTips ? 0 : 1 }, a2);
  278. },
  279. chooseImage: function(a2) {
  280. c("chooseImage", {
  281. scene: "1|2",
  282. count: a2.count || 9,
  283. sizeType: a2.sizeType || ["original", "compressed"],
  284. sourceType: a2.sourceType || ["album", "camera"]
  285. }, function() {
  286. return a2._complete = function(a3) {
  287. if (u) {
  288. var b2 = a3.localIds;
  289. b2 && (a3.localIds = JSON.parse(b2));
  290. }
  291. }, a2;
  292. }());
  293. },
  294. previewImage: function(a2) {
  295. c(o.previewImage, { current: a2.current, urls: a2.urls }, a2);
  296. },
  297. uploadImage: function(a2) {
  298. c("uploadImage", { localId: a2.localId, isShowProgressTips: 0 == a2.isShowProgressTips ? 0 : 1 }, a2);
  299. },
  300. downloadImage: function(a2) {
  301. c("downloadImage", { serverId: a2.serverId, isShowProgressTips: 0 == a2.isShowProgressTips ? 0 : 1 }, a2);
  302. },
  303. getNetworkType: function(a2) {
  304. var b2 = function(a3) {
  305. var c2, d2, e2, b3 = a3.errMsg;
  306. if (a3.errMsg = "getNetworkType:ok", c2 = a3.subtype, delete a3.subtype, c2)
  307. a3.networkType = c2;
  308. else
  309. switch (d2 = b3.indexOf(":"), e2 = b3.substring(d2 + 1)) {
  310. case "wifi":
  311. case "edge":
  312. case "wwan":
  313. a3.networkType = e2;
  314. break;
  315. default:
  316. a3.errMsg = "getNetworkType:fail";
  317. }
  318. return a3;
  319. };
  320. c("getNetworkType", {}, function() {
  321. return a2._complete = function(a3) {
  322. a3 = b2(a3);
  323. }, a2;
  324. }());
  325. },
  326. openLocation: function(a2) {
  327. c("openLocation", {
  328. latitude: a2.latitude,
  329. longitude: a2.longitude,
  330. name: a2.name || "",
  331. address: a2.address || "",
  332. scale: a2.scale || 28,
  333. infoUrl: a2.infoUrl || ""
  334. }, a2);
  335. },
  336. getLocation: function(a2) {
  337. a2 = a2 || {}, c(o.getLocation, { type: a2.type || "wgs84" }, function() {
  338. return a2._complete = function(a3) {
  339. delete a3.type;
  340. }, a2;
  341. }());
  342. },
  343. hideOptionMenu: function(a2) {
  344. c("hideOptionMenu", {}, a2);
  345. },
  346. showOptionMenu: function(a2) {
  347. c("showOptionMenu", {}, a2);
  348. },
  349. closeWindow: function(a2) {
  350. a2 = a2 || {}, c("closeWindow", { immediate_close: a2.immediateClose || 0 }, a2);
  351. },
  352. hideMenuItems: function(a2) {
  353. c("hideMenuItems", { menuList: a2.menuList }, a2);
  354. },
  355. showMenuItems: function(a2) {
  356. c("showMenuItems", { menuList: a2.menuList }, a2);
  357. },
  358. hideAllNonBaseMenuItem: function(a2) {
  359. c("hideAllNonBaseMenuItem", {}, a2);
  360. },
  361. showAllNonBaseMenuItem: function(a2) {
  362. c("showAllNonBaseMenuItem", {}, a2);
  363. },
  364. scanQRCode: function(a2) {
  365. a2 = a2 || {}, c("scanQRCode", {
  366. needResult: a2.needResult || 0,
  367. scanType: a2.scanType || ["qrCode", "barCode"]
  368. }, function() {
  369. return a2._complete = function(a3) {
  370. var b2, c2;
  371. v && (b2 = a3.resultStr, b2 && (c2 = JSON.parse(b2), a3.resultStr = c2 && c2.scan_code && c2.scan_code.scan_result));
  372. }, a2;
  373. }());
  374. },
  375. openProductSpecificView: function(a2) {
  376. c(o.openProductSpecificView, { pid: a2.productId, view_type: a2.viewType || 0 }, a2);
  377. },
  378. addCard: function(a2) {
  379. var e2, f2, g2, h2, b2 = a2.cardList, d2 = [];
  380. for (e2 = 0, f2 = b2.length; f2 > e2; ++e2)
  381. g2 = b2[e2], h2 = { card_id: g2.cardId, card_ext: g2.cardExt }, d2.push(h2);
  382. c(o.addCard, { card_list: d2 }, function() {
  383. return a2._complete = function(a3) {
  384. var c2, d3, e3, b3 = a3.card_list;
  385. if (b3) {
  386. for (b3 = JSON.parse(b3), c2 = 0, d3 = b3.length; d3 > c2; ++c2)
  387. e3 = b3[c2], e3.cardId = e3.card_id, e3.cardExt = e3.card_ext, e3.isSuccess = e3.is_succ ? true : false, delete e3.card_id, delete e3.card_ext, delete e3.is_succ;
  388. a3.cardList = b3, delete a3.card_list;
  389. }
  390. }, a2;
  391. }());
  392. },
  393. chooseCard: function(a2) {
  394. c("chooseCard", {
  395. app_id: z.appId,
  396. location_id: a2.shopId || "",
  397. sign_type: a2.signType || "SHA1",
  398. card_id: a2.cardId || "",
  399. card_type: a2.cardType || "",
  400. card_sign: a2.cardSign,
  401. time_stamp: a2.timestamp + "",
  402. nonce_str: a2.nonceStr
  403. }, function() {
  404. return a2._complete = function(a3) {
  405. a3.cardList = a3.choose_card_info, delete a3.choose_card_info;
  406. }, a2;
  407. }());
  408. },
  409. openCard: function(a2) {
  410. var e2, f2, g2, h2, b2 = a2.cardList, d2 = [];
  411. for (e2 = 0, f2 = b2.length; f2 > e2; ++e2)
  412. g2 = b2[e2], h2 = { card_id: g2.cardId, code: g2.code }, d2.push(h2);
  413. c(o.openCard, { card_list: d2 }, a2);
  414. },
  415. chooseWXPay: function(a2) {
  416. c(o.chooseWXPay, f(a2), a2);
  417. }
  418. }, b && (a.wx = a.jWeixin = C), C;
  419. }(window, true);
  420. var weixin_jsapi_default = window.wx;
  421. export {
  422. weixin_jsapi_default as default
  423. };
  424. //# sourceMappingURL=weixin-jsapi.js.map