weixin.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. !(function(e, n) {
  2. 'function' == typeof define && (define.amd || define.cmd)
  3. ? define(function() {
  4. return n(e)
  5. })
  6. : n(e, !0)
  7. })(this, function(e, n) {
  8. function i(n, i, t) {
  9. e.WeixinJSBridge
  10. ? WeixinJSBridge.invoke(n, o(i), function(e) {
  11. c(n, e, t)
  12. })
  13. : u(n, t)
  14. }
  15. function t(n, i, t) {
  16. e.WeixinJSBridge
  17. ? WeixinJSBridge.on(n, function(e) {
  18. t && t.trigger && t.trigger(e), c(n, e, i)
  19. })
  20. : t
  21. ? u(n, t)
  22. : u(n, i)
  23. }
  24. function o(e) {
  25. return (
  26. (e = e || {}),
  27. (e.appId = C.appId),
  28. (e.verifyAppId = C.appId),
  29. (e.verifySignType = 'sha1'),
  30. (e.verifyTimestamp = C.timestamp + ''),
  31. (e.verifyNonceStr = C.nonceStr),
  32. (e.verifySignature = C.signature),
  33. e
  34. )
  35. }
  36. function r(e) {
  37. return { timeStamp: e.timestamp + '', nonceStr: e.nonceStr, package: e.package, paySign: e.paySign, signType: e.signType || 'SHA1' }
  38. }
  39. function a(e) {
  40. return (
  41. (e.postalCode = e.addressPostalCode),
  42. delete e.addressPostalCode,
  43. (e.provinceName = e.proviceFirstStageName),
  44. delete e.proviceFirstStageName,
  45. (e.cityName = e.addressCitySecondStageName),
  46. delete e.addressCitySecondStageName,
  47. (e.countryName = e.addressCountiesThirdStageName),
  48. delete e.addressCountiesThirdStageName,
  49. (e.detailInfo = e.addressDetailInfo),
  50. delete e.addressDetailInfo,
  51. e
  52. )
  53. }
  54. function c(e, n, i) {
  55. 'openEnterpriseChat' == e && (n.errCode = n.err_code), delete n.err_code, delete n.err_desc, delete n.err_detail
  56. var t = n.errMsg
  57. t || ((t = n.err_msg), delete n.err_msg, (t = s(e, t)), (n.errMsg = t)),
  58. (i = i || {})._complete && (i._complete(n), delete i._complete),
  59. (t = n.errMsg || ''),
  60. C.debug && !i.isInnerInvoke && alert(JSON.stringify(n))
  61. var o = t.indexOf(':')
  62. switch (t.substring(o + 1)) {
  63. case 'ok':
  64. i.success && i.success(n)
  65. break
  66. case 'cancel':
  67. i.cancel && i.cancel(n)
  68. break
  69. default:
  70. i.fail && i.fail(n)
  71. }
  72. i.complete && i.complete(n)
  73. }
  74. function s(e, n) {
  75. var i = e,
  76. t = v[i]
  77. t && (i = t)
  78. var o = 'ok'
  79. if (n) {
  80. var r = n.indexOf(':')
  81. 'confirm' == (o = n.substring(r + 1)) && (o = 'ok'),
  82. 'failed' == o && (o = 'fail'),
  83. -1 != o.indexOf('failed_') && (o = o.substring(7)),
  84. -1 != o.indexOf('fail_') && (o = o.substring(5)),
  85. ('access denied' != (o = (o = o.replace(/_/g, ' ')).toLowerCase()) && 'no permission to execute' != o) || (o = 'permission denied'),
  86. 'config' == i && 'function not exist' == o && (o = 'ok'),
  87. '' == o && (o = 'fail')
  88. }
  89. return (n = i + ':' + o)
  90. }
  91. function d(e) {
  92. if (e) {
  93. for (var n = 0, i = e.length; n < i; ++n) {
  94. var t = e[n],
  95. o = h[t]
  96. o && (e[n] = o)
  97. }
  98. return e
  99. }
  100. }
  101. function u(e, n) {
  102. if (!(!C.debug || (n && n.isInnerInvoke))) {
  103. var i = v[e]
  104. i && (e = i), n && n._complete && delete n._complete, console.log('"' + e + '",', n || '')
  105. }
  106. }
  107. function l(e) {
  108. if (!(k || w || C.debug || x < '6.0.2' || V.systemType < 0)) {
  109. var n = new Image()
  110. ;(V.appId = C.appId),
  111. (V.initTime = A.initEndTime - A.initStartTime),
  112. (V.preVerifyTime = A.preVerifyEndTime - A.preVerifyStartTime),
  113. N.getNetworkType({
  114. isInnerInvoke: !0,
  115. success: function(e) {
  116. V.networkType = e.networkType
  117. var i =
  118. 'https://open.weixin.qq.com/sdk/report?v=' +
  119. V.version +
  120. '&o=' +
  121. V.isPreVerifyOk +
  122. '&s=' +
  123. V.systemType +
  124. '&c=' +
  125. V.clientVersion +
  126. '&a=' +
  127. V.appId +
  128. '&n=' +
  129. V.networkType +
  130. '&i=' +
  131. V.initTime +
  132. '&p=' +
  133. V.preVerifyTime +
  134. '&u=' +
  135. V.url
  136. n.src = i
  137. }
  138. })
  139. }
  140. }
  141. function p() {
  142. return new Date().getTime()
  143. }
  144. function f(n) {
  145. T && (e.WeixinJSBridge ? n() : S.addEventListener && S.addEventListener('WeixinJSBridgeReady', n, !1))
  146. }
  147. function m() {
  148. N.invoke ||
  149. ((N.invoke = function(n, i, t) {
  150. e.WeixinJSBridge && WeixinJSBridge.invoke(n, o(i), t)
  151. }),
  152. (N.on = function(n, i) {
  153. e.WeixinJSBridge && WeixinJSBridge.on(n, i)
  154. }))
  155. }
  156. function g(e) {
  157. if ('string' == typeof e && e.length > 0) {
  158. var n = e.split('?')[0],
  159. i = e.split('?')[1]
  160. return (n += '.html'), void 0 !== i ? n + '?' + i : n
  161. }
  162. }
  163. if (!e.jWeixin) {
  164. var h = {
  165. config: 'preVerifyJSAPI',
  166. onMenuShareTimeline: 'menu:share:timeline',
  167. onMenuShareAppMessage: 'menu:share:appmessage',
  168. onMenuShareQQ: 'menu:share:qq',
  169. onMenuShareWeibo: 'menu:share:weiboApp',
  170. onMenuShareQZone: 'menu:share:QZone',
  171. previewImage: 'imagePreview',
  172. getLocation: 'geoLocation',
  173. openProductSpecificView: 'openProductViewWithPid',
  174. addCard: 'batchAddCard',
  175. openCard: 'batchViewCard',
  176. chooseWXPay: 'getBrandWCPayRequest',
  177. openEnterpriseRedPacket: 'getRecevieBizHongBaoRequest',
  178. startSearchBeacons: 'startMonitoringBeacons',
  179. stopSearchBeacons: 'stopMonitoringBeacons',
  180. onSearchBeacons: 'onBeaconsInRange',
  181. consumeAndShareCard: 'consumedShareCard',
  182. openAddress: 'editAddress'
  183. },
  184. v = (function() {
  185. var e = {}
  186. for (var n in h) e[h[n]] = n
  187. return e
  188. })(),
  189. S = e.document,
  190. I = S.title,
  191. y = navigator.userAgent.toLowerCase(),
  192. _ = navigator.platform.toLowerCase(),
  193. k = !(!_.match('mac') && !_.match('win')),
  194. w = -1 != y.indexOf('wxdebugger'),
  195. T = -1 != y.indexOf('micromessenger'),
  196. M = -1 != y.indexOf('android'),
  197. P = -1 != y.indexOf('iphone') || -1 != y.indexOf('ipad'),
  198. x = (function() {
  199. var e = y.match(/micromessenger\/(\d+\.\d+\.\d+)/) || y.match(/micromessenger\/(\d+\.\d+)/)
  200. return e ? e[1] : ''
  201. })(),
  202. A = { initStartTime: p(), initEndTime: 0, preVerifyStartTime: 0, preVerifyEndTime: 0 },
  203. V = {
  204. version: 1,
  205. appId: '',
  206. initTime: 0,
  207. preVerifyTime: 0,
  208. networkType: '',
  209. isPreVerifyOk: 1,
  210. systemType: P ? 1 : M ? 2 : -1,
  211. clientVersion: x,
  212. url: encodeURIComponent(location.href)
  213. },
  214. C = {},
  215. L = { _completes: [] },
  216. B = { state: 0, data: {} }
  217. f(function() {
  218. A.initEndTime = p()
  219. })
  220. var O = !1,
  221. E = [],
  222. N = {
  223. config: function(e) {
  224. ;(C = e), u('config', e)
  225. var n = !1 !== C.check
  226. f(function() {
  227. if (n)
  228. i(
  229. h.config,
  230. { verifyJsApiList: d(C.jsApiList) },
  231. (function() {
  232. ;(L._complete = function(e) {
  233. ;(A.preVerifyEndTime = p()), (B.state = 1), (B.data = e)
  234. }),
  235. (L.success = function(e) {
  236. V.isPreVerifyOk = 0
  237. }),
  238. (L.fail = function(e) {
  239. L._fail ? L._fail(e) : (B.state = -1)
  240. })
  241. var e = L._completes
  242. return (
  243. e.push(function() {
  244. l()
  245. }),
  246. (L.complete = function(n) {
  247. for (var i = 0, t = e.length; i < t; ++i) e[i]()
  248. L._completes = []
  249. }),
  250. L
  251. )
  252. })()
  253. ),
  254. (A.preVerifyStartTime = p())
  255. else {
  256. B.state = 1
  257. for (var e = L._completes, t = 0, o = e.length; t < o; ++t) e[t]()
  258. L._completes = []
  259. }
  260. }),
  261. m()
  262. },
  263. ready: function(e) {
  264. 0 != B.state ? e() : (L._completes.push(e), !T && C.debug && e())
  265. },
  266. error: function(e) {
  267. x < '6.0.2' || (-1 == B.state ? e(B.data) : (L._fail = e))
  268. },
  269. checkJsApi: function(e) {
  270. var n = function(e) {
  271. var n = e.checkResult
  272. for (var i in n) {
  273. var t = v[i]
  274. t && ((n[t] = n[i]), delete n[i])
  275. }
  276. return e
  277. }
  278. i(
  279. 'checkJsApi',
  280. { jsApiList: d(e.jsApiList) },
  281. ((e._complete = function(e) {
  282. if (M) {
  283. var i = e.checkResult
  284. i && (e.checkResult = JSON.parse(i))
  285. }
  286. e = n(e)
  287. }),
  288. e)
  289. )
  290. },
  291. onMenuShareTimeline: function(e) {
  292. t(
  293. h.onMenuShareTimeline,
  294. {
  295. complete: function() {
  296. i(
  297. 'shareTimeline',
  298. {
  299. title: e.title || I,
  300. desc: e.title || I,
  301. img_url: e.imgUrl || '',
  302. link: e.link || location.href,
  303. type: e.type || 'link',
  304. data_url: e.dataUrl || ''
  305. },
  306. e
  307. )
  308. }
  309. },
  310. e
  311. )
  312. },
  313. onMenuShareAppMessage: function(e) {
  314. t(
  315. h.onMenuShareAppMessage,
  316. {
  317. complete: function(n) {
  318. 'favorite' === n.scene
  319. ? i('sendAppMessage', {
  320. title: e.title || I,
  321. desc: e.desc || '',
  322. link: e.link || location.href,
  323. img_url: e.imgUrl || '',
  324. type: e.type || 'link',
  325. data_url: e.dataUrl || ''
  326. })
  327. : i(
  328. 'sendAppMessage',
  329. {
  330. title: e.title || I,
  331. desc: e.desc || '',
  332. link: e.link || location.href,
  333. img_url: e.imgUrl || '',
  334. type: e.type || 'link',
  335. data_url: e.dataUrl || ''
  336. },
  337. e
  338. )
  339. }
  340. },
  341. e
  342. )
  343. },
  344. onMenuShareQQ: function(e) {
  345. t(
  346. h.onMenuShareQQ,
  347. {
  348. complete: function() {
  349. i('shareQQ', { title: e.title || I, desc: e.desc || '', img_url: e.imgUrl || '', link: e.link || location.href }, e)
  350. }
  351. },
  352. e
  353. )
  354. },
  355. onMenuShareWeibo: function(e) {
  356. t(
  357. h.onMenuShareWeibo,
  358. {
  359. complete: function() {
  360. i('shareWeiboApp', { title: e.title || I, desc: e.desc || '', img_url: e.imgUrl || '', link: e.link || location.href }, e)
  361. }
  362. },
  363. e
  364. )
  365. },
  366. onMenuShareQZone: function(e) {
  367. t(
  368. h.onMenuShareQZone,
  369. {
  370. complete: function() {
  371. i('shareQZone', { title: e.title || I, desc: e.desc || '', img_url: e.imgUrl || '', link: e.link || location.href }, e)
  372. }
  373. },
  374. e
  375. )
  376. },
  377. updateTimelineShareData: function(e) {
  378. i('updateTimelineShareData', { title: e.title, link: e.link, imgUrl: e.imgUrl }, e)
  379. },
  380. updateAppMessageShareData: function(e) {
  381. i('updateAppMessageShareData', { title: e.title, desc: e.desc, link: e.link, imgUrl: e.imgUrl }, e)
  382. },
  383. startRecord: function(e) {
  384. i('startRecord', {}, e)
  385. },
  386. stopRecord: function(e) {
  387. i('stopRecord', {}, e)
  388. },
  389. onVoiceRecordEnd: function(e) {
  390. t('onVoiceRecordEnd', e)
  391. },
  392. playVoice: function(e) {
  393. i('playVoice', { localId: e.localId }, e)
  394. },
  395. pauseVoice: function(e) {
  396. i('pauseVoice', { localId: e.localId }, e)
  397. },
  398. stopVoice: function(e) {
  399. i('stopVoice', { localId: e.localId }, e)
  400. },
  401. onVoicePlayEnd: function(e) {
  402. t('onVoicePlayEnd', e)
  403. },
  404. uploadVoice: function(e) {
  405. i('uploadVoice', { localId: e.localId, isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 }, e)
  406. },
  407. downloadVoice: function(e) {
  408. i('downloadVoice', { serverId: e.serverId, isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 }, e)
  409. },
  410. translateVoice: function(e) {
  411. i('translateVoice', { localId: e.localId, isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 }, e)
  412. },
  413. chooseImage: function(e) {
  414. i(
  415. 'chooseImage',
  416. {
  417. scene: '1|2',
  418. count: e.count || 9,
  419. sizeType: e.sizeType || ['original', 'compressed'],
  420. sourceType: e.sourceType || ['album', 'camera']
  421. },
  422. ((e._complete = function(e) {
  423. if (M) {
  424. var n = e.localIds
  425. try {
  426. n && (e.localIds = JSON.parse(n))
  427. } catch (e) {}
  428. }
  429. }),
  430. e)
  431. )
  432. },
  433. getLocation: function(e) {},
  434. previewImage: function(e) {
  435. i(h.previewImage, { current: e.current, urls: e.urls }, e)
  436. },
  437. uploadImage: function(e) {
  438. i('uploadImage', { localId: e.localId, isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 }, e)
  439. },
  440. downloadImage: function(e) {
  441. i('downloadImage', { serverId: e.serverId, isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 }, e)
  442. },
  443. getLocalImgData: function(e) {
  444. !1 === O
  445. ? ((O = !0),
  446. i(
  447. 'getLocalImgData',
  448. { localId: e.localId },
  449. ((e._complete = function(e) {
  450. if (((O = !1), E.length > 0)) {
  451. var n = E.shift()
  452. wx.getLocalImgData(n)
  453. }
  454. }),
  455. e)
  456. ))
  457. : E.push(e)
  458. },
  459. getNetworkType: function(e) {
  460. var n = function(e) {
  461. var n = e.errMsg
  462. e.errMsg = 'getNetworkType:ok'
  463. var i = e.subtype
  464. if ((delete e.subtype, i)) e.networkType = i
  465. else {
  466. var t = n.indexOf(':'),
  467. o = n.substring(t + 1)
  468. switch (o) {
  469. case 'wifi':
  470. case 'edge':
  471. case 'wwan':
  472. e.networkType = o
  473. break
  474. default:
  475. e.errMsg = 'getNetworkType:fail'
  476. }
  477. }
  478. return e
  479. }
  480. i(
  481. 'getNetworkType',
  482. {},
  483. ((e._complete = function(e) {
  484. e = n(e)
  485. }),
  486. e)
  487. )
  488. },
  489. openLocation: function(e) {
  490. i(
  491. 'openLocation',
  492. {
  493. latitude: e.latitude,
  494. longitude: e.longitude,
  495. name: e.name || '',
  496. address: e.address || '',
  497. scale: e.scale || 28,
  498. infoUrl: e.infoUrl || ''
  499. },
  500. e
  501. )
  502. },
  503. getLocation: function(e) {
  504. ;(e = e || {}),
  505. i(
  506. h.getLocation,
  507. { type: e.type || 'wgs84' },
  508. ((e._complete = function(e) {
  509. delete e.type
  510. }),
  511. e)
  512. )
  513. },
  514. hideOptionMenu: function(e) {
  515. i('hideOptionMenu', {}, e)
  516. },
  517. showOptionMenu: function(e) {
  518. i('showOptionMenu', {}, e)
  519. },
  520. closeWindow: function(e) {
  521. i('closeWindow', {}, (e = e || {}))
  522. },
  523. hideMenuItems: function(e) {
  524. i('hideMenuItems', { menuList: e.menuList }, e)
  525. },
  526. showMenuItems: function(e) {
  527. i('showMenuItems', { menuList: e.menuList }, e)
  528. },
  529. hideAllNonBaseMenuItem: function(e) {
  530. i('hideAllNonBaseMenuItem', {}, e)
  531. },
  532. showAllNonBaseMenuItem: function(e) {
  533. i('showAllNonBaseMenuItem', {}, e)
  534. },
  535. scanQRCode: function(e) {
  536. i(
  537. 'scanQRCode',
  538. { needResult: (e = e || {}).needResult || 0, scanType: e.scanType || ['qrCode', 'barCode'] },
  539. ((e._complete = function(e) {
  540. if (P) {
  541. var n = e.resultStr
  542. if (n) {
  543. var i = JSON.parse(n)
  544. e.resultStr = i && i.scan_code && i.scan_code.scan_result
  545. }
  546. }
  547. }),
  548. e)
  549. )
  550. },
  551. openAddress: function(e) {
  552. i(
  553. h.openAddress,
  554. {},
  555. ((e._complete = function(e) {
  556. e = a(e)
  557. }),
  558. e)
  559. )
  560. },
  561. openProductSpecificView: function(e) {
  562. i(h.openProductSpecificView, { pid: e.productId, view_type: e.viewType || 0, ext_info: e.extInfo }, e)
  563. },
  564. addCard: function(e) {
  565. for (var n = e.cardList, t = [], o = 0, r = n.length; o < r; ++o) {
  566. var a = n[o],
  567. c = { card_id: a.cardId, card_ext: a.cardExt }
  568. t.push(c)
  569. }
  570. i(
  571. h.addCard,
  572. { card_list: t },
  573. ((e._complete = function(e) {
  574. var n = e.card_list
  575. if (n) {
  576. for (var i = 0, t = (n = JSON.parse(n)).length; i < t; ++i) {
  577. var o = n[i]
  578. ;(o.cardId = o.card_id),
  579. (o.cardExt = o.card_ext),
  580. (o.isSuccess = !!o.is_succ),
  581. delete o.card_id,
  582. delete o.card_ext,
  583. delete o.is_succ
  584. }
  585. ;(e.cardList = n), delete e.card_list
  586. }
  587. }),
  588. e)
  589. )
  590. },
  591. chooseCard: function(e) {
  592. i(
  593. 'chooseCard',
  594. {
  595. app_id: C.appId,
  596. location_id: e.shopId || '',
  597. sign_type: e.signType || 'SHA1',
  598. card_id: e.cardId || '',
  599. card_type: e.cardType || '',
  600. card_sign: e.cardSign,
  601. time_stamp: e.timestamp + '',
  602. nonce_str: e.nonceStr
  603. },
  604. ((e._complete = function(e) {
  605. ;(e.cardList = e.choose_card_info), delete e.choose_card_info
  606. }),
  607. e)
  608. )
  609. },
  610. openCard: function(e) {
  611. for (var n = e.cardList, t = [], o = 0, r = n.length; o < r; ++o) {
  612. var a = n[o],
  613. c = { card_id: a.cardId, code: a.code }
  614. t.push(c)
  615. }
  616. i(h.openCard, { card_list: t }, e)
  617. },
  618. consumeAndShareCard: function(e) {
  619. i(h.consumeAndShareCard, { consumedCardId: e.cardId, consumedCode: e.code }, e)
  620. },
  621. chooseWXPay: function(e) {
  622. i(h.chooseWXPay, r(e), e)
  623. },
  624. openEnterpriseRedPacket: function(e) {
  625. i(h.openEnterpriseRedPacket, r(e), e)
  626. },
  627. startSearchBeacons: function(e) {
  628. i(h.startSearchBeacons, { ticket: e.ticket }, e)
  629. },
  630. stopSearchBeacons: function(e) {
  631. i(h.stopSearchBeacons, {}, e)
  632. },
  633. onSearchBeacons: function(e) {
  634. t(h.onSearchBeacons, e)
  635. },
  636. openEnterpriseChat: function(e) {
  637. i('openEnterpriseChat', { useridlist: e.userIds, chatname: e.groupName }, e)
  638. },
  639. launchMiniProgram: function(e) {
  640. i('launchMiniProgram', { targetAppId: e.targetAppId, path: g(e.path), envVersion: e.envVersion }, e)
  641. },
  642. miniProgram: {
  643. navigateBack: function(e) {
  644. ;(e = e || {}),
  645. f(function() {
  646. i('invokeMiniProgramAPI', { name: 'navigateBack', arg: { delta: e.delta || 1 } }, e)
  647. })
  648. },
  649. navigateTo: function(e) {
  650. f(function() {
  651. i('invokeMiniProgramAPI', { name: 'navigateTo', arg: { url: e.url } }, e)
  652. })
  653. },
  654. redirectTo: function(e) {
  655. f(function() {
  656. i('invokeMiniProgramAPI', { name: 'redirectTo', arg: { url: e.url } }, e)
  657. })
  658. },
  659. switchTab: function(e) {
  660. f(function() {
  661. i('invokeMiniProgramAPI', { name: 'switchTab', arg: { url: e.url } }, e)
  662. })
  663. },
  664. reLaunch: function(e) {
  665. f(function() {
  666. i('invokeMiniProgramAPI', { name: 'reLaunch', arg: { url: e.url } }, e)
  667. })
  668. },
  669. postMessage: function(e) {
  670. f(function() {
  671. i('invokeMiniProgramAPI', { name: 'postMessage', arg: e.data || {} }, e)
  672. })
  673. },
  674. getEnv: function(n) {
  675. f(function() {
  676. n({ miniprogram: 'miniprogram' === e.__wxjs_environment })
  677. })
  678. }
  679. }
  680. },
  681. b = 1,
  682. R = {}
  683. return (
  684. S.addEventListener(
  685. 'error',
  686. function(e) {
  687. if (!M) {
  688. var n = e.target,
  689. i = n.tagName,
  690. t = n.src
  691. if (('IMG' == i || 'VIDEO' == i || 'AUDIO' == i || 'SOURCE' == i) && -1 != t.indexOf('wxlocalresource://')) {
  692. e.preventDefault(), e.stopPropagation()
  693. var o = n['wx-id']
  694. if ((o || ((o = b++), (n['wx-id'] = o)), R[o])) return
  695. ;(R[o] = !0),
  696. wx.ready(function() {
  697. wx.getLocalImgData({
  698. localId: t,
  699. success: function(e) {
  700. n.src = e.localData
  701. }
  702. })
  703. })
  704. }
  705. }
  706. },
  707. !0
  708. ),
  709. S.addEventListener(
  710. 'load',
  711. function(e) {
  712. if (!M) {
  713. var n = e.target,
  714. i = n.tagName
  715. n.src
  716. if ('IMG' == i || 'VIDEO' == i || 'AUDIO' == i || 'SOURCE' == i) {
  717. var t = n['wx-id']
  718. t && (R[t] = !1)
  719. }
  720. }
  721. },
  722. !0
  723. ),
  724. n && (e.wx = e.jWeixin = N),
  725. N
  726. )
  727. }
  728. })