Last active
April 12, 2024 06:23
-
-
Save icai/a0e1767ec536d43123c305c91041b1c6 to your computer and use it in GitHub Desktop.
支付宝 appx/web-view.js 源代码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*! | |
| * | |
| * ap/v1.25.9 | |
| * Mon Jun 20 2022 08:37:45 GMT+0000 (Coordinated Universal Time) | |
| * | |
| */ | |
| var myApp = (function (modules) { | |
| var moduleCache = {}; | |
| function require(moduleId) { | |
| if (moduleCache[moduleId]) return moduleCache[moduleId].exports; | |
| var module = (moduleCache[moduleId] = { | |
| id: moduleId, | |
| loaded: false, | |
| exports: {}, | |
| }); | |
| modules[moduleId].call( | |
| module.exports, | |
| module, | |
| module.exports, | |
| require | |
| ); | |
| module.loaded = true; | |
| return module.exports; | |
| } | |
| require.m = modules; | |
| require.c = moduleCache; | |
| require.d = function (exports, name, getter) { | |
| if (!require.o(exports, name)) { | |
| Object.defineProperty(exports, name, { enumerable: true, get: getter }); | |
| } | |
| }; | |
| require.r = function (exports) { | |
| if (typeof Symbol !== "undefined" && Symbol.toStringTag) { | |
| Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); | |
| } | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| }; | |
| require.t = function (value, mode) { | |
| if (mode & 1) value = require(value); | |
| if (mode & 8) return value; | |
| if (mode & 4 && typeof value === "object" && value && value.__esModule) | |
| return value; | |
| var ns = Object.create(null); | |
| require.r(ns); | |
| Object.defineProperty(ns, "default", { enumerable: true, value: value }); | |
| if (mode & 2 && typeof value != "string") | |
| for (var key in value) | |
| require.d( | |
| ns, | |
| key, | |
| function (key) { | |
| return value[key]; | |
| }.bind(null, key) | |
| ); | |
| return ns; | |
| }; | |
| require.n = function (module) { | |
| var getter = | |
| module && module.__esModule | |
| ? function () { | |
| return module.default; | |
| } | |
| : function () { | |
| return module; | |
| }; | |
| require.d(getter, "a", getter); | |
| return getter; | |
| }; | |
| require.o = function (object, property) { | |
| return Object.prototype.hasOwnProperty.call(object, property); | |
| }; | |
| require.p = ""; | |
| return require(require.s = 1); | |
| })([ | |
| function (module, exports) { | |
| function assign(target) { | |
| for (var i = 1; i < arguments.length; i++) { | |
| var source = arguments[i]; | |
| for (var key in source) { | |
| if (Object.prototype.hasOwnProperty.call(source, key)) { | |
| target[key] = source[key]; | |
| } | |
| } | |
| } | |
| return target; | |
| } | |
| module.exports = assign; | |
| }, | |
| function (module, __webpack_exports__, __webpack_require__) { | |
| "use strict"; | |
| __webpack_require__.r(__webpack_exports__); | |
| var _assign__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); | |
| var _assign__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n( | |
| _assign__WEBPACK_IMPORTED_MODULE_0__ | |
| ); | |
| var getKeys = function (obj) { | |
| return obj && typeof obj === "object" ? Object.keys(obj) : []; | |
| }; | |
| function parseParam(format, value) { | |
| var token, | |
| parsedValue, | |
| parsedToken, | |
| result = {}; | |
| switch (format) { | |
| case "%s": | |
| parsedValue = | |
| typeof value === "object" ? JSON.stringify(value) : value + ""; | |
| break; | |
| case "%c": | |
| if (value.startsWith("#")) value = value.substring(1); | |
| if (value.length === 3) value = value.replace(/(.)/g, "$1$1"); | |
| parsedValue = parseInt(value, 16); | |
| if (isNaN(parsedValue)) | |
| console.error(value + " is an invalid hex color."); | |
| break; | |
| case "%b": | |
| if (typeof value === "string") | |
| value = value.replace(/^data:(\/|\w|\-|\.)+;base64,/i, ""); | |
| parsedValue = value; | |
| break; | |
| case "%d": | |
| parsedValue = parseInt(value, 10); | |
| break; | |
| case "%f": | |
| parsedValue = parseFloat(value); | |
| break; | |
| default: | |
| parsedValue = value; | |
| break; | |
| } | |
| return parsedValue; | |
| } | |
| function applyFormat(target, source, defaultValues) { | |
| getKeys(source).forEach(function (key) { | |
| var tokenMatch = source[key].match(/(\w+)(%\w)$/i); | |
| var tokenObj = { key: source[key] }; | |
| if (tokenMatch) { | |
| tokenObj.key = tokenMatch[1]; | |
| tokenObj.type = tokenMatch[2]; | |
| } | |
| if ( | |
| key in target || | |
| (defaultValues && key in defaultValues && !(tokenObj.key in target)) | |
| ) { | |
| if (target[tokenObj.key] === undefined) { | |
| target[tokenObj.key] = parseParam( | |
| tokenObj.type, | |
| defaultValues ? defaultValues[key] : target[key] | |
| ); | |
| if (tokenObj.key !== key) delete target[key]; | |
| } | |
| } | |
| }); | |
| return target; | |
| } | |
| function handleCallback(options, callback) { | |
| var completeFn = options.complete || function () {}; | |
| var successFn = options.success || function () {}; | |
| var failFn = options.fail || function () {}; | |
| if (callback && callback.error) failFn(callback); | |
| else if (successFn && callback) successFn(callback); | |
| completeFn(callback); | |
| } | |
| var imagePreviewDefaults = { | |
| current: "init%d", | |
| enableSavePhoto: "enablesavephoto", | |
| }; | |
| var imageChooseDefaults = { | |
| count: 1, | |
| sourceType: ["camera"], | |
| }; | |
| var imageChooseTransforms = { | |
| before: function (options) { | |
| applyFormat(options, imageChooseDefaults); | |
| }, | |
| after: function (options) { | |
| applyFormat(options, { | |
| errorCode: "error", | |
| errorDesc: "errorMessage", | |
| localIds: "apFilePaths", | |
| tempFilePaths: "apFilePaths", | |
| }); | |
| if (typeof options.apFilePaths === "string") | |
| options.apFilePaths = JSON.parse(options.apFilePaths); | |
| options.tempFilePaths = options.apFilePaths; | |
| }, | |
| }; | |
| var imageViewerTransforms = { | |
| method: "imageViewer", | |
| before: function (options) { | |
| applyFormat(options, { current: "init%d", enableSavePhoto: "enablesavephoto" }); | |
| options.init = options.init || 0; | |
| options.images = []; | |
| (options.urls || []).forEach(function (url) { | |
| options.images.push({ url: url }); | |
| }); | |
| delete options.urls; | |
| }, | |
| }; | |
| var userAgent = navigator.userAgent || navigator.swuserAgent; | |
| var isAlipay = !!userAgent.match(/Alipay/); | |
| var versionMatch = userAgent.match(/AlipayApp\((\S*)\)/); | |
| var aliAppVersion = ["", "0.0.0"]; | |
| if (versionMatch) { | |
| aliAppVersion = versionMatch[1].split("/")[1].match(/(\d+\.\d+\.\d+)/); | |
| } | |
| var alipayLite = userAgent.match(/Griver\/(\d+\.\d+\.\d+)/); | |
| var alipayVersion = alipayLite | |
| ? aliAppVersion | |
| : userAgent.match(/Ariver\/(\d+\.\d+\.\d+)/) | |
| ? aliAppVersion | |
| : ["", "0.0.0"]; | |
| var alipayVersionParts = alipayVersion[1].split(".").map(function (part) { | |
| return Number(part); | |
| }); | |
| var isGriver = alipayLite || !!userAgent.match(/Griver/); | |
| var isWindows = userAgent.indexOf("Windows") > -1; | |
| var isMac = userAgent.indexOf("Macintosh") > -1; | |
| var isAndroid = userAgent.indexOf("Android") > -1; | |
| var isiOS = !!userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); | |
| var languageMatch = userAgent.match(/Language\/(\S+)/); | |
| var language = languageMatch ? languageMatch[1] : ""; | |
| function checkUCBS() { | |
| var ucbsMatch = userAgent.match(/UCBS\/(\d+\.\d+)/); | |
| return (ucbsMatch && ucbsMatch[1]) || ""; | |
| } | |
| checkUCBS(); | |
| function openInBrowser(api, url, login, installed, extraQuery, isLite) { | |
| if ("installed" in installed) { | |
| var isTaobaoInstalled = function (cb) { | |
| var scheme = isLite ? "taobaolite://" : "taobao://"; | |
| var packageName = isLite ? "com.taobao.litetao" : "com.taobao.taobao"; | |
| api( | |
| "isInstalledApp", | |
| { packagename: packageName, scheme: scheme }, | |
| function (response) { | |
| if (response.error) { | |
| console.warn("openTaobao does not have permission", response); | |
| } else { | |
| if (login) { | |
| api("getLoginToken", {}, function (res) { | |
| var token = null; | |
| var encrypted = false; | |
| if (res.token !== "" && "token" in res) { | |
| token = res.token; | |
| encrypted = res.encrypted; | |
| } | |
| if (token) { | |
| url += "&loginToken=" + token + "&tokenEncrypted=" + encrypted; | |
| } | |
| api("openInBrowser", { url: url }); | |
| }); | |
| } else { | |
| api("openInBrowser", { url: url }); | |
| } | |
| } | |
| } | |
| ); | |
| api("remoteLog", { | |
| bizType: "TINYAPP", | |
| seedId: "APPX_OPEN_TAOBAO", | |
| type: "monitor", | |
| param1: url, | |
| }); | |
| }; | |
| isTaobaoInstalled(); | |
| } else { | |
| var downloadUrl = isLite | |
| ? "https://pages.tmall.com/wow/sale/act/download-page-new" | |
| : "https://h5.m.taobao.com/bcec/downloadTaobao.html"; | |
| if (typeof extraQuery === "string") downloadUrl += "?" + extraQuery; | |
| api("openInBrowser", { url: downloadUrl }); | |
| } | |
| } | |
| var storageAPI = function () { | |
| return { | |
| setStorage: { | |
| method: "setTinyLocalStorage", | |
| before: function (options) { | |
| options.value = JSON.stringify({ APDataStorage: options.data }); | |
| options.data = options.value; | |
| options.key = String(options.key); | |
| options.type = "user"; | |
| }, | |
| }, | |
| getStorage: { | |
| method: "getTinyLocalStorage", | |
| before: function (options) { | |
| options.key = String(options.key); | |
| options.type = "user"; | |
| }, | |
| after: function (response) { | |
| if (response.error === 11) { | |
| response.data = null; | |
| delete response.error; | |
| delete response.errorMessage; | |
| delete response.success; | |
| } | |
| if (response.data) { | |
| var data = JSON.parse(response.data); | |
| response.data = data.APDataStorage; | |
| } | |
| }, | |
| }, | |
| removeStorage: { | |
| method: "removeTinyLocalStorage", | |
| before: function (options) { | |
| options.key = String(options.key); | |
| options.type = "user"; | |
| }, | |
| }, | |
| clearStorage: { | |
| method: "clearTinyLocalStorage", | |
| before: function (options) { | |
| options.type = "user"; | |
| }, | |
| }, | |
| getStorageInfo: { method: "getTinyLocalStorageInfo" }, | |
| }; | |
| }; | |
| var insidePlus = userAgent.indexOf("InsidePlus") > -1; | |
| var isDingTalk = userAgent.toLowerCase().indexOf("dingtalk") > -1 && !insidePlus; | |
| var bridgeReady = new Promise(function (resolve) { | |
| window.AlipayJSBridge ? resolve() : document.addEventListener("AlipayJSBridgeReady", resolve); | |
| }); | |
| var AlipayBridge = self; | |
| var alipayBridgeMethods = { | |
| call: function () { | |
| for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | |
| args[_key] = arguments[_key]; | |
| } | |
| bridgeReady.then(function () { | |
| var _AlipayJSBridge; | |
| (_AlipayJSBridge = AlipayBridge).call.apply(_AlipayJSBridge, args); | |
| }); | |
| }, | |
| postMessage: function (data) { | |
| bridgeReady.then(function () { | |
| var message = { type: "message", detail: data }; | |
| AlipayBridge.AlipayJSBridge.call("postWebViewMessage", message); | |
| }); | |
| }, | |
| getEnv: function (callback) { | |
| var ua = navigator.userAgent; | |
| if (ua.indexOf("Nebula") === -1 && ua.indexOf("Ariver") === -1) { | |
| callback && callback({ miniprogram: false }); | |
| } else { | |
| bridgeReady.then(function () { | |
| AlipayBridge.AlipayJSBridge.call("getEmbedWebViewEnv", function (env) { | |
| callback && callback(env); | |
| }); | |
| }); | |
| } | |
| }, | |
| startShare: function () { | |
| AlipayBridge.AlipayJSBridge.call("postWebViewMessage", { type: "webViewShare" }); | |
| }, | |
| }; | |
| [ | |
| "navigateTo", | |
| "navigateBack", | |
| "switchTab", | |
| "reLaunch", | |
| "redirectTo", | |
| ].forEach(function (method) { | |
| alipayBridgeMethods[method] = function (options) { | |
| bridgeReady.then(function () { | |
| var params = Object.assign({}, options); | |
| var successFn = options.success || function () {}; | |
| var completeFn = options.complete || function () {}; | |
| var failFn = options.fail || function () {}; | |
| if (params.success || params.complete || params.fail) { | |
| W[++V] = Object.assign({}, params); | |
| delete params.success; | |
| delete params.complete; | |
| delete params.fail; | |
| } | |
| AlipayBridge.AlipayJSBridge.call("postWebViewMessage", { | |
| type: method, | |
| callback: V, | |
| param: params, | |
| }); | |
| }); | |
| }; | |
| }); | |
| var nativeAPIs = { | |
| alert: { | |
| before: function (options) { | |
| applyFormat(options, { content: "message%s", buttonText: "button%s" }); | |
| }, | |
| }, | |
| showLoading: { | |
| before: function (options) { | |
| applyFormat(options, { content: "text%s" }); | |
| }, | |
| }, | |
| hideLoading: {}, | |
| previewImage: { | |
| method: "imageViewer", | |
| before: function (options) { | |
| applyFormat(options, { current: "init%d", enableSavePhoto: "enablesavephoto" }); | |
| options.init = options.init || 0; | |
| options.images = []; | |
| (options.urls || []).forEach(function (url) { | |
| options.images.push({ u: url }); | |
| }); | |
| delete options.urls; | |
| }, | |
| }, | |
| chooseImage: { | |
| before: function (options) { | |
| applyFormat(options, { content: "message%s", buttonText: "button%s" }); | |
| }, | |
| after: function (response) { | |
| applyFormat(response, { | |
| errorCode: "error", | |
| errorDesc: "errorMessage", | |
| localIds: "apFilePaths", | |
| tempFilePaths: "apFilePaths", | |
| }); | |
| if (typeof response.apFilePaths === "string") { | |
| response.apFilePaths = JSON.parse(response.apFilePaths); | |
| } | |
| response.tempFilePaths = response.apFilePaths; | |
| }, | |
| }, | |
| getNetworkType: { | |
| after: function (response) { | |
| if (response.networkInfo) { | |
| response.networkType = response.networkInfo.toUpperCase(); | |
| } | |
| }, | |
| }, | |
| openLocation: { | |
| before: function (options) { | |
| options.scale = options.scale || 15; | |
| options.hidden = "1"; | |
| }, | |
| }, | |
| openTaobao: bridgeReady.then(function () { | |
| return { | |
| method: function (options) { | |
| var api = function () { | |
| return AlipayBridge.AlipayJSBridge.call; | |
| }; | |
| var isLite = options.isLite; | |
| var action = options.url; | |
| api( | |
| "isInstalledApp", | |
| { | |
| packagename: isLite | |
| ? "com.taobao.litetao" | |
| : "com.taobao.taobao", | |
| scheme: isLite ? "taobaolite://" : "taobao://", | |
| }, | |
| function (response) { | |
| openInBrowser( | |
| api, | |
| action, | |
| options.login, | |
| response, | |
| options.extraQuery, | |
| isLite | |
| ); | |
| } | |
| ); | |
| api("remoteLog", { | |
| bizType: "TINYAPP", | |
| seedId: "APPX_OPEN_TAOBAO", | |
| type: "monitor", | |
| param1: action, | |
| }); | |
| }, | |
| }; | |
| }), | |
| tradePay: {}, | |
| getLocation: bridgeReady.then(function () { | |
| return { | |
| method: "getCurrentLocation", | |
| before: function (options) { | |
| applyFormat(options, { accuracy: "horizontalAccuracy", type: "requestType" }); | |
| options.requestType = options.requestType || 0; | |
| options.useDefault = true; | |
| options.bizType = options.bizType | |
| ? AlipayBridge.AlipayJSBridge.startupParams.parentAppId + | |
| "-" + | |
| options.bizType | |
| : AlipayBridge.AlipayJSBridge.startupParams.parentAppId; | |
| if (isAndroid) { | |
| options.isHighAccuracy = options.isHighAccuracy === undefined ? true : options.isHighAccuracy; | |
| options.isNeedSpeed = options.isNeedSpeed === undefined ? true : options.isNeedSpeed; | |
| } | |
| }, | |
| after: function (response) { | |
| applyFormat(response, { citycode: "cityCode", adcode: "adCode" }); | |
| if (!response.city && response.province) { | |
| response.city = response.province; | |
| } | |
| if (response.latitude) response.latitude = response.latitude.toString(); | |
| if (response.longitude) response.longitude = response.longitude.toString(); | |
| if (response.accuracy) { | |
| response.accuracy = response.accuracy.toString(); | |
| response.horizontalAccuracy = response.accuracy; | |
| } | |
| delete response.speed; | |
| }, | |
| }; | |
| }), | |
| }; | |
| if (isDingTalk) { | |
| [ | |
| "setStorage", | |
| "getStorage", | |
| "removeStorage", | |
| "clearStorage", | |
| "getStorageInfo", | |
| "tradePay", | |
| ].forEach(function (method) { | |
| delete nativeAPIs[method]; | |
| }); | |
| } | |
| var methods = Object.keys(nativeAPIs); | |
| methods.forEach(function (method) { | |
| alipayBridgeMethods[method] = function (options) { | |
| bridgeReady.then(function () { | |
| var nativeMethod = nativeAPIs[method] || {}; | |
| if (nativeMethod instanceof Promise) { | |
| nativeMethod.then(function (resolvedMethod) { | |
| invokeAlipayJSBridge(options, method, resolvedMethod); | |
| }); | |
| } else { | |
| invokeAlipayJSBridge(options, method, nativeMethod); | |
| } | |
| }); | |
| }; | |
| }); | |
| function invokeAlipayJSBridge(options, method, nativeMethod) { | |
| var hasCallback = options.callback !== false; | |
| var _ref = (function (options, nativeMethod) { | |
| var params = Object.assign({}, options); | |
| var callbackParams = { | |
| success: params.success || U, | |
| fail: params.fail || U, | |
| complete: params.complete || U, | |
| }; | |
| delete params.success; | |
| delete params.fail; | |
| delete params.complete; | |
| if (nativeMethod && nativeMethod.before) { | |
| nativeMethod.before(params); | |
| } | |
| return { newParam: params, callbackParam: callbackParams, apiName: nativeMethod.method ? nativeMethod.method : method }; | |
| })(options, nativeMethod); | |
| var newParam = _ref.newParam; | |
| var callbackParam = _ref.callbackParam; | |
| var apiName = _ref.apiName; | |
| if (nativeMethod.after) { | |
| nativeMethod.after(apiName); | |
| } | |
| if (options === undefined) { | |
| AlipayBridge.AlipayJSBridge.call(apiName); | |
| } else { | |
| var bridgeCall = AlipayBridge.AlipayJSBridge.call.bind( | |
| AlipayBridge.AlipayJSBridge, | |
| apiName, | |
| newParam | |
| ); | |
| if (hasCallback) { | |
| bridgeCall(function (response) { | |
| var res = response; | |
| if (nativeMethod.after) nativeMethod.after(res); | |
| callbackParam.success(res); | |
| callbackParam.complete(res); | |
| callbackParam.fail(res); | |
| }); | |
| } else { | |
| bridgeCall(); | |
| } | |
| } | |
| } | |
| var AliPay = { | |
| call: function call() { | |
| for ( | |
| var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; | |
| _key2 < _len2; | |
| _key2++ | |
| ) { | |
| args[_key2] = arguments[_key2]; | |
| } | |
| bridgeReady.then(function () { | |
| var _AlipayJSBridge2; | |
| (_AlipayJSBridge2 = AlipayBridge).call.apply(_AlipayJSBridge2, args); | |
| }); | |
| }, | |
| postMessage: function postMessage(data) { | |
| bridgeReady.then(function () { | |
| var message = { | |
| type: "message", | |
| detail: data, | |
| }; | |
| AlipayBridge.AlipayJSBridge.call("postWebViewMessage", message); | |
| }); | |
| }, | |
| getEnv: function getEnv(callback) { | |
| var ua = navigator.userAgent; | |
| if (ua.indexOf("Nebula") === -1 && ua.indexOf("Ariver") === -1) { | |
| callback && | |
| callback({ | |
| miniprogram: false, | |
| }); | |
| } else { | |
| bridgeReady.then(function () { | |
| AlipayBridge.AlipayJSBridge.call("getEmbedWebViewEnv", function ( | |
| env | |
| ) { | |
| callback && | |
| callback(env); | |
| }); | |
| }); | |
| } | |
| }, | |
| startShare: function startShare() { | |
| AlipayBridge.AlipayJSBridge.call("postWebViewMessage", { | |
| type: "webViewShare", | |
| }); | |
| }, | |
| }; | |
| [ | |
| "navigateTo", | |
| "navigateBack", | |
| "switchTab", | |
| "reLaunch", | |
| "redirectTo", | |
| ].forEach(function (method) { | |
| AliPay[method] = function (options) { | |
| bridgeReady.then(function () { | |
| var params = Object.assign({}, options); | |
| var successFn = options.success || function () {}; | |
| var completeFn = options.complete || function () {}; | |
| var failFn = options.fail || function () {}; | |
| if (params.success || params.complete || params.fail) { | |
| W[++V] = Object.assign({}, params); | |
| delete params.success; | |
| delete params.complete; | |
| delete params.fail; | |
| } | |
| AlipayBridge.AlipayJSBridge.call("postWebViewMessage", { | |
| type: method, | |
| callback: V, | |
| param: params, | |
| }); | |
| }); | |
| }; | |
| }); | |
| var AlipayBridge_1 = AliPay; | |
| var navigator$1 = window.navigator; | |
| if (navigator$1.userAgent.indexOf("Alipay") !== -1) { | |
| if (window.AlipayJSBridge) { | |
| AlipayBridge_1.AlipayJSBridge = window.AlipayJSBridge; | |
| } else { | |
| document.addEventListener( | |
| "AlipayJSBridgeReady", | |
| function () { | |
| AlipayBridge_1.AlipayJSBridge = window.AlipayJSBridge; | |
| }, | |
| false | |
| ); | |
| } | |
| } | |
| exports.assign = _assign__WEBPACK_IMPORTED_MODULE_0___default.a; | |
| exports.openTaobao = function (url, isLite, login, extraQuery) { | |
| var api = function () { | |
| return window.AlipayJSBridge.call; | |
| }; | |
| api( | |
| "isInstalledApp", | |
| { | |
| packagename: isLite ? "com.taobao.litetao" : "com.taobao.taobao", | |
| scheme: isLite ? "taobaolite://" : "taobao://", | |
| }, | |
| function (response) { | |
| openInBrowser(api, url, login, response, extraQuery, isLite); | |
| } | |
| ); | |
| api("remoteLog", { | |
| bizType: "TINYAPP", | |
| seedId: "APPX_OPEN_TAOBAO", | |
| type: "monitor", | |
| param1: url, | |
| }); | |
| }; | |
| exports.getEnv = function (callback) { | |
| var ua = navigator.userAgent; | |
| if (ua.indexOf("Nebula") === -1 && ua.indexOf("Ariver") === -1) { | |
| callback && | |
| callback({ | |
| miniprogram: false, | |
| }); | |
| } else { | |
| window.AlipayJSBridge.call("getEmbedWebViewEnv", function (env) { | |
| callback && | |
| callback(env); | |
| }); | |
| } | |
| }; | |
| exports.startShare = function () { | |
| window.AlipayJSBridge.call("postWebViewMessage", { | |
| type: "webViewShare", | |
| }); | |
| }; | |
| exports.default = AlipayBridge_1; | |
| }, | |
| ]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*! | |
| * | |
| * ap/v1.25.9 | |
| * Mon Jun 20 2022 08:37:45 GMT+0000 (Coordinated Universal Time) | |
| * | |
| */ | |
| var my = (function (e) { | |
| var t = {}; | |
| function n(a) { | |
| if (t[a]) return t[a].exports; | |
| var r = (t[a] = { i: a, l: !1, exports: {} }); | |
| return e[a].call(r.exports, r, r.exports, n), (r.l = !0), r.exports; | |
| } | |
| return ( | |
| (n.m = e), | |
| (n.c = t), | |
| (n.d = function (e, t, a) { | |
| n.o(e, t) || Object.defineProperty(e, t, { enumerable: !0, get: a }); | |
| }), | |
| (n.r = function (e) { | |
| "undefined" != typeof Symbol && | |
| Symbol.toStringTag && | |
| Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), | |
| Object.defineProperty(e, "__esModule", { value: !0 }); | |
| }), | |
| (n.t = function (e, t) { | |
| if ((1 & t && (e = n(e)), 8 & t)) return e; | |
| if (4 & t && "object" == typeof e && e && e.__esModule) return e; | |
| var a = Object.create(null); | |
| if ( | |
| (n.r(a), | |
| Object.defineProperty(a, "default", { enumerable: !0, value: e }), | |
| 2 & t && "string" != typeof e) | |
| ) | |
| for (var r in e) | |
| n.d( | |
| a, | |
| r, | |
| function (t) { | |
| return e[t]; | |
| }.bind(null, r) | |
| ); | |
| return a; | |
| }), | |
| (n.n = function (e) { | |
| var t = | |
| e && e.__esModule | |
| ? function () { | |
| return e.default; | |
| } | |
| : function () { | |
| return e; | |
| }; | |
| return n.d(t, "a", t), t; | |
| }), | |
| (n.o = function (e, t) { | |
| return Object.prototype.hasOwnProperty.call(e, t); | |
| }), | |
| (n.p = ""), | |
| n((n.s = 1)) | |
| ); | |
| })([ | |
| function (e, t) { | |
| function n() { | |
| return ( | |
| (e.exports = n = | |
| Object.assign || | |
| function (e) { | |
| for (var t = 1; t < arguments.length; t++) { | |
| var n = arguments[t]; | |
| for (var a in n) | |
| Object.prototype.hasOwnProperty.call(n, a) && (e[a] = n[a]); | |
| } | |
| return e; | |
| }), | |
| n.apply(this, arguments) | |
| ); | |
| } | |
| e.exports = n; | |
| }, | |
| function (e, t, n) { | |
| "use strict"; | |
| n.r(t); | |
| var a = n(0), | |
| r = n.n(a); | |
| var o = function (e) { | |
| return e && "object" == typeof e ? Object.keys(e) : []; | |
| }; | |
| function i(e, t) { | |
| var n, a, r, o; | |
| return ( | |
| "%s" === e | |
| ? (t = "object" == typeof (o = t) ? JSON.stringify(o) : o + "") | |
| : "%c" === e | |
| ? (0 === (r = "" + (a = t)).indexOf("#") && (r = r.substr(1)), | |
| 3 === r.length && (r = r.replace(/(.)/g, "$1$1")), | |
| (r = parseInt(r, 16)), | |
| isNaN(r) && console.error(a + " is invalid hex color."), | |
| (t = r)) | |
| : "%b" === e | |
| ? ("string" == typeof (n = t) && | |
| (n = n.replace(/^data:(\/|\w|\-|\.)+;base64,/i, "")), | |
| (t = n)) | |
| : "%d" === e | |
| ? (t = parseInt(t, 10)) | |
| : "%f" === e && (t = parseFloat(t)), | |
| t | |
| ); | |
| } | |
| function c(e, t, n) { | |
| var a; | |
| return ( | |
| (n = n || {}), | |
| o(t).forEach(function (r) { | |
| var o, | |
| c, | |
| s, | |
| l = t[r]; | |
| (c = ((o = l) || "").match(/(\w+)(%\w)$/i)), | |
| (s = { k: o }), | |
| c && ((s.k = c[1]), (s.t = c[2])), | |
| void 0 !== (l = (a = s).k) && | |
| (r in e || r in n) && | |
| void 0 === e[l] && | |
| ((e[l] = i(a.t, void 0 === n[r] ? e[r] : n[r])), | |
| l !== r && delete e[r]); | |
| }), | |
| e | |
| ); | |
| } | |
| function s(e, t) { | |
| void 0 === e && (e = {}); | |
| var n = e, | |
| a = n.complete, | |
| r = n.success, | |
| o = n.fail; | |
| t && t.error ? o && o(t) : r && r(t), a && a(t); | |
| } | |
| var l, | |
| u = { | |
| b: function (e) { | |
| c(e, { content: "message%s", buttonText: "button%s" }); | |
| }, | |
| }, | |
| d = { | |
| b: function (e) { | |
| c(e, { content: "text%s" }); | |
| }, | |
| }, | |
| f = { | |
| b: function (e) { | |
| (e.count = e.count || 1), | |
| "string" == typeof e.sourceType && (e.sourceType = [e.sourceType]); | |
| }, | |
| a: function (e) { | |
| c(e, { | |
| errorCode: "error", | |
| errorDesc: "errorMessage", | |
| localIds: "apFilePaths", | |
| tempFilePaths: "apFilePaths", | |
| }), | |
| "string" == typeof e.apFilePaths && | |
| (e.apFilePaths = JSON.parse(e.apFilePaths)), | |
| (e.tempFilePaths = e.apFilePaths); | |
| }, | |
| }, | |
| p = { | |
| m: "imageViewer", | |
| b: function (e) { | |
| c(e, { current: "init%d", enableSavePhoto: "enablesavephoto" }), | |
| e.init || (e.init = 0), | |
| (e.images = []), | |
| (e.urls || []).forEach(function (t) { | |
| e.images.push({ u: t }); | |
| }), | |
| delete e.urls; | |
| }, | |
| }, | |
| g = navigator.userAgent || navigator.swuserAgent, | |
| y = | |
| (g.match(/Ariver\/(\d+\.\d+\.\d+)/), | |
| g.match(/Griver\/(\d+\.\d+\.\d+)/)), | |
| v = g.match(/DingMiniApp\/(\d+\.\d+\.\d+)/), | |
| m = g.match(/AliApp\((\S*)/), | |
| h = g.match(/AriverApp\((\S*)/), | |
| b = g.match(/GriverApp\((\S*)/), | |
| S = g.match(/TaurusApp\((\S*)/), | |
| A = | |
| (!!m && 2 === m.length && m[1].split("/")) || | |
| (!!h && 2 === h.length && h[1].split("/")) || | |
| (!!b && 2 === b.length && b[1].split("/")) || | |
| (!!S && 2 === S.length && S[1].split("/")), | |
| w = (g.match(/VGUI\/(\d+\.\d+\.\d+)/), ["", "0.0.0"]), | |
| O = g.match(/Language\/(\S+)/); | |
| A | |
| ? (A[0], (w = A[1].match(/(\d+\.\d+\.\d+)/)), v && ((l = w), (w = v))) | |
| : y && ("Griver", (w = y)); | |
| var P, | |
| T = w[1].split(".").map(function (e) { | |
| return Number(e); | |
| }), | |
| k = (T[0], T[1], T[2], g.indexOf("InsidePlus") > -1), | |
| x = | |
| (g.toLowerCase().indexOf("dingtalk"), | |
| g.indexOf("Windows"), | |
| g.indexOf("Macintosh"), | |
| w && w[1], | |
| l && l[1], | |
| g.indexOf("Android") > -1); | |
| g.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), | |
| g.indexOf("AlipayIDE"), | |
| O && O[1], | |
| g.indexOf("Language/en"), | |
| g.indexOf("Language/zh-HK"); | |
| function B() { | |
| if (void 0 !== P) return P; | |
| var e = g.match(/UCBS\/(\d+\.\d+)/); | |
| return (P = (e && e[1]) || ""); | |
| } | |
| B(); | |
| function L(e, t, n, a, r, o) { | |
| "installed" in a && | |
| (function (e, t, n) { | |
| var a = /^(\w+):\/\//; | |
| e( | |
| "configService.getConfig", | |
| { configKey: "APPX_OPENTAOBAO_IN_BROWSER" }, | |
| function (e) { | |
| if (e.configKey) { | |
| var r; | |
| try { | |
| r = JSON.parse(e.configKey); | |
| } catch (e) { | |
| console.error(e); | |
| } | |
| var o = !1; | |
| if (Array.isArray(r) && t) { | |
| var i = t.match(a), | |
| c = i && i[1]; | |
| ((c && r.indexOf(c) > -1) || r.indexOf("*") > -1) && (o = !0); | |
| } | |
| n( | |
| o | |
| ? { success: !0 } | |
| : { error: 4, errorMessage: "无权调用该接口" } | |
| ); | |
| } else n({ success: !0 }); | |
| } | |
| ); | |
| })(e, t, function (i) { | |
| if (i.error) console.warn("openTaobao does not have permission", i); | |
| else if (a.installed) | |
| n | |
| ? e("getLoginToken", {}, function (n) { | |
| var a = null, | |
| r = !1; | |
| "token" in n && | |
| "" !== n.token && | |
| ((a = n.token), (r = n.encrypted)), | |
| a && (t += "&loginToken=" + a + "&tokenEncrypted=" + r), | |
| e("openInBrowser", { url: t }); | |
| }) | |
| : e("openInBrowser", { url: t }); | |
| else { | |
| var c = o | |
| ? "https://pages.tmall.com/wow/sale/act/download-page-new" | |
| : "https://h5.m.taobao.com/bcec/downloadTaobao.html"; | |
| "string" == typeof r && (c = c + "?" + r), | |
| e("openInBrowser", { url: c }); | |
| } | |
| }); | |
| } | |
| var I = function () { | |
| return { | |
| setStorage: { | |
| m: "setTinyLocalStorage", | |
| b: function (e) { | |
| (e.value = JSON.stringify({ APDataStorage: e.data })), | |
| (e.data = e.value), | |
| (e.key = String(e.key)), | |
| (e.type = "user"); | |
| }, | |
| }, | |
| getStorage: { | |
| m: "getTinyLocalStorage", | |
| b: function (e) { | |
| (e.key = String(e.key)), (e.type = "user"); | |
| }, | |
| a: function (e) { | |
| if ( | |
| (11 === e.error && | |
| ((e.data = null), | |
| delete e.error, | |
| delete e.errorMessage, | |
| delete e.success), | |
| e.data) | |
| ) { | |
| var t = JSON.parse(e.data); | |
| e.data = t.APDataStorage; | |
| } | |
| }, | |
| }, | |
| removeStorage: { | |
| m: "removeTinyLocalStorage", | |
| b: function (e) { | |
| (e.key = String(e.key)), (e.type = "user"); | |
| }, | |
| }, | |
| clearStorage: { | |
| m: "clearTinyLocalStorage", | |
| b: function (e) { | |
| e.type = "user"; | |
| }, | |
| }, | |
| getStorageInfo: { m: "getTinyLocalStorageInfo" }, | |
| }; | |
| }, | |
| J = navigator.userAgent || navigator.swuserAgent, | |
| N = J.indexOf("InsidePlus") > -1, | |
| E = J.toLowerCase().indexOf("dingtalk") > -1 && !N, | |
| M = new Promise(function (e) { | |
| window.AlipayJSBridge | |
| ? e() | |
| : document.addEventListener("AlipayJSBridgeReady", e); | |
| }), | |
| C = self, | |
| j = r()( | |
| { | |
| alert: u, | |
| showLoading: d, | |
| hideLoading: {}, | |
| previewImage: p, | |
| chooseImage: f, | |
| getNetworkType: { | |
| a: function (e) { | |
| e.networkInfo && (e.networkType = e.networkInfo.toUpperCase()); | |
| }, | |
| }, | |
| openLocation: { | |
| b: function (e) { | |
| (e.scale = e.scale || 15), (e.hidden = "1"); | |
| }, | |
| }, | |
| openTaobao: M.then(function () { | |
| return ( | |
| (e = function () { | |
| return C.AlipayJSBridge.call; | |
| }), | |
| { | |
| d: function (t) { | |
| var n = e(), | |
| a = t.isLite; | |
| n( | |
| "isInstalledApp", | |
| { | |
| packagename: a | |
| ? "com.taobao.litetao" | |
| : "com.taobao.taobao", | |
| scheme: a ? "taobaolite://" : "taobao://", | |
| }, | |
| function (e) { | |
| L(n, t.url, t.login, e, t.extraQuery, a); | |
| } | |
| ), | |
| n("remoteLog", { | |
| bizType: "TINYAPP", | |
| seedId: "APPX_OPEN_TAOBAO", | |
| type: "monitor", | |
| param1: t.url, | |
| }); | |
| }, | |
| } | |
| ); | |
| var e; | |
| }), | |
| tradePay: {}, | |
| getLocation: M.then(function () { | |
| return ( | |
| (e = function () { | |
| return C.AlipayJSBridge.startupParams.parentAppId; | |
| }), | |
| { | |
| m: "getCurrentLocation", | |
| b: function (t) { | |
| c(t, { accuracy: "horizontalAccuracy", type: "requestType" }), | |
| t.requestType || ((t.requestType = 0), (t.useDefault = !0)), | |
| (t.bizType = t.bizType ? e() + "-" + t.bizType : e()), | |
| x && | |
| (void 0 === t.isHighAccuracy && (t.isHighAccuracy = !0), | |
| void 0 === t.isNeedSpeed && (t.isNeedSpeed = !0)); | |
| }, | |
| a: function (e) { | |
| c(e, { citycode: "cityCode", adcode: "adCode" }), | |
| !e.city && e.province && (e.city = e.province), | |
| e.latitude && (e.latitude += ""), | |
| e.longitude && (e.longitude += ""), | |
| e.accuracy && | |
| ((e.accuracy += ""), (e.horizontalAccuracy = e.accuracy)), | |
| delete e.speed; | |
| }, | |
| } | |
| ); | |
| var e; | |
| }), | |
| }, | |
| I() | |
| ); | |
| E && | |
| [ | |
| "setStorage", | |
| "getStorage", | |
| "removeStorage", | |
| "clearStorage", | |
| "getStorageInfo", | |
| "tradePay", | |
| ].forEach(function (e) { | |
| delete j[e]; | |
| }); | |
| var _, | |
| D = self, | |
| F = new Promise(function (e) { | |
| window.AlipayJSBridge | |
| ? e() | |
| : document.addEventListener("AlipayJSBridgeReady", e); | |
| }), | |
| V = 0, | |
| W = {}, | |
| z = self, | |
| U = function () {}, | |
| G = function (e, t, n) { | |
| var a = !1 !== n.callback, | |
| o = (function (e, t, n) { | |
| var a = r()({}, e), | |
| o = { | |
| success: a.success || U, | |
| fail: a.fail || U, | |
| complete: a.complete || U, | |
| }; | |
| return ( | |
| delete a.success, | |
| delete a.fail, | |
| delete a.complete, | |
| n && n.b && n.b(a), | |
| { newParam: a, callbackParam: o, apiName: n.m ? n.m : t } | |
| ); | |
| })(e, t, n); | |
| if (n.d) n.d(o.newParam); | |
| else if (void 0 === e) z.AlipayJSBridge.call(o.apiName); | |
| else { | |
| var i = z.AlipayJSBridge.call.bind( | |
| z.AlipayJSBridge, | |
| o.apiName, | |
| o.newParam | |
| ); | |
| a | |
| ? i(function (e) { | |
| var t = e; | |
| n.a && n.a(t), s(o.callbackParam, t); | |
| }) | |
| : i(); | |
| } | |
| }, | |
| K = { | |
| call: function () { | |
| for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++) | |
| t[n] = arguments[n]; | |
| F.then(function () { | |
| var e; | |
| (e = z.AlipayJSBridge).call.apply(e, t); | |
| }); | |
| }, | |
| postMessage: function (e) { | |
| F.then(function () { | |
| var t = { type: "message", detail: e }; | |
| z.AlipayJSBridge.call("postWebViewMessage", t); | |
| }); | |
| }, | |
| getEnv: function (e) { | |
| var t = navigator.userAgent; | |
| -1 === t.indexOf("Nebula") && -1 === t.indexOf("Ariver") | |
| ? e && e({ miniprogram: !1 }) | |
| : F.then(function () { | |
| z.AlipayJSBridge.call("getEmbedWebViewEnv", function (t) { | |
| e && e(t); | |
| }); | |
| }); | |
| }, | |
| startShare: function () { | |
| z.AlipayJSBridge.call("postWebViewMessage", { type: "webViewShare" }); | |
| }, | |
| }; | |
| [ | |
| "navigateTo", | |
| "navigateBack", | |
| "switchTab", | |
| "reLaunch", | |
| "redirectTo", | |
| ].forEach(function (e) { | |
| K[e] = function (t) { | |
| F.then(function () { | |
| var n = r()({}, t); | |
| (n.success || n.complete || n.fail) && | |
| ((W[++V] = r()({}, n)), | |
| delete n.success, | |
| delete n.complete, | |
| delete n.fail), | |
| z.AlipayJSBridge.call("postWebViewMessage", { | |
| type: e, | |
| callback: V, | |
| param: n, | |
| }); | |
| }); | |
| }; | |
| }), | |
| o(j).forEach(function (e) { | |
| K[e] = function (t) { | |
| F.then(function () { | |
| var n = j[e] || {}; | |
| n instanceof Promise | |
| ? n.then(function (n) { | |
| G(t, e, n); | |
| }) | |
| : G(t, e, n); | |
| }); | |
| }; | |
| }), | |
| document.addEventListener("onToWebViewMessage", function (e) { | |
| var t = e.data, | |
| n = t.callback, | |
| a = t.res; | |
| "response" === a.type | |
| ? W[n] && (s(W[n], a.res), delete W[n]) | |
| : "message" === a.type && | |
| K.onMessage && | |
| K.onMessage(JSON.parse(a.data)); | |
| }), | |
| (_ = K), | |
| E && | |
| ((D.dd = _), | |
| Object.defineProperties(D.dd, { | |
| enableUrlChangeDetect: { | |
| set: function (e) { | |
| !0 === e && | |
| (function () { | |
| var e = self; | |
| if (!e._urlChangeDetected) { | |
| var t = e.history || {}; | |
| (t.pushState = r(t, "pushState")), | |
| (t.replaceState = r(t, "replaceState")), | |
| n(e, "popstate", function () { | |
| a(); | |
| }), | |
| n(e, "hashchange", function () { | |
| a(); | |
| }), | |
| (e._urlChangeDetected = !0); | |
| } | |
| function n(e, t, n) { | |
| e.addEventListener(t, n, !1); | |
| } | |
| function a() { | |
| e.AlipayJSBridge && | |
| e.AlipayJSBridge.call("onWebViewUrlChange"); | |
| } | |
| function r(e, t) { | |
| var n = e[t]; | |
| return function () { | |
| var e = n.apply(this, arguments); | |
| return a(), e; | |
| }; | |
| } | |
| })(); | |
| }, | |
| }, | |
| })); | |
| t.default = K; | |
| }, | |
| ]).default; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment