<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>apk文件包上传</title>
    <style>
        ul {
            width: 300px;
        }
        img {
            display: block;
            width: 100%;
            height: 300px;
            margin-bottom: 20px;
        }
        #login_container{
            margin: 200px auto;
            width: 400px;
        }
    </style>
    <script src="https://g.alicdn.com/dingding/dinglogin/0.0.5/ddLogin.js"></script>
</head>
<body>
    <div id="login_container"></div>
<script>
    let url = encodeURIComponent('http://upload-apk.srccwl.com/return/login');
    let goto = encodeURIComponent('https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoap7dwt39svqfxlnkx&response_type=code&scope=snsapi_login&state=STATE&redirect_uri='+url)
    DDLogin({
        id:"login_container",
        goto: goto,
        width : "400",
        height: "400"
    });
    let handleMessage = function (event) {
        let origin = event.origin;
        if( origin == "https://login.dingtalk.com" ) {
            let loginTmpCode = event.data;
            window.location.href="https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoap7dwt39svqfxlnkx&response_type=code&scope=snsapi_login&state=STATE&redirect_uri="+url+"&loginTmpCode="+loginTmpCode
        }
    };
    if (typeof window.addEventListener != 'undefined') {
        window.addEventListener('message', handleMessage, false);
    } else if (typeof window.attachEvent != 'undefined') {
        window.attachEvent('onmessage', handleMessage);
    }
</script>
</body>
</html>