You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
information-system/dinglogin/dingmail.js

44 lines
1.9 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

$(function(){
var url = encodeURIComponent("https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoagxeeheunc0p95eu8&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=http://www.mycht.cn/webht.php/apps/dingmail/index/auth_login");
var obj = DDLogin({
id:"login_container",//这里需要你在自己的页面定义一个HTML标签并设置id例如<div id="login_container"></div>或<span id="login_container"></span>
goto: url,
style: "",
href: "",
width : "300px",
height: "300px"
});
var hanndleMessage = function (event) {
var loginTmpCode = event.data; //拿到loginTmpCode后就可以在这里构造跳转链接进行跳转了
var origin = event.origin;
login_url = 'https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoagxeeheunc0p95eu8&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=http://www.mycht.cn/webht.php/apps/dingmail/index/auth_login&loginTmpCode='+loginTmpCode;
window.location.href = login_url;
};
if (typeof window.addEventListener != 'undefined') {
window.addEventListener('message', hanndleMessage, false);
} else if (typeof window.attachEvent != 'undefined') {
window.attachEvent('onmessage', hanndleMessage);
}
$('.login_type').click(function(){
console.log($(this).html());
if($(this).html() == '钉钉帐号密码登录'){
$('.pc_login').removeClass('hide');
$('#login_container').addClass('hide');
$('.ding_login').addClass('hide');
$(this).addClass('login_type_active');
$(this).prev().removeClass('login_type_active');
}
if($(this).html() == '钉钉扫码登录'){
$('.ding_login').removeClass('hide');
$('#login_container').removeClass('hide');
$('.pc_login').addClass('hide');
$(this).addClass('login_type_active');
$(this).next().removeClass('login_type_active');
}
});
});