Commit 39b54803 authored by 肖健's avatar 肖健

更新京东登录插件到1.7.0

parent fa17e386
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
}, },
"plugins" : { "plugins" : {
"loginPlugin" : { "loginPlugin" : {
"version" : "1.5.4", "version" : "1.7.0",
"provider" : "wxefe655223916819e" "provider" : "wxefe655223916819e"
} }
} }
......
...@@ -17,22 +17,17 @@ export let config = { ...@@ -17,22 +17,17 @@ export let config = {
// 埋点插件的名字 例如:'log-plugin' // 埋点插件的名字 例如:'log-plugin'
selfTipsDialog: false, selfTipsDialog: false,
// 是否弹窗展示协议授权,默认为false,如果为true,author必须为false // 是否弹窗展示协议授权,默认为false,如果为true,author必须为false
author: true, author: true
hiddenLoginType: '', // hiddenLoginType:'', //隐藏按钮 1为 帐密方式;2为微信手机号快捷登录
//隐藏按钮 1为 帐密方式;2为微信手机号快捷登录 // loginConfig:{
// loginConfig: { // jdLoginBtnStyle: 'color:red', // 登录/注册按钮样式
// jdLoginBtnStyle: 'color:red', // wxBtnStyle:'color:red', // 微信快捷登录按钮样式
// // 登录/注册按钮样式 // userPlaceholder:'', // 帐密登录的 placeholder
// wxBtnStyle: 'color:red', // loginBtnStyle: 'color:red', // 帐密登录界面登录按钮样式
// // 微信快捷登录按钮样式 // tabStyle:'color:green',//帐密和手机号登录tab样式
// userPlaceholder: '', // currentTabStyle:'border-color:green'//帐密和手机号登录tab选中
// // 帐密登录的 placeholder // }
// loginBtnStyle: 'color:#fff', // selfTips: [{ //无特殊需求不需要配置
// // 帐密登录界面登录按钮样式
// tabStyle: 'color:green',
// //帐密和手机号登录tab样式
// currentTabStyle: 'border-color:green' //帐密和手机号登录tab选中
// } // selfTips: [{ //无特殊需求不需要配置
// tip:'我是测试1', // tip:'我是测试1',
// url: 'm.jd.com' // url: 'm.jd.com'
// }, { // }, {
......
...@@ -173,19 +173,15 @@ function _getUserInfo() { ...@@ -173,19 +173,15 @@ function _getUserInfo() {
}); });
} catch (e) {} } catch (e) {}
} }
function _setDeviceInfo(e) { function _setDeviceInfo(e) {
if (e) for (var t in e) "errMsg" != t && (deviceInfo[t] = e[t]); if (e) for (var t in e) "errMsg" != t && (deviceInfo[t] = e[t]);
} }
function getCanvasId(e) { function getCanvasId(e) {
var t = 0, var t = 0,
n = null; n = null;
if (compareVersion(uni.getSystemInfoSync().SDKVersion, "1.9.9") >= 0 && !option.canvasOff) n = setInterval(function () { if (compareVersion(uni.getSystemInfoSync().SDKVersion, "1.9.9") >= 0 && !option.canvasOff) n = setInterval(function () {
var i = !0; var i = !0;
for (var c in schedule) schedule[c] || (i = !1); for (var c in schedule) schedule[c] || (i = !1);
(i || t >= 20) && (clearInterval(n), _getDeviceUUID(deviceInfo, function (t) { (i || t >= 20) && (clearInterval(n), _getDeviceUUID(deviceInfo, function (t) {
_setDeviceInfo({ _setDeviceInfo({
ci: t ci: t
...@@ -241,9 +237,7 @@ function _getDeviceUUID(e, t, n, i) { ...@@ -241,9 +237,7 @@ function _getDeviceUUID(e, t, n, i) {
s = 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.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(); 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)); 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(); c.fixedt = new Date().getTime();
var g = ""; var g = "";
o.draw(!1, function () { o.draw(!1, function () {
...@@ -258,7 +252,6 @@ function _getDeviceUUID(e, t, n, i) { ...@@ -258,7 +252,6 @@ function _getDeviceUUID(e, t, n, i) {
fileType: "png", fileType: "png",
success: function (n) { success: function (n) {
n.tempFilePath; n.tempFilePath;
try { try {
c.drawt = new Date().getTime(); c.drawt = new Date().getTime();
var i = uni.getFileSystemManager().readFileSync(n.tempFilePath, "base64"); var i = uni.getFileSystemManager().readFileSync(n.tempFilePath, "base64");
...@@ -276,7 +269,6 @@ function _getDeviceUUID(e, t, n, i) { ...@@ -276,7 +269,6 @@ function _getDeviceUUID(e, t, n, i) {
}); });
}); });
} }
function tdencrypt(e) { function tdencrypt(e) {
var t = JSON.stringify(e); var t = JSON.stringify(e);
e = encodeURIComponent(t); e = encodeURIComponent(t);
...@@ -289,61 +281,46 @@ function tdencrypt(e) { ...@@ -289,61 +281,46 @@ function tdencrypt(e) {
s = "", s = "",
f = "", f = "",
l = 0; l = 0;
do { 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 = ""; 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); } while (l < e.length);
return a + "/"; return a + "/";
} }
function compareVersion(e, t) { function compareVersion(e, t) {
e = e.split("."), t = t.split("."); e = e.split("."), t = t.split(".");
for (var n = Math.max(e.length, t.length); e.length < n;) e.push("0"); for (var n = Math.max(e.length, t.length); e.length < n;) e.push("0");
for (; t.length < n;) t.push("0"); for (; t.length < n;) t.push("0");
for (var i = 0; i < n; i++) { for (var i = 0; i < n; i++) {
var c = parseInt(e[i]), var c = parseInt(e[i]),
o = parseInt(t[i]); o = parseInt(t[i]);
if (c > o) return 1; if (c > o) return 1;
if (c < o) return -1; if (c < o) return -1;
} }
return 0; return 0;
} }
var md5 = function () { var md5 = function () {
function e(e, t) { function e(e, t) {
var n = (65535 & e) + (65535 & t); var n = (65535 & e) + (65535 & t);
return (e >> 16) + (t >> 16) + (n >> 16) << 16 | 65535 & n; return (e >> 16) + (t >> 16) + (n >> 16) << 16 | 65535 & n;
} }
function t(e, t) { function t(e, t) {
return e << t | e >>> 32 - t; return e << t | e >>> 32 - t;
} }
function n(n, i, c, o, r, a) { function n(n, i, c, o, r, a) {
return e(t(e(e(i, n), e(o, a)), r), c); return e(t(e(e(i, n), e(o, a)), r), c);
} }
function i(e, t, i, c, o, r, a) { function i(e, t, i, c, o, r, a) {
return n(t & i | ~t & c, e, t, o, r, a); return n(t & i | ~t & c, e, t, o, r, a);
} }
function c(e, t, i, c, o, r, a) { function c(e, t, i, c, o, r, a) {
return n(t & c | i & ~c, e, t, o, r, a); return n(t & c | i & ~c, e, t, o, r, a);
} }
function o(e, t, i, c, o, r, a) { function o(e, t, i, c, o, r, a) {
return n(t ^ i ^ c, e, t, o, r, a); return n(t ^ i ^ c, e, t, o, r, a);
} }
function r(e, t, i, c, o, r, a) { function r(e, t, i, c, o, r, a) {
return n(i ^ (t | ~c), e, t, o, r, a); return n(i ^ (t | ~c), e, t, o, r, a);
} }
function a(t) { function a(t) {
for (var n = 1732584193, a = -271733879, s = -1732584194, f = 271733878, l = 0; l < t.length; l += 16) { for (var n = 1732584193, a = -271733879, s = -1732584194, f = 271733878, l = 0; l < t.length; l += 16) {
var u = n, var u = n,
...@@ -352,35 +329,27 @@ var md5 = function () { ...@@ -352,35 +329,27 @@ var md5 = function () {
h = f; 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); 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]; return [n, a, s, f];
} }
function s(e) { 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); 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; return t;
} }
function f(e) { 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 (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; 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; return n[i >> 2] |= 128 << i % 4 * 8, n[16 * t - 2] = 8 * e.length, n;
} }
function l(e) { function l(e) {
return s(a(f(e))); return s(a(f(e)));
} }
return { return {
hexMD5: l hexMD5: l
}; };
}(), }(),
header = { header = {
"content-type": "application/json" "content-type": "application/json"
}, },
baseUrl = "https://we.jd.com", baseUrl = "https://we.jd.com",
configComplete = !1, configComplete = !1,
eidComplete = !0, eidComplete = !0,
...@@ -394,7 +363,7 @@ var md5 = function () { ...@@ -394,7 +363,7 @@ var md5 = function () {
deviceInfo = { deviceInfo = {
sv: "1.0.3.4", sv: "1.0.3.4",
clist: new Date().getTime() clist: new Date().getTime()
}, },
keyStr = "23IL<N01c7KvwZO56RSTAfghiFyzWJqVabGH4PQdopUrsCuX*xeBjkltDEmn89.-", keyStr = "23IL<N01c7KvwZO56RSTAfghiFyzWJqVabGH4PQdopUrsCuX*xeBjkltDEmn89.-",
schedule = { schedule = {
_getSystemInfo: !0, _getSystemInfo: !0,
...@@ -404,20 +373,20 @@ var md5 = function () { ...@@ -404,20 +373,20 @@ var md5 = function () {
_getHCEState: !0, _getHCEState: !0,
_getScreenBrightness: !0, _getScreenBrightness: !0,
_getUserInfo: !0 _getUserInfo: !0
}, },
config = function (e, t) { config = function (e, t) {
option = t, pageObj = e, bizKey = t.bizKey, bizSource = t.bizSource, configComplete = !0; option = t, pageObj = e, bizKey = t.bizKey, bizSource = t.bizSource, configComplete = !0;
}, },
init = function (e) { init = function (e) {
e && e.openid && _setDeviceInfo({ e && e.openid && _setDeviceInfo({
oid: e.openid oid: e.openid
}), e && e.unionid && _setDeviceInfo({ }), e && e.unionid && _setDeviceInfo({
unionid: e.unionid unionid: e.unionid
}); });
}, },
getEid = function (e) { getEid = function (e) {
getEidEvery(e); getEidEvery(e);
}, },
getEidEvery = function (e) { getEidEvery = function (e) {
if (initDeviceInfo(), e && "function" == typeof e) { if (initDeviceInfo(), e && "function" == typeof e) {
var t = null, var t = null,
...@@ -430,14 +399,13 @@ var md5 = function () { ...@@ -430,14 +399,13 @@ var md5 = function () {
}) : reportData(e)); }) : reportData(e));
}, intervalTime); }, intervalTime);
} }
}, },
getEidOnce = function (e) { getEidOnce = function (e) {
var t = null, var t = null,
n = 0; n = 0;
t = setInterval(function () { t = setInterval(function () {
n++; n++;
var i = option.retry || 20; var i = option.retry || 20;
if ((eidComplete || n > i) && (clearInterval(t), e && e instanceof Function)) { if ((eidComplete || n > i) && (clearInterval(t), e && e instanceof Function)) {
var c = uni.getStorageSync("tk"); var c = uni.getStorageSync("tk");
e(c ? { e(c ? {
...@@ -448,8 +416,7 @@ var md5 = function () { ...@@ -448,8 +416,7 @@ var md5 = function () {
}); });
} }
}, intervalTime); }, intervalTime);
}; };
module.exports = { module.exports = {
config: config, config: config,
init: init, init: init,
......
<template> <template>
<block> <view style="height: 100%">
<index @smsloginres="smsloginResListener" :config="config" :checkboxChecked="checkboxChecked" /> <index @showauthor="showLoad" @smsloginres="smsloginResListener" :config="config" :checkboxChecked="checkboxChecked" />
<view v-if="config.hiddenLoginType != 2"> <view v-if="config.hiddenLoginType != 2">
<button <button
v-if="!stopClick && checkboxChecked" v-if="!stopClick && checkboxChecked"
...@@ -15,13 +15,20 @@ ...@@ -15,13 +15,20 @@
<button class="phone-btn" :style="config.loginConfig && config.loginConfig.wxBtnStyle" v-else @tap="needAuthor">微信手机号快捷登录</button> <button class="phone-btn" :style="config.loginConfig && config.loginConfig.wxBtnStyle" v-else @tap="needAuthor">微信手机号快捷登录</button>
</view> </view>
<!-- 弹窗类型展示协议授权 --> <!-- 弹窗类型展示协议授权 -->
<view class="dialog-tips" v-if="config.selfTipsDialog"> <view class="dialog-tips" v-if="selfTipsDialog">
<view> <view>
<instruction class="no-fix" :config="config" @changecheck="changeCheckbox" /> <instruction class="no-fix" type="modal" :config="config" @changecheck="changeCheckbox" />
<p> <button
<button class="phone-btn bg-btn" @tap="reject">拒绝</button> v-if="smsBtn"
<button v-if="!stopClick && checkboxChecked" class="phone-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">同意</button> class="phone-btn phone-modal"
</p> :style="config.loginConfig && config.loginConfig.wxBtnStyle"
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
>
确认
</button>
<index v-if="userBtn" type="modal" @showauthor="showLoad" @smsloginres="smsloginResListener" :config="config" :checkboxChecked="true" />
<view class="cancel" @tap="reject">我再想想</view>
</view> </view>
</view> </view>
<!-- 底部展示协议授权 --> <!-- 底部展示协议授权 -->
...@@ -29,15 +36,13 @@ ...@@ -29,15 +36,13 @@
<view> <view>
<canvas class="f8be360ead1f4a3d9afb5e312b845ebb" canvas-id="fbfd3ec3c4ab4213b9a09b5c5e769ceb"></canvas> <canvas class="f8be360ead1f4a3d9afb5e312b845ebb" canvas-id="fbfd3ec3c4ab4213b9a09b5c5e769ceb"></canvas>
</view> </view>
</block> </view>
</template> </template>
<script> <script>
import util from '../util.js'; import util from '../util.js';
let plugin = requirePlugin('loginPlugin'); let plugin = requirePlugin('loginPlugin');
let fm = require('../fm.min.js'); let fm = require('../fm.min.js');
let config = util.getLoginConfig(); let config = util.getLoginConfig();
export default { export default {
components: {}, components: {},
...@@ -46,19 +51,24 @@ export default { ...@@ -46,19 +51,24 @@ export default {
config, config,
stopClick: false, stopClick: false,
checkboxChecked: !config.author, checkboxChecked: !config.author,
selfTipsDialog: false,
detail: '', detail: '',
code: '', code: '',
userBtn: false,
smsBtn: false,
wxBtnStyle: '' wxBtnStyle: ''
}; };
}, },
onLoad(options) { onLoad(options) {
plugin.onLoginSuccess((data) => {
console.jdLoginLog(data, '登录成功');
});
let { riskFail } = options; let { riskFail } = options;
this.config = util.getLoginConfig(options) //风控失败不重置缓存 this.config = util.getLoginConfig(options)
//风控失败不重置缓存
if (!riskFail) { if (!riskFail) {
util.setLoginParamsStorage(options); util.setLoginParamsStorage(options);
} }
plugin.setLog({ plugin.setLog({
url: 'pages/login/index/index', url: 'pages/login/index/index',
pageId: 'WLogin_Diversion' pageId: 'WLogin_Diversion'
...@@ -72,34 +82,38 @@ export default { ...@@ -72,34 +82,38 @@ export default {
}, },
methods: { methods: {
smsloginResListener(res = {}) { smsloginResListener(res = {}) {
if (this.checkboxChecked) { if (this.checkboxChecked || this.userBtn) {
util.handleJump(res.detail); util.handleJump(res.detail);
} else { } else {
this.showLoad(); this.showLoad('useBtn');
} }
}, },
showLoad() { showLoad(type) {
uni.showToast({ // wx.showToast({
title: '请阅读并勾选页面底部协议', // title: '请阅读并勾选页面底部协议',
icon: 'none', // icon: "none",
duration: 3000 // duration: 3000
}); // })
// if(type.detail){
// console.log(type.detail)
// }
this.selfTipsDialog = true;
this[type.detail || type] = true;
}, },
changeCheckbox(e) { changeCheckbox(e) {
this.checkboxChecked = e.detail this.checkboxChecked = e.detail;
}, },
needAuthor() { needAuthor() {
if (!this.checkboxChecked) { if (!this.checkboxChecked) {
this.showLoad(); this.showLoad('smsBtn');
} }
}, },
getPhoneNumber(event = {}) { getPhoneNumber(event = {}) {
let { stopClick } = this; let { stopClick } = this;
if (stopClick) { if (stopClick) {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
...@@ -107,20 +121,17 @@ export default { ...@@ -107,20 +121,17 @@ export default {
}); });
return; return;
} }
this.stopClick = true;
this.stopClick = true
let { detail } = event; let { detail } = event;
let { iv, encryptedData } = detail; let { iv, encryptedData } = detail;
plugin.clickLog({ plugin.clickLog({
event, event,
eid: 'WLogin_Diversion_Wechat' eid: 'WLogin_Diversion_Wechat'
}); });
if (!iv || !encryptedData) { if (!iv || !encryptedData) {
this.stopClick = false this.stopClick = false;
return; return;
} }
uni.showLoading({ uni.showLoading({
title: '加载中' title: '加载中'
}); });
...@@ -135,16 +146,13 @@ export default { ...@@ -135,16 +146,13 @@ export default {
mobileLogin() { mobileLogin() {
let { code, detail } = this; let { code, detail } = this;
let { iv, encryptedData } = detail; let { iv, encryptedData } = detail;
if (!code || !iv || !encryptedData) { if (!code || !iv || !encryptedData) {
return; return;
} }
const startClick = () => { const startClick = () => {
uni.hideLoading(); uni.hideLoading();
this.stopClick = false this.stopClick = false
}; };
plugin plugin
.WXMobileLogin({ .WXMobileLogin({
iv, iv,
...@@ -155,21 +163,18 @@ export default { ...@@ -155,21 +163,18 @@ export default {
if ([32, 33].indexOf(res.err_code) >= 0) { if ([32, 33].indexOf(res.err_code) >= 0) {
return plugin.loginRequest({}); return plugin.loginRequest({});
} }
if (res.err_code == 124) { if (res.err_code == 124) {
return this.getWxcode(); return this.getWxcode();
} // 风控提示用户去浏览器解除 重新获取code } // 风控提示用户去浏览器解除 重新获取code
return res; return res;
}) })
.then((res) => { .then((res) => {
let { pt_key, rsa_modulus, guid } = res; let { pt_key, rsa_modulus, guid } = res;
if (!pt_key && rsa_modulus && guid) { if (!pt_key && rsa_modulus && guid) {
// login 返回 // login 返回
res.pluginUrl = plugin.formatPluginPage('main'); res.pluginUrl = plugin.formatPluginPage('main');
} // startClick() }
// startClick()
util.handleJump(res); util.handleJump(res);
}) })
.catch((res) => { .catch((res) => {
...@@ -198,15 +203,15 @@ export default { ...@@ -198,15 +203,15 @@ export default {
// 拒绝协议 // 拒绝协议
reject() { reject() {
let { rejectReturnPage, rejectPageType } = this.config; // let {rejectReturnPage, rejectPageType} = this.data.config;
// if(rejectReturnPage){
if (rejectReturnPage) { // wx[`${rejectPageType}` || 'rejectTo']({url:rejectReturnPage})
uni[`${rejectPageType}` || 'rejectTo']({ // }else{
url: rejectReturnPage // wx.navigateBack()
}); // }
} else { this.selfTipsDialog = false;
uni.navigateBack(); this.userBtn = false;
} this.smsBtn = false;
} }
} }
}; };
...@@ -243,46 +248,51 @@ export default { ...@@ -243,46 +248,51 @@ export default {
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
background-color: rgba(0, 0, 0, 0.8); background-color: rgba(0, 0, 0, 0.6);
} }
.dialog-tips > view { .dialog-tips > view {
position: absolute; position: absolute;
border-radius: 16rpx; border-radius: 16rpx;
width: 80%; width: 70%;
padding: 60rpx 40rpx; padding: 40rpx 20rpx;
background-color: #fff; background-color: #fff;
top: 50%; top: 50%;
left: 50%; left: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
} }
.dialog-tips view button { /* .dialog-tips view button{
display: inline-block; display: inline-block;
width: 45%; width: 45%;
margin: 0; margin:0;
} } */
.dialog-tips view button.phone-btn { .dialog-tips view.cancel {
margin-left: 10%; font-size: 30rpx;
} color: rgba(100, 101, 102, 1);
.dialog-tips view button.bg-btn { text-align: center;
background: rgba(242, 242, 242, 1); margin-top: 30rpx;
border-radius: 50rpx;
color: rgba(136, 136, 136, 1);
margin: 0;
} }
.dialog-tips .no-fix > view { .dialog-tips .no-fix > view {
position: static; position: static;
margin-bottom: 20rpx; margin-bottom: 20rpx;
text-align: left; text-align: left;
} }
.dialog-tips .no-fix > view > view { /* .dialog-tips .no-fix>view>view{
font-size: 28rpx; font-size: 28rpx;
line-height: 50rpx; line-height: 50rpx;
color: #1269e2; color: #1269E2;
} } */
.dialog-tips .no-fix > view > view:first-child { /* .dialog-tips .no-fix>view>text:last-child{
color: #000;
}
.dialog-tips .no-fix > view > text:last-child {
display: block; display: block;
} */
.phone-modal {
padding: 0;
width: 320rpx;
height: 64rpx;
line-height: 64rpx;
background: rgba(81, 169, 56, 1);
border-radius: 32rpx;
margin: 0 0 0 calc(50% - 160rpx) !important;
color: #fff;
text-align: center;
} }
</style> </style>
let plugin = requirePlugin('loginPlugin'); let plugin = requirePlugin('loginPlugin');
(function () { (function () {
if (console.jdLoginLog) return; if (console.jdLoginLog) {
return;
}
let normalLog = console.log; let normalLog = console.log;
console.jdLoginLog = (...args) => { console.jdLoginLog = (...args) => {
args.unshift('-------登录插件-------'); args.unshift('-------登录插件-------');
normalLog && normalLog(...args); if (normalLog) {
normalLog(...args);
}
}; };
})(); })();
const utils = { const utils = {
redirectPage(url) { redirectPage(url) {
uni.redirectTo({ uni.redirectTo({
url url
}); });
}, },
redirectToH5({ page, wvroute }) { redirectToH5({ page, wvroute }) {
let url = plugin.formH5Url({ let url = plugin.formH5Url({
page: decodeURIComponent(page), page: decodeURIComponent(page),
...@@ -24,7 +24,6 @@ const utils = { ...@@ -24,7 +24,6 @@ const utils = {
}); });
utils.redirectPage(url); utils.redirectPage(url);
}, },
navigateToH5({ page, wvroute }) { navigateToH5({ page, wvroute }) {
let url = plugin.formH5Url({ let url = plugin.formH5Url({
page: decodeURIComponent(page), page: decodeURIComponent(page),
...@@ -34,11 +33,12 @@ const utils = { ...@@ -34,11 +33,12 @@ const utils = {
url url
}); });
}, },
setLoginParamsStorage(obj = {}) { setLoginParamsStorage(obj = {}) {
if (obj.appid && isNaN(Number(obj.appid))) {
delete obj.appid;
}
plugin.setLoginStorageSync(utils.getLoginConfig(obj)); plugin.setLoginStorageSync(utils.getLoginConfig(obj));
}, },
/* /*
首页存缓存逻辑(兼容不适用loginConfig直接存缓存): 首页存缓存逻辑(兼容不适用loginConfig直接存缓存):
同名参数优先级:url 中参数 > loginConfig > 缓存中 同名参数优先级:url 中参数 > loginConfig > 缓存中
...@@ -50,60 +50,56 @@ const utils = { ...@@ -50,60 +50,56 @@ const utils = {
o.pageType = pageType; o.pageType = pageType;
return o; return o;
}; };
let storageConfig = plugin.getLoginParams(); let storageConfig = plugin.getLoginParams();
let config = handleUndefinedType(utils.getDefaultConfig()); let config = handleUndefinedType(utils.getDefaultConfig());
let loginParams = { ...storageConfig, ...config }; let loginParams = {
...storageConfig,
...config
};
if (plugin.isObject(obj)) { if (plugin.isObject(obj)) {
loginParams = { ...loginParams, ...handleUndefinedType(obj) }; loginParams = {
...loginParams,
...handleUndefinedType(obj)
};
} else { } else {
console.jdLoginLog('登录参数必须为对象'); console.jdLoginLog('登录参数必须为对象');
} }
return loginParams; return loginParams;
}, },
getDefaultConfig() { getDefaultConfig() {
let lgConfig; let lgConfig;
try { try {
lgConfig = require('./config.js'); lgConfig = require('./config.js');
} catch (err) { } catch (err) {
console.log('CatchClause', err);
console.log('CatchClause', err);
lgConfig = {}; lgConfig = {};
} }
return lgConfig.config || {}; return lgConfig.config || {};
}, },
handleJump(p = {}) { handleJump(p = {}) {
let { goback, pluginUrl, riskUrl } = p; let { goback, pluginUrl, riskUrl } = p;
if (goback) { if (goback) {
utils.goBack(); utils.goBack();
return; return;
} }
if (pluginUrl) { if (pluginUrl) {
utils.redirectPage(pluginUrl); utils.redirectPage(pluginUrl);
return; return;
} }
if (riskUrl) {
riskUrl &&
utils.redirectToH5({ utils.redirectToH5({
page: riskUrl page: riskUrl
}); });
}
}, },
goBack() { goBack() {
let params = plugin.getLoginParams(), let params = plugin.getLoginParams();
{ returnPage, pageType } = params; let { returnPage, pageType } = params;
if (pageType == 'navigateBack') { if (pageType == 'navigateBack') {
uni[pageType](); uni[pageType]();
return; return;
} }
if (!returnPage) { if (!returnPage) {
uni.showToast({ uni.showToast({
title: '没有returnPage,无法跳转', title: '没有returnPage,无法跳转',
...@@ -111,10 +107,8 @@ const utils = { ...@@ -111,10 +107,8 @@ const utils = {
}); });
return; return;
} }
if (pageType !== 'h5') { if (pageType !== 'h5') {
returnPage = decodeURIComponent(returnPage); returnPage = decodeURIComponent(returnPage);
if (pageType && pageType != 'rediretTo') { if (pageType && pageType != 'rediretTo') {
uni[pageType]({ uni[pageType]({
url: returnPage url: returnPage
...@@ -122,7 +116,6 @@ const utils = { ...@@ -122,7 +116,6 @@ const utils = {
} else { } else {
utils.redirectPage(returnPage); utils.redirectPage(returnPage);
} }
return; return;
} else { } else {
utils.redirectToH5({ utils.redirectToH5({
...@@ -131,68 +124,77 @@ const utils = { ...@@ -131,68 +124,77 @@ const utils = {
return; return;
} }
}, },
h5Init(options) { h5Init(options) {
let p = plugin.getLoginParams(); let p = plugin.getLoginParams();
if (plugin.isEmptyObj(p)) utils.setLoginParamsStorage(options); if (plugin.isEmptyObj(p)) {
utils.setLoginParamsStorage(options);
}
}, },
setCustomNavigation() { setCustomNavigation() {
let { navigationBarColor, navigationBarTitle } = plugin.getLoginParams(); let { navigationBarColor, navigationBarTitle } = plugin.getLoginParams();
plugin.isObject(navigationBarColor) && uni.setNavigationBarColor(navigationBarColor); if (plugin.isObject(navigationBarColor)) {
plugin.isObject(navigationBarTitle) && uni.setNavigationBarTitle(navigationBarTitle); uni.setNavigationBarColor(navigationBarColor);
}
if (plugin.isObject(navigationBarTitle)) {
uni.setNavigationBarTitle(navigationBarTitle);
}
}, },
requestWithLoginStatus(obj = {}) { requestWithLoginStatus(obj = {}) {
obj.header = obj.header || {}; obj.header = obj.header || {};
let [GUID = '', KEY = '', TOKEN = '', PIN = ''] = plugin.getJdListStorage(['guid', 'pt_key', 'pt_token', 'pt_pin']), 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}`, let _cookie = `guid=${GUID}; pt_pin=${encodeURIComponent(PIN)}; pt_key=${KEY}; pt_token=${TOKEN}`;
{ cookie } = obj.header; let { cookie } = obj.header;
obj.header.cookie = cookie ? `${cookie};${_cookie}` : _cookie; obj.header.cookie = cookie ? `${cookie};${_cookie}` : _cookie;
uni.request(obj); uni.request(obj);
}, },
silentauthlogin(options, goToLogin, callback) { silentauthlogin(options, goToLogin, callback) {
uni.login({ uni.login({
success(res = {}) { success(res = {}) {
let { code } = res; let { code } = res;
if (code) { if (code) {
utils.setLoginParamsStorage(options); utils.setLoginParamsStorage(options);
plugin plugin
.silentauthlogin({ ...options, code }, goToLogin) .silentauthlogin(
{
...options,
code
},
goToLogin
)
.then((res) => { .then((res) => {
callback && if (callback) {
callback({ callback({
isSuccess: res.err_code == 0 isSuccess: res.err_code == 0
}); });
}
if (goToLogin && res.err_code == 0) { if (goToLogin && res.err_code == 0) {
utils.handleJump(res); utils.handleJump(res);
} }
}) })
.catch((res) => { .catch((res) => {
callback && if (callback) {
callback({ callback({
isSuccess: false isSuccess: false
}); });
}
console.jdLoginLog('请重试一次'); console.jdLoginLog('请重试一次');
}); });
} else { } else {
callback && if (callback) {
callback({ callback({
isSuccess: false isSuccess: false
}); });
}
console.jdLoginLog('wx.login 获取code失败'); console.jdLoginLog('wx.login 获取code失败');
} }
}, },
fail() { fail() {
callback && if (callback) {
callback({ callback({
isSuccess: false isSuccess: false
}); });
} }
}
}); });
} }
}; };
......
<template> <template>
<block> <view style="height: 100%">
<web-view /> <web-view />
</block> </view>
</template> </template>
<script> <script>
...@@ -18,9 +18,9 @@ export default { ...@@ -18,9 +18,9 @@ export default {
// success: res => { // success: res => {
// } // }
// }) // })
util.setCustomNavigation(); util.setCustomNavigation();
let { token, islogin } = options; let { token, islogin } = options;
if (Number(islogin) === 0) { if (Number(islogin) === 0) {
// wx.showModal({ // wx.showModal({
// title: '提示', // title: '提示',
...@@ -34,7 +34,6 @@ export default { ...@@ -34,7 +34,6 @@ export default {
util.redirectPage('/pages/login/index/index?riskFail=1'); util.redirectPage('/pages/login/index/index?riskFail=1');
return; return;
} }
this.handleBackFromH5(token); this.handleBackFromH5(token);
}, },
methods: { methods: {
...@@ -45,7 +44,6 @@ export default { ...@@ -45,7 +44,6 @@ export default {
}) })
.then((res = {}) => { .then((res = {}) => {
let { goback, err_msg } = res; let { goback, err_msg } = res;
if (goback) { if (goback) {
plugin.gobackLog({ plugin.gobackLog({
route: 7 route: 7
...@@ -53,7 +51,6 @@ export default { ...@@ -53,7 +51,6 @@ export default {
util.goBack(); util.goBack();
return; return;
} }
if (err_msg) { if (err_msg) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
......
<template> <template>
<block> <view style="height: 100%">
<web-view :src="url" /> <web-view :src="url" />
</block> </view>
</template> </template>
<script> <script>
...@@ -19,8 +19,7 @@ export default { ...@@ -19,8 +19,7 @@ export default {
util.h5Init(options); util.h5Init(options);
this.h5_url = h5_url this.h5_url = h5_url
util.setCustomNavigation(); util.setCustomNavigation();
this.genTokenFun();
this._genToken();
}, },
onShareAppMessage: function () { onShareAppMessage: function () {
let { h5_url } = this; let { h5_url } = this;
...@@ -30,7 +29,7 @@ export default { ...@@ -30,7 +29,7 @@ export default {
}; };
}, },
methods: { methods: {
_genToken() { genTokenFun() {
let { h5_url } = this; let { h5_url } = this;
plugin plugin
.genToken({ .genToken({
...@@ -38,7 +37,6 @@ export default { ...@@ -38,7 +37,6 @@ export default {
}) })
.then((res) => { .then((res) => {
let { isSuccess, err_code, url, tokenkey, err_msg } = res; let { isSuccess, err_code, url, tokenkey, err_msg } = res;
if (isSuccess && !err_code) { if (isSuccess && !err_code) {
this.url = `${url}?to=${h5_url}&tokenkey=${tokenkey}` this.url = `${url}?to=${h5_url}&tokenkey=${tokenkey}`
} else { } else {
...@@ -47,7 +45,7 @@ export default { ...@@ -47,7 +45,7 @@ export default {
content: err_msg || '页面跳转失败,请重试', content: err_msg || '页面跳转失败,请重试',
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
this._genToken(); this.genTokenFun();
} }
} }
}); });
......
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