Commit a5eba71a authored by 郝增润's avatar 郝增润

Merge branch 'hotfix/20211104-wechatAccess' into 'master'

Hotfix/20211104-wechat-access

See merge request !19
parents 54269720 49d71cad
......@@ -19,4 +19,19 @@ public class IndexController {
modelAndView.setViewName("autologin");
return modelAndView;
}
@GetMapping("/autologin2")
public ModelAndView autologin2() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("autologin2");
return modelAndView;
}
@GetMapping("/autologin3")
public ModelAndView autologin3() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("autologin3");
return modelAndView;
}
}
......@@ -180,7 +180,9 @@ public class Open2DuibaController {
try {
LOGGER.info("autologin,autologinParam={}", JSON.toJSONString(autologinParam));
String token = autologinParam.getToken();
String source = JdTokenSourceEnum.JD.getSource();
// String source = JdTokenSourceEnum.JD.getSource();
String source = Optional.ofNullable(autologinParam.getSource()).orElse(JdTokenSourceEnum.JD.getSource());
LOGGER.info("source,source={}", source);
String redirectUrl = autologinParam.getRedirectUrl();
String env = autologinParam.getEnv();
......
spring.application.name=jd-activity
spring.profiles.active=prod
#先排除一些autoconfigure
# 先排除一些autoconfigure
spring.autoconfigure.exclude=
# tomcat
server.port=8080
server.tomcat.accesslog.enabled=false
server.tomcat.uri-encoding=UTF-8
server.tomcat.threads.max=300
#服务器连接超时
# 服务器连接超时
server.tomcat.connection-timeout=8s
# logging
logging.file.path=${user.home}/logs/${spring.application.name}
......
......@@ -51,6 +51,14 @@
function openLoginPanel() {
console.log("登录面板")
var isWechat = JSSDK.Client.isWeixin();
var isQQ = JSSDK.Client.isQQ();
if (isWechat || isQQ) {
var redirectUrlPrimary = window.location.href.replace('autologin', 'autologin3') + '&source=02'
var url = 'https://wq.jd.com/pinbind/pintokenredirect?biz=jm-business-center&url=' + encodeURIComponent(redirectUrlPrimary)
window.location.href = url;
return;
}
JSSDK.Isv.requestLogin(isLogin);
}
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>正在加载..</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<script src="//yun.duiba.com.cn/aurora/assets/4c37d75a75d8e7534d9e3b056911ba06ac5bf8f8.js"></script>
<!-- <script src="//yun.duiba.com.cn/js-libs/vConsole/3.3.4/vconsole.min.js"></script> -->
<!-- jquery.min.js -->
<script src="//h5static.m.jd.com/act/jm-jdshare/2.0.0/jm-jdshare.js"></script>
<script src="//s3.pstatp.com/cdn/expire-1-M/jquery/3.3.1/jquery.min.js"></script>
<script>
// new VConsole();
</script>
<style>
.box {
width: 100%;
height: 100vh;
}
.box > div {
width: 100%;
height: 30px;
line-height: 30px;
text-align: center;
border: 2px solid #ccc;
margin: 5px 0;
}
</style>
</head>
<body>
<div class="box">
<!-- <div onclick="openLoginPanel()">唤起登录面板</div> -->
<!-- <div onclick="jumpToPage()">跳转</div> -->
</div>
<script language="javascript">
(function () {
console.log(2)
openLoginPanel();
})()
function openLoginPanel() {
console.log("登录面板")
var isWechat = JSSDK.Client.isWeixin();
var isQQ = JSSDK.Client.isQQ();
if (isWechat || isQQ) {
var redirectUrlPrimary = window.location.href.replace('autologin2', 'autologin3') + '&source=02'
var url = 'https://wq.jd.com/pinbind/pintokenredirect?biz=jm-business-center&url=' + encodeURIComponent(redirectUrlPrimary)
window.location.href = url;
return;
}
JSSDK.Isv.requestLogin(isLogin);
}
function isLogin(res) {
console.log("login回调/打开登录面板的回调", res)
setTimeout(function () {
console.log(res.data)
if (res.data == 1) {
// 已登录
getToken();
} else {
// 未登录
}
}, 0);
}
function getToken() {
console.log("进入获取token方法", window.location.href)
JSSDK.Isv.requestIsvToken({
url: window.location.href
}, callBackToken);
}
function callBackToken(res) {
console.log("获取token的返回", res)
autoLogin(res.data);
}
var pageUrl = "";
function autoLogin(token) {
var redirect = getUrlParam("redirect");
var env = getUrlParam("env");
var shopId = getUrlParam("shopId");
var venderId = getUrlParam("venderId");
var appKey = getUrlParam("appKey");
var needCredits = getUrlParam("needCredits");
$.ajax({
type: 'post',
url: `/open2Duiba/autologin`,
data: JSON.stringify({
token: token,
redirectUrl: redirect,
env: env,
shopId: shopId,
venderId: venderId,
appKey: appKey,
needCredits: needCredits
}),
async: false,
contentType: 'application/json',
dataType: 'json', //返回 JSON 数据
beforeSend: function () {
},
success: function (data, status) {
console.log("autoLogin返回参数:", data)
pageUrl = data.data;
console.log(pageUrl)
window.location.href = pageUrl;
},
complete: function () {
},
error: function (data, status, e) {
console.log("接口调用错误", e)
}
});
}
function jumpToPage() {
console.log(pageUrl)
window.location.href = pageUrl;
}
function getUrlParam(name) {
var search = window.location.search;
var matched = search
.slice(1)
.match(new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i'));
return search.length ? matched && matched[2] : null;
}
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>正在加载..</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<script src="//yun.duiba.com.cn/aurora/assets/4c37d75a75d8e7534d9e3b056911ba06ac5bf8f8.js"></script>
<!-- <script src="//yun.duiba.com.cn/js-libs/vConsole/3.3.4/vconsole.min.js"></script> -->
<!-- jquery.min.js -->
<script src="//h5static.m.jd.com/act/jm-jdshare/2.0.0/jm-jdshare.js"></script>
<script src="//s3.pstatp.com/cdn/expire-1-M/jquery/3.3.1/jquery.min.js"></script>
<script>
// new VConsole();
</script>
<style>
.box {
width: 100%;
height: 100vh;
}
.box > div {
width: 100%;
height: 30px;
line-height: 30px;
text-align: center;
border: 2px solid #ccc;
margin: 5px 0;
}
</style>
</head>
<body>
<div class="box">
<!-- <div onclick="openLoginPanel()">唤起登录面板</div> -->
<!-- <div onclick="jumpToPage()">跳转</div> -->
</div>
<script language="javascript">
(function () {
// openLoginPanel();
var token = getUrlParam("token");
autoLogin(token)
})()
function openLoginPanel() {
console.log("登录面板")
JSSDK.Isv.requestLogin(isLogin);
}
function isLogin(res) {
console.log("login回调/打开登录面板的回调", res)
setTimeout(function () {
console.log(res.data)
if (res.data == 1) {
// 已登录
getToken();
} else {
// 未登录
}
}, 0);
}
function getToken() {
console.log("进入获取token方法", window.location.href)
JSSDK.Isv.requestIsvToken({
url: window.location.href
}, callBackToken);
}
function callBackToken(res) {
console.log("获取token的返回", res)
autoLogin(res.data);
}
var pageUrl = "";
function autoLogin(token) {
var redirect = getUrlParam("redirect");
var env = getUrlParam("env");
var shopId = getUrlParam("shopId");
var venderId = getUrlParam("venderId");
var source = getUrlParam("source");
var appKey = getUrlParam("appKey");
var needCredits = getUrlParam("needCredits");
$.ajax({
type: 'post',
url: `/open2Duiba/autologin`,
data: JSON.stringify({
token: token,
redirectUrl: redirect,
source: source,
env: env,
shopId: shopId,
venderId: venderId,
appKey: appKey,
needCredits: needCredits
}),
async: false,
contentType: 'application/json',
dataType: 'json', //返回 JSON 数据
beforeSend: function () {
},
success: function (data, status) {
console.log("autoLogin返回参数:", data)
pageUrl = data.data;
console.log(pageUrl)
window.location.href = pageUrl;
},
complete: function () {
},
error: function (data, status, e) {
console.log("接口调用错误", e)
}
});
}
function jumpToPage() {
console.log(pageUrl)
window.location.href = pageUrl;
}
function getUrlParam(name) {
var search = window.location.search;
var matched = search
.slice(1)
.match(new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i'));
return search.length ? matched && matched[2] : null;
}
</script>
</body>
</html>
\ No newline at end of file
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