<!DOCTYPE html>
<!-- 所有静态资源文件去除前面的../static/ -->
<html>
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>H5微应用免登</title>
    <script src="layui/jquery-1.8.3.min.js"></script>

    <script src="https://g.alicdn.com/dingding/dingtalk-jsapi/2.13.42/dingtalk.open.js"></script>
</head>
<body>

</body>

<script>
    dd.ready(function() {
        // dd.ready参数为回调函数，在环境准备就绪时触发，jsapi的调用需要保证在该回调函数触发后调用，否则无效。
        dd.runtime.permission.requestAuthCode({
            corpId: "ding78f523768b8e3863a1320dcb25e91351",
            onSuccess : function(result) {
                console.log(result);

                code= result.code;
                // 调用成功时回调
                console.log(code);
            },
            onFail : function(err) {
                // 调用失败时回调
                console.log(err)
            }

        });

        // dd.runtime.permission.requestOperateAuthCode({
        //     corpId: "ding78f523768b8e3863a1320dcb25e91351",
        //     agentId:"1418526292",
        //     onSuccess: function(result) {
        //         /*{
        //             code: 'hYLK98jkf0m' //string authCode
        //         }*/
        //         code = result.code;
        //         console.log(code);
        //     },
        //     onFail : function(err) {}
        //
        // })
    });

    alert("111");
    alert("222");
    alert(code);

    

</script>
</html>