Skip to content

Instantly share code, notes, and snippets.

@vutranHS
Last active December 3, 2018 08:52
Show Gist options
  • Save vutranHS/01fd443d90b0f685963456ba22936629 to your computer and use it in GitHub Desktop.
Save vutranHS/01fd443d90b0f685963456ba22936629 to your computer and use it in GitHub Desktop.
(function(global) {
if (typeof define !== 'undefined') {
return;
}
/* eslint strict:0 */
var modules = {};
var inGuard = false;
function def(id, deps, factory) {
if (deps instanceof Function) {
factory = deps;
deps = [];
}
modules[id] = {
factory: factory,
deps: deps,
module: {
exports: {}
},
isInitialized: false,
hasError: false,
};
}
function req(id) {
// Weex built-in modules
if (id.indexOf('@weex-module') === 0) {
return {};
}
var originId = id;
id = id.replace('@ali', 'kg');
var mod = modules[id];
if (!mod) {
id = id + '/index';
mod = modules[id];
}
if (mod && mod.isInitialized) {
return mod.module.exports;
}
return requireImpl(id, originId);
}
function requireImpl(id, originId) {
if (global.ErrorUtils && !inGuard) {
inGuard = true;
var returnValue;
try {
returnValue = requireImpl.apply(this, arguments);
} catch (e) {
global.ErrorUtils.reportFatalError(e);
}
inGuard = false;
return returnValue;
}
var mod = modules[id];
if (!mod) {
throw new Error('Requiring unknown module "' + originId + '"');
}
if (mod.hasError) {
throw new Error('Requiring module "' + originId + '" which threw an exception');
}
try {
// We must optimistically mark mod as initialized before running the factory to keep any
// require cycles inside the factory from causing an infinite require loop.
mod.isInitialized = true;
// keep args in sync with with defineModuleCode in
// rx/bundler/src/resolver.js
mod.factory(req, mod.module.exports, mod.module);
} catch (e) {
mod.hasError = true;
mod.isInitialized = false;
throw e;
}
return mod.module.exports;
}
global.define = def;
global.require = req;
global.__d = def;
global.__r = req;
})(this);
! function a(b, c, d) {
function e(g, h) {
if (!c[g]) {
if (!b[g]) {
var i = "function" == typeof require && require;
if (!h && i) return i(g, !0);
if (f) return f(g, !0);
var j = new Error("Cannot find module '" + g + "'");
throw j.code = "MODULE_NOT_FOUND",
j
}
var k = c[g] = {
exports: {}
};
b[g][0].call(k.exports, function(a) {
var c = b[g][1][a];
return e(c ? c : a)
}, k, k.exports, a, b, c, d)
}
return c[g].exports
}
for (var f = "function" == typeof require && require, g = 0; g < d.length; g++)
e(d[g]);
return e
}({
1: [function(a, b) {
function c() {}
var d = b.exports = {};
d.nextTick = function() {
var a = "undefined" != typeof window && window.setImmediate,
b = "undefined" != typeof window && window.postMessage && window.addEventListener;
if (a) return function(a) {
return window.setImmediate(a)
};
if (b) {
var c = [];
return window.addEventListener("message", function(a) {
var b = a.source;
if ((b === window || null === b) && "process-tick" === a.data && (a.stopPropagation(),
c.length > 0)) {
var d = c.shift();
d()
}
}, !0),
function(a) {
c.push(a),
window.postMessage("process-tick", "*")
}
}
return function(a) {
setTimeout(a, 0)
}
}(),
d.title = "browser",
d.browser = !0,
d.env = {},
d.argv = [],
d.on = c,
d.addListener = c,
d.once = c,
d.off = c,
d.removeListener = c,
d.removeAllListeners = c,
d.emit = c,
d.binding = function() {
throw new Error("process.binding is not supported")
},
d.cwd = function() {
return "/"
},
d.chdir = function() {
throw new Error("process.chdir is not supported")
}
}, {}],
2: [function(a, b) {
"use strict";
function c(a) {
function b(a) {
return null === i ? void k.push(a) : void f(function() {
var b = i ? a.onFulfilled : a.onRejected;
if (null === b) return void(i ? a.resolve : a.reject)(j);
var c;
try {
c = b(j)
} catch (d) {
return void a.reject(d)
}
a.resolve(c)
})
}
function c(a) {
try {
if (a === l) throw new TypeError("A promise cannot be resolved with itself.");
if (a && ("object" == typeof a || "function" == typeof a)) {
var b = a.then;
if ("function" == typeof b) return void e(b.bind(a), c, g)
}
i = !0,
j = a,
h()
} catch (d) {
g(d)
}
}
function g(a) {
i = !1,
j = a,
h()
}
function h() {
for (var a = 0, c = k.length; c > a; a++)
b(k[a]);
k = null
}
if ("object" != typeof this) throw new TypeError("Promises must be constructed via new");
if ("function" != typeof a) throw new TypeError("not a function");
var i = null,
j = null,
k = [],
l = this;
this.then = function(a, c) {
return new l.constructor(function(e, f) {
b(new d(a, c, e, f))
})
},
e(a, c, g)
}
function d(a, b, c, d) {
this.onFulfilled = "function" == typeof a ? a : null,
this.onRejected = "function" == typeof b ? b : null,
this.resolve = c,
this.reject = d
}
function e(a, b, c) {
var d = !1;
try {
a(function(a) {
d || (d = !0,
b(a))
}, function(a) {
d || (d = !0,
c(a))
})
} catch (e) {
if (d) return;
d = !0,
c(e)
}
}
var f = a("asap");
b.exports = c
}, {
asap: 4
}],
3: [function(a, b) {
"use strict";
function c(a) {
this.then = function(b) {
return "function" != typeof b ? this : new d(function(c, d) {
e(function() {
try {
c(b(a))
} catch (e) {
d(e)
}
})
})
}
}
var d = a("./core.js"),
e = a("asap");
b.exports = d,
c.prototype = d.prototype;
var f = new c(!0),
g = new c(!1),
h = new c(null),
i = new c(void 0),
j = new c(0),
k = new c("");
d.resolve = function(a) {
if (a instanceof d) return a;
if (null === a) return h;
if (void 0 === a) return i;
if (a === !0) return f;
if (a === !1) return g;
if (0 === a) return j;
if ("" === a) return k;
if ("object" == typeof a || "function" == typeof a) try {
var b = a.then;
if ("function" == typeof b) return new d(b.bind(a))
} catch (e) {
return new d(function(a, b) {
b(e)
})
}
return new c(a)
},
d.all = function(a) {
var b = Array.prototype.slice.call(a);
return new d(function(a, c) {
function d(f, g) {
try {
if (g && ("object" == typeof g || "function" == typeof g)) {
var h = g.then;
if ("function" == typeof h) return void h.call(g, function(a) {
d(f, a)
}, c)
}
b[f] = g,
0 === --e && a(b)
} catch (i) {
c(i)
}
}
if (0 === b.length) return a([]);
for (var e = b.length, f = 0; f < b.length; f++)
d(f, b[f])
})
},
d.reject = function(a) {
return new d(function(b, c) {
c(a)
})
},
d.race = function(a) {
return new d(function(b, c) {
a.forEach(function(a) {
d.resolve(a).then(b, c)
})
})
},
d.prototype["catch"] = function(a) {
return this.then(null, a)
}
}, {
"./core.js": 2,
asap: 4
}],
4: [function(a, b) {
(function(a) {
function c() {
for (; e.next;) {
e = e.next;
var a = e.task;
e.task = void 0;
var b = e.domain;
b && (e.domain = void 0,
b.enter());
try {
a()
} catch (d) {
if (i) throw b && b.exit(),
setTimeout(c, 0),
b && b.enter(),
d;
setTimeout(function() {
throw d
}, 0)
}
b && b.exit()
}
g = !1
}
function d(b) {
f = f.next = {
task: b,
domain: i && a.domain,
next: null
},
g || (g = !0,
h())
}
var e = {
task: void 0,
next: null
}, f = e,
g = !1,
h = void 0,
i = !1;
if ("undefined" != typeof a && a.nextTick) i = !0,
h = function() {
a.nextTick(c)
};
else if ("function" == typeof setImmediate) h = "undefined" != typeof window ? setImmediate.bind(window, c) : function() {
setImmediate(c)
};
else if ("undefined" != typeof MessageChannel) {
var j = new MessageChannel;
j.port1.onmessage = c,
h = function() {
j.port2.postMessage(0)
}
} else h = function() {
setTimeout(c, 0)
};
b.exports = d
}).call(this, a("_process"))
}, {
_process: 1
}],
5: [function() {
"function" != typeof Promise.prototype.done && (Promise.prototype.done = function() {
var a = arguments.length ? this.then.apply(this, arguments) : this;
a.then(null, function(a) {
setTimeout(function() {
throw a
}, 0)
})
})
}, {}],
6: [function(a) {
a("asap");
"undefined" == typeof Promise && (Promise = a("./lib/core.js"),
a("./lib/es6-extensions.js")),
a("./polyfill-done.js")
}, {
"./lib/core.js": 2,
"./lib/es6-extensions.js": 3,
"./polyfill-done.js": 5,
asap: 4
}]
}, {}, [6]);
! function(a, b) {
function c() {
var a = {}, b = new p(function(b, c) {
a.resolve = b,
a.reject = c
});
return a.promise = b,
a
}
function d(a, b) {
for (var c in b)
void 0 === a[c] && (a[c] = b[c]);
return a
}
function e(a) {
var b = document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0] || document.firstElementChild || document;
b.appendChild(a)
}
function f(a) {
var b = [];
for (var c in a)
a[c] && b.push(c + "=" + encodeURIComponent(a[c]));
return b.join("&")
}
function g(a) {
try {
return ".com" === a.substring(a.lastIndexOf(".")) ? a.substring(a.lastIndexOf(".", a.lastIndexOf(".") - 1) + 1) : a.split(".").slice(1).join(".")
} catch (b) {
return a.substring(a.lastIndexOf(".", a.lastIndexOf(".") - 1) + 1)
}
}
function h(a) {
function b(a, b) {
return a << b | a >>> 32 - b
}
function c(a, b) {
var c, d, e, f, g;
return e = 2147483648 & a,
f = 2147483648 & b,
c = 1073741824 & a,
d = 1073741824 & b,
g = (1073741823 & a) + (1073741823 & b),
c & d ? 2147483648 ^ g ^ e ^ f : c | d ? 1073741824 & g ? 3221225472 ^ g ^ e ^ f : 1073741824 ^ g ^ e ^ f : g ^ e ^ f
}
function d(a, b, c) {
return a & b | ~a & c
}
function e(a, b, c) {
return a & c | b & ~c
}
function f(a, b, c) {
return a ^ b ^ c
}
function g(a, b, c) {
return b ^ (a | ~c)
}
function h(a, e, f, g, h, i, j) {
return a = c(a, c(c(d(e, f, g), h), j)),
c(b(a, i), e)
}
function i(a, d, f, g, h, i, j) {
return a = c(a, c(c(e(d, f, g), h), j)),
c(b(a, i), d)
}
function j(a, d, e, g, h, i, j) {
return a = c(a, c(c(f(d, e, g), h), j)),
c(b(a, i), d)
}
function k(a, d, e, f, h, i, j) {
return a = c(a, c(c(g(d, e, f), h), j)),
c(b(a, i), d)
}
function l(a) {
for (var b, c = a.length, d = c + 8, e = (d - d % 64) / 64, f = 16 * (e + 1), g = new Array(f - 1), h = 0, i = 0; c > i;)
b = (i - i % 4) / 4,
h = i % 4 * 8,
g[b] = g[b] | a.charCodeAt(i) << h,
i++;
return b = (i - i % 4) / 4,
h = i % 4 * 8,
g[b] = g[b] | 128 << h,
g[f - 2] = c << 3,
g[f - 1] = c >>> 29,
g
}
function m(a) {
var b, c, d = "",
e = "";
for (c = 0; 3 >= c; c++)
b = a >>> 8 * c & 255,
e = "0" + b.toString(16),
d += e.substr(e.length - 2, 2);
return d
}
function n(a) {
a = a.replace(/\r\n/g, "\n");
for (var b = "", c = 0; c < a.length; c++) {
var d = a.charCodeAt(c);
128 > d ? b += String.fromCharCode(d) : d > 127 && 2048 > d ? (b += String.fromCharCode(d >> 6 | 192),
b += String.fromCharCode(63 & d | 128)) : (b += String.fromCharCode(d >> 12 | 224),
b += String.fromCharCode(d >> 6 & 63 | 128),
b += String.fromCharCode(63 & d | 128))
}
return b
}
var o, p, q, r, s, t, u, v, w, x = [],
y = 7,
z = 12,
A = 17,
B = 22,
C = 5,
D = 9,
E = 14,
F = 20,
G = 4,
H = 11,
I = 16,
J = 23,
K = 6,
L = 10,
M = 15,
N = 21;
for (a = n(a),
x = l(a),
t = 1732584193,
u = 4023233417,
v = 2562383102,
w = 271733878,
o = 0; o < x.length; o += 16)
p = t,
q = u,
r = v,
s = w,
t = h(t, u, v, w, x[o + 0], y, 3614090360),
w = h(w, t, u, v, x[o + 1], z, 3905402710),
v = h(v, w, t, u, x[o + 2], A, 606105819),
u = h(u, v, w, t, x[o + 3], B, 3250441966),
t = h(t, u, v, w, x[o + 4], y, 4118548399),
w = h(w, t, u, v, x[o + 5], z, 1200080426),
v = h(v, w, t, u, x[o + 6], A, 2821735955),
u = h(u, v, w, t, x[o + 7], B, 4249261313),
t = h(t, u, v, w, x[o + 8], y, 1770035416),
w = h(w, t, u, v, x[o + 9], z, 2336552879),
v = h(v, w, t, u, x[o + 10], A, 4294925233),
u = h(u, v, w, t, x[o + 11], B, 2304563134),
t = h(t, u, v, w, x[o + 12], y, 1804603682),
w = h(w, t, u, v, x[o + 13], z, 4254626195),
v = h(v, w, t, u, x[o + 14], A, 2792965006),
u = h(u, v, w, t, x[o + 15], B, 1236535329),
t = i(t, u, v, w, x[o + 1], C, 4129170786),
w = i(w, t, u, v, x[o + 6], D, 3225465664),
v = i(v, w, t, u, x[o + 11], E, 643717713),
u = i(u, v, w, t, x[o + 0], F, 3921069994),
t = i(t, u, v, w, x[o + 5], C, 3593408605),
w = i(w, t, u, v, x[o + 10], D, 38016083),
v = i(v, w, t, u, x[o + 15], E, 3634488961),
u = i(u, v, w, t, x[o + 4], F, 3889429448),
t = i(t, u, v, w, x[o + 9], C, 568446438),
w = i(w, t, u, v, x[o + 14], D, 3275163606),
v = i(v, w, t, u, x[o + 3], E, 4107603335),
u = i(u, v, w, t, x[o + 8], F, 1163531501),
t = i(t, u, v, w, x[o + 13], C, 2850285829),
w = i(w, t, u, v, x[o + 2], D, 4243563512),
v = i(v, w, t, u, x[o + 7], E, 1735328473),
u = i(u, v, w, t, x[o + 12], F, 2368359562),
t = j(t, u, v, w, x[o + 5], G, 4294588738),
w = j(w, t, u, v, x[o + 8], H, 2272392833),
v = j(v, w, t, u, x[o + 11], I, 1839030562),
u = j(u, v, w, t, x[o + 14], J, 4259657740),
t = j(t, u, v, w, x[o + 1], G, 2763975236),
w = j(w, t, u, v, x[o + 4], H, 1272893353),
v = j(v, w, t, u, x[o + 7], I, 4139469664),
u = j(u, v, w, t, x[o + 10], J, 3200236656),
t = j(t, u, v, w, x[o + 13], G, 681279174),
w = j(w, t, u, v, x[o + 0], H, 3936430074),
v = j(v, w, t, u, x[o + 3], I, 3572445317),
u = j(u, v, w, t, x[o + 6], J, 76029189),
t = j(t, u, v, w, x[o + 9], G, 3654602809),
w = j(w, t, u, v, x[o + 12], H, 3873151461),
v = j(v, w, t, u, x[o + 15], I, 530742520),
u = j(u, v, w, t, x[o + 2], J, 3299628645),
t = k(t, u, v, w, x[o + 0], K, 4096336452),
w = k(w, t, u, v, x[o + 7], L, 1126891415),
v = k(v, w, t, u, x[o + 14], M, 2878612391),
u = k(u, v, w, t, x[o + 5], N, 4237533241),
t = k(t, u, v, w, x[o + 12], K, 1700485571),
w = k(w, t, u, v, x[o + 3], L, 2399980690),
v = k(v, w, t, u, x[o + 10], M, 4293915773),
u = k(u, v, w, t, x[o + 1], N, 2240044497),
t = k(t, u, v, w, x[o + 8], K, 1873313359),
w = k(w, t, u, v, x[o + 15], L, 4264355552),
v = k(v, w, t, u, x[o + 6], M, 2734768916),
u = k(u, v, w, t, x[o + 13], N, 1309151649),
t = k(t, u, v, w, x[o + 4], K, 4149444226),
w = k(w, t, u, v, x[o + 11], L, 3174756917),
v = k(v, w, t, u, x[o + 2], M, 718787259),
u = k(u, v, w, t, x[o + 9], N, 3951481745),
t = c(t, p),
u = c(u, q),
v = c(v, r),
w = c(w, s);
var O = m(t) + m(u) + m(v) + m(w);
return O.toLowerCase()
}
function i(a) {
return "[object Object]" == {}.toString.call(a)
}
function j(a, b, c) {
var d = c || {};
document.cookie = a.replace(/[^+#$&^`|]/g, encodeURIComponent).replace("(", "%28").replace(")", "%29") + "=" + b.replace(/[^+#$&\/:<-\[\]-}]/g, encodeURIComponent) + (d.domain ? ";domain=" + d.domain : "") + (d.path ? ";path=" + d.path : "") + (d.secure ? ";secure" : "") + (d.httponly ? ";HttpOnly" : "")
}
function k(a) {
var b = new RegExp("(?:^|;\\s*)" + a + "\\=([^;]+)(?:;\\s*|$)").exec(document.cookie);
return b ? b[1] : void 0
}
function l(a, b, c) {
var d = new Date;
d.setTime(d.getTime() - 864e5);
var e = "/";
document.cookie = a + "=;path=" + e + ";domain=." + b + ";expires=" + d.toGMTString(),
document.cookie = a + "=;path=" + e + ";domain=." + c + "." + b + ";expires=" + d.toGMTString()
}
function m() {
var b = a.location.hostname;
if (!b) {
var c = a.parent.location.hostname;
c && ~c.indexOf("zebra.alibaba-inc.com") && (b = c)
}
var d = ["taobao.net", "taobao.com", "tmall.com", "tmall.hk", "alibaba-inc.com"],
e = new RegExp("([^.]*?)\\.?((?:" + d.join(")|(?:").replace(/\./g, "\\.") + "))", "i"),
f = b.match(e) || [],
g = f[2] || "taobao.com",
h = f[1] || "m";
"taobao.net" !== g || "x" !== h && "waptest" !== h && "daily" !== h ? "taobao.net" === g && "demo" === h ? h = "demo" : "alibaba-inc.com" === g && "zebra" === h ? h = "zebra" : "waptest" !== h && "wapa" !== h && "m" !== h && (h = "m") : h = "waptest";
var i = "h5api";
"taobao.net" === g && "waptest" === h && (i = "acs"),
r.mainDomain = g,
r.subDomain = h,
r.prefix = i
}
function n() {
var b = a.navigator.userAgent,
c = b.match(/WindVane[\/\s]([\d\.\_]+)/);
c && (r.WindVaneVersion = c[1]);
var d = b.match(/AliApp\(([^\/]+)\/([\d\.\_]+)\)/i);
d && (r.AliAppName = d[1],
r.AliAppVersion = d[2])
}
function o(a) {
this.id = ++v,
this.params = d(a || {}, {
v: "*",
data: {},
type: "get",
dataType: "jsonp"
}),
this.params.type = this.params.type.toLowerCase(),
"object" == typeof this.params.data && (this.params.data = JSON.stringify(this.params.data)),
this.middlewares = s.slice(0)
}
var p = a.Promise,
q = (p || {
resolve: function() {
return void 0
}
}).resolve();
String.prototype.trim || (String.prototype.trim = function() {
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "")
});
var r = {
useJsonpResultType: !1,
safariGoLogin: !0,
useAlipayJSBridge: !1
}, s = [],
t = {
ERROR: -1,
SUCCESS: 0,
TOKEN_EXPIRED: 1,
SESSION_EXPIRED: 2
};
m(),
n();
var u = "AP" === r.AliAppName && parseFloat(r.AliAppVersion) >= 10.1;
u && 10.1 === parseFloat(r.AliAppVersion) && parseInt(r.AliAppVersion.substr(5)) < 2 && (u = !1);
var v = 0,
w = "2.4.11";
o.prototype.use = function(a) {
if (!a) throw new Error("middleware is undefined");
return this.middlewares.push(a),
this
},
o.prototype.__processRequestMethod = function(a) {
var b = this.params,
c = this.options;
"get" === b.type && "jsonp" === b.dataType ? c.getJSONP = !0 : "get" === b.type && "originaljsonp" === b.dataType ? c.getOriginalJSONP = !0 : "get" === b.type && "json" === b.dataType ? c.getJSON = !0 : "post" === b.type && (c.postJSON = !0),
a()
},
o.prototype.__processRequestType = function(c) {
var d = this,
e = this.params,
f = this.options;
if (r.H5Request === !0 && (f.H5Request = !0),
r.WindVaneRequest === !0 && (f.WindVaneRequest = !0),
f.H5Request === !1 && f.WindVaneRequest === !0) {
if (!u && (!b.windvane || parseFloat(f.WindVaneVersion) < 5.4)) throw new Error("WINDVANE_NOT_FOUND::缺少WindVane环境");
if (u && !a.AlipayJSBridge) throw new Error("ALIPAY_NOT_READY::支付宝通道未准备好,支付宝请见 https://lark.alipay.com/mtbsdkdocs/mtopjssdkdocs/pucq6z")
} else if (f.H5Request === !0) f.WindVaneRequest = !1;
else if ("undefined" == typeof f.WindVaneRequest && "undefined" == typeof f.H5Request && (b.windvane && parseFloat(f.WindVaneVersion) >= 5.4 ? f.WindVaneRequest = !0 : f.H5Request = !0,
u)) if (f.WindVaneRequest = f.H5Request = void 0,
a.AlipayJSBridge) if (i(e.data)) f.WindVaneRequest = !0;
else try {
i(JSON.parse(e.data)) ? f.WindVaneRequest = !0 : f.H5Request = !0
} catch (g) {
f.H5Request = !0
} else f.H5Request = !0;
var h = a.navigator.userAgent.toLowerCase();
return h.indexOf("youku") > -1 && f.mainDomain.indexOf("youku.com") < 0 && (f.WindVaneRequest = !1,
f.H5Request = !0),
f.mainDomain.indexOf("youku.com") > -1 && h.indexOf("youku") < 0 && (f.WindVaneRequest = !1,
f.H5Request = !0),
c ? c().then(function() {
var a = f.retJson.ret;
if (a instanceof Array && (a = a.join(",")),
f.WindVaneRequest === !0 && u && f.retJson.error || !a || a.indexOf("PARAM_PARSE_ERROR") > -1 || a.indexOf("HY_FAILED") > -1 || a.indexOf("HY_NO_HANDLER") > -1 || a.indexOf("HY_CLOSED") > -1 || a.indexOf("HY_EXCEPTION") > -1 || a.indexOf("HY_NO_PERMISSION") > -1) {
console.log('get token', a);
if (!u || !isNaN(f.retJson.error) || -1 !== f.retJson.error.indexOf("FAIL_SYS_ACCESS_DENIED")) return u && i(e.data) && (e.data = JSON.stringify(e.data)),
r.H5Request = !0,
d.__sequence([d.__processRequestType, d.__processToken, d.__processRequestUrl, d.middlewares, d.__processRequest]);
"undefined" == typeof f.retJson.api && "undefined" == typeof f.retJson.v && (f.retJson.api = e.api,
f.retJson.v = e.v,
f.retJson.ret = [f.retJson.error + "::" + f.retJson.errorMessage],
f.retJson.data = {})
}
}) : void 0
};
var x = "_m_h5_c",
y = "_m_h5_tk",
z = "_m_h5_tk_enc";
o.prototype.__getTokenFromAlipay = function() {
var b = c(),
d = this.options,
e = (a.navigator.userAgent, !! location.protocol.match(/^https?\:$/));
console.log('token', d);
return d.useAlipayJSBridge === !0 && !e && u && a.AlipayJSBridge && a.AlipayJSBridge.call ? a.AlipayJSBridge.call("getMtopToken", function(a) {
console.log('token', d, a);
a && a.token && (d.token = a.token),
b.resolve()
}, function() {
b.resolve()
}) : b.resolve(),
b.promise
},
o.prototype.__getTokenFromCookie = function() {
var a = this.options;
var hihi;
if (a.CDR && k(x)) {
a.token = k(x).split(";")[0];
} else {
a.token = a.token || k(y);
}
return a.token && (a.token = a.token.split("_")[0]),
p.resolve()
},
o.prototype.__waitWKWebViewCookie = function(b) {
var c = this.options;
c.waitWKWebViewCookieFn && c.H5Request && a.webkit && a.webkit.messageHandlers ? c.waitWKWebViewCookieFn(b) : b()
},
o.prototype.__processToken = function(a) {
var b = this,
c = this.options;
this.params;
return c.token && delete c.token,
c.WindVaneRequest !== !0 ? q.then(function() {
return b.__getTokenFromAlipay()
}).then(function(haha) {
console.log(haha);
return b.__getTokenFromCookie()
}).then(a).then(function() {
var a = c.retJson,
d = a.ret;
if (d instanceof Array && (d = d.join(",")),
d.indexOf("TOKEN_EMPTY") > -1 || c.CDR === !0 && d.indexOf("ILLEGAL_ACCESS") > -1 || d.indexOf("TOKEN_EXOIRED") > -1) {
if (c.maxRetryTimes = c.maxRetryTimes || 5,
c.failTimes = c.failTimes || 0,
c.H5Request && ++c.failTimes < c.maxRetryTimes) return b.__sequence([b.__waitWKWebViewCookie, b.__processToken, b.__processRequestUrl, b.middlewares, b.__processRequest]);
c.maxRetryTimes > 0 && (l(x, c.pageDomain, "*"),
l(y, c.mainDomain, c.subDomain),
l(z, c.mainDomain, c.subDomain)),
a.retType = t.TOKEN_EXPIRED
console.log('token', z);
}
}) : void a()
},
o.prototype.__processRequestUrl = function(b) {
var c = this.params,
d = this.options;
console.log('where d options', d);
if (d.hostSetting && d.hostSetting[a.location.hostname]) {
var e = d.hostSetting[a.location.hostname];
e.prefix && (d.prefix = e.prefix),
e.subDomain && (d.subDomain = e.subDomain),
e.mainDomain && (d.mainDomain = e.mainDomain)
}
if (d.H5Request === !0) {
var f = "//" + (d.prefix ? d.prefix + "." : "") + (d.subDomain ? d.subDomain + "." : "") + d.mainDomain + "/h5/" + c.api.toLowerCase() + "/" + c.v.toLowerCase() + "/",
g = c.appKey || ("waptest" === d.subDomain ? "4272" : "12574478"),
i = (new Date).getTime(),
j = h(d.token + "&" + i + "&" + g + "&" + c.data),
k = {
jsv: w,
appKey: g,
t: i,
sign: j
}, l = {
data: c.data,
ua: c.ua
};
if (f.includes('querydetail')) {
f = f.replace('querydetail', 'slash');
const newData = JSON.parse(c.data);
newData.skuId = '335592730';
newData.itemId = '252210917';
const hihi = JSON.stringify(newData);
j = h(d.token + "&" + i + "&" + g + "&" + hihi);
k = {
jsv: w,
appKey: g,
t: i,
sign: j
};
l = {
data: hihi,
ua: '114#oTvSejXbTTobpobr0sRlwa/00jXe9kChgM+8hFsZXdudCsrI7FMc4RxyF0/h7OhzinSnTe/nmmkVWHrNENCM8Sws4u+OSBVvS1LN0R5sLRXkimgtXmpmQe6lHWXTkbozKCcpiO9WwblFoQCTfZ8sgQ7wfTsnnTb8z6gm8TsTbpJUyUxxBENT4L2jQTfMXl8rL6rmTJob19uVQjHTEZTwtY8w0sZ4SzTUGWJMjJ7KvBt0Iw3RFHR0dgvRjx9VPbuC5poCCBGkBVnR9+y85a4Kni9QvWDS/CQwmQgWGE9IJ5fLYlKu1cc6xYZVbfIKQxsuO4QWxbP4OvjoSg+ByaXGBASMZ0k+rjYBgWfRlEx+f5rhbzVP7g/sUuGSQTE34tlgbfQ+wdjypTOlRQNegNmIryxFS3g1/zoMwa82vQBtZICdJ1LMoVks00fNycBjZ7TINiMnFmjqPyD1UNNjD5tXTSSdMzJJDcuSCQ+yk5O4Gc9tKwrN8R/oa/9DITMl2KfBnav9x7zeWXNfvE7IwKPf20zX15ZSMBfs78WHJqXmBOYpW3VaCX2IU9nq9Z09mNpmKHjsKg7asrtMMltJt26fnHQEGHAdFhCUoDhSwYKNLDme844RGL8/4KwWC7GG+uMiyBpyFhu4klgM'
};
c.api = 'mtop.lazada.promotion.slash.slash';
}
console.log('hihi', f, k, l);
Object.keys(c).forEach(function(a) {
"undefined" == typeof k[a] && "undefined" == typeof l[a] && "headers" !== a && "ext_headers" !== a && "ext_querys" !== a && (k[a] = c[a])
}),
c.ext_querys && Object.keys(c.ext_querys).forEach(function(a) {
k[a] = c.ext_querys[a]
}),
d.getJSONP ? k.type = "jsonp" : d.getOriginalJSONP ? k.type = "originaljsonp" : (d.getJSON || d.postJSON) && (k.type = "originaljson"),
"undefined" != typeof c.valueType && ("original" === c.valueType ? d.getJSONP || d.getOriginalJSONP ? k.type = "originaljsonp" : (d.getJSON || d.postJSON) && (k.type = "originaljson") : "string" === c.valueType && (d.getJSONP || d.getOriginalJSONP ? k.type = "jsonp" : (d.getJSON || d.postJSON) && (k.type = "json"))),
d.useJsonpResultType === !0 && "originaljson" === k.type && delete k.type,
d.dangerouslySetProtocol && (f = d.dangerouslySetProtocol + ":" + f),
d.querystring = k,
d.postdata = l,
d.path = f
}
b()
},
o.prototype.__processUnitPrefix = function(a) {
a()
};
var A = 0;
o.prototype.__requestJSONP = function(a) {
function b(a) {
if (k && clearTimeout(k),
l.parentNode && l.parentNode.removeChild(l),
"TIMEOUT" === a) window[j] = function() {
window[j] = void 0;
try {
delete window[j]
} catch (a) {}
};
else {
window[j] = void 0;
try {
delete window[j]
} catch (b) {}
}
}
var d = c(),
g = this.params,
h = this.options,
i = g.timeout || 2e4,
j = "mtopjsonp" + (g.jsonpIncPrefix || "") + ++A,
k = setTimeout(function() {
a(h.timeoutErrMsg || "TIMEOUT::接口超时"),
b("TIMEOUT")
}, i);
h.querystring.callback = j;
var l = document.createElement("script");
return l.src = h.path + "?" + f(h.querystring) + "&" + f(h.postdata),
l.async = !0,
l.onerror = function() {
b("ABORT"),
a(h.abortErrMsg || "ABORT::接口异常退出")
},
window[j] = function() {
h.results = Array.prototype.slice.call(arguments),
b(),
d.resolve()
},
e(l),
d.promise
},
o.prototype.__requestJSON = function(b) {
function d(a) {
l && clearTimeout(l),
"TIMEOUT" === a && i.abort()
}
var e = c(),
g = this.params,
h = this.options,
i = new a.XMLHttpRequest,
j = g.timeout || 2e4,
l = setTimeout(function() {
b(h.timeoutErrMsg || "TIMEOUT::接口超时"),
d("TIMEOUT")
}, j);
h.CDR && k(x) && (h.querystring.c = decodeURIComponent(k(x))),
i.onreadystatechange = function() {
if (4 == i.readyState) {
var a, c, f = i.status;
if (f >= 200 && 300 > f || 304 == f) {
d(),
a = i.responseText,
c = i.getAllResponseHeaders() || "";
try {
a = /^\s*$/.test(a) ? {} : JSON.parse(a),
a.responseHeaders = c,
h.results = [a],
e.resolve()
} catch (g) {
b("PARSE_JSON_ERROR::解析JSON失败")
}
} else d("ABORT"),
b(h.abortErrMsg || "ABORT::接口异常退出")
}
};
var m, n, o = h.path + "?" + f(h.querystring);
h.getJSON ? (m = "GET",
o += "&" + f(h.postdata)) : h.postJSON && (m = "POST",
n = f(h.postdata)),
i.open(m, o, !0),
i.withCredentials = !0,
i.setRequestHeader("Accept", "application/json"),
i.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
var p = g.ext_headers || g.headers;
if (p) for (var q in p)
i.setRequestHeader(q, p[q]);
return i.send(n),
e.promise
},
o.prototype.__requestWindVane = function(a) {
function d(a) {
g.results = [a],
e.resolve()
}
var e = c(),
f = this.params,
g = this.options,
h = f.data,
i = f.api,
j = f.v,
k = g.postJSON ? 1 : 0,
l = g.getJSON || g.postJSON || g.getOriginalJSONP ? "originaljson" : "";
"undefined" != typeof f.valueType && ("original" === f.valueType ? l = "originaljson" : "string" === f.valueType && (l = "")),
g.useJsonpResultType === !0 && (l = "");
var m, n, o = "https" === location.protocol ? 1 : 0,
p = f.isSec || 0,
q = f.sessionOption || "AutoLoginOnly",
r = f.ecode || 0,
s = f.ext_headers || {}, t = f.ext_querys || {};
s.referer = location.href,
n = "undefined" != typeof f.timer ? parseInt(f.timer) : "undefined" != typeof f.timeout ? parseInt(f.timeout) : 2e4,
m = 2 * n,
f.needLogin === !0 && "undefined" == typeof f.sessionOption && (q = "AutoLoginAndManualLogin"),
"undefined" != typeof f.secType && "undefined" == typeof f.isSec && (p = f.secType);
var u = {
api: i,
v: j,
post: String(k),
type: l,
isHttps: String(o),
ecode: String(r),
isSec: String(p),
param: JSON.parse(h),
timer: n,
sessionOption: q,
ext_headers: s,
ext_querys: t
};
return f.ttid && g.dangerouslySetWVTtid === !0 && (u.ttid = f.ttid),
b.windvane.call("MtopWVPlugin", "send", u, d, d, m),
e.promise
},
o.prototype.__requestAlipay = function(b) {
function d(a) {
g.results = [a],
e.resolve()
}
var e = c(),
f = this.params,
g = this.options,
h = {
apiName: f.api,
apiVersion: f.v,
needEcodeSign: "1" === String(f.ecode),
usePost: !! g.postJSON
};
return i(f.data) || (f.data = JSON.parse(f.data)),
h.data = f.data,
f.ttid && g.dangerouslySetWVTtid === !0 && (h.ttid = f.ttid), (g.getJSON || g.postJSON || g.getOriginalJSONP) && (h.type = "originaljson"),
"undefined" != typeof f.valueType && ("original" === f.valueType ? h.type = "originaljson" : "string" === f.valueType && delete h.type),
g.useJsonpResultType === !0 && delete h.type,
a.AlipayJSBridge.call("mtop", h, d),
e.promise
},
o.prototype.__processRequest = function(a, b) {
var c = this;
return q.then(function() {
var a = c.options;
if (a.H5Request && (a.getJSONP || a.getOriginalJSONP)) return c.__requestJSONP(b);
if (a.H5Request && (a.getJSON || a.postJSON)) return c.__requestJSON(b);
if (a.WindVaneRequest) return u ? c.__requestAlipay(b) : c.__requestWindVane(b);
throw new Error("UNEXCEPT_REQUEST::错误的请求类型")
}).then(a).then(function() {
var a = c.options,
b = (c.params,
a.results[0]),
d = b && b.ret || [];
b.ret = d,
d instanceof Array && (d = d.join(","));
var e = b.c;
a.CDR && e && j(x, e, {
domain: a.pageDomain,
path: "/"
}),
d.indexOf("SUCCESS") > -1 ? b.retType = t.SUCCESS : b.retType = t.ERROR,
a.retJson = b
})
},
o.prototype.__sequence = function(a) {
function b(a) {
if (a instanceof Array) a.forEach(b);
else {
var g, h = c(),
i = c();
e.push(function() {
return h = c(),
g = a.call(d, function(a) {
return h.resolve(a),
i.promise
}, function(a) {
return h.reject(a),
i.promise
}),
g && (g = g["catch"](function(a) {
h.reject(a)
})),
h.promise
}),
f.push(function(a) {
return i.resolve(a),
g
})
}
}
var d = this,
e = [],
f = [];
a.forEach(b);
for (var g, h = q; g = e.shift();)
h = h.then(g);
for (; g = f.pop();)
h = h.then(g);
return h
};
var B = function(a) {
a()
}, C = function(a) {
a()
};
o.prototype.request = function(c) {
var e = this;
if (this.options = d(c || {}, r), !p) {
var f = "当前浏览器不支持Promise,请在windows对象上挂载Promise对象可参考(http://gitlab.alibaba-inc.com/mtb/lib-es6polyfill/tree/master)中的解决方案";
throw b.mtop = {
ERROR: f
},
new Error(f)
}
var h = p.resolve([B, C]).then(function(a) {
var b = a[0],
c = a[1];
return e.__sequence([b, e.__processRequestMethod, e.__processRequestType, e.__processToken, e.__processRequestUrl, e.middlewares, e.__processRequest, c])
}).then(function() {
var a = e.options.retJson;
return a.retType !== t.SUCCESS ? p.reject(a) : e.options.successCallback ? void e.options.successCallback(a) : p.resolve(a)
})["catch"](function(a) {
var b;
return a instanceof Error ? (console.error(a.stack),
b = {
ret: [a.message],
stack: [a.stack],
retJson: t.ERROR
}) : b = "string" == typeof a ? {
ret: [a],
retJson: t.ERROR
} : void 0 !== a ? a : e.options.retJson,
e.options.failureCallback ? void e.options.failureCallback(b) : p.reject(b)
});
return this.__processRequestType(),
e.options.H5Request && (e.constructor.__firstProcessor || (e.constructor.__firstProcessor = h),
B = function(a) {
e.constructor.__firstProcessor.then(a)["catch"](a)
}), ("get" === this.params.type && "json" === this.params.dataType || "post" === this.params.type) && (c.pageDomain = c.pageDomain || g(a.location.hostname),
c.mainDomain !== c.pageDomain && (c.maxRetryTimes = 4,
c.CDR = !0)),
h
},
b.mtop = function(a) {
return new o(a)
},
b.mtop.request = function(a, b, c) {
var d = {
H5Request: a.H5Request,
WindVaneRequest: a.WindVaneRequest,
LoginRequest: a.LoginRequest,
AntiCreep: a.AntiCreep,
AntiFlood: a.AntiFlood,
successCallback: b,
failureCallback: c || b
};
return new o(a).request(d)
},
b.mtop.H5Request = function(a, b, c) {
var d = {
H5Request: !0,
successCallback: b,
failureCallback: c || b
};
return new o(a).request(d)
},
b.mtop.middlewares = s,
b.mtop.config = r,
b.mtop.RESPONSE_TYPE = t,
b.mtop.CLASS = o
}(window, window.lib || (window.lib = {})),
function(a, b) {
function c(a) {
return a.preventDefault(), !1
}
function d(a) {
var b = new RegExp("(?:^|;\\s*)" + a + "\\=([^;]+)(?:;\\s*|$)").exec(document.cookie);
return b ? b[1] : void 0
}
function e(b, d) {
var e = this,
f = a.dpr || 1,
g = document.createElement("div"),
h = document.documentElement.getBoundingClientRect(),
i = Math.max(h.width, window.innerWidth) / f,
j = Math.max(h.height, window.innerHeight) / f;
g.style.cssText = ["-webkit-transform:scale(" + f + ") translateZ(0)", "-ms-transform:scale(" + f + ") translateZ(0)", "transform:scale(" + f + ") translateZ(0)", "-webkit-transform-origin:0 0", "-ms-transform-origin:0 0", "transform-origin:0 0", "width:" + i + "px", "height:" + j + "px", "z-index:999999", "position:" + (i > 800 ? "fixed" : "absolute"), "left:0", "top:0px", "background:" + (i > 800 ? "rgba(0,0,0,.5)" : "#FFF"), "display:none"].join(";");
var k = document.createElement("div");
k.style.cssText = ["width:100%", "height:52px", "background:#EEE", "line-height:52px", "text-align:left", "box-sizing:border-box", "padding-left:20px", "position:absolute", "left:0", "top:0", "font-size:16px", "font-weight:bold", "color:#333"].join(";"),
k.innerText = b;
var l = document.createElement("a");
l.style.cssText = ["display:block", "position:absolute", "right:0", "top:0", "height:52px", "line-height:52px", "padding:0 20px", "color:#999"].join(";"),
l.innerText = "关闭";
var m = document.createElement("iframe");
m.style.cssText = ["width:100%", "height:100%", "border:0", "overflow:hidden"].join(";"),
i > 800 && (k.style.cssText = ["width:370px", "height:52px", "background:#EEE", "line-height:52px", "text-align:left", "box-sizing:border-box", "padding-left:20px", "position:absolute", "left:" + (i / 2 - 185) + "px", "top:40px", "font-size:16px", "font-weight:bold", "color:#333"].join(";"),
m.style.cssText = ["position:absolute", "top:92px", "left:" + (i / 2 - 185) + "px", "width:370px", "height:480px", "border:0", "background:#FFF", "overflow:hidden"].join(";")),
k.appendChild(l),
g.appendChild(k),
g.appendChild(m),
g.className = "J_MIDDLEWARE_FRAME_WIDGET",
document.body.appendChild(g),
m.src = d,
l.addEventListener("click", function() {
e.hide();
var a = document.createEvent("HTMLEvents");
a.initEvent("close", !1, !1),
g.dispatchEvent(a)
}, !1),
this.addEventListener = function() {
g.addEventListener.apply(g, arguments)
},
this.removeEventListener = function() {
g.removeEventListener.apply(g, arguments)
},
this.show = function() {
document.addEventListener("touchmove", c, !1),
g.style.display = "block",
window.scrollTo(0, 0)
},
this.hide = function() {
document.removeEventListener("touchmove", c),
window.scrollTo(0, -h.top),
g.parentNode && g.parentNode.removeChild(g)
}
}
function f(a) {
var c = this,
d = this.options,
e = this.params;
return a().then(function() {
var a = d.retJson,
f = a.ret,
g = navigator.userAgent.toLowerCase(),
h = g.indexOf("safari") > -1 && g.indexOf("chrome") < 0 && g.indexOf("qqbrowser") < 0;
if (f instanceof Array && (f = f.join(",")), (f.indexOf("SESSION_EXPIRED") > -1 || f.indexOf("SID_INVALID") > -1 || f.indexOf("AUTH_REJECT") > -1 || f.indexOf("NEED_LOGIN") > -1) && (a.retType = l.SESSION_EXPIRED, !d.WindVaneRequest && (k.LoginRequest === !0 || d.LoginRequest === !0 || e.needLogin === !0))) {
if (!b.login) throw new Error("LOGIN_NOT_FOUND::缺少lib.login");
if (d.safariGoLogin !== !0 || !h || "taobao.com" === d.pageDomain) return b.login.goLoginAsync().then(function(a) {
return c.__sequence([c.__processToken, c.__processRequestUrl, c.__processUnitPrefix, c.middlewares, c.__processRequest])
})["catch"](function(a) {
throw "CANCEL" === a ? new Error("LOGIN_CANCEL::用户取消登录") : new Error("LOGIN_FAILURE::用户登录失败")
});
b.login.goLogin()
}
})
}
function g(a) {
var b = this.options;
this.params;
return b.H5Request !== !0 || k.AntiFlood !== !0 && b.AntiFlood !== !0 ? void a() : a().then(function() {
var a = b.retJson,
c = a.ret;
c instanceof Array && (c = c.join(",")),
c.indexOf("FAIL_SYS_USER_VALIDATE") > -1 && a.data.url && (b.AntiFloodReferer ? location.href = a.data.url.replace(/(http_referer=).+/, "$1" + b.AntiFloodReferer) : location.href = a.data.url)
})
}
function h(b) {
var c = this,
f = this.options,
g = this.params;
return g.forceAntiCreep !== !0 && f.H5Request !== !0 || k.AntiCreep !== !0 && f.AntiCreep !== !0 ? void b() : b().then(function() {
var b = f.retJson,
h = b.ret;
if (h instanceof Array && (h = h.join(",")),
h.indexOf("RGV587_ERROR::SM") > -1 && b.data.url) {
var j = "_m_h5_smt",
k = d(j),
l = !1;
if (f.saveAntiCreepToken === !0 && k) {
k = JSON.parse(k);
for (var m in k)
g[m] && (l = !0)
}
if (f.saveAntiCreepToken === !0 && k && !l) {
for (var m in k)
g[m] = k[m];
return c.__sequence([c.__processToken, c.__processRequestUrl, c.__processUnitPrefix, c.middlewares, c.__processRequest])
}
return new i(function(d, h) {
function i() {
m.removeEventListener("close", i),
a.removeEventListener("message", k),
h("USER_INPUT_CANCEL::用户取消输入")
}
function k(b) {
var e;
try {
e = JSON.parse(b.data) || {}
} catch (l) {}
if (e && "child" === e.type) {
m.removeEventListener("close", i),
a.removeEventListener("message", k),
m.hide();
var n;
try {
n = JSON.parse(decodeURIComponent(e.content)),
"string" == typeof n && (n = JSON.parse(n));
for (var o in n)
g[o] = n[o];
f.saveAntiCreepToken === !0 ? (document.cookie = j + "=" + JSON.stringify(n) + ";",
a.location.reload()) : c.__sequence([c.__processToken, c.__processRequestUrl, c.__processUnitPrefix, c.middlewares, c.__processRequest]).then(d)
} catch (l) {
h("USER_INPUT_FAILURE::用户输入失败")
}
}
}
var l = b.data.url,
m = new e("", l);
m.addEventListener("close", i, !1),
a.addEventListener("message", k, !1),
m.show()
})
}
})
}
if (!b || !b.mtop || b.mtop.ERROR) throw new Error("Mtop 初始化失败!请参考Mtop文档http://gitlab.alibaba-inc.com/mtb/lib-mtop");
var i = a.Promise,
j = b.mtop.CLASS,
k = b.mtop.config,
l = b.mtop.RESPONSE_TYPE;
b.mtop.middlewares.push(f),
b.mtop.loginRequest = function(a, b, c) {
var d = {
LoginRequest: !0,
H5Request: !0,
successCallback: b,
failureCallback: c || b
};
return new j(a).request(d)
},
b.mtop.antiFloodRequest = function(a, b, c) {
var d = {
AntiFlood: !0,
successCallback: b,
failureCallback: c || b
};
return new j(a).request(d)
},
b.mtop.middlewares.push(g),
b.mtop.antiCreepRequest = function(a, b, c) {
var d = {
AntiCreep: !0,
successCallback: b,
failureCallback: c || b
};
return new j(a).request(d)
},
b.mtop.middlewares.push(h)
}(window, window.lib || (window.lib = {}));
! function(a, b) {
function c(a) {
return a.preventDefault(), !1
}
function d(b, d) {
var e = this,
f = a.dpr || 1,
h = document.createElement("div"),
i = document.documentElement.getBoundingClientRect(),
j = Math.max(i.width, window.innerWidth) / f,
k = Math.max(i.height, window.innerHeight) / f;
h.style.cssText = ["-webkit-transform:scale(" + f + ") translateZ(0)", "-ms-transform:scale(" + f + ") translateZ(0)", "transform:scale(" + f + ") translateZ(0)", "-webkit-transform-origin:0 0", "-ms-transform-origin:0 0", "transform-origin:0 0", "width:" + j + "px", "height:" + k + "px", "z-index:999999", "position:absolute", "left:0", "top:0px", "background:#FFF", "display:none"].join(";");
var l = document.createElement("div");
l.style.cssText = ["width:100%", "height:52px", "background:#EEE", "line-height:52px", "text-align:left", "box-sizing:border-box", "padding-left:20px", "position:absolute", "left:0", "top:0", "font-size:16px", "font-weight:bold", "color:#333"].join(";"),
l.innerText = b;
var m = document.createElement("a");
m.style.cssText = ["display:block", "position:absolute", "right:0", "top:0", "height:52px", "line-height:52px", "padding:0 20px", "color:#999"].join(";"),
m.innerText = "关闭";
var n = document.createElement("iframe");
n.style.cssText = ["width:100%", "height:100%", "border:0", "overflow:hidden"].join(";"),
l.appendChild(m),
h.appendChild(l),
h.appendChild(n),
g.body.appendChild(h),
n.src = d,
m.addEventListener("click", function() {
e.hide();
var a = g.createEvent("HTMLEvents");
a.initEvent("close", !1, !1),
h.dispatchEvent(a)
}, !1),
this.addEventListener = function() {
h.addEventListener.apply(h, arguments)
},
this.removeEventListener = function() {
h.removeEventListener.apply(h, arguments)
},
this.show = function() {
document.addEventListener("touchmove", c, !1),
h.style.display = "block",
window.scrollTo(0, 0)
},
this.hide = function() {
document.removeEventListener("touchmove", c),
window.scrollTo(0, -i.top),
g.body.removeChild(h)
}
}
function e(a, b) {
this.request = a,
this.response = b;
var c = 0,
d = {};
this.on = function(a, b) {
d[a] = b
},
this.next = function() {
var b = m[c++];
b ? a[b.__name__] ? b(this) : this.next() : this.end()
},
this.reset = function() {
c = 0,
d.reset && d.reset.call(this)
},
this.end = function() {
d.end && d.end.call(this)
}
}
function f(a, b) {
b.__name__ = a,
m.push(b)
}
var g = a.document,
h = a.navigator.userAgent,
i = h.match(/WindVane[\/\s]([\d\.\_]+)/);
i && (i = i[1]);
var j, k, l = h.match(/AliApp\(([^\/]+)\/([\d\.\_]+)\)/i);
l && (j = l[1],
k = l[2]),
b.mtop = b.mtop || {},
b.mtop.middleware = {};
var m = [];
b.mtop.middleware.pipe = function(a, b) {
return new e(a, b)
},
b.mtop.middleware.add = f,
f("LoginRequest", function(a) {
function c() {
a.reset()
}
function d() {
a.response && a.response.ret.push("MW_ERROR::LOGIN_FAILURE"),
a.end()
}
function e() {
a.response && a.response.ret.push("MW_ERROR::WIDGET_CANCEL"),
a.end()
}
var f = (a.response && a.response.ret || []).join(",");
f.indexOf("SESSION_EXPIRED") > -1 || f.indexOf("SID_INVALID") > -1 || f.indexOf("AUTH_REJECT") > -1 || f.indexOf("NEED_LOGIN") > -1 ? b.login.goLogin(function(a) {
"SUCCESS" === a ? c() : "CANCEL" === a ? e() : d()
}) : a.next()
}),
f("AntiCreep", function(b) {
function c() {
h.removeEventListener("close", c),
a.removeEventListener("message", e),
b.response && b.response.ret.push("MW_ERROR::WIDGET_CANCEL"),
b.end()
}
function e() {
h.removeEventListener("close", c),
a.removeEventListener("message", e);
var d = JSON.parse(g.data) || {};
if (d && "child" === d.type) {
var f;
try {
f = JSON.parse(decodeURIComponent(d.content)),
"string" == typeof f && (f = JSON.parse(f))
} catch (g) {
f = null
}
if (f) {
for (var i in f)
b.request[i] = f[i];
b.reset()
} else b.response && b.response.ret.push("MW_ERROR::SM_FAILURE"),
b.end();
h.hide()
} else b.end()
}
var f = (b.response && b.response.ret || []).join(",");
if (!l && f.indexOf("RGV587_ERROR::SM") > -1 && b.response.data.url) {
var g = b.response.data.url,
h = new d("", g);
h.addEventListener("close", c, !1),
a.addEventListener("message", e, !1),
h.show()
} else b.next()
}),
f("AntiFlood", function(a) {
var b = (a.response && a.response.ret || []).join(",");
if (!l && b.indexOf("FAIL_SYS_USER_VALIDATE") > -1 && a.response.data.url) {
var c = a.response.data.url;
location.href = c
} else a.next()
})
}(window, window.lib || (window.lib = {}));
! function(a, b) {
function c(a, b) {
a = a.toString().split("."),
b = b.toString().split(".");
for (var c = 0; c < a.length || c < b.length; c++) {
var d = parseInt(a[c], 10),
e = parseInt(b[c], 10);
if (window.isNaN(d) && (d = 0),
window.isNaN(e) && (e = 0),
d < e) return -1;
if (d > e) return 1
}
return 0
}
var d = a.Promise,
e = a.document,
f = a.navigator.userAgent,
g = /Windows\sPhone\s(?:OS\s)?[\d\.]+/i.test(f) || /Windows\sNT\s[\d\.]+/i.test(f),
h = g && a.WindVane_Win_Private && a.WindVane_Win_Private.call,
i = /iPhone|iPad|iPod/i.test(f),
j = /Android/i.test(f),
k = f.match(/WindVane[\/\s](\d+[._]\d+[._]\d+)/),
l = Object.prototype.hasOwnProperty,
m = b.windvane = a.WindVane || (a.WindVane = {}),
n = (a.WindVane_Native,
Math.floor(65536 * Math.random())),
o = 1,
p = [],
q = 3,
r = "hybrid",
s = "wv_hybrid",
t = "iframe_",
u = "param_",
v = "chunk_",
w = 6e5,
x = 6e5,
y = 6e4;
k = k ? (k[1] || "0.0.0").replace(/\_/g, ".") : "0.0.0";
var z = {
isAvailable: 1 === c(k, "0"),
call: function(a, b, c, e, f, g) {
var h, i;
"number" == typeof arguments[arguments.length - 1] && (g = arguments[arguments.length - 1]),
"function" != typeof e && (e = null),
"function" != typeof f && (f = null),
d && (i = {},
i.promise = new d(function(a, b) {
i.resolve = a,
i.reject = b
})),
h = A.getSid();
var j = {
success: e,
failure: f,
deferred: i
};
if (g > 0 && (j.timeout = setTimeout(function() {
z.onFailure(h, {
ret: "HY_TIMEOUT"
})
}, g)),
A.registerCall(h, j),
A.registerGC(h, g),
z.isAvailable ? A.callMethod(a, b, c, h) : z.onFailure(h, {
ret: "HY_NOT_IN_WINDVANE"
}),
i) return i.promise
},
fireEvent: function(a, b, c) {
var d = e.createEvent("HTMLEvents");
d.initEvent(a, !1, !0),
d.param = A.parseData(b || A.getData(c)),
e.dispatchEvent(d)
},
getParam: function(a) {
return A.getParam(a)
},
setData: function(a, b) {
A.setData(a, b)
},
onSuccess: function(a, b) {
A.onComplete(a, b, "success")
},
onFailure: function(a, b) {
A.onComplete(a, b, "failure")
}
}, A = {
params: {},
chunks: {},
calls: {},
getSid: function() {
return (n + o++) % 65536 + ""
},
buildParam: function(a) {
return a && "object" == typeof a ? JSON.stringify(a) : a || ""
},
getParam: function(a) {
return this.params[u + a] || ""
},
setParam: function(a, b) {
this.params[u + a] = b
},
parseData: function(a) {
var b;
if (a && "string" == typeof a) try {
b = JSON.parse(a)
} catch (a) {
b = {
ret: ["WV_ERR::PARAM_PARSE_ERROR"]
}
} else b = a || {};
return b
},
setData: function() {
this.chunks[v + sid] = this.chunks[v + sid] || [],
this.chunks[v + sid].push(chunk)
},
getData: function(a) {
return this.chunks[v + a] ? this.chunks[v + a].join("") : ""
},
registerCall: function(a, b) {
this.calls[a] = b
},
unregisterCall: function(a) {
var b = {};
return this.calls[a] && (b = this.calls[a],
delete this.calls[a]),
b
},
useIframe: function(a, b) {
var c = t + a,
d = p.pop();
d || (d = e.createElement("iframe"),
d.setAttribute("frameborder", "0"),
d.style.cssText = "width:0;height:0;border:0;display:none;"),
d.setAttribute("id", c),
d.setAttribute("src", b),
d.parentNode || setTimeout(function() {
e.body.appendChild(d)
}, 5)
},
retrieveIframe: function(a) {
var b = t + a,
c = e.querySelector("#" + b);
p.length >= q ? e.body.removeChild(c) : p.indexOf(c) < 0 && p.push(c)
},
callMethod: function(b, c, d, e) {
if (d = A.buildParam(d),
g) h ? a.WindVane_Win_Private.call(b, c, e, d) : this.onComplete(e, {
ret: "HY_NO_HANDLER_ON_WP"
}, "failure");
else {
var f = r + "://" + b + ":" + e + "/" + c + "?" + d;
if (i) this.setParam(e, d),
this.useIframe(e, f);
else if (j) {
var k = s + ":";
window.prompt(f, k)
} else this.onComplete(e, {
ret: "HY_NOT_SUPPORT_DEVICE"
}, "failure")
}
},
registerGC: function(a, b) {
var c = this,
d = Math.max(b || 0, w),
e = Math.max(b || 0, y),
f = Math.max(b || 0, x);
setTimeout(function() {
c.unregisterCall(a)
}, d),
i ? setTimeout(function() {
c.params[u + a] && delete c.params[u + a]
}, e) : j && setTimeout(function() {
c.chunks[v + a] && delete c.chunks[v + a]
}, f)
},
onComplete: function(a, b, c) {
var d = this.unregisterCall(a),
e = d.success,
f = d.failure,
g = d.deferred,
h = d.timeout;
h && clearTimeout(h),
b = b ? b : this.getData(a),
b = this.parseData(b);
var k = b.ret;
"string" == typeof k && (b = b.value || b,
b.ret || (b.ret = [k])),
"success" === c ? (e && e(b),
g && g.resolve(b)) : "failure" === c && (f && f(b),
g && g.reject(b)),
i ? (this.retrieveIframe(a),
this.params[u + a] && delete this.params[u + a]) : j && this.chunks[v + a] && delete this.chunks[v + a]
}
};
for (var B in z)
l.call(m, B) || (m[B] = z[B])
}(window, window.lib || (window.lib = {}));
"use strict";
var _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(a) {
return typeof a
} : function(a) {
return a && "function" == typeof Symbol && a.constructor === Symbol && a !== Symbol.prototype ? "symbol" : typeof a
};
! function(a, n) {
function i(a) {
var n = this;
if (!n.options) return a();
if (!n.params) return a();
var i = n.params || {}, o = n.options || {}, e = m(),
t = e.regionID,
r = e.language,
d = p(t);
o.querystring = o.querystring || {},
o.querystring["x-i18n-regionID"] = i["x-i18n-regionID"] || t || i.regionID,
o.querystring["x-i18n-language"] = i["x-i18n-language"] || r || i.language,
o.querystring.appkey = c() ? "4272" : "24677475";
var l = new RegExp(["(" + o.prefix + ")", "(" + o.subDomain + ")", o.mainDomain].join("."));
return 0 === o.prefix.length && (l = new RegExp(["(" + o.subDomain + ")", o.mainDomain].join("."))),
o.path && 0 !== o.path.length ? (0 !== d.prefix.length ? o.path = o.path.replace(l, d.prefix + "." + d.subDomain + "." + d.mainDomain) : o.path = o.path.replace(l, d.subDomain + "." + d.mainDomain),
a()) : a()
}
var o = {
ID: {
prefix: "",
subDomain: "acs-m",
mainDomain: "lazada.co.id"
},
MY: {
prefix: "",
subDomain: "acs-m",
mainDomain: "lazada.com.my"
},
PH: {
prefix: "",
subDomain: "acs-m",
mainDomain: "lazada.com.ph"
},
SG: {
prefix: "",
subDomain: "acs-m",
mainDomain: "lazada.sg"
},
TH: {
prefix: "",
subDomain: "acs-m",
mainDomain: "lazada.co.th"
},
VN: {
prefix: "",
subDomain: "acs-m",
mainDomain: "lazada.vn"
},
DAILY: {
prefix: "acs",
subDomain: "waptest",
mainDomain: "lazada.test"
},
PRE: {
ID: {
prefix: "",
subDomain: "acs-wapa",
mainDomain: "lazada.co.id"
},
MY: {
prefix: "",
subDomain: "acs-wapa",
mainDomain: "lazada.com.my"
},
PH: {
prefix: "",
subDomain: "acs-wapa",
mainDomain: "lazada.com.ph"
},
SG: {
prefix: "",
subDomain: "acs-wapa",
mainDomain: "lazada.sg"
},
TH: {
prefix: "",
subDomain: "acs-wapa",
mainDomain: "lazada.co.th"
},
VN: {
prefix: "",
subDomain: "acs-wapa",
mainDomain: "lazada.vn"
}
}
}, e = {
ID: {
id: "360",
lang: ["id"],
langShort: ["id"],
currency: "IDR",
domain: "lazada.co.id"
},
MY: {
id: "458",
currency: "MYR",
lang: ["en-MY", "ms"],
langShort: ["en", "ms"],
domain: "lazada.com.my"
},
PH: {
id: "608",
currency: "PHP",
lang: ["en-PH"],
langShort: ["en"],
domain: "lazada.com.ph"
},
SG: {
id: "702",
currency: "SGD",
lang: ["en-SG"],
langShort: ["en"],
domain: "lazada.sg"
},
TH: {
id: "764",
currency: "THB",
lang: ["th", "en"],
domain: "lazada.co.th"
},
VN: {
id: "704",
currency: "VND",
lang: ["vi", "en"],
domain: "lazada.vn"
}
}, t = "function" == typeof callNative,
r = function() {
if (t) return "weex";
var a = navigator.userAgent.toLowerCase();
if (/AliApp/i.test(a)) {
var n = "",
i = a.match(/AliApp\(([a-z-A-Z]{1,20})\/(\d+(\.\d+){0,3})?\)/i);
if (i && i.length >= 3 && (n = i[1]),
n && ("la-android" === n.toLowerCase() || "la" === n.toLowerCase())) return "windvane"
}
return "h5"
};
if ("windvane" === r() || "weex" === r()) return void console.warn("native 内中间件失效");
if (!n || !n.mtop || n.mtop.ERROR) throw new Error("Mtop 初始化失败!请参考Mtop文档http://gitlab.alibaba-inc.com/mtb/lib-mtop");
var m = function() {
var a = "",
n = "",
i = void 0;
if ("object" === ("undefined" == typeof window ? "undefined" : _typeof(window)) && window._i18n_) {
if ("string" == typeof(i = window._i18n_)) try {
i = JSON.parse(i)
} catch (a) {
i = {}
}
"object" === (void 0 === i ? "undefined" : _typeof(i)) && (a = i.regionID,
n = i.language)
}
if (!a && window.g_config && "object" === _typeof(window.g_config) && (a = window.g_config.regionID,
n = window.g_config.language), !a && "object" === ("undefined" == typeof location ? "undefined" : _typeof(location)) && location.hostname) for (var o in e) {
var t = e[o];
if (t && t.domain && location.hostname.indexOf(t.domain) >= 0) {
a = o,
n = e[o].lang[0];
break
}
}
return a = a || "",
n = n || "", {
regionID: a,
language: n
}
}, c = function() {
var a = window && window.location.host || "";
return RegExp(/127.0.0.1|local|daily|waptest|test/).test(a) || location.search.indexOf("debug=true") >= 0
}, d = function() {
var a = "object" === ("undefined" == typeof location ? "undefined" : _typeof(location)) && location.hostname || "";
return a.indexOf("-p.lazada.") >= 0 || a.indexOf("pre-wormhole.") >= 0
}, p = function(a) {
var n = "";
if (c()) n = o.DAILY;
else if (d()) n = o.PRE[a.toLocaleUpperCase()];
else {
if ("string" != typeof a || !a) {
var i = m() || {};
a = i.regionID || "SG"
}
n = o[a.toLocaleUpperCase()]
}
return n
};
n.mtop.middlewares.push(i)
}(window, window.lib || (window.lib = {}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment