Commit 599ff6e1 authored by lijiongliang's avatar lijiongliang

新增京东登录

parent 77869420
......@@ -68,6 +68,12 @@
"scope.userLocation" : {
"desc" : "你的位置信息将用于定位"
}
},
"plugins": {
"loginPlugin": {
"version": "1.5.4",
"provider": "wxefe655223916819e"
}
}
},
"mp-alipay" : {
......
......@@ -38,6 +38,20 @@
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/login/index/index",
"style": {
"navigationBarTitleText": "登录"
}
},
{
"path": "pages/login/web-view/web-view",
"style": {}
},
{
"path": "pages/login/wv-common/wv-common",
"style": {}
}
],
"subPackages": [
......@@ -236,6 +250,12 @@
]
}
],
"plugins": {
"loginPlugin": {
"version": "1.5.4",
"provider": "wxefe655223916819e"
}
},
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "首页",
......@@ -243,7 +263,11 @@
"backgroundColor": "#ffffff",
"rpxCalcMaxDeviceWidth": 750, // rpx 计算所支持的最大设备宽度,单位 px,默认值为 960
"rpxCalcBaseDeviceWidth": 375, // rpx 计算使用的基准设备宽度,设备实际宽度超出 rpx 计算所支持的最大设备宽度时将按基准宽度计算,单位 px,默认值为 375
"rpxCalcIncludeWidth": 750 // rpx 计算特殊处理的值,始终按实际的设备宽度计算,单位 rpx,默认值为 750
"rpxCalcIncludeWidth": 750 ,// rpx 计算特殊处理的值,始终按实际的设备宽度计算,单位 rpx,默认值为 750
"usingComponents": {
"index": "plugin://loginPlugin/index",
"instruction":"plugin://loginPlugin/instruction"
}
}
// "tabBar": {
// "color": "#595656",
......
export let config = {
appid: 1814,
returnPage: undefined,
pageType: undefined,
isLogout: 1,
noWXinfo: 1,
h5path: undefined,
logoPath: undefined,
isTest: undefined,
//1 预发接口,改为undefined 调用线上接口
isKepler: undefined,
navigationBarColor: undefined,
navigationBarTitle: undefined,
tabNum: 2,
requestHost: 'https://wxapplogin2.m.jd.com',
logPluginName: 'DDDDDDDDD',
// 埋点插件的名字 例如:'log-plugin'
selfTipsDialog: false,
// 是否弹窗展示协议授权,默认为false,如果为true,author必须为false
author: true,
hiddenLoginType: '2',
//隐藏按钮 1为 帐密方式;2为微信手机号快捷登录
loginConfig: {
jdLoginBtnStyle: 'color:red',
// 登录/注册按钮样式
wxBtnStyle: 'color:red',
// 微信快捷登录按钮样式
userPlaceholder: '',
// 帐密登录的 placeholder
loginBtnStyle: 'color:red',
// 帐密登录界面登录按钮样式
tabStyle: 'color:green',
//帐密和手机号登录tab样式
currentTabStyle: 'border-color:green' //帐密和手机号登录tab选中
} // selfTips: [{ //无特殊需求不需要配置
// tip:'我是测试1',
// url: 'm.jd.com'
// }, {
// tip:'我是测试2',
// url:'https://pro.m.jd.com/mall/active/2hqsQcyM5bEUVSStkN3BwrBHqVLd/index.html'
// }]
};
"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
<template>
<block>
<index @smsloginres="smsloginResListener" :config="config" :checkboxChecked="checkboxChecked" />
<view v-if="config.hiddenLoginType != 2">
<button
v-if="!stopClick && checkboxChecked"
class="phone-btn"
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
:style="config.loginConfig && config.loginConfig.wxBtnStyle"
>
微信手机号快捷登录
</button>
<!-- 防止连续点击触发获取微信用户信息 -->
<button class="phone-btn" :style="config.loginConfig && config.loginConfig.wxBtnStyle" v-else @tap="needAuthor">微信手机号快捷登录</button>
</view>
<!-- 弹窗类型展示协议授权 -->
<view class="dialog-tips" v-if="config.selfTipsDialog">
<view>
<instruction class="no-fix" :config="config" @changecheck="changeCheckbox" />
<p>
<button class="phone-btn bg-btn" @tap="reject">拒绝</button>
<button v-if="!stopClick && checkboxChecked" class="phone-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">同意</button>
</p>
</view>
</view>
<!-- 底部展示协议授权 -->
<instruction v-else :config="config" @changecheck="changeCheckbox" />
<view>
<canvas class="f8be360ead1f4a3d9afb5e312b845ebb" canvas-id="fbfd3ec3c4ab4213b9a09b5c5e769ceb"></canvas>
</view>
</block>
</template>
<script>
import util from '../util.js';
let plugin = requirePlugin('loginPlugin');
let fm = require('../fm.min.js');
let config = util.getLoginConfig();
export default {
components: {},
data() {
return {
config,
stopClick: false,
checkboxChecked: !config.author,
detail: '',
code: '',
wxBtnStyle: ''
};
},
onLoad(options) {
let { riskFail } = options;
this.config = util.getLoginConfig(options) //风控失败不重置缓存
if (!riskFail) {
util.setLoginParamsStorage(options);
}
plugin.setLog({
url: 'pages/login/index/index',
pageId: 'WLogin_Diversion'
});
util.setCustomNavigation();
this.getWxcode();
this.setFingerData();
},
onShow() {
plugin.pvLog();
},
methods: {
smsloginResListener(res = {}) {
if (this.checkboxChecked) {
util.handleJump(res.detail);
} else {
this.showLoad();
}
},
showLoad() {
uni.showToast({
title: '请阅读并勾选页面底部协议',
icon: 'none',
duration: 3000
});
},
changeCheckbox(e) {
this.checkboxChecked = e.detail
},
needAuthor() {
if (!this.checkboxChecked) {
this.showLoad();
}
},
getPhoneNumber(event = {}) {
let { stopClick } = this;
if (stopClick) {
uni.showToast({
icon: 'none',
title: '请不要重复点击'
});
return;
}
this.stopClick = true
let { detail } = event;
let { iv, encryptedData } = detail;
plugin.clickLog({
event,
eid: 'WLogin_Diversion_Wechat'
});
if (!iv || !encryptedData) {
this.stopClick = false
return;
}
uni.showLoading({
title: '加载中'
});
this.detail = detail
this.mobileLogin();
plugin.clickLog({
event,
eid: 'WLogin_DiversionWechat_Allow'
});
},
mobileLogin() {
let { code, detail } = this;
let { iv, encryptedData } = detail;
if (!code || !iv || !encryptedData) {
return;
}
const startClick = () => {
uni.hideLoading();
this.stopClick = false
};
plugin
.WXMobileLogin({
iv,
encryptedData,
code
})
.then((res) => {
if ([32, 33].indexOf(res.err_code) >= 0) {
return plugin.loginRequest({});
}
if (res.err_code == 124) {
return this.getWxcode();
} // 风控提示用户去浏览器解除 重新获取code
return res;
})
.then((res) => {
let { pt_key, rsa_modulus, guid } = res;
if (!pt_key && rsa_modulus && guid) {
// login 返回
res.pluginUrl = plugin.formatPluginPage('main');
} // startClick()
util.handleJump(res);
})
.catch((res) => {
startClick();
console.jdLoginLog(res);
});
},
getWxcode() {
uni.login({
success: (res = {}) => {
this.code = res.code
}
});
},
setFingerData() {
fm.config(this, {
bizKey: plugin.bizKey
});
fm.init();
fm.getEid((res = {}) => {
plugin.setJdStorageSync('finger_tk', res.tk);
});
},
// 拒绝协议
reject() {
let { rejectReturnPage, rejectPageType } = this.config;
if (rejectReturnPage) {
uni[`${rejectPageType}` || 'rejectTo']({
url: rejectReturnPage
});
} else {
uni.navigateBack();
}
}
}
};
</script>
<style>
/* pages/login/login.wxss */
.phone-btn {
margin: 40rpx auto 152rpx auto;
width: 658rpx;
height: 92rpx;
line-height: 92rpx;
border-radius: 100rpx;
background-color: #1aad19;
color: #fff;
font-size: 32rpx;
}
.phone-btn::after {
border: none;
}
.f8be360ead1f4a3d9afb5e312b845ebb {
position: absolute;
width: 100%;
height: 100%;
border: solid 1px #cdcdcd;
opacity: 0;
left: -100%;
top: -100%;
z-index: -2147483648;
}
/* 协议弹窗样式 */
.dialog-tips {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.8);
}
.dialog-tips > view {
position: absolute;
border-radius: 16rpx;
width: 80%;
padding: 60rpx 40rpx;
background-color: #fff;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.dialog-tips view button {
display: inline-block;
width: 45%;
margin: 0;
}
.dialog-tips view button.phone-btn {
margin-left: 10%;
}
.dialog-tips view button.bg-btn {
background: rgba(242, 242, 242, 1);
border-radius: 50rpx;
color: rgba(136, 136, 136, 1);
margin: 0;
}
.dialog-tips .no-fix > view {
position: static;
margin-bottom: 20rpx;
text-align: left;
}
.dialog-tips .no-fix > view > view {
font-size: 28rpx;
line-height: 50rpx;
color: #1269e2;
}
.dialog-tips .no-fix > view > view:first-child {
color: #000;
}
.dialog-tips .no-fix > view > text:last-child {
display: block;
}
</style>
let plugin = requirePlugin('loginPlugin');
(function () {
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 = {}) {
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) {
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') {
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();
plugin.isObject(navigationBarColor) && uni.setNavigationBarColor(navigationBarColor);
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']),
_cookie = `guid=${GUID}; pt_pin=${encodeURIComponent(PIN)}; pt_key=${KEY}; pt_token=${TOKEN}`,
{ 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) => {
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失败');
}
},
fail() {
callback &&
callback({
isSuccess: false
});
}
});
}
};
export default utils;
<template>
<block>
<web-view />
</block>
</template>
<script>
import util from '../util.js';
let plugin = requirePlugin('loginPlugin');
export default {
data() {
return {};
},
onLoad(options = {}) {
// wx.showModal({
// title: '提示',
// content: 'JIN',
// success: res => {
// }
// })
util.setCustomNavigation();
let { token, islogin } = options;
if (Number(islogin) === 0) {
// wx.showModal({
// title: '提示',
// content: JSON.stringify(options),
// success: res => {
// if (res.confirm) {
// util.redirectPage('/pages/login/index/index?riskFail=1')
// }
// }
// })
util.redirectPage('/pages/login/index/index?riskFail=1');
return;
}
this.handleBackFromH5(token);
},
methods: {
handleBackFromH5(token) {
plugin
.tokenLogin({
token
})
.then((res = {}) => {
let { goback, err_msg } = res;
if (goback) {
plugin.gobackLog({
route: 7
});
util.goBack();
return;
}
if (err_msg) {
uni.showModal({
title: '提示',
content: err_msg,
success: (res) => {
if (res.confirm) {
this.handleBackFromH5(token);
}
}
});
}
})
.catch((res) => console.jdLoginLog(res));
}
}
};
</script>
<style></style>
<template>
<block>
<web-view :src="url" />
</block>
</template>
<script>
import util from '../util.js';
let plugin = requirePlugin('loginPlugin');
export default {
data() {
return {
h5_url: '',
url: ''
};
},
onLoad: function (options = {}) {
let { h5_url = '' } = options;
util.h5Init(options);
this.setData({
h5_url
});
util.setCustomNavigation();
this._genToken();
},
onShareAppMessage: function () {
let { h5_url } = this;
return {
title: '京东',
path: `/pages/login/wv-common/wv-common?h5_url=${h5_url}`
};
},
methods: {
_genToken() {
let { h5_url } = this;
plugin
.genToken({
h5_url
})
.then((res) => {
let { isSuccess, err_code, url, tokenkey, err_msg } = res;
if (isSuccess && !err_code) {
this.setData({
url: `${url}?to=${h5_url}&tokenkey=${tokenkey}`
});
} else {
uni.showModal({
title: '提示',
content: err_msg || '页面跳转失败,请重试',
success: (res) => {
if (res.confirm) {
this._genToken();
}
}
});
}
})
.catch((res) => console.jdLoginLog(res));
}
}
};
</script>
<style>
/* pages/login/wv-common/wv-common.wxss */
</style>
......@@ -20,6 +20,7 @@ import index from './home'
import moveCar from './moveCar'
import shop from './shop'
import personal from './personal'
let plugin = requirePlugin('loginPlugin');
export default {
components: {
......@@ -43,6 +44,7 @@ export default {
})
},
onShow: function () {
console.log(plugin.getPtKey(),1111111)
uni.hideHomeButton()
if(this.tab == 'personal'){
this.$refs.personal.getUserInfo();
......@@ -57,11 +59,18 @@ export default {
}
},
methods: {
goLogin(){
let returnPage= '/pages/main';
uni.navigateTo({
url:"/pages/login/index/index?returnPage="+returnPage
})
},
tabChange(index) {
let that = this
switch (index) {
case 0:
this.tab = 'index'
this.goLogin()
break;
case 1:
this.tab = 'moveCar'
......
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