Commit db095df5 by zhujian

Merge branch 'feature/wufan/20200109/work-weixin' into gray

parents 0fb90a58 7f3699f2
......@@ -28,7 +28,7 @@
display: flex;
align-items: center;
justify-content: center;
background:rgba(244, 246, 250, 1) ;
background: rgba(244, 246, 250, 1);
}
......@@ -81,6 +81,14 @@
prod: 'https://gateway-heimdall.xiaomai5.com/'
};
var APPID_MAP = {
dev: 'ww80fd6928a46cf33a',
dev1: 'ww80fd6928a46cf33a',
rc: 'ww2009937c82bc57bd',
gray: 'ww2009937c82bc57bd',
prod: 'ww2009937c82bc57bd'
};
function getParameterByName(name) {
......@@ -96,26 +104,22 @@
const appTermEnum = getParameterByName('appTermEnum');
const code = getParameterByName('code');
const ticket = getParameterByName('ticket');
console.log(appTermEnum, code, ticket);
if (!code) {
const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww80fd6928a46cf33a&redirect_uri=${encodeURIComponent(location.href)}&response_type=code&scope=snsapi_privateinfo&state=STATE#wechat_redirect`
if (!code) {
postJSON('hades/anon/hades/getCorpTrainSuiteId', {}, (res) => {
const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${res.result}&redirect_uri=${encodeURIComponent(location.href)}&response_type=code&scope=snsapi_privateinfo&state=STATE#wechat_redirect`
location.href = url
})
return
}
const ajaxOptions = {
data: JSON.stringify({
} else {
postJSON("hades/anon/hades/wXWorkUserTicketLogin", {
appTermEnum: appTermEnum,
code: code,
ticket: ticket
}),
type: 'POST',
url: BASIC_HOST_MAP[env] + "hades/anon/hades/wXWorkUserTicketLogin",
contentType: 'application/json; charset=UTF-8',
timeout: 20000,
dataType: 'json',
success(res, status, xhr) {
}, (res) => {
if (res.code == 200) {
$('#success').show()
} else {
......@@ -125,10 +129,33 @@
$('#message').html(message)
}
})
}
function postJSON(url, data, callback) {
const ajaxOptions = {
data: JSON.stringify(),
type: 'POST',
url: BASIC_HOST_MAP[env] + url,
contentType: 'application/json; charset=UTF-8',
timeout: 20000,
dataType: 'json',
success(res, status, xhr) {
callback(res)
},
};
$.ajax(ajaxOptions)
}
});
</script>
......
......@@ -26,7 +26,7 @@ export default function WechatLogin(props: any) {
if (status === 0) {
Service.Hades("anon/hades/getTicket", {}).then((res: any) => {
setTicket(res.result)
const redirect = `${location.origin + location.pathname.replace('index.html', 'h5.html')}?ticket=${res.result}&appTermEnum=XIAOMAI_CLOUD_CLASS_PC_WEB_ADMIN&env=${process.env.DEPLOY_ENV || 'dev'}`
const redirect = `${location.origin + location.pathname.replace('index.html', '') + 'h5.html'}?ticket=${res.result}&appTermEnum=XIAOMAI_CLOUD_CLASS_PC_WEB_ADMIN&env=${process.env.DEPLOY_ENV || 'dev'}`
// console.log(redirect)
// const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww409ccf9c6e31f19e&redirect_uri=${encodeURIComponent(redirect)}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
// console.log(url)
......
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