Commit d1c04132 authored by 肖健's avatar 肖健

更新js

parent d36ebe78
"use strict";
function initDeviceInfo() {
_getSystemInfo(), _getNetworkType(), _getWifiInfo(), _getHCEState(), _getScreenBrightness(), _getAccountInfo(), _getUserInfo();
}
function _getSystemInfo() {
try {
schedule._getSystemInfo = !1, uni.getSystemInfo({
success: function (e) {
_setDeviceInfo({
vlv: e.SDKVersion,
ve: e.version || "",
fs: e.fontSizeSetting || -1,
la: e.language || "",
br: e.brand || "",
mo: e.model || "",
pr: e.pixelRatio || -1,
pl: e.platform || "",
sh: e.screenHeight || "",
sw: e.screenWidth || "",
sbh: e.statusBarHeight || "",
sy: e.system || "",
wh: e.windowHeight || "",
ww: e.windowWidth || "",
bl: e.benchmarkLevel || ""
});
},
complete: function (e) {
schedule._getSystemInfo = !0;
}
});
} catch (e) {
schedule._getSystemInfo = !0;
}
}
function _getNetworkType() {
try {
schedule._getNetworkType = !1, uni.getNetworkType({
success: function (e) {
_setDeviceInfo({
nt: e.networkType || ""
});
},
complete: function (e) {
schedule._getNetworkType = !0;
}
});
} catch (e) {
schedule._getNetworkType = !0;
}
}
function _getWifiInfo() {
try {
schedule._getWifiInfo = !1, uni.getConnectedWifi({
success: function (e) {
if (e.wifi) for (var t in e.wifi) {
var n = {};
n.bs = e.wifi.BSSID, n.ss = e.wifi.SSID, n.aj = e.wifi.autoJoined, n.jj = e.wifi.justJoined, n.sc = e.wifi.secure, n.sgs = e.wifi.signalStrength, _setDeviceInfo({
wi: n
});
}
},
complete: function (e) {
schedule._getWifiInfo = !0;
}
});
} catch (e) {
schedule._getWifiInfo = !0;
}
}
function _getSoterAuthentication() {
try {
schedule._getSoterAuthentication = !1, uni.startSoterAuthentication({
requestAuthModes: ["fake"],
challenge: "code",
complete: function (e) {
e.resultJSON && _setDeviceInfo({
cpi: JSON.parse(e.resultJSON).cpu_id
}), schedule._getSoterAuthentication = !0;
}
});
} catch (e) {
schedule._getSoterAuthentication = !0;
}
}
function _getHCEState() {
try {
schedule._getHCEState = !1, uni.getHCEState({
success: function (e) {
_setDeviceInfo(e && 0 == e.errCode ? {
hh: 0
} : e.errCode ? {
hh: e.errCode
} : {
hh: 1
});
},
fail: function (e) {
_setDeviceInfo({
hh: 1
});
},
complete: function () {
schedule._getHCEState = !0;
}
});
} catch (e) {
_setDeviceInfo({
hh: -1
}), schedule._getHCEState = !0;
}
}
function _getScreenBrightness() {
try {
schedule._getScreenBrightness = !1, uni.getScreenBrightness({
success: function (e) {
_setDeviceInfo({
sbr: e.value
});
},
complete: function (e) {
schedule._getScreenBrightness = !0;
}
});
} catch (e) {
schedule._getScreenBrightness = !0;
}
}
function _getAccountInfo() {
try {
var e = uni.getAccountInfoSync();
e && e.miniProgram && _setDeviceInfo({
vid: e.miniProgram.appId
});
} catch (e) {}
}
function _getUserInfo() {
function e() {
try {
schedule._getUserInfo = !1, uni.getUserInfo({
success: function (e) {
e.userInfo && _setDeviceInfo({
au: e.userInfo.avatarUrl,
ge: e.userInfo.gender,
nn: e.userInfo.nickName,
city: e.userInfo.city,
province: e.userInfo.province,
country: e.userInfo.country
});
},
complete: function (e) {
schedule._getUserInfo = !0;
}
});
} catch (e) {
schedule._getUserInfo = !0;
}
}
try {
uni.getSetting({
success: function (t) {
t.authSetting["scope.userInfo"] && e();
}
});
} catch (e) {}
}
function _setDeviceInfo(e) {
if (e) for (var t in e) "errMsg" != t && (deviceInfo[t] = e[t]);
}
function getCanvasId(e) {
var t = 0,
n = null;
if (compareVersion(uni.getSystemInfoSync().SDKVersion, "1.9.9") >= 0 && !option.canvasOff) n = setInterval(function () {
var i = !0;
for (var c in schedule) schedule[c] || (i = !1);
(i || t >= 20) && (clearInterval(n), _getDeviceUUID(deviceInfo, function (t) {
_setDeviceInfo({
ci: t
}), e && e();
})), t++;
}, intervalTime);else e && e();
}
function reportData(e) {
eidComplete = !1;
var t = uni.getStorageSync("tk");
deviceInfo.bk = bizKey, deviceInfo.cpi && delete deviceInfo.cpi, deviceInfo.unionid && delete deviceInfo.unionid, deviceInfo.cliet = new Date().getTime();
var n = tdencrypt(deviceInfo);
uni.request({
url: baseUrl + "/stone/1/" + (void 0 == t || null == t || "" == t ? "L64RTJ562VJEYNEQN67XMUWSR4UFLOIQHJYZ3MWERRIKJGP24SDSBDS4I4AMVU24Y3Y7A4UPDICN2" : t),
method: "POST",
data: n,
header: header,
success: function (e) {
e.data && 0 == e.data.code && e.data.data && uni.setStorageSync("tk", e.data.data.tk);
},
fail: function (e) {},
complete: function (t) {
reportCallback && reportCallback(e, t), eidComplete = !0;
}
});
}
function reportCallback(e, t) {
var n = uni.getStorageSync("tk");
t.data ? 0 == t.data.code ? (t.data.data && t.data.data.tk && (n = t.data.data.tk), e({
tk: t.data.data.tk
})) : e({
errMsg: t.data.msg,
tk: n
}) : e({
errMsg: t.errMsg,
tk: n
});
}
function _getDeviceUUID(e, t, n, i) {
var c = {
st: new Date().getTime()
},
o = uni.createCanvasContext(canvasId, this);
if (!o) return void (n && n instanceof Function && n({
errMsg: "Canvas creation failed,Please check if canvasId is consistent"
}));
var r = e.pl || "";
o.globalCompositeOperation = "android" == r ? "xor" : "multiply", o.rect(0, 0, 10, 10), o.rect(2, 2, 6, 6), o.textBaseline = "alphabetic", o.fillStyle = "#f60", o.fillRect(32, 1, 62, 20), o.fillStyle = "#069", o.fillText("Cwwm aa fjorddbank glbyphs veext qtuiz, 😃", 2, 15), o.fillStyle = "rgba(102, 204, 0, 0.2)", o.font = "18pt Arial", o.fillText("Cwwm aa fjorddbank glbyphs veext qtuiz, 😃", 4, 45), o.fillStyle = "rgb(255,0,255)", c.txts = new Date().getTime();
var a = 16,
s = 16;
o.beginPath(), o.arc(a, s, 16, 0, 2 * Math.PI, !0), o.closePath(), o.fill(), a = 32, s = 16, o.fillStyle = "rgb(0,255,255)", o.beginPath(), o.arc(a, s, 16, 0, 2 * Math.PI, !0), o.closePath(), o.fill(), a = 24, s = 32, o.fillStyle = "rgb(255,255,0)", o.beginPath(), o.arc(a, s, 16, 0, 2 * Math.PI, !0), o.closePath(), o.fill(), a = 24, s = 24, o.fillStyle = "rgb(255,0,255)", o.arc(a, s, 24, 0, 2 * Math.PI, !0), o.arc(a, s, 8, 0, 2 * Math.PI, !0), o.fill(), c.circlet = new Date().getTime();
o.beginPath(), o.textBaseline = "top", o.font = "14px Arial", o.fillStyle = "#000", o.closePath();
for (var f = "", l = ["cpi", "br", "mo", "pr", "pl", "sh", "sw", "hh"], u = 0; u < l.length; u++) f = e[l[u]] || "", o.fillText(f, 0, 15 * (u + 1));
c.fixedt = new Date().getTime();
var g = "";
o.draw(!1, function () {
uni.canvasToTempFilePath({
canvasId: canvasId,
x: 0,
y: 0,
width: 100,
height: 100,
destWidth: 100,
destHeight: 100,
fileType: "png",
success: function (n) {
n.tempFilePath;
try {
c.drawt = new Date().getTime();
var i = uni.getFileSystemManager().readFileSync(n.tempFilePath, "base64");
g = md5.hexMD5(i), c.md5t = new Date().getTime(), e.cavt = c, t && t(g);
} catch (e) {
t && t("");
}
},
fail: function (e) {
t && t("");
},
complete: function (e) {
i && i(e);
}
});
});
}
function tdencrypt(e) {
var t = JSON.stringify(e);
e = encodeURIComponent(t);
var n,
i,
c,
o,
r,
a = "",
s = "",
f = "",
l = 0;
do {
c = (n = e.charCodeAt(l++)) >> 2, o = (3 & n) << 4 | (i = e.charCodeAt(l++)) >> 4, r = (15 & i) << 2 | (s = e.charCodeAt(l++)) >> 6, f = 63 & s, isNaN(i) ? r = f = 64 : isNaN(s) && (f = 64), a = a + keyStr.charAt(c) + keyStr.charAt(o) + keyStr.charAt(r) + keyStr.charAt(f), n = i = s = "", c = o = r = f = "";
} while (l < e.length);
return a + "/";
}
function compareVersion(e, t) {
e = e.split("."), t = t.split(".");
for (var n = Math.max(e.length, t.length); e.length < n;) e.push("0");
for (; t.length < n;) t.push("0");
for (var i = 0; i < n; i++) {
var c = parseInt(e[i]),
o = parseInt(t[i]);
if (c > o) return 1;
if (c < o) return -1;
}
return 0;
}
var md5 = function () {
function e(e, t) {
var n = (65535 & e) + (65535 & t);
return (e >> 16) + (t >> 16) + (n >> 16) << 16 | 65535 & n;
}
function t(e, t) {
return e << t | e >>> 32 - t;
}
function n(n, i, c, o, r, a) {
return e(t(e(e(i, n), e(o, a)), r), c);
}
function i(e, t, i, c, o, r, a) {
return n(t & i | ~t & c, e, t, o, r, a);
}
function c(e, t, i, c, o, r, a) {
return n(t & c | i & ~c, e, t, o, r, a);
}
function o(e, t, i, c, o, r, a) {
return n(t ^ i ^ c, e, t, o, r, a);
}
function r(e, t, i, c, o, r, a) {
return n(i ^ (t | ~c), e, t, o, r, a);
}
function a(t) {
for (var n = 1732584193, a = -271733879, s = -1732584194, f = 271733878, l = 0; l < t.length; l += 16) {
var u = n,
g = a,
d = s,
h = f;
a = r(a = r(a = r(a = r(a = o(a = o(a = o(a = o(a = c(a = c(a = c(a = c(a = i(a = i(a = i(a = i(a, s = i(s, f = i(f, n = i(n, a, s, f, t[l + 0], 7, -680876936), a, s, t[l + 1], 12, -389564586), n, a, t[l + 2], 17, 606105819), f, n, t[l + 3], 22, -1044525330), s = i(s, f = i(f, n = i(n, a, s, f, t[l + 4], 7, -176418897), a, s, t[l + 5], 12, 1200080426), n, a, t[l + 6], 17, -1473231341), f, n, t[l + 7], 22, -45705983), s = i(s, f = i(f, n = i(n, a, s, f, t[l + 8], 7, 1770035416), a, s, t[l + 9], 12, -1958414417), n, a, t[l + 10], 17, -42063), f, n, t[l + 11], 22, -1990404162), s = i(s, f = i(f, n = i(n, a, s, f, t[l + 12], 7, 1804603682), a, s, t[l + 13], 12, -40341101), n, a, t[l + 14], 17, -1502002290), f, n, t[l + 15], 22, 1236535329), s = c(s, f = c(f, n = c(n, a, s, f, t[l + 1], 5, -165796510), a, s, t[l + 6], 9, -1069501632), n, a, t[l + 11], 14, 643717713), f, n, t[l + 0], 20, -373897302), s = c(s, f = c(f, n = c(n, a, s, f, t[l + 5], 5, -701558691), a, s, t[l + 10], 9, 38016083), n, a, t[l + 15], 14, -660478335), f, n, t[l + 4], 20, -405537848), s = c(s, f = c(f, n = c(n, a, s, f, t[l + 9], 5, 568446438), a, s, t[l + 14], 9, -1019803690), n, a, t[l + 3], 14, -187363961), f, n, t[l + 8], 20, 1163531501), s = c(s, f = c(f, n = c(n, a, s, f, t[l + 13], 5, -1444681467), a, s, t[l + 2], 9, -51403784), n, a, t[l + 7], 14, 1735328473), f, n, t[l + 12], 20, -1926607734), s = o(s, f = o(f, n = o(n, a, s, f, t[l + 5], 4, -378558), a, s, t[l + 8], 11, -2022574463), n, a, t[l + 11], 16, 1839030562), f, n, t[l + 14], 23, -35309556), s = o(s, f = o(f, n = o(n, a, s, f, t[l + 1], 4, -1530992060), a, s, t[l + 4], 11, 1272893353), n, a, t[l + 7], 16, -155497632), f, n, t[l + 10], 23, -1094730640), s = o(s, f = o(f, n = o(n, a, s, f, t[l + 13], 4, 681279174), a, s, t[l + 0], 11, -358537222), n, a, t[l + 3], 16, -722521979), f, n, t[l + 6], 23, 76029189), s = o(s, f = o(f, n = o(n, a, s, f, t[l + 9], 4, -640364487), a, s, t[l + 12], 11, -421815835), n, a, t[l + 15], 16, 530742520), f, n, t[l + 2], 23, -995338651), s = r(s, f = r(f, n = r(n, a, s, f, t[l + 0], 6, -198630844), a, s, t[l + 7], 10, 1126891415), n, a, t[l + 14], 15, -1416354905), f, n, t[l + 5], 21, -57434055), s = r(s, f = r(f, n = r(n, a, s, f, t[l + 12], 6, 1700485571), a, s, t[l + 3], 10, -1894986606), n, a, t[l + 10], 15, -1051523), f, n, t[l + 1], 21, -2054922799), s = r(s, f = r(f, n = r(n, a, s, f, t[l + 8], 6, 1873313359), a, s, t[l + 15], 10, -30611744), n, a, t[l + 6], 15, -1560198380), f, n, t[l + 13], 21, 1309151649), s = r(s, f = r(f, n = r(n, a, s, f, t[l + 4], 6, -145523070), a, s, t[l + 11], 10, -1120210379), n, a, t[l + 2], 15, 718787259), f, n, t[l + 9], 21, -343485551), n = e(n, u), a = e(a, g), s = e(s, d), f = e(f, h);
}
return [n, a, s, f];
}
function s(e) {
for (var t = "", n = 0; n < 4 * e.length; n++) t += "0123456789abcdef".charAt(e[n >> 2] >> n % 4 * 8 + 4 & 15) + "0123456789abcdef".charAt(e[n >> 2] >> n % 4 * 8 & 15);
return t;
}
function f(e) {
for (var t = 1 + (e.length + 8 >> 6), n = new Array(16 * t), i = 0; i < 16 * t; i++) n[i] = 0;
for (i = 0; i < e.length; i++) n[i >> 2] |= (255 & e.charCodeAt(i)) << i % 4 * 8;
return n[i >> 2] |= 128 << i % 4 * 8, n[16 * t - 2] = 8 * e.length, n;
}
function l(e) {
return s(a(f(e)));
}
return {
hexMD5: l
};
}(),
header = {
"content-type": "application/json"
},
baseUrl = "https://we.jd.com",
configComplete = !1,
eidComplete = !0,
intervalTime = 100,
option = null,
pageObj = null,
bizKey = "",
bizSource = "",
eid = "",
canvasId = "fbfd3ec3c4ab4213b9a09b5c5e769ceb",
deviceInfo = {
sv: "1.0.3.4",
clist: new Date().getTime()
},
keyStr = "23IL<N01c7KvwZO56RSTAfghiFyzWJqVabGH4PQdopUrsCuX*xeBjkltDEmn89.-",
schedule = {
_getSystemInfo: !0,
_getNetworkType: !0,
_getWifiInfo: !0,
_getSoterAuthentication: !0,
_getHCEState: !0,
_getScreenBrightness: !0,
_getUserInfo: !0
},
config = function (e, t) {
option = t, pageObj = e, bizKey = t.bizKey, bizSource = t.bizSource, configComplete = !0;
},
init = function (e) {
e && e.openid && _setDeviceInfo({
oid: e.openid
}), e && e.unionid && _setDeviceInfo({
unionid: e.unionid
});
},
getEid = function (e) {
getEidEvery(e);
},
getEidEvery = function (e) {
if (initDeviceInfo(), e && "function" == typeof e) {
var t = null,
n = 0;
t = setInterval(function () {
n++;
var i = option.retry || 20;
(eidComplete || n > i) && (clearInterval(t), "plugin" != bizSource ? getCanvasId(function (t) {
reportData(e);
}) : reportData(e));
}, intervalTime);
}
},
getEidOnce = function (e) {
var t = null,
n = 0;
t = setInterval(function () {
n++;
var i = option.retry || 20;
if ((eidComplete || n > i) && (clearInterval(t), e && e instanceof Function)) {
var c = uni.getStorageSync("tk");
e(c ? {
tk: c
} : {
errMsg: "Build failed",
tk: c
});
}
}, intervalTime);
};
module.exports = {
config: config,
init: init,
getEid: getEid
};
\ No newline at end of file
"use strict";function initDeviceInfo(){_getSystemInfo(),_getNetworkType(),_getWifiInfo(),_getHCEState(),_getScreenBrightness(),_getAccountInfo(),_getUserInfo()}function _getSystemInfo(){try{(schedule._getSystemInfo=!1),wx.getSystemInfo({success:function(e){_setDeviceInfo({vlv:e.SDKVersion,ve:e.version||"",fs:e.fontSizeSetting||-1,la:e.language||"",br:e.brand||"",mo:e.model||"",pr:e.pixelRatio||-1,pl:e.platform||"",sh:e.screenHeight||"",sw:e.screenWidth||"",sbh:e.statusBarHeight||"",sy:e.system||"",wh:e.windowHeight||"",ww:e.windowWidth||"",bl:e.benchmarkLevel||"",})},complete:function(e){schedule._getSystemInfo=!0},})}catch(e){schedule._getSystemInfo=!0}}function _getNetworkType(){try{(schedule._getNetworkType=!1),wx.getNetworkType({success:function(e){_setDeviceInfo({nt:e.networkType||""})},complete:function(e){schedule._getNetworkType=!0},})}catch(e){schedule._getNetworkType=!0}}function _getWifiInfo(){try{(schedule._getWifiInfo=!1),wx.getConnectedWifi({success:function(e){if(e.wifi)for(var t in e.wifi){var n={};(n.bs=e.wifi.BSSID),(n.ss=e.wifi.SSID),(n.aj=e.wifi.autoJoined),(n.jj=e.wifi.justJoined),(n.sc=e.wifi.secure),(n.sgs=e.wifi.signalStrength),_setDeviceInfo({wi:n})}},complete:function(e){schedule._getWifiInfo=!0},})}catch(e){schedule._getWifiInfo=!0}}function _getSoterAuthentication(){try{(schedule._getSoterAuthentication=!1),wx.startSoterAuthentication({requestAuthModes:["fake"],challenge:"code",complete:function(e){e.resultJSON&&_setDeviceInfo({cpi:JSON.parse(e.resultJSON).cpu_id}),(schedule._getSoterAuthentication=!0)},})}catch(e){schedule._getSoterAuthentication=!0}}function _getHCEState(){try{(schedule._getHCEState=!1),wx.getHCEState({success:function(e){_setDeviceInfo(e&&0==e.errCode?{hh:0}:e.errCode?{hh:e.errCode}:{hh:1})},fail:function(e){_setDeviceInfo({hh:1})},complete:function(){schedule._getHCEState=!0},})}catch(e){_setDeviceInfo({hh:-1}),(schedule._getHCEState=!0)}}function _getScreenBrightness(){try{(schedule._getScreenBrightness=!1),wx.getScreenBrightness({success:function(e){_setDeviceInfo({sbr:e.value})},complete:function(e){schedule._getScreenBrightness=!0},})}catch(e){schedule._getScreenBrightness=!0}}function _getAccountInfo(){try{var e=wx.getAccountInfoSync();e&&e.miniProgram&&_setDeviceInfo({vid:e.miniProgram.appId})}catch(e){}}function _getUserInfo(){function e(){try{(schedule._getUserInfo=!1),wx.getUserInfo({success:function(e){e.userInfo&&_setDeviceInfo({au:e.userInfo.avatarUrl,ge:e.userInfo.gender,nn:e.userInfo.nickName,city:e.userInfo.city,province:e.userInfo.province,country:e.userInfo.country,})},complete:function(e){schedule._getUserInfo=!0},})}catch(e){schedule._getUserInfo=!0}}try{wx.getSetting({success:function(t){t.authSetting["scope.userInfo"]&&e()},})}catch(e){}}function _setDeviceInfo(e){if(e)for(var t in e)"errMsg"!=t&&(deviceInfo[t]=e[t])}function getCanvasId(e){var t=0,n=null;if(compareVersion(wx.getSystemInfoSync().SDKVersion,"1.9.9")>=0&&!option.canvasOff)n=setInterval(function(){var i=!0;for(var c in schedule)schedule[c]||(i=!1);(i||t>=20)&&(clearInterval(n),_getDeviceUUID(deviceInfo,function(t){_setDeviceInfo({ci:t}),e&&e()})),t++},intervalTime);else e&&e()}function reportData(e){eidComplete=!1;var t=wx.getStorageSync("tk");(deviceInfo.bk=bizKey),deviceInfo.cpi&&delete deviceInfo.cpi,deviceInfo.unionid&&delete deviceInfo.unionid,(deviceInfo.cliet=new Date().getTime());var n=tdencrypt(deviceInfo);wx.request({url:baseUrl+"/stone/1/"+(void 0==t||null==t||""==t?"L64RTJ562VJEYNEQN67XMUWSR4UFLOIQHJYZ3MWERRIKJGP24SDSBDS4I4AMVU24Y3Y7A4UPDICN2":t),method:"POST",data:n,header:header,success:function(e){e.data&&0==e.data.code&&e.data.data&&wx.setStorageSync("tk",e.data.data.tk)},fail:function(e){},complete:function(t){reportCallback&&reportCallback(e,t),(eidComplete=!0)},})}function reportCallback(e,t){var n=wx.getStorageSync("tk");t.data?0==t.data.code?(t.data.data&&t.data.data.tk&&(n=t.data.data.tk),e({tk:t.data.data.tk})):e({errMsg:t.data.msg,tk:n}):e({errMsg:t.errMsg,tk:n})}function _getDeviceUUID(e,t,n,i){var c={st:new Date().getTime()},o=wx.createCanvasContext(canvasId,this);if(!o)return void(n&&n instanceof Function&&n({errMsg:"Canvas creation failed,Please check if canvasId is consistent",}));var r=e.pl||"";(o.globalCompositeOperation="android"==r?"xor":"multiply"),o.rect(0,0,10,10),o.rect(2,2,6,6),(o.textBaseline="alphabetic"),(o.fillStyle="#f60"),o.fillRect(32,1,62,20),(o.fillStyle="#069"),o.fillText("Cwwm aa fjorddbank glbyphs veext qtuiz, 😃",2,15),(o.fillStyle="rgba(102, 204, 0, 0.2)"),(o.font="18pt Arial"),o.fillText("Cwwm aa fjorddbank glbyphs veext qtuiz, 😃",4,45),(o.fillStyle="rgb(255,0,255)"),(c.txts=new Date().getTime());var a=16,s=16;o.beginPath(),o.arc(a,s,16,0,2*Math.PI,!0),o.closePath(),o.fill(),(a=32),(s=16),(o.fillStyle="rgb(0,255,255)"),o.beginPath(),o.arc(a,s,16,0,2*Math.PI,!0),o.closePath(),o.fill(),(a=24),(s=32),(o.fillStyle="rgb(255,255,0)"),o.beginPath(),o.arc(a,s,16,0,2*Math.PI,!0),o.closePath(),o.fill(),(a=24),(s=24),(o.fillStyle="rgb(255,0,255)"),o.arc(a,s,24,0,2*Math.PI,!0),o.arc(a,s,8,0,2*Math.PI,!0),o.fill(),(c.circlet=new Date().getTime());o.beginPath(),(o.textBaseline="top"),(o.font="14px Arial"),(o.fillStyle="#000"),o.closePath();for(var f="",l=["cpi","br","mo","pr","pl","sh","sw","hh"],u=0;u<l.length;u++)(f=e[l[u]]||""),o.fillText(f,0,15*(u+1));c.fixedt=new Date().getTime();var g="";o.draw(!1,function(){wx.canvasToTempFilePath({canvasId:canvasId,x:0,y:0,width:100,height:100,destWidth:100,destHeight:100,fileType:"png",success:function(n){n.tempFilePath;try{c.drawt=new Date().getTime();var i=wx.getFileSystemManager().readFileSync(n.tempFilePath,"base64");(g=md5.hexMD5(i)),(c.md5t=new Date().getTime()),(e.cavt=c),t&&t(g)}catch(e){t&&t("")}},fail:function(e){t&&t("")},complete:function(e){i&&i(e)},})})}function tdencrypt(e){var t=JSON.stringify(e);e=encodeURIComponent(t);var n,i,c,o,r,a="",s="",f="",l=0;do{(c=(n=e.charCodeAt(l++))>>2),(o=((3&n)<<4)|((i=e.charCodeAt(l++))>>4)),(r=((15&i)<<2)|((s=e.charCodeAt(l++))>>6)),(f=63&s),isNaN(i)?(r=f=64):isNaN(s)&&(f=64),(a=a+keyStr.charAt(c)+keyStr.charAt(o)+keyStr.charAt(r)+keyStr.charAt(f)),(n=i=s=""),(c=o=r=f="")}while(l<e.length);return a+"/"}function compareVersion(e,t){(e=e.split(".")),(t=t.split("."));for(var n=Math.max(e.length,t.length);e.length<n;)e.push("0");for(;t.length<n;)t.push("0");for(var i=0;i<n;i++){var c=parseInt(e[i]),o=parseInt(t[i]);if(c>o)return 1;if(c<o)return-1}return 0}var md5=(function(){function e(e,t){var n=(65535&e)+(65535&t);return(((e>>16)+(t>>16)+(n>>16))<<16)|(65535&n)}function t(e,t){return(e<<t)|(e>>>(32-t))}function n(n,i,c,o,r,a){return e(t(e(e(i,n),e(o,a)),r),c)}function i(e,t,i,c,o,r,a){return n((t&i)|(~t&c),e,t,o,r,a)}function c(e,t,i,c,o,r,a){return n((t&c)|(i&~c),e,t,o,r,a)}function o(e,t,i,c,o,r,a){return n(t^i^c,e,t,o,r,a)}function r(e,t,i,c,o,r,a){return n(i^(t|~c),e,t,o,r,a)}function a(t){for(var n=1732584193,a=-271733879,s=-1732584194,f=271733878,l=0;l<t.length;l+=16){var u=n,g=a,d=s,h=f;(a=r((a=r((a=r((a=r((a=o((a=o((a=o((a=o((a=c((a=c((a=c((a=c((a=i((a=i((a=i((a=i(a,(s=i(s,(f=i(f,(n=i(n,a,s,f,t[l+0],7,-680876936)),a,s,t[l+1],12,-389564586)),n,a,t[l+2],17,606105819)),f,n,t[l+3],22,-1044525330)),(s=i(s,(f=i(f,(n=i(n,a,s,f,t[l+4],7,-176418897)),a,s,t[l+5],12,1200080426)),n,a,t[l+6],17,-1473231341)),f,n,t[l+7],22,-45705983)),(s=i(s,(f=i(f,(n=i(n,a,s,f,t[l+8],7,1770035416)),a,s,t[l+9],12,-1958414417)),n,a,t[l+10],17,-42063)),f,n,t[l+11],22,-1990404162)),(s=i(s,(f=i(f,(n=i(n,a,s,f,t[l+12],7,1804603682)),a,s,t[l+13],12,-40341101)),n,a,t[l+14],17,-1502002290)),f,n,t[l+15],22,1236535329)),(s=c(s,(f=c(f,(n=c(n,a,s,f,t[l+1],5,-165796510)),a,s,t[l+6],9,-1069501632)),n,a,t[l+11],14,643717713)),f,n,t[l+0],20,-373897302)),(s=c(s,(f=c(f,(n=c(n,a,s,f,t[l+5],5,-701558691)),a,s,t[l+10],9,38016083)),n,a,t[l+15],14,-660478335)),f,n,t[l+4],20,-405537848)),(s=c(s,(f=c(f,(n=c(n,a,s,f,t[l+9],5,568446438)),a,s,t[l+14],9,-1019803690)),n,a,t[l+3],14,-187363961)),f,n,t[l+8],20,1163531501)),(s=c(s,(f=c(f,(n=c(n,a,s,f,t[l+13],5,-1444681467)),a,s,t[l+2],9,-51403784)),n,a,t[l+7],14,1735328473)),f,n,t[l+12],20,-1926607734)),(s=o(s,(f=o(f,(n=o(n,a,s,f,t[l+5],4,-378558)),a,s,t[l+8],11,-2022574463)),n,a,t[l+11],16,1839030562)),f,n,t[l+14],23,-35309556)),(s=o(s,(f=o(f,(n=o(n,a,s,f,t[l+1],4,-1530992060)),a,s,t[l+4],11,1272893353)),n,a,t[l+7],16,-155497632)),f,n,t[l+10],23,-1094730640)),(s=o(s,(f=o(f,(n=o(n,a,s,f,t[l+13],4,681279174)),a,s,t[l+0],11,-358537222)),n,a,t[l+3],16,-722521979)),f,n,t[l+6],23,76029189)),(s=o(s,(f=o(f,(n=o(n,a,s,f,t[l+9],4,-640364487)),a,s,t[l+12],11,-421815835)),n,a,t[l+15],16,530742520)),f,n,t[l+2],23,-995338651)),(s=r(s,(f=r(f,(n=r(n,a,s,f,t[l+0],6,-198630844)),a,s,t[l+7],10,1126891415)),n,a,t[l+14],15,-1416354905)),f,n,t[l+5],21,-57434055)),(s=r(s,(f=r(f,(n=r(n,a,s,f,t[l+12],6,1700485571)),a,s,t[l+3],10,-1894986606)),n,a,t[l+10],15,-1051523)),f,n,t[l+1],21,-2054922799)),(s=r(s,(f=r(f,(n=r(n,a,s,f,t[l+8],6,1873313359)),a,s,t[l+15],10,-30611744)),n,a,t[l+6],15,-1560198380)),f,n,t[l+13],21,1309151649)),(s=r(s,(f=r(f,(n=r(n,a,s,f,t[l+4],6,-145523070)),a,s,t[l+11],10,-1120210379)),n,a,t[l+2],15,718787259)),f,n,t[l+9],21,-343485551)),(n=e(n,u)),(a=e(a,g)),(s=e(s,d)),(f=e(f,h))}return[n,a,s,f]}function s(e){for(var t="",n=0;n<4*e.length;n++)t+="0123456789abcdef".charAt((e[n>>2]>>((n%4)*8+4))&15)+"0123456789abcdef".charAt((e[n>>2]>>((n%4)*8))&15);return t}function f(e){for(var t=1+((e.length+8)>>6),n=new Array(16*t),i=0;i<16*t;i++)n[i]=0;for(i=0;i<e.length;i++)n[i>>2]|=(255&e.charCodeAt(i))<<((i%4)*8);return((n[i>>2]|=128<<((i%4)*8)),(n[16*t-2]=8*e.length),n)}function l(e){return s(a(f(e)))}return{hexMD5:l}})(),header={"content-type":"application/json"},baseUrl="https://we.jd.com",configComplete=!1,eidComplete=!0,intervalTime=100,option=null,pageObj=null,bizKey="",bizSource="",eid="",canvasId="fbfd3ec3c4ab4213b9a09b5c5e769ceb",deviceInfo={sv:"1.0.3.4",clist:new Date().getTime()},keyStr="23IL<N01c7KvwZO56RSTAfghiFyzWJqVabGH4PQdopUrsCuX*xeBjkltDEmn89.-",schedule={_getSystemInfo:!0,_getNetworkType:!0,_getWifiInfo:!0,_getSoterAuthentication:!0,_getHCEState:!0,_getScreenBrightness:!0,_getUserInfo:!0,},config=function(e,t){(option=t),(pageObj=e),(bizKey=t.bizKey),(bizSource=t.bizSource),(configComplete=!0)},init=function(e){e&&e.openid&&_setDeviceInfo({oid:e.openid}),e&&e.unionid&&_setDeviceInfo({unionid:e.unionid})},getEid=function(e){getEidEvery(e)},getEidEvery=function(e){if((initDeviceInfo(),e&&"function"==typeof e)){var t=null,n=0;t=setInterval(function(){n++;var i=option.retry||20;(eidComplete||n>i)&&(clearInterval(t),"plugin"!=bizSource?getCanvasId(function(t){reportData(e)}):reportData(e))},intervalTime)}},getEidOnce=function(e){var t=null,n=0;t=setInterval(function(){n++;var i=option.retry||20;if((eidComplete||n>i)&&(clearInterval(t),e&&e instanceof Function)){var c=wx.getStorageSync("tk");e(c?{tk:c}:{errMsg:"Build failed",tk:c})}},intervalTime)};module.exports={config:config,init:init,getEid:getEid};
\ No newline at end of file
let plugin = requirePlugin('loginPlugin');
let plugin = requirePlugin("loginPlugin");
(function () {
if (console.jdLoginLog) {
return;
}
let normalLog = console.log;
console.jdLoginLog = (...args) => {
args.unshift('-------登录插件-------');
if (normalLog) {
normalLog(...args);
}
};
})();
if (console.jdLoginLog) return
let normalLog = console.log;
console.jdLoginLog = (...args) => {
args.unshift('-------登录插件-------')
normalLog && normalLog(...args);
}
})()
const utils = {
redirectPage(url) {
uni.redirectTo({
url
});
},
redirectToH5({ page, wvroute }) {
let url = plugin.formH5Url({
page: decodeURIComponent(page),
wvroute
});
utils.redirectPage(url);
},
navigateToH5({ page, wvroute }) {
let url = plugin.formH5Url({
page: decodeURIComponent(page),
wvroute
});
uni.navigateTo({
url
});
},
setLoginParamsStorage(obj = {}) {
if (obj.appid && isNaN(Number(obj.appid))) {
delete obj.appid;
}
plugin.setLoginStorageSync(utils.getLoginConfig(obj));
},
/*
redirectPage(url) {
wx.redirectTo({
url
});
},
redirectToH5({ page, wvroute }) {
let url = plugin.formH5Url({ page: decodeURIComponent(page), wvroute })
utils.redirectPage(url)
},
navigateToH5({ page, wvroute }) {
let url = plugin.formH5Url({ page: decodeURIComponent(page), wvroute })
wx.navigateTo({ url })
},
setLoginParamsStorage(obj = {}) {
if(obj.appid && isNaN(Number(obj.appid))){
delete obj.appid
}
plugin.setLoginStorageSync(utils.getLoginConfig(obj));
},
/*
首页存缓存逻辑(兼容不适用loginConfig直接存缓存):
同名参数优先级:url 中参数 > loginConfig > 缓存中
*/
getLoginConfig(obj = {}) {
//兼容缓存中有returnPage, 传递的参数中无,塞缓存时会用缓存中的值,导致不匹配
const handleUndefinedType = (o = {}) => {
let { pageType = 'redirectTo' } = o;
o.pageType = pageType;
return o;
};
let storageConfig = plugin.getLoginParams();
let config = handleUndefinedType(utils.getDefaultConfig());
let loginParams = {
...storageConfig,
...config
};
if (plugin.isObject(obj)) {
loginParams = {
...loginParams,
...handleUndefinedType(obj)
};
} else {
console.jdLoginLog('登录参数必须为对象');
}
return loginParams;
},
getDefaultConfig() {
let lgConfig;
try {
lgConfig = require('./config.js');
} catch (err) {
console.log('CatchClause', err);
console.log('CatchClause', err);
lgConfig = {};
}
return lgConfig.config || {};
},
handleJump(p = {}) {
let { goback, pluginUrl, riskUrl } = p;
if (goback) {
utils.goBack();
return;
}
if (pluginUrl) {
utils.redirectPage(pluginUrl);
return;
}
if (riskUrl) {
utils.redirectToH5({
page: riskUrl
});
}
},
goBack() {
let params = plugin.getLoginParams();
let { returnPage, pageType } = params;
if (pageType == 'navigateBack') {
uni[pageType]();
return;
}
if (!returnPage) {
uni.showToast({
title: '没有returnPage,无法跳转',
icon: 'none'
});
return;
}
if (pageType !== 'h5') {
returnPage = decodeURIComponent(returnPage);
if (pageType && pageType != 'rediretTo') {
uni[pageType]({
url: returnPage
});
} else {
utils.redirectPage(returnPage);
}
return;
} else {
utils.redirectToH5({
page: returnPage
});
return;
}
},
h5Init(options) {
let p = plugin.getLoginParams();
if (plugin.isEmptyObj(p)) {
utils.setLoginParamsStorage(options);
}
},
setCustomNavigation() {
let { navigationBarColor, navigationBarTitle } = plugin.getLoginParams();
if (plugin.isObject(navigationBarColor)) {
uni.setNavigationBarColor(navigationBarColor);
}
if (plugin.isObject(navigationBarTitle)) {
uni.setNavigationBarTitle(navigationBarTitle);
}
},
requestWithLoginStatus(obj = {}) {
obj.header = obj.header || {};
let [GUID = '', KEY = '', TOKEN = '', PIN = ''] = plugin.getJdListStorage(['guid', 'pt_key', 'pt_token', 'pt_pin']);
let _cookie = `guid=${GUID}; pt_pin=${encodeURIComponent(PIN)}; pt_key=${KEY}; pt_token=${TOKEN}`;
let { cookie } = obj.header;
obj.header.cookie = cookie ? `${cookie};${_cookie}` : _cookie;
uni.request(obj);
},
silentauthlogin(options, goToLogin, callback) {
uni.login({
success(res = {}) {
let { code } = res;
if (code) {
utils.setLoginParamsStorage(options);
plugin
.silentauthlogin(
{
...options,
code
},
goToLogin
)
.then((res) => {
if (callback) {
callback({
isSuccess: res.err_code == 0
});
}
if (goToLogin && res.err_code == 0) {
utils.handleJump(res);
}
})
.catch((res) => {
if (callback) {
callback({
isSuccess: false
});
}
console.jdLoginLog('请重试一次');
});
} else {
if (callback) {
callback({
isSuccess: false
});
}
console.jdLoginLog('wx.login 获取code失败');
}
},
fail() {
if (callback) {
callback({
isSuccess: false
getLoginConfig(obj = {}) {
//兼容缓存中有returnPage, 传递的参数中无,塞缓存时会用缓存中的值,导致不匹配
const handleUndefinedType = (o={})=>{
let { pageType = 'redirectTo' } = o
o.pageType = pageType;
return o
}
let storageConfig = plugin.getLoginParams();
let config = handleUndefinedType(utils.getDefaultConfig());
let loginParams = { ...storageConfig, ...config };
if (plugin.isObject(obj)) {
loginParams = { ...loginParams, ...handleUndefinedType(obj) }
} else {
console.jdLoginLog('登录参数必须为对象')
}
return loginParams
},
getDefaultConfig() {
let lgConfig;
try {
lgConfig = require("./config.js");
} catch (err) {
lgConfig = {};
}
return lgConfig.config || {}
},
handleJump(p = {}) {
let { goback, pluginUrl, riskUrl } = p;
if (goback) {
utils.goBack();
return
}
if (pluginUrl) {
utils.redirectPage(pluginUrl);
return
}
riskUrl && utils.redirectToH5({ page: riskUrl })
},
goBack() {
let params = plugin.getLoginParams(),
{ returnPage, pageType } = params;
if(pageType == 'navigateBack'){
wx[pageType]();
return;
}
if (!returnPage) {
wx.showToast({
title: '没有returnPage,无法跳转',
icon: 'none'
})
return
}
if (pageType !== 'h5') {
returnPage = decodeURIComponent(returnPage);
if(pageType && pageType != 'rediretTo'){
wx[pageType]({url: returnPage})
}else{
utils.redirectPage(returnPage)
}
return;
} else {
utils.redirectToH5({ page: returnPage })
return;
}
},
h5Init(options) {
let p = plugin.getLoginParams();
if (plugin.isEmptyObj(p)) utils.setLoginParamsStorage(options)
},
setCustomNavigation() {
let { navigationBarColor, navigationBarTitle } = plugin.getLoginParams();
plugin.isObject(navigationBarColor) && wx.setNavigationBarColor(navigationBarColor);
plugin.isObject(navigationBarTitle) && wx.setNavigationBarTitle(navigationBarTitle);
},
requestWithLoginStatus(obj = {}) {
obj.header = obj.header || {};
let [GUID = '', KEY = '', TOKEN = '', PIN = ''] = plugin.getJdListStorage(['guid', 'pt_key', 'pt_token', 'pt_pin']),
_cookie = `guid=${GUID}; pt_pin=${encodeURIComponent(PIN)}; pt_key=${KEY}; pt_token=${TOKEN}`,
{ cookie } = obj.header ;
obj.header.cookie = cookie ? `${cookie};${_cookie}` : _cookie;
wx.request(obj)
},
silentauthlogin(options, goToLogin, callback) {
wx.login({
success(res = {}) {
let { code } = res;
if (code) {
utils.setLoginParamsStorage(options);
plugin.silentauthlogin({ ...options, code }, goToLogin)
.then((res) => {
callback && callback({isSuccess: res.err_code == 0});
if(goToLogin && res.err_code == 0){
utils.handleJump(res)
}
})
.catch((res) => {
callback && callback({isSuccess: false});
console.jdLoginLog('请重试一次');
});
}
} else {
callback && callback({isSuccess: false});
console.jdLoginLog('wx.login 获取code失败');
}
});
}
};
export default utils;
},
fail() {
callback && callback({isSuccess: false});
},
});
}
}
export default utils
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment