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

更新京东登录插件到1.7.0

parent fa17e386
......@@ -74,7 +74,7 @@
},
"plugins" : {
"loginPlugin" : {
"version" : "1.5.4",
"version" : "1.7.0",
"provider" : "wxefe655223916819e"
}
}
......
......@@ -17,22 +17,17 @@ export let config = {
// 埋点插件的名字 例如:'log-plugin'
selfTipsDialog: false,
// 是否弹窗展示协议授权,默认为false,如果为true,author必须为false
author: true,
hiddenLoginType: '',
//隐藏按钮 1为 帐密方式;2为微信手机号快捷登录
// loginConfig: {
// jdLoginBtnStyle: 'color:red',
// // 登录/注册按钮样式
// wxBtnStyle: 'color:red',
// // 微信快捷登录按钮样式
// userPlaceholder: '',
// // 帐密登录的 placeholder
// loginBtnStyle: 'color:#fff',
// // 帐密登录界面登录按钮样式
// tabStyle: 'color:green',
// //帐密和手机号登录tab样式
// currentTabStyle: 'border-color:green' //帐密和手机号登录tab选中
// } // selfTips: [{ //无特殊需求不需要配置
author: true
// hiddenLoginType:'', //隐藏按钮 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'
// }, {
......
......@@ -173,19 +173,15 @@ function _getUserInfo() {
});
} 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
......@@ -241,9 +237,7 @@ function _getDeviceUUID(e, t, n, i) {
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 () {
......@@ -258,7 +252,6 @@ function _getDeviceUUID(e, t, n, i) {
fileType: "png",
success: function (n) {
n.tempFilePath;
try {
c.drawt = new Date().getTime();
var i = uni.getFileSystemManager().readFileSync(n.tempFilePath, "base64");
......@@ -276,7 +269,6 @@ function _getDeviceUUID(e, t, n, i) {
});
});
}
function tdencrypt(e) {
var t = JSON.stringify(e);
e = encodeURIComponent(t);
......@@ -289,61 +281,46 @@ function tdencrypt(e) {
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,
......@@ -352,35 +329,27 @@ var md5 = function () {
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,
......@@ -394,7 +363,7 @@ var md5 = function () {
deviceInfo = {
sv: "1.0.3.4",
clist: new Date().getTime()
},
},
keyStr = "23IL<N01c7KvwZO56RSTAfghiFyzWJqVabGH4PQdopUrsCuX*xeBjkltDEmn89.-",
schedule = {
_getSystemInfo: !0,
......@@ -404,20 +373,20 @@ var md5 = function () {
_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,
......@@ -430,14 +399,13 @@ var md5 = function () {
}) : 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 ? {
......@@ -448,8 +416,7 @@ var md5 = function () {
});
}
}, intervalTime);
};
};
module.exports = {
config: config,
init: init,
......
<template>
<block>
<index @smsloginres="smsloginResListener" :config="config" :checkboxChecked="checkboxChecked" />
<view style="height: 100%">
<index @showauthor="showLoad" @smsloginres="smsloginResListener" :config="config" :checkboxChecked="checkboxChecked" />
<view v-if="config.hiddenLoginType != 2">
<button
v-if="!stopClick && checkboxChecked"
......@@ -15,13 +15,20 @@
<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 class="dialog-tips" v-if="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>
<instruction class="no-fix" type="modal" :config="config" @changecheck="changeCheckbox" />
<button
v-if="smsBtn"
class="phone-btn phone-modal"
: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>
<!-- 底部展示协议授权 -->
......@@ -29,15 +36,13 @@
<view>
<canvas class="f8be360ead1f4a3d9afb5e312b845ebb" canvas-id="fbfd3ec3c4ab4213b9a09b5c5e769ceb"></canvas>
</view>
</block>
</view>
</template>
<script>
import util from '../util.js';
let plugin = requirePlugin('loginPlugin');
let fm = require('../fm.min.js');
let config = util.getLoginConfig();
export default {
components: {},
......@@ -46,19 +51,24 @@ export default {
config,
stopClick: false,
checkboxChecked: !config.author,
selfTipsDialog: false,
detail: '',
code: '',
userBtn: false,
smsBtn: false,
wxBtnStyle: ''
};
},
onLoad(options) {
plugin.onLoginSuccess((data) => {
console.jdLoginLog(data, '登录成功');
});
let { riskFail } = options;
this.config = util.getLoginConfig(options) //风控失败不重置缓存
this.config = util.getLoginConfig(options)
//风控失败不重置缓存
if (!riskFail) {
util.setLoginParamsStorage(options);
}
plugin.setLog({
url: 'pages/login/index/index',
pageId: 'WLogin_Diversion'
......@@ -72,34 +82,38 @@ export default {
},
methods: {
smsloginResListener(res = {}) {
if (this.checkboxChecked) {
if (this.checkboxChecked || this.userBtn) {
util.handleJump(res.detail);
} else {
this.showLoad();
this.showLoad('useBtn');
}
},
showLoad() {
uni.showToast({
title: '请阅读并勾选页面底部协议',
icon: 'none',
duration: 3000
});
showLoad(type) {
// wx.showToast({
// title: '请阅读并勾选页面底部协议',
// icon: "none",
// duration: 3000
// })
// if(type.detail){
// console.log(type.detail)
// }
this.selfTipsDialog = true;
this[type.detail || type] = true;
},
changeCheckbox(e) {
this.checkboxChecked = e.detail
this.checkboxChecked = e.detail;
},
needAuthor() {
if (!this.checkboxChecked) {
this.showLoad();
this.showLoad('smsBtn');
}
},
getPhoneNumber(event = {}) {
let { stopClick } = this;
if (stopClick) {
uni.showToast({
icon: 'none',
......@@ -107,20 +121,17 @@ export default {
});
return;
}
this.stopClick = true
this.stopClick = true;
let { detail } = event;
let { iv, encryptedData } = detail;
plugin.clickLog({
event,
eid: 'WLogin_Diversion_Wechat'
});
if (!iv || !encryptedData) {
this.stopClick = false
this.stopClick = false;
return;
}
uni.showLoading({
title: '加载中'
});
......@@ -135,16 +146,13 @@ export default {
mobileLogin() {
let { code, detail } = this;
let { iv, encryptedData } = detail;
if (!code || !iv || !encryptedData) {
return;
}
const startClick = () => {
uni.hideLoading();
this.stopClick = false
};
plugin
.WXMobileLogin({
iv,
......@@ -155,21 +163,18 @@ export default {
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()
}
// startClick()
util.handleJump(res);
})
.catch((res) => {
......@@ -198,15 +203,15 @@ export default {
// 拒绝协议
reject() {
let { rejectReturnPage, rejectPageType } = this.config;
if (rejectReturnPage) {
uni[`${rejectPageType}` || 'rejectTo']({
url: rejectReturnPage
});
} else {
uni.navigateBack();
}
// let {rejectReturnPage, rejectPageType} = this.data.config;
// if(rejectReturnPage){
// wx[`${rejectPageType}` || 'rejectTo']({url:rejectReturnPage})
// }else{
// wx.navigateBack()
// }
this.selfTipsDialog = false;
this.userBtn = false;
this.smsBtn = false;
}
}
};
......@@ -243,46 +248,51 @@ export default {
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.8);
background-color: rgba(0, 0, 0, 0.6);
}
.dialog-tips > view {
position: absolute;
border-radius: 16rpx;
width: 80%;
padding: 60rpx 40rpx;
width: 70%;
padding: 40rpx 20rpx;
background-color: #fff;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.dialog-tips view button {
/* .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;
margin:0;
} */
.dialog-tips view.cancel {
font-size: 30rpx;
color: rgba(100, 101, 102, 1);
text-align: center;
margin-top: 30rpx;
}
.dialog-tips .no-fix > view {
position: static;
margin-bottom: 20rpx;
text-align: left;
}
.dialog-tips .no-fix > view > view {
/* .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 {
color: #1269E2;
} */
/* .dialog-tips .no-fix>view>text:last-child{
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>
let plugin = requirePlugin('loginPlugin');
(function () {
if (console.jdLoginLog) return;
if (console.jdLoginLog) {
return;
}
let normalLog = console.log;
console.jdLoginLog = (...args) => {
args.unshift('-------登录插件-------');
normalLog && normalLog(...args);
if (normalLog) {
normalLog(...args);
}
};
})();
const utils = {
redirectPage(url) {
uni.redirectTo({
url
});
},
redirectToH5({ page, wvroute }) {
let url = plugin.formH5Url({
page: decodeURIComponent(page),
......@@ -24,7 +24,6 @@ const utils = {
});
utils.redirectPage(url);
},
navigateToH5({ page, wvroute }) {
let url = plugin.formH5Url({
page: decodeURIComponent(page),
......@@ -34,11 +33,12 @@ const utils = {
url
});
},
setLoginParamsStorage(obj = {}) {
if (obj.appid && isNaN(Number(obj.appid))) {
delete obj.appid;
}
plugin.setLoginStorageSync(utils.getLoginConfig(obj));
},
/*
首页存缓存逻辑(兼容不适用loginConfig直接存缓存):
同名参数优先级:url 中参数 > loginConfig > 缓存中
......@@ -50,60 +50,56 @@ const utils = {
o.pageType = pageType;
return o;
};
let storageConfig = plugin.getLoginParams();
let config = handleUndefinedType(utils.getDefaultConfig());
let loginParams = { ...storageConfig, ...config };
let loginParams = {
...storageConfig,
...config
};
if (plugin.isObject(obj)) {
loginParams = { ...loginParams, ...handleUndefinedType(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;
}
riskUrl &&
if (riskUrl) {
utils.redirectToH5({
page: riskUrl
});
}
},
goBack() {
let params = plugin.getLoginParams(),
{ returnPage, pageType } = params;
let params = plugin.getLoginParams();
let { returnPage, pageType } = params;
if (pageType == 'navigateBack') {
uni[pageType]();
return;
}
if (!returnPage) {
uni.showToast({
title: '没有returnPage,无法跳转',
......@@ -111,10 +107,8 @@ const utils = {
});
return;
}
if (pageType !== 'h5') {
returnPage = decodeURIComponent(returnPage);
if (pageType && pageType != 'rediretTo') {
uni[pageType]({
url: returnPage
......@@ -122,7 +116,6 @@ const utils = {
} else {
utils.redirectPage(returnPage);
}
return;
} else {
utils.redirectToH5({
......@@ -131,68 +124,77 @@ const utils = {
return;
}
},
h5Init(options) {
let p = plugin.getLoginParams();
if (plugin.isEmptyObj(p)) utils.setLoginParamsStorage(options);
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);
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']),
_cookie = `guid=${GUID}; pt_pin=${encodeURIComponent(PIN)}; pt_key=${KEY}; pt_token=${TOKEN}`,
{ cookie } = 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)
.silentauthlogin(
{
...options,
code
},
goToLogin
)
.then((res) => {
callback &&
if (callback) {
callback({
isSuccess: res.err_code == 0
});
}
if (goToLogin && res.err_code == 0) {
utils.handleJump(res);
}
})
.catch((res) => {
callback &&
if (callback) {
callback({
isSuccess: false
});
}
console.jdLoginLog('请重试一次');
});
} else {
callback &&
if (callback) {
callback({
isSuccess: false
});
}
console.jdLoginLog('wx.login 获取code失败');
}
},
fail() {
callback &&
if (callback) {
callback({
isSuccess: false
});
}
}
});
}
};
......
<template>
<block>
<view style="height: 100%">
<web-view />
</block>
</view>
</template>
<script>
......@@ -18,9 +18,9 @@ export default {
// success: res => {
// }
// })
util.setCustomNavigation();
let { token, islogin } = options;
if (Number(islogin) === 0) {
// wx.showModal({
// title: '提示',
......@@ -34,7 +34,6 @@ export default {
util.redirectPage('/pages/login/index/index?riskFail=1');
return;
}
this.handleBackFromH5(token);
},
methods: {
......@@ -45,7 +44,6 @@ export default {
})
.then((res = {}) => {
let { goback, err_msg } = res;
if (goback) {
plugin.gobackLog({
route: 7
......@@ -53,7 +51,6 @@ export default {
util.goBack();
return;
}
if (err_msg) {
uni.showModal({
title: '提示',
......
<template>
<block>
<view style="height: 100%">
<web-view :src="url" />
</block>
</view>
</template>
<script>
......@@ -19,8 +19,7 @@ export default {
util.h5Init(options);
this.h5_url = h5_url
util.setCustomNavigation();
this._genToken();
this.genTokenFun();
},
onShareAppMessage: function () {
let { h5_url } = this;
......@@ -30,7 +29,7 @@ export default {
};
},
methods: {
_genToken() {
genTokenFun() {
let { h5_url } = this;
plugin
.genToken({
......@@ -38,7 +37,6 @@ export default {
})
.then((res) => {
let { isSuccess, err_code, url, tokenkey, err_msg } = res;
if (isSuccess && !err_code) {
this.url = `${url}?to=${h5_url}&tokenkey=${tokenkey}`
} else {
......@@ -47,7 +45,7 @@ export default {
content: err_msg || '页面跳转失败,请重试',
success: (res) => {
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