diff --git a/index.js b/index.js index a05328c..61bb2f3 100644 --- a/index.js +++ b/index.js @@ -1,467 +1,673 @@ -!function (a, b) { - module.exports = b(a) -}(window, function (a, b) { - function c(b, c, d) { - a.WeixinJSBridge ? WeixinJSBridge.invoke(b, e(c), function (a) { - h(b, a, d) - }) : k(b, d) - } +! function (e, n) { + module.exports = n(e) +}(this, function (e, n) { + function i(n, i, t) { + e.WeixinJSBridge ? WeixinJSBridge.invoke(n, o(i), function (e) { + c(n, e, t) + }) : u(n, t) + } - function d(b, c, d) { - a.WeixinJSBridge ? WeixinJSBridge.on(b, function (a) { - d && d.trigger && d.trigger(a), h(b, a, c) - }) : d ? k(b, d) : k(b, c) - } + function t(n, i, t) { + e.WeixinJSBridge ? WeixinJSBridge.on(n, function (e) { + t && t.trigger && t.trigger(e), c(n, e, i) + }) : t ? u(n, t) : u(n, i) + } - function e(a) { - return a = a || {}, a.appId = D.appId, a.verifyAppId = D.appId, a.verifySignType = "sha1", a.verifyTimestamp = D.timestamp + "", a.verifyNonceStr = D.nonceStr, a.verifySignature = D.signature, a - } + function o(e) { + return e = e || {}, e.appId = C.appId, e.verifyAppId = C.appId, e.verifySignType = "sha1", e.verifyTimestamp = C.timestamp + "", e.verifyNonceStr = C.nonceStr, e.verifySignature = C.signature, e + } - function f(a) { - return { - timeStamp: a.timestamp + "", - nonceStr: a.nonceStr, - "package": a["package"], - paySign: a.paySign, - signType: a.signType || "SHA1" + function r(e) { + return { + timeStamp: e.timestamp + "", + nonceStr: e.nonceStr, + package: e.package, + paySign: e.paySign, + signType: e.signType || "SHA1" + } + } + + function a(e) { + return e.postalCode = e.addressPostalCode, delete e.addressPostalCode, e.provinceName = e.proviceFirstStageName, delete e.proviceFirstStageName, e.cityName = e.addressCitySecondStageName, delete e.addressCitySecondStageName, e.countryName = e.addressCountiesThirdStageName, delete e.addressCountiesThirdStageName, e.detailInfo = e.addressDetailInfo, delete e.addressDetailInfo, e + } + + function c(e, n, i) { + "openEnterpriseChat" == e && (n.errCode = n.err_code), delete n.err_code, delete n.err_desc, delete n.err_detail; + var t = n.errMsg; + t || (t = n.err_msg, delete n.err_msg, t = s(e, t), n.errMsg = t), (i = i || {})._complete && (i._complete(n), delete i._complete), t = n.errMsg || "", C.debug && !i.isInnerInvoke && alert(JSON.stringify(n)); + var o = t.indexOf(":"); + switch (t.substring(o + 1)) { + case "ok": + i.success && i.success(n); + break; + case "cancel": + i.cancel && i.cancel(n); + break; + default: + i.fail && i.fail(n) + } + i.complete && i.complete(n) + } + + function s(e, n) { + var i = e, + t = v[i]; + t && (i = t); + var o = "ok"; + if (n) { + var r = n.indexOf(":"); + "confirm" == (o = n.substring(r + 1)) && (o = "ok"), "failed" == o && (o = "fail"), -1 != o.indexOf("failed_") && (o = o.substring(7)), -1 != o.indexOf("fail_") && (o = o.substring(5)), "access denied" != (o = (o = o.replace(/_/g, " ")).toLowerCase()) && "no permission to execute" != o || (o = "permission denied"), "config" == i && "function not exist" == o && (o = "ok"), "" == o && (o = "fail") + } + return n = i + ":" + o + } + + function d(e) { + if (e) { + for (var n = 0, i = e.length; n < i; ++n) { + var t = e[n], + o = h[t]; + o && (e[n] = o) + } + return e + } + } + + function u(e, n) { + if (!(!C.debug || n && n.isInnerInvoke)) { + var i = v[e]; + i && (e = i), n && n._complete && delete n._complete, console.log('"' + e + '",', n || "") + } + } + + function l(e) { + if (!(w || T || C.debug || x < "6.0.2" || A.systemType < 0)) { + var n = new Image; + A.appId = C.appId, A.initTime = V.initEndTime - V.initStartTime, A.preVerifyTime = V.preVerifyEndTime - V.preVerifyStartTime, N.getNetworkType({ + isInnerInvoke: !0, + success: function (e) { + A.networkType = e.networkType; + var i = "https://open.weixin.qq.com/sdk/report?v=" + A.version + "&o=" + A.isPreVerifyOk + "&s=" + A.systemType + "&c=" + A.clientVersion + "&a=" + A.appId + "&n=" + A.networkType + "&i=" + A.initTime + "&p=" + A.preVerifyTime + "&u=" + A.url; + n.src = i } + }) } + } - function g(a) { - return a.postalCode = a.addressPostalCode, delete a.addressPostalCode, a.provinceName = a.proviceFirstStageName, delete a.proviceFirstStageName, a.cityName = a.addressCitySecondStageName, delete a.addressCitySecondStageName, a.countryName = a.addressCountiesThirdStageName, delete a.addressCountiesThirdStageName, a.detailInfo = a.addressDetailInfo, delete a.addressDetailInfo, a + function p() { + return (new Date).getTime() + } + + function f(n) { + k && (e.WeixinJSBridge ? "preInject" === I.__wxjsjs__isPreInject ? I.addEventListener && I.addEventListener("WeixinJSBridgeReady", n, !1) : n() : I.addEventListener && I.addEventListener("WeixinJSBridgeReady", n, !1)) + } + + function m() { + N.invoke || (N.invoke = function (n, i, t) { + e.WeixinJSBridge && WeixinJSBridge.invoke(n, o(i), t) + }, N.on = function (n, i) { + e.WeixinJSBridge && WeixinJSBridge.on(n, i) + }) + } + + function g(e) { + if ("string" == typeof e && e.length > 0) { + var n = e.split("?")[0], + i = e.split("?")[1]; + return n += ".html", void 0 !== i ? n + "?" + i : n } - - function h(a, b, c) { - "openEnterpriseChat" == a && (b.errCode = b.err_code), delete b.err_code, delete b.err_desc, delete b.err_detail; - var d = b.errMsg; - d || (d = b.err_msg, delete b.err_msg, d = i(a, d), b.errMsg = d), c = c || {}, c._complete && (c._complete(b), delete c._complete), d = b.errMsg || "", D.debug && !c.isInnerInvoke && alert(JSON.stringify(b)); - var e = d.indexOf(":"), f = d.substring(e + 1); - switch (f) { - case"ok": - c.success && c.success(b); - break; - case"cancel": - c.cancel && c.cancel(b); - break; - default: - c.fail && c.fail(b) - } - c.complete && c.complete(b) - } - - function i(a, b) { - var c = a, d = q[c]; - d && (c = d); - var e = "ok"; - if (b) { - var f = b.indexOf(":"); - e = b.substring(f + 1), "confirm" == e && (e = "ok"), "failed" == e && (e = "fail"), -1 != e.indexOf("failed_") && (e = e.substring(7)), -1 != e.indexOf("fail_") && (e = e.substring(5)), e = e.replace(/_/g, " "), e = e.toLowerCase(), ("access denied" == e || "no permission to execute" == e) && (e = "permission denied"), "config" == c && "function not exist" == e && (e = "ok"), "" == e && (e = "fail") - } - return b = c + ":" + e - } - - function j(a) { - if (a) { - for (var b = 0, c = a.length; c > b; ++b) { - var d = a[b], e = p[d]; - e && (a[b] = e) + } + if (!e.jWeixin) { + var h = { + config: "preVerifyJSAPI", + onMenuShareTimeline: "menu:share:timeline", + onMenuShareAppMessage: "menu:share:appmessage", + onMenuShareQQ: "menu:share:qq", + onMenuShareWeibo: "menu:share:weiboApp", + onMenuShareQZone: "menu:share:QZone", + previewImage: "imagePreview", + getLocation: "geoLocation", + openProductSpecificView: "openProductViewWithPid", + addCard: "batchAddCard", + openCard: "batchViewCard", + chooseWXPay: "getBrandWCPayRequest", + openEnterpriseRedPacket: "getRecevieBizHongBaoRequest", + startSearchBeacons: "startMonitoringBeacons", + stopSearchBeacons: "stopMonitoringBeacons", + onSearchBeacons: "onBeaconsInRange", + consumeAndShareCard: "consumedShareCard", + openAddress: "editAddress" + }, + v = function () { + var e = {}; + for (var n in h) e[h[n]] = n; + return e + }(), + I = e.document, + S = I.title, + y = navigator.userAgent.toLowerCase(), + _ = navigator.platform.toLowerCase(), + w = !(!_.match("mac") && !_.match("win")), + T = -1 != y.indexOf("wxdebugger"), + k = -1 != y.indexOf("micromessenger"), + M = -1 != y.indexOf("android"), + P = -1 != y.indexOf("iphone") || -1 != y.indexOf("ipad"), + x = function () { + var e = y.match(/micromessenger\/(\d+\.\d+\.\d+)/) || y.match(/micromessenger\/(\d+\.\d+)/); + return e ? e[1] : "" + }(), + V = { + initStartTime: p(), + initEndTime: 0, + preVerifyStartTime: 0, + preVerifyEndTime: 0 + }, + A = { + version: 1, + appId: "", + initTime: 0, + preVerifyTime: 0, + networkType: "", + isPreVerifyOk: 1, + systemType: P ? 1 : M ? 2 : -1, + clientVersion: x, + url: encodeURIComponent(location.href) + }, + C = {}, + L = { + _completes: [] + }, + B = { + state: 0, + data: {} + }; + f(function () { + V.initEndTime = p() + }); + var E = !1, + O = [], + N = { + config: function (e) { + C = e, u("config", e); + var n = !1 !== C.check; + f(function () { + if (n) i(h.config, { + verifyJsApiList: d(C.jsApiList) + }, function () { + L._complete = function (e) { + V.preVerifyEndTime = p(), B.state = 1, B.data = e + }, L.success = function (e) { + A.isPreVerifyOk = 0 + }, L.fail = function (e) { + L._fail ? L._fail(e) : B.state = -1 + }; + var e = L._completes; + return e.push(function () { + l() + }), L.complete = function (n) { + for (var i = 0, t = e.length; i < t; ++i) e[i](); + L._completes = [] + }, L + }()), V.preVerifyStartTime = p(); + else { + B.state = 1; + for (var e = L._completes, t = 0, o = e.length; t < o; ++t) e[t](); + L._completes = [] } - return a - } - } - - function k(a, b) { - if (!(!D.debug || b && b.isInnerInvoke)) { - var c = q[a]; - c && (a = c), b && b._complete && delete b._complete, console.log('"' + a + '",', b || "") - } - } - - function l(a) { - if (!(v || w || D.debug || "6.0.2" > A || C.systemType < 0)) { - var b = new Image; - C.appId = D.appId, C.initTime = B.initEndTime - B.initStartTime, C.preVerifyTime = B.preVerifyEndTime - B.preVerifyStartTime, I.getNetworkType({ - isInnerInvoke: !0, - success: function (a) { - C.networkType = a.networkType; - var c = "https://open.weixin.qq.com/sdk/report?v=" + C.version + "&o=" + C.isPreVerifyOk + "&s=" + C.systemType + "&c=" + C.clientVersion + "&a=" + C.appId + "&n=" + C.networkType + "&i=" + C.initTime + "&p=" + C.preVerifyTime + "&u=" + C.url; - b.src = c + }), m() + }, + ready: function (e) { + 0 != B.state ? e() : (L._completes.push(e), !k && C.debug && e()) + }, + error: function (e) { + x < "6.0.2" || (-1 == B.state ? e(B.data) : L._fail = e) + }, + checkJsApi: function (e) { + var n = function (e) { + var n = e.checkResult; + for (var i in n) { + var t = v[i]; + t && (n[t] = n[i], delete n[i]) + } + return e + }; + i("checkJsApi", { + jsApiList: d(e.jsApiList) + }, (e._complete = function (e) { + if (M) { + var i = e.checkResult; + i && (e.checkResult = JSON.parse(i)) + } + e = n(e) + }, e)) + }, + onMenuShareTimeline: function (e) { + t(h.onMenuShareTimeline, { + complete: function () { + i("shareTimeline", { + title: e.title || S, + desc: e.title || S, + img_url: e.imgUrl || "", + link: e.link || location.href, + type: e.type || "link", + data_url: e.dataUrl || "" + }, e) + } + }, e) + }, + onMenuShareAppMessage: function (e) { + t(h.onMenuShareAppMessage, { + complete: function () { + i("sendAppMessage", { + title: e.title || S, + desc: e.desc || "", + link: e.link || location.href, + img_url: e.imgUrl || "", + type: e.type || "link", + data_url: e.dataUrl || "" + }, e) + } + }, e) + }, + onMenuShareQQ: function (e) { + t(h.onMenuShareQQ, { + complete: function () { + i("shareQQ", { + title: e.title || S, + desc: e.desc || "", + img_url: e.imgUrl || "", + link: e.link || location.href + }, e) + } + }, e) + }, + onMenuShareWeibo: function (e) { + t(h.onMenuShareWeibo, { + complete: function () { + i("shareWeiboApp", { + title: e.title || S, + desc: e.desc || "", + img_url: e.imgUrl || "", + link: e.link || location.href + }, e) + } + }, e) + }, + onMenuShareQZone: function (e) { + t(h.onMenuShareQZone, { + complete: function () { + i("shareQZone", { + title: e.title || S, + desc: e.desc || "", + img_url: e.imgUrl || "", + link: e.link || location.href + }, e) + } + }, e) + }, + startRecord: function (e) { + i("startRecord", {}, e) + }, + stopRecord: function (e) { + i("stopRecord", {}, e) + }, + onVoiceRecordEnd: function (e) { + t("onVoiceRecordEnd", e) + }, + playVoice: function (e) { + i("playVoice", { + localId: e.localId + }, e) + }, + pauseVoice: function (e) { + i("pauseVoice", { + localId: e.localId + }, e) + }, + stopVoice: function (e) { + i("stopVoice", { + localId: e.localId + }, e) + }, + onVoicePlayEnd: function (e) { + t("onVoicePlayEnd", e) + }, + uploadVoice: function (e) { + i("uploadVoice", { + localId: e.localId, + isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 + }, e) + }, + downloadVoice: function (e) { + i("downloadVoice", { + serverId: e.serverId, + isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 + }, e) + }, + translateVoice: function (e) { + i("translateVoice", { + localId: e.localId, + isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 + }, e) + }, + chooseImage: function (e) { + i("chooseImage", { + scene: "1|2", + count: e.count || 9, + sizeType: e.sizeType || ["original", "compressed"], + sourceType: e.sourceType || ["album", "camera"] + }, (e._complete = function (e) { + if (M) { + var n = e.localIds; + n && (e.localIds = JSON.parse(n)) + } + }, e)) + }, + getLocation: function (e) {}, + previewImage: function (e) { + i(h.previewImage, { + current: e.current, + urls: e.urls + }, e) + }, + uploadImage: function (e) { + i("uploadImage", { + localId: e.localId, + isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 + }, e) + }, + downloadImage: function (e) { + i("downloadImage", { + serverId: e.serverId, + isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 + }, e) + }, + getLocalImgData: function (e) { + !1 === E ? (E = !0, i("getLocalImgData", { + localId: e.localId + }, (e._complete = function (e) { + if (E = !1, O.length > 0) { + var n = O.shift(); + wx.getLocalImgData(n) + } + }, e))) : O.push(e) + }, + getNetworkType: function (e) { + var n = function (e) { + var n = e.errMsg; + e.errMsg = "getNetworkType:ok"; + var i = e.subtype; + if (delete e.subtype, i) e.networkType = i; + else { + var t = n.indexOf(":"), + o = n.substring(t + 1); + switch (o) { + case "wifi": + case "edge": + case "wwan": + e.networkType = o; + break; + default: + e.errMsg = "getNetworkType:fail" + } + } + return e + }; + i("getNetworkType", {}, (e._complete = function (e) { + e = n(e) + }, e)) + }, + openLocation: function (e) { + i("openLocation", { + latitude: e.latitude, + longitude: e.longitude, + name: e.name || "", + address: e.address || "", + scale: e.scale || 28, + infoUrl: e.infoUrl || "" + }, e) + }, + getLocation: function (e) { + e = e || {}, i(h.getLocation, { + type: e.type || "wgs84" + }, (e._complete = function (e) { + delete e.type + }, e)) + }, + hideOptionMenu: function (e) { + i("hideOptionMenu", {}, e) + }, + showOptionMenu: function (e) { + i("showOptionMenu", {}, e) + }, + closeWindow: function (e) { + i("closeWindow", {}, e = e || {}) + }, + hideMenuItems: function (e) { + i("hideMenuItems", { + menuList: e.menuList + }, e) + }, + showMenuItems: function (e) { + i("showMenuItems", { + menuList: e.menuList + }, e) + }, + hideAllNonBaseMenuItem: function (e) { + i("hideAllNonBaseMenuItem", {}, e) + }, + showAllNonBaseMenuItem: function (e) { + i("showAllNonBaseMenuItem", {}, e) + }, + scanQRCode: function (e) { + i("scanQRCode", { + needResult: (e = e || {}).needResult || 0, + scanType: e.scanType || ["qrCode", "barCode"] + }, (e._complete = function (e) { + if (P) { + var n = e.resultStr; + if (n) { + var i = JSON.parse(n); + e.resultStr = i && i.scan_code && i.scan_code.scan_result + } + } + }, e)) + }, + openAddress: function (e) { + i(h.openAddress, {}, (e._complete = function (e) { + e = a(e) + }, e)) + }, + openProductSpecificView: function (e) { + i(h.openProductSpecificView, { + pid: e.productId, + view_type: e.viewType || 0, + ext_info: e.extInfo + }, e) + }, + addCard: function (e) { + for (var n = e.cardList, t = [], o = 0, r = n.length; o < r; ++o) { + var a = n[o], + c = { + card_id: a.cardId, + card_ext: a.cardExt + }; + t.push(c) + } + i(h.addCard, { + card_list: t + }, (e._complete = function (e) { + var n = e.card_list; + if (n) { + for (var i = 0, t = (n = JSON.parse(n)).length; i < t; ++i) { + var o = n[i]; + o.cardId = o.card_id, o.cardExt = o.card_ext, o.isSuccess = !!o.is_succ, delete o.card_id, delete o.card_ext, delete o.is_succ + } + e.cardList = n, delete e.card_list + } + }, e)) + }, + chooseCard: function (e) { + i("chooseCard", { + app_id: C.appId, + location_id: e.shopId || "", + sign_type: e.signType || "SHA1", + card_id: e.cardId || "", + card_type: e.cardType || "", + card_sign: e.cardSign, + time_stamp: e.timestamp + "", + nonce_str: e.nonceStr + }, (e._complete = function (e) { + e.cardList = e.choose_card_info, delete e.choose_card_info + }, e)) + }, + openCard: function (e) { + for (var n = e.cardList, t = [], o = 0, r = n.length; o < r; ++o) { + var a = n[o], + c = { + card_id: a.cardId, + code: a.code + }; + t.push(c) + } + i(h.openCard, { + card_list: t + }, e) + }, + consumeAndShareCard: function (e) { + i(h.consumeAndShareCard, { + consumedCardId: e.cardId, + consumedCode: e.code + }, e) + }, + chooseWXPay: function (e) { + i(h.chooseWXPay, r(e), e) + }, + openEnterpriseRedPacket: function (e) { + i(h.openEnterpriseRedPacket, r(e), e) + }, + startSearchBeacons: function (e) { + i(h.startSearchBeacons, { + ticket: e.ticket + }, e) + }, + stopSearchBeacons: function (e) { + i(h.stopSearchBeacons, {}, e) + }, + onSearchBeacons: function (e) { + t(h.onSearchBeacons, e) + }, + openEnterpriseChat: function (e) { + i("openEnterpriseChat", { + useridlist: e.userIds, + chatname: e.groupName + }, e) + }, + launchMiniProgram: function (e) { + i("launchMiniProgram", { + targetAppId: e.targetAppId, + path: g(e.path), + envVersion: e.envVersion + }, e) + }, + miniProgram: { + navigateBack: function (e) { + e = e || {}, f(function () { + i("invokeMiniProgramAPI", { + name: "navigateBack", + arg: { + delta: e.delta || 1 } + }, e) }) + }, + navigateTo: function (e) { + f(function () { + i("invokeMiniProgramAPI", { + name: "navigateTo", + arg: { + url: e.url + } + }, e) + }) + }, + redirectTo: function (e) { + f(function () { + i("invokeMiniProgramAPI", { + name: "redirectTo", + arg: { + url: e.url + } + }, e) + }) + }, + switchTab: function (e) { + f(function () { + i("invokeMiniProgramAPI", { + name: "switchTab", + arg: { + url: e.url + } + }, e) + }) + }, + reLaunch: function (e) { + f(function () { + i("invokeMiniProgramAPI", { + name: "reLaunch", + arg: { + url: e.url + } + }, e) + }) + }, + postMessage: function (e) { + f(function () { + i("invokeMiniProgramAPI", { + name: "postMessage", + arg: e.data || {} + }, e) + }) + }, + getEnv: function (n) { + f(function () { + n({ + miniprogram: "miniprogram" === e.__wxjs_environment + }) + }) + } } - } - - function m() { - return (new Date).getTime() - } - - function n(b) { - x && (a.WeixinJSBridge ? b() : r.addEventListener && r.addEventListener("WeixinJSBridgeReady", b, !1)) - } - - function o() { - I.invoke || (I.invoke = function (b, c, d) { - a.WeixinJSBridge && WeixinJSBridge.invoke(b, e(c), d) - }, I.on = function (b, c) { - a.WeixinJSBridge && WeixinJSBridge.on(b, c) - }) - } - - if (!a.jWeixin) { - var p = { - config: "preVerifyJSAPI", - onMenuShareTimeline: "menu:share:timeline", - onMenuShareAppMessage: "menu:share:appmessage", - onMenuShareQQ: "menu:share:qq", - onMenuShareWeibo: "menu:share:weiboApp", - onMenuShareQZone: "menu:share:QZone", - previewImage: "imagePreview", - getLocation: "geoLocation", - openProductSpecificView: "openProductViewWithPid", - addCard: "batchAddCard", - openCard: "batchViewCard", - chooseWXPay: "getBrandWCPayRequest", - openEnterpriseRedPacket: "getRecevieBizHongBaoRequest", - startSearchBeacons: "startMonitoringBeacons", - stopSearchBeacons: "stopMonitoringBeacons", - onSearchBeacons: "onBeaconsInRange", - consumeAndShareCard: "consumedShareCard", - openAddress: "editAddress" - }, q = function () { - var a = {}; - for (var b in p)a[p[b]] = b; - return a - }(), r = a.document, s = r.title, t = navigator.userAgent.toLowerCase(), u = navigator.platform.toLowerCase(), v = !(!u.match("mac") && !u.match("win")), w = -1 != t.indexOf("wxdebugger"), x = -1 != t.indexOf("micromessenger"), y = -1 != t.indexOf("android"), z = -1 != t.indexOf("iphone") || -1 != t.indexOf("ipad"), A = function () { - var a = t.match(/micromessenger\/(\d+\.\d+\.\d+)/) || t.match(/micromessenger\/(\d+\.\d+)/); - return a ? a[1] : "" - }(), B = {initStartTime: m(), initEndTime: 0, preVerifyStartTime: 0, preVerifyEndTime: 0}, C = { - version: 1, - appId: "", - initTime: 0, - preVerifyTime: 0, - networkType: "", - isPreVerifyOk: 1, - systemType: z ? 1 : y ? 2 : -1, - clientVersion: A, - url: encodeURIComponent(location.href) - }, D = {}, E = {_completes: []}, F = {state: 0, data: {}}; - n(function () { - B.initEndTime = m() - }); - var G = !1, H = [], I = { - config: function (a) { - D = a, k("config", a); - var b = D.check === !1 ? !1 : !0; - n(function () { - if (b)c(p.config, {verifyJsApiList: j(D.jsApiList)}, function () { - E._complete = function (a) { - B.preVerifyEndTime = m(), F.state = 1, F.data = a - }, E.success = function (a) { - C.isPreVerifyOk = 0 - }, E.fail = function (a) { - E._fail ? E._fail(a) : F.state = -1 - }; - var a = E._completes; - return a.push(function () { - l() - }), E.complete = function (b) { - for (var c = 0, d = a.length; d > c; ++c)a[c](); - E._completes = [] - }, E - }()), B.preVerifyStartTime = m(); else { - F.state = 1; - for (var a = E._completes, d = 0, e = a.length; e > d; ++d)a[d](); - E._completes = [] - } - }), D.beta && o() - }, ready: function (a) { - 0 != F.state ? a() : (E._completes.push(a), !x && D.debug && a()) - }, error: function (a) { - "6.0.2" > A || (-1 == F.state ? a(F.data) : E._fail = a) - }, checkJsApi: function (a) { - var b = function (a) { - var b = a.checkResult; - for (var c in b) { - var d = q[c]; - d && (b[d] = b[c], delete b[c]) - } - return a - }; - c("checkJsApi", {jsApiList: j(a.jsApiList)}, function () { - return a._complete = function (a) { - if (y) { - var c = a.checkResult; - c && (a.checkResult = JSON.parse(c)) - } - a = b(a) - }, a - }()) - }, onMenuShareTimeline: function (a) { - d(p.onMenuShareTimeline, { - complete: function () { - c("shareTimeline", { - title: a.title || s, - desc: a.title || s, - img_url: a.imgUrl || "", - link: a.link || location.href, - type: a.type || "link", - data_url: a.dataUrl || "" - }, a) - } - }, a) - }, onMenuShareAppMessage: function (a) { - d(p.onMenuShareAppMessage, { - complete: function () { - c("sendAppMessage", { - title: a.title || s, - desc: a.desc || "", - link: a.link || location.href, - img_url: a.imgUrl || "", - type: a.type || "link", - data_url: a.dataUrl || "" - }, a) - } - }, a) - }, onMenuShareQQ: function (a) { - d(p.onMenuShareQQ, { - complete: function () { - c("shareQQ", { - title: a.title || s, - desc: a.desc || "", - img_url: a.imgUrl || "", - link: a.link || location.href - }, a) - } - }, a) - }, onMenuShareWeibo: function (a) { - d(p.onMenuShareWeibo, { - complete: function () { - c("shareWeiboApp", { - title: a.title || s, - desc: a.desc || "", - img_url: a.imgUrl || "", - link: a.link || location.href - }, a) - } - }, a) - }, onMenuShareQZone: function (a) { - d(p.onMenuShareQZone, { - complete: function () { - c("shareQZone", { - title: a.title || s, - desc: a.desc || "", - img_url: a.imgUrl || "", - link: a.link || location.href - }, a) - } - }, a) - }, startRecord: function (a) { - c("startRecord", {}, a) - }, stopRecord: function (a) { - c("stopRecord", {}, a) - }, onVoiceRecordEnd: function (a) { - d("onVoiceRecordEnd", a) - }, playVoice: function (a) { - c("playVoice", {localId: a.localId}, a) - }, pauseVoice: function (a) { - c("pauseVoice", {localId: a.localId}, a) - }, stopVoice: function (a) { - c("stopVoice", {localId: a.localId}, a) - }, onVoicePlayEnd: function (a) { - d("onVoicePlayEnd", a) - }, uploadVoice: function (a) { - c("uploadVoice", {localId: a.localId, isShowProgressTips: 0 == a.isShowProgressTips ? 0 : 1}, a) - }, downloadVoice: function (a) { - c("downloadVoice", {serverId: a.serverId, isShowProgressTips: 0 == a.isShowProgressTips ? 0 : 1}, a) - }, translateVoice: function (a) { - c("translateVoice", {localId: a.localId, isShowProgressTips: 0 == a.isShowProgressTips ? 0 : 1}, a) - }, chooseImage: function (a) { - c("chooseImage", { - scene: "1|2", - count: a.count || 9, - sizeType: a.sizeType || ["original", "compressed"], - sourceType: a.sourceType || ["album", "camera"] - }, function () { - return a._complete = function (a) { - if (y) { - var b = a.localIds; - b && (a.localIds = JSON.parse(b)) - } - }, a - }()) - }, getLocation: function (a) { - }, previewImage: function (a) { - c(p.previewImage, {current: a.current, urls: a.urls}, a) - }, uploadImage: function (a) { - c("uploadImage", {localId: a.localId, isShowProgressTips: 0 == a.isShowProgressTips ? 0 : 1}, a) - }, downloadImage: function (a) { - c("downloadImage", {serverId: a.serverId, isShowProgressTips: 0 == a.isShowProgressTips ? 0 : 1}, a) - }, getLocalImgData: function (a) { - G === !1 ? (G = !0, c("getLocalImgData", {localId: a.localId}, function () { - return a._complete = function (a) { - if (G = !1, H.length > 0) { - var b = H.shift(); - wx.getLocalImgData(b) - } - }, a - }())) : H.push(a) - }, getNetworkType: function (a) { - var b = function (a) { - var b = a.errMsg; - a.errMsg = "getNetworkType:ok"; - var c = a.subtype; - if (delete a.subtype, c)a.networkType = c; else { - var d = b.indexOf(":"), e = b.substring(d + 1); - switch (e) { - case"wifi": - case"edge": - case"wwan": - a.networkType = e; - break; - default: - a.errMsg = "getNetworkType:fail" - } - } - return a - }; - c("getNetworkType", {}, function () { - return a._complete = function (a) { - a = b(a) - }, a - }()) - }, openLocation: function (a) { - c("openLocation", { - latitude: a.latitude, - longitude: a.longitude, - name: a.name || "", - address: a.address || "", - scale: a.scale || 28, - infoUrl: a.infoUrl || "" - }, a) - }, getLocation: function (a) { - a = a || {}, c(p.getLocation, {type: a.type || "wgs84"}, function () { - return a._complete = function (a) { - delete a.type - }, a - }()) - }, hideOptionMenu: function (a) { - c("hideOptionMenu", {}, a) - }, showOptionMenu: function (a) { - c("showOptionMenu", {}, a) - }, closeWindow: function (a) { - a = a || {}, c("closeWindow", {}, a) - }, hideMenuItems: function (a) { - c("hideMenuItems", {menuList: a.menuList}, a) - }, showMenuItems: function (a) { - c("showMenuItems", {menuList: a.menuList}, a) - }, hideAllNonBaseMenuItem: function (a) { - c("hideAllNonBaseMenuItem", {}, a) - }, showAllNonBaseMenuItem: function (a) { - c("showAllNonBaseMenuItem", {}, a) - }, scanQRCode: function (a) { - a = a || {}, c("scanQRCode", { - needResult: a.needResult || 0, - scanType: a.scanType || ["qrCode", "barCode"] - }, function () { - return a._complete = function (a) { - if (z) { - var b = a.resultStr; - if (b) { - var c = JSON.parse(b); - a.resultStr = c && c.scan_code && c.scan_code.scan_result - } - } - }, a - }()) - }, openAddress: function (a) { - c(p.openAddress, {}, function () { - return a._complete = function (a) { - a = g(a) - }, a - }()) - }, openProductSpecificView: function (a) { - c(p.openProductSpecificView, {pid: a.productId, view_type: a.viewType || 0, ext_info: a.extInfo}, a) - }, addCard: function (a) { - for (var b = a.cardList, d = [], e = 0, f = b.length; f > e; ++e) { - var g = b[e], h = {card_id: g.cardId, card_ext: g.cardExt}; - d.push(h) - } - c(p.addCard, {card_list: d}, function () { - return a._complete = function (a) { - var b = a.card_list; - if (b) { - b = JSON.parse(b); - for (var c = 0, d = b.length; d > c; ++c) { - var e = b[c]; - e.cardId = e.card_id, e.cardExt = e.card_ext, e.isSuccess = e.is_succ ? !0 : !1, delete e.card_id, delete e.card_ext, delete e.is_succ - } - a.cardList = b, delete a.card_list - } - }, a - }()) - }, chooseCard: function (a) { - c("chooseCard", { - app_id: D.appId, - location_id: a.shopId || "", - sign_type: a.signType || "SHA1", - card_id: a.cardId || "", - card_type: a.cardType || "", - card_sign: a.cardSign, - time_stamp: a.timestamp + "", - nonce_str: a.nonceStr - }, function () { - return a._complete = function (a) { - a.cardList = a.choose_card_info, delete a.choose_card_info - }, a - }()) - }, openCard: function (a) { - for (var b = a.cardList, d = [], e = 0, f = b.length; f > e; ++e) { - var g = b[e], h = {card_id: g.cardId, code: g.code}; - d.push(h) - } - c(p.openCard, {card_list: d}, a) - }, consumeAndShareCard: function (a) { - c(p.consumeAndShareCard, {consumedCardId: a.cardId, consumedCode: a.code}, a) - }, chooseWXPay: function (a) { - c(p.chooseWXPay, f(a), a) - }, openEnterpriseRedPacket: function (a) { - c(p.openEnterpriseRedPacket, f(a), a) - }, startSearchBeacons: function (a) { - c(p.startSearchBeacons, {ticket: a.ticket}, a) - }, stopSearchBeacons: function (a) { - c(p.stopSearchBeacons, {}, a) - }, onSearchBeacons: function (a) { - d(p.onSearchBeacons, a) - }, openEnterpriseChat: function (a) { - c("openEnterpriseChat", {useridlist: a.userIds, chatname: a.groupName}, a) - } - }, J = 1, K = {}; - return r.addEventListener("error", function (a) { - if (!y) { - var b = a.target, c = b.tagName, d = b.src; - if ("IMG" == c || "VIDEO" == c || "AUDIO" == c || "SOURCE" == c) { - var e = -1 != d.indexOf("wxlocalresource://"); - if (e) { - a.preventDefault(), a.stopPropagation(); - var f = b["wx-id"]; - if (f || (f = J++, b["wx-id"] = f), K[f])return; - K[f] = !0, wx.getLocalImgData({ - localId: d, success: function (a) { - b.src = a.localData - } - }) - } - } - } - }, !0), r.addEventListener("load", function (a) { - if (!y) { - var b = a.target, c = b.tagName; - b.src; - if ("IMG" == c || "VIDEO" == c || "AUDIO" == c || "SOURCE" == c) { - var d = b["wx-id"]; - d && (K[d] = !1) - } - } - }, !0), b && (a.wx = a.jWeixin = I), I - } + }, + b = 1, + R = {}; + return I.addEventListener("error", function (e) { + if (!M) { + var n = e.target, + i = n.tagName, + t = n.src; + if (("IMG" == i || "VIDEO" == i || "AUDIO" == i || "SOURCE" == i) && -1 != t.indexOf("wxlocalresource://")) { + e.preventDefault(), e.stopPropagation(); + var o = n["wx-id"]; + if (o || (o = b++, n["wx-id"] = o), R[o]) return; + R[o] = !0, wx.ready(function () { + wx.getLocalImgData({ + localId: t, + success: function (e) { + n.src = e.localData + } + }) + }) + } + } + }, !0), I.addEventListener("load", function (e) { + if (!M) { + var n = e.target, + i = n.tagName; + n.src; + if ("IMG" == i || "VIDEO" == i || "AUDIO" == i || "SOURCE" == i) { + var t = n["wx-id"]; + t && (R[t] = !1) + } + } + }, !0), n && (e.wx = e.jWeixin = N), N + } }); \ No newline at end of file diff --git a/index.original.js b/index.original.js index c901be1..6f95d21 100644 --- a/index.original.js +++ b/index.original.js @@ -1,2 +1,2 @@ -// from https://res.wx.qq.com/open/js/jweixin-1.2.0.js -!function(a,b){"function"==typeof define&&(define.amd||define.cmd)?define(function(){return b(a)}):b(a,!0)}(this,function(a,b){function c(b,c,d){a.WeixinJSBridge?WeixinJSBridge.invoke(b,e(c),function(a){h(b,a,d)}):k(b,d)}function d(b,c,d){a.WeixinJSBridge?WeixinJSBridge.on(b,function(a){d&&d.trigger&&d.trigger(a),h(b,a,c)}):d?k(b,d):k(b,c)}function e(a){return a=a||{},a.appId=D.appId,a.verifyAppId=D.appId,a.verifySignType="sha1",a.verifyTimestamp=D.timestamp+"",a.verifyNonceStr=D.nonceStr,a.verifySignature=D.signature,a}function f(a){return{timeStamp:a.timestamp+"",nonceStr:a.nonceStr,"package":a["package"],paySign:a.paySign,signType:a.signType||"SHA1"}}function g(a){return a.postalCode=a.addressPostalCode,delete a.addressPostalCode,a.provinceName=a.proviceFirstStageName,delete a.proviceFirstStageName,a.cityName=a.addressCitySecondStageName,delete a.addressCitySecondStageName,a.countryName=a.addressCountiesThirdStageName,delete a.addressCountiesThirdStageName,a.detailInfo=a.addressDetailInfo,delete a.addressDetailInfo,a}function h(a,b,c){"openEnterpriseChat"==a&&(b.errCode=b.err_code),delete b.err_code,delete b.err_desc,delete b.err_detail;var d=b.errMsg;d||(d=b.err_msg,delete b.err_msg,d=i(a,d),b.errMsg=d),c=c||{},c._complete&&(c._complete(b),delete c._complete),d=b.errMsg||"",D.debug&&!c.isInnerInvoke&&alert(JSON.stringify(b));var e=d.indexOf(":"),f=d.substring(e+1);switch(f){case"ok":c.success&&c.success(b);break;case"cancel":c.cancel&&c.cancel(b);break;default:c.fail&&c.fail(b)}c.complete&&c.complete(b)}function i(a,b){var c=a,d=q[c];d&&(c=d);var e="ok";if(b){var f=b.indexOf(":");e=b.substring(f+1),"confirm"==e&&(e="ok"),"failed"==e&&(e="fail"),-1!=e.indexOf("failed_")&&(e=e.substring(7)),-1!=e.indexOf("fail_")&&(e=e.substring(5)),e=e.replace(/_/g," "),e=e.toLowerCase(),("access denied"==e||"no permission to execute"==e)&&(e="permission denied"),"config"==c&&"function not exist"==e&&(e="ok"),""==e&&(e="fail")}return b=c+":"+e}function j(a){if(a){for(var b=0,c=a.length;c>b;++b){var d=a[b],e=p[d];e&&(a[b]=e)}return a}}function k(a,b){if(!(!D.debug||b&&b.isInnerInvoke)){var c=q[a];c&&(a=c),b&&b._complete&&delete b._complete,console.log('"'+a+'",',b||"")}}function l(a){if(!(v||w||D.debug||"6.0.2">A||C.systemType<0)){var b=new Image;C.appId=D.appId,C.initTime=B.initEndTime-B.initStartTime,C.preVerifyTime=B.preVerifyEndTime-B.preVerifyStartTime,I.getNetworkType({isInnerInvoke:!0,success:function(a){C.networkType=a.networkType;var c="https://open.weixin.qq.com/sdk/report?v="+C.version+"&o="+C.isPreVerifyOk+"&s="+C.systemType+"&c="+C.clientVersion+"&a="+C.appId+"&n="+C.networkType+"&i="+C.initTime+"&p="+C.preVerifyTime+"&u="+C.url;b.src=c}})}}function m(){return(new Date).getTime()}function n(b){x&&(a.WeixinJSBridge?b():r.addEventListener&&r.addEventListener("WeixinJSBridgeReady",b,!1))}function o(){I.invoke||(I.invoke=function(b,c,d){a.WeixinJSBridge&&WeixinJSBridge.invoke(b,e(c),d)},I.on=function(b,c){a.WeixinJSBridge&&WeixinJSBridge.on(b,c)})}if(!a.jWeixin){var p={config:"preVerifyJSAPI",onMenuShareTimeline:"menu:share:timeline",onMenuShareAppMessage:"menu:share:appmessage",onMenuShareQQ:"menu:share:qq",onMenuShareWeibo:"menu:share:weiboApp",onMenuShareQZone:"menu:share:QZone",previewImage:"imagePreview",getLocation:"geoLocation",openProductSpecificView:"openProductViewWithPid",addCard:"batchAddCard",openCard:"batchViewCard",chooseWXPay:"getBrandWCPayRequest",openEnterpriseRedPacket:"getRecevieBizHongBaoRequest",startSearchBeacons:"startMonitoringBeacons",stopSearchBeacons:"stopMonitoringBeacons",onSearchBeacons:"onBeaconsInRange",consumeAndShareCard:"consumedShareCard",openAddress:"editAddress"},q=function(){var a={};for(var b in p)a[p[b]]=b;return a}(),r=a.document,s=r.title,t=navigator.userAgent.toLowerCase(),u=navigator.platform.toLowerCase(),v=!(!u.match("mac")&&!u.match("win")),w=-1!=t.indexOf("wxdebugger"),x=-1!=t.indexOf("micromessenger"),y=-1!=t.indexOf("android"),z=-1!=t.indexOf("iphone")||-1!=t.indexOf("ipad"),A=function(){var a=t.match(/micromessenger\/(\d+\.\d+\.\d+)/)||t.match(/micromessenger\/(\d+\.\d+)/);return a?a[1]:""}(),B={initStartTime:m(),initEndTime:0,preVerifyStartTime:0,preVerifyEndTime:0},C={version:1,appId:"",initTime:0,preVerifyTime:0,networkType:"",isPreVerifyOk:1,systemType:z?1:y?2:-1,clientVersion:A,url:encodeURIComponent(location.href)},D={},E={_completes:[]},F={state:0,data:{}};n(function(){B.initEndTime=m()});var G=!1,H=[],I={config:function(a){D=a,k("config",a);var b=D.check===!1?!1:!0;n(function(){if(b)c(p.config,{verifyJsApiList:j(D.jsApiList)},function(){E._complete=function(a){B.preVerifyEndTime=m(),F.state=1,F.data=a},E.success=function(a){C.isPreVerifyOk=0},E.fail=function(a){E._fail?E._fail(a):F.state=-1};var a=E._completes;return a.push(function(){l()}),E.complete=function(b){for(var c=0,d=a.length;d>c;++c)a[c]();E._completes=[]},E}()),B.preVerifyStartTime=m();else{F.state=1;for(var a=E._completes,d=0,e=a.length;e>d;++d)a[d]();E._completes=[]}}),D.beta&&o()},ready:function(a){0!=F.state?a():(E._completes.push(a),!x&&D.debug&&a())},error:function(a){"6.0.2">A||(-1==F.state?a(F.data):E._fail=a)},checkJsApi:function(a){var b=function(a){var b=a.checkResult;for(var c in b){var d=q[c];d&&(b[d]=b[c],delete b[c])}return a};c("checkJsApi",{jsApiList:j(a.jsApiList)},function(){return a._complete=function(a){if(y){var c=a.checkResult;c&&(a.checkResult=JSON.parse(c))}a=b(a)},a}())},onMenuShareTimeline:function(a){d(p.onMenuShareTimeline,{complete:function(){c("shareTimeline",{title:a.title||s,desc:a.title||s,img_url:a.imgUrl||"",link:a.link||location.href,type:a.type||"link",data_url:a.dataUrl||""},a)}},a)},onMenuShareAppMessage:function(a){d(p.onMenuShareAppMessage,{complete:function(){c("sendAppMessage",{title:a.title||s,desc:a.desc||"",link:a.link||location.href,img_url:a.imgUrl||"",type:a.type||"link",data_url:a.dataUrl||""},a)}},a)},onMenuShareQQ:function(a){d(p.onMenuShareQQ,{complete:function(){c("shareQQ",{title:a.title||s,desc:a.desc||"",img_url:a.imgUrl||"",link:a.link||location.href},a)}},a)},onMenuShareWeibo:function(a){d(p.onMenuShareWeibo,{complete:function(){c("shareWeiboApp",{title:a.title||s,desc:a.desc||"",img_url:a.imgUrl||"",link:a.link||location.href},a)}},a)},onMenuShareQZone:function(a){d(p.onMenuShareQZone,{complete:function(){c("shareQZone",{title:a.title||s,desc:a.desc||"",img_url:a.imgUrl||"",link:a.link||location.href},a)}},a)},startRecord:function(a){c("startRecord",{},a)},stopRecord:function(a){c("stopRecord",{},a)},onVoiceRecordEnd:function(a){d("onVoiceRecordEnd",a)},playVoice:function(a){c("playVoice",{localId:a.localId},a)},pauseVoice:function(a){c("pauseVoice",{localId:a.localId},a)},stopVoice:function(a){c("stopVoice",{localId:a.localId},a)},onVoicePlayEnd:function(a){d("onVoicePlayEnd",a)},uploadVoice:function(a){c("uploadVoice",{localId:a.localId,isShowProgressTips:0==a.isShowProgressTips?0:1},a)},downloadVoice:function(a){c("downloadVoice",{serverId:a.serverId,isShowProgressTips:0==a.isShowProgressTips?0:1},a)},translateVoice:function(a){c("translateVoice",{localId:a.localId,isShowProgressTips:0==a.isShowProgressTips?0:1},a)},chooseImage:function(a){c("chooseImage",{scene:"1|2",count:a.count||9,sizeType:a.sizeType||["original","compressed"],sourceType:a.sourceType||["album","camera"]},function(){return a._complete=function(a){if(y){var b=a.localIds;b&&(a.localIds=JSON.parse(b))}},a}())},getLocation:function(a){},previewImage:function(a){c(p.previewImage,{current:a.current,urls:a.urls},a)},uploadImage:function(a){c("uploadImage",{localId:a.localId,isShowProgressTips:0==a.isShowProgressTips?0:1},a)},downloadImage:function(a){c("downloadImage",{serverId:a.serverId,isShowProgressTips:0==a.isShowProgressTips?0:1},a)},getLocalImgData:function(a){G===!1?(G=!0,c("getLocalImgData",{localId:a.localId},function(){return a._complete=function(a){if(G=!1,H.length>0){var b=H.shift();wx.getLocalImgData(b)}},a}())):H.push(a)},getNetworkType:function(a){var b=function(a){var b=a.errMsg;a.errMsg="getNetworkType:ok";var c=a.subtype;if(delete a.subtype,c)a.networkType=c;else{var d=b.indexOf(":"),e=b.substring(d+1);switch(e){case"wifi":case"edge":case"wwan":a.networkType=e;break;default:a.errMsg="getNetworkType:fail"}}return a};c("getNetworkType",{},function(){return a._complete=function(a){a=b(a)},a}())},openLocation:function(a){c("openLocation",{latitude:a.latitude,longitude:a.longitude,name:a.name||"",address:a.address||"",scale:a.scale||28,infoUrl:a.infoUrl||""},a)},getLocation:function(a){a=a||{},c(p.getLocation,{type:a.type||"wgs84"},function(){return a._complete=function(a){delete a.type},a}())},hideOptionMenu:function(a){c("hideOptionMenu",{},a)},showOptionMenu:function(a){c("showOptionMenu",{},a)},closeWindow:function(a){a=a||{},c("closeWindow",{},a)},hideMenuItems:function(a){c("hideMenuItems",{menuList:a.menuList},a)},showMenuItems:function(a){c("showMenuItems",{menuList:a.menuList},a)},hideAllNonBaseMenuItem:function(a){c("hideAllNonBaseMenuItem",{},a)},showAllNonBaseMenuItem:function(a){c("showAllNonBaseMenuItem",{},a)},scanQRCode:function(a){a=a||{},c("scanQRCode",{needResult:a.needResult||0,scanType:a.scanType||["qrCode","barCode"]},function(){return a._complete=function(a){if(z){var b=a.resultStr;if(b){var c=JSON.parse(b);a.resultStr=c&&c.scan_code&&c.scan_code.scan_result}}},a}())},openAddress:function(a){c(p.openAddress,{},function(){return a._complete=function(a){a=g(a)},a}())},openProductSpecificView:function(a){c(p.openProductSpecificView,{pid:a.productId,view_type:a.viewType||0,ext_info:a.extInfo},a)},addCard:function(a){for(var b=a.cardList,d=[],e=0,f=b.length;f>e;++e){var g=b[e],h={card_id:g.cardId,card_ext:g.cardExt};d.push(h)}c(p.addCard,{card_list:d},function(){return a._complete=function(a){var b=a.card_list;if(b){b=JSON.parse(b);for(var c=0,d=b.length;d>c;++c){var e=b[c];e.cardId=e.card_id,e.cardExt=e.card_ext,e.isSuccess=e.is_succ?!0:!1,delete e.card_id,delete e.card_ext,delete e.is_succ}a.cardList=b,delete a.card_list}},a}())},chooseCard:function(a){c("chooseCard",{app_id:D.appId,location_id:a.shopId||"",sign_type:a.signType||"SHA1",card_id:a.cardId||"",card_type:a.cardType||"",card_sign:a.cardSign,time_stamp:a.timestamp+"",nonce_str:a.nonceStr},function(){return a._complete=function(a){a.cardList=a.choose_card_info,delete a.choose_card_info},a}())},openCard:function(a){for(var b=a.cardList,d=[],e=0,f=b.length;f>e;++e){var g=b[e],h={card_id:g.cardId,code:g.code};d.push(h)}c(p.openCard,{card_list:d},a)},consumeAndShareCard:function(a){c(p.consumeAndShareCard,{consumedCardId:a.cardId,consumedCode:a.code},a)},chooseWXPay:function(a){c(p.chooseWXPay,f(a),a)},openEnterpriseRedPacket:function(a){c(p.openEnterpriseRedPacket,f(a),a)},startSearchBeacons:function(a){c(p.startSearchBeacons,{ticket:a.ticket},a)},stopSearchBeacons:function(a){c(p.stopSearchBeacons,{},a)},onSearchBeacons:function(a){d(p.onSearchBeacons,a)},openEnterpriseChat:function(a){c("openEnterpriseChat",{useridlist:a.userIds,chatname:a.groupName},a)}},J=1,K={};return r.addEventListener("error",function(a){if(!y){var b=a.target,c=b.tagName,d=b.src;if("IMG"==c||"VIDEO"==c||"AUDIO"==c||"SOURCE"==c){var e=-1!=d.indexOf("wxlocalresource://");if(e){a.preventDefault(),a.stopPropagation();var f=b["wx-id"];if(f||(f=J++,b["wx-id"]=f),K[f])return;K[f]=!0,wx.getLocalImgData({localId:d,success:function(a){b.src=a.localData}})}}}},!0),r.addEventListener("load",function(a){if(!y){var b=a.target,c=b.tagName;b.src;if("IMG"==c||"VIDEO"==c||"AUDIO"==c||"SOURCE"==c){var d=b["wx-id"];d&&(K[d]=!1)}}},!0),b&&(a.wx=a.jWeixin=I),I}}); +// from https://res.wx.qq.com/open/js/jweixin-1.3.2.js +!function(e,n){"function"==typeof define&&(define.amd||define.cmd)?define(function(){return n(e)}):n(e,!0)}(this,function(e,n){function i(n,i,t){e.WeixinJSBridge?WeixinJSBridge.invoke(n,o(i),function(e){c(n,e,t)}):u(n,t)}function t(n,i,t){e.WeixinJSBridge?WeixinJSBridge.on(n,function(e){t&&t.trigger&&t.trigger(e),c(n,e,i)}):t?u(n,t):u(n,i)}function o(e){return e=e||{},e.appId=C.appId,e.verifyAppId=C.appId,e.verifySignType="sha1",e.verifyTimestamp=C.timestamp+"",e.verifyNonceStr=C.nonceStr,e.verifySignature=C.signature,e}function r(e){return{timeStamp:e.timestamp+"",nonceStr:e.nonceStr,package:e.package,paySign:e.paySign,signType:e.signType||"SHA1"}}function a(e){return e.postalCode=e.addressPostalCode,delete e.addressPostalCode,e.provinceName=e.proviceFirstStageName,delete e.proviceFirstStageName,e.cityName=e.addressCitySecondStageName,delete e.addressCitySecondStageName,e.countryName=e.addressCountiesThirdStageName,delete e.addressCountiesThirdStageName,e.detailInfo=e.addressDetailInfo,delete e.addressDetailInfo,e}function c(e,n,i){"openEnterpriseChat"==e&&(n.errCode=n.err_code),delete n.err_code,delete n.err_desc,delete n.err_detail;var t=n.errMsg;t||(t=n.err_msg,delete n.err_msg,t=s(e,t),n.errMsg=t),(i=i||{})._complete&&(i._complete(n),delete i._complete),t=n.errMsg||"",C.debug&&!i.isInnerInvoke&&alert(JSON.stringify(n));var o=t.indexOf(":");switch(t.substring(o+1)){case"ok":i.success&&i.success(n);break;case"cancel":i.cancel&&i.cancel(n);break;default:i.fail&&i.fail(n)}i.complete&&i.complete(n)}function s(e,n){var i=e,t=v[i];t&&(i=t);var o="ok";if(n){var r=n.indexOf(":");"confirm"==(o=n.substring(r+1))&&(o="ok"),"failed"==o&&(o="fail"),-1!=o.indexOf("failed_")&&(o=o.substring(7)),-1!=o.indexOf("fail_")&&(o=o.substring(5)),"access denied"!=(o=(o=o.replace(/_/g," ")).toLowerCase())&&"no permission to execute"!=o||(o="permission denied"),"config"==i&&"function not exist"==o&&(o="ok"),""==o&&(o="fail")}return n=i+":"+o}function d(e){if(e){for(var n=0,i=e.length;n0){var n=e.split("?")[0],i=e.split("?")[1];return n+=".html",void 0!==i?n+"?"+i:n}}if(!e.jWeixin){var h={config:"preVerifyJSAPI",onMenuShareTimeline:"menu:share:timeline",onMenuShareAppMessage:"menu:share:appmessage",onMenuShareQQ:"menu:share:qq",onMenuShareWeibo:"menu:share:weiboApp",onMenuShareQZone:"menu:share:QZone",previewImage:"imagePreview",getLocation:"geoLocation",openProductSpecificView:"openProductViewWithPid",addCard:"batchAddCard",openCard:"batchViewCard",chooseWXPay:"getBrandWCPayRequest",openEnterpriseRedPacket:"getRecevieBizHongBaoRequest",startSearchBeacons:"startMonitoringBeacons",stopSearchBeacons:"stopMonitoringBeacons",onSearchBeacons:"onBeaconsInRange",consumeAndShareCard:"consumedShareCard",openAddress:"editAddress"},v=function(){var e={};for(var n in h)e[h[n]]=n;return e}(),I=e.document,S=I.title,y=navigator.userAgent.toLowerCase(),_=navigator.platform.toLowerCase(),w=!(!_.match("mac")&&!_.match("win")),T=-1!=y.indexOf("wxdebugger"),k=-1!=y.indexOf("micromessenger"),M=-1!=y.indexOf("android"),P=-1!=y.indexOf("iphone")||-1!=y.indexOf("ipad"),x=function(){var e=y.match(/micromessenger\/(\d+\.\d+\.\d+)/)||y.match(/micromessenger\/(\d+\.\d+)/);return e?e[1]:""}(),V={initStartTime:p(),initEndTime:0,preVerifyStartTime:0,preVerifyEndTime:0},A={version:1,appId:"",initTime:0,preVerifyTime:0,networkType:"",isPreVerifyOk:1,systemType:P?1:M?2:-1,clientVersion:x,url:encodeURIComponent(location.href)},C={},L={_completes:[]},B={state:0,data:{}};f(function(){V.initEndTime=p()});var E=!1,O=[],N={config:function(e){C=e,u("config",e);var n=!1!==C.check;f(function(){if(n)i(h.config,{verifyJsApiList:d(C.jsApiList)},function(){L._complete=function(e){V.preVerifyEndTime=p(),B.state=1,B.data=e},L.success=function(e){A.isPreVerifyOk=0},L.fail=function(e){L._fail?L._fail(e):B.state=-1};var e=L._completes;return e.push(function(){l()}),L.complete=function(n){for(var i=0,t=e.length;i0){var n=O.shift();wx.getLocalImgData(n)}},e))):O.push(e)},getNetworkType:function(e){var n=function(e){var n=e.errMsg;e.errMsg="getNetworkType:ok";var i=e.subtype;if(delete e.subtype,i)e.networkType=i;else{var t=n.indexOf(":"),o=n.substring(t+1);switch(o){case"wifi":case"edge":case"wwan":e.networkType=o;break;default:e.errMsg="getNetworkType:fail"}}return e};i("getNetworkType",{},(e._complete=function(e){e=n(e)},e))},openLocation:function(e){i("openLocation",{latitude:e.latitude,longitude:e.longitude,name:e.name||"",address:e.address||"",scale:e.scale||28,infoUrl:e.infoUrl||""},e)},getLocation:function(e){e=e||{},i(h.getLocation,{type:e.type||"wgs84"},(e._complete=function(e){delete e.type},e))},hideOptionMenu:function(e){i("hideOptionMenu",{},e)},showOptionMenu:function(e){i("showOptionMenu",{},e)},closeWindow:function(e){i("closeWindow",{},e=e||{})},hideMenuItems:function(e){i("hideMenuItems",{menuList:e.menuList},e)},showMenuItems:function(e){i("showMenuItems",{menuList:e.menuList},e)},hideAllNonBaseMenuItem:function(e){i("hideAllNonBaseMenuItem",{},e)},showAllNonBaseMenuItem:function(e){i("showAllNonBaseMenuItem",{},e)},scanQRCode:function(e){i("scanQRCode",{needResult:(e=e||{}).needResult||0,scanType:e.scanType||["qrCode","barCode"]},(e._complete=function(e){if(P){var n=e.resultStr;if(n){var i=JSON.parse(n);e.resultStr=i&&i.scan_code&&i.scan_code.scan_result}}},e))},openAddress:function(e){i(h.openAddress,{},(e._complete=function(e){e=a(e)},e))},openProductSpecificView:function(e){i(h.openProductSpecificView,{pid:e.productId,view_type:e.viewType||0,ext_info:e.extInfo},e)},addCard:function(e){for(var n=e.cardList,t=[],o=0,r=n.length;o