|
|
$(function(){
|
|
|
var url = encodeURIComponent("https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoar4ini4akuc7mifny&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=http://share.chtcdn.com/webht.php/apps/dingmailtest/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=dingoar4ini4akuc7mifny&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=http://share.chtcdn.com/webht.php/apps/dingmailtest/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(){
|
|
|
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');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
});
|