开发者社区> 问答> 正文

PC版免登授权没反应,大神帮忙看看


<script type="text/javascript" src="https://g.alicdn.com/dingding/dingtalk-pc-api/2.7.0/index.js"></script>

<script type="text/javascript">
    var _config = {
        agentId: '<%=agentId%>',
            corpId: '<%=corpId%>',
            timeStamp: '<%=timeStamp%>',
            nonce: '<%=nonceStr%>',
            signature: '<%=signature%>'
        };




        //jsapi的配置。我注销之后代码仍然可正确执行。这里我没有了解到具体的函义与用法
        DingTalkPC.config({
            agentId: _config.agentId, // 必填,微应用ID
            corpId: _config.corpId,//必填,企业ID
            timeStamp: _config.timeStamp, // 必填,生成签名的时间戳
            nonceStr: _config.nonce, // 必填,生成签名的随机串
            signature: _config.signature, // 必填,签名
            jsApiList: [
                'device.notification.confirm',
                'device.notification.alert',
            'runtime.permission.requestAuthCode']
        });
        DingTalkPC.ready(function(res){
            DingTalkPC.runtime.permission.requestAuthCode({
                corpId: _config.corpId,
                onSuccess: function (result) {
                    /*{
                        code: 'hYLK98jkf0m' //string authCode
                    }*/


                    $.ajax({
                        url: "ajax/ajax_Qd.ashx",
                        data: "LClass=getUser&ddCode=" + result.code,
                        type: 'post',
                        dataType: "json",
                        success: function (data) {


                            if (data.starus == 1) {
                                location.href = "list.aspx?userid=" + data.userid + "&dept=" + data.department;
                            }
                            else {
                                
                            }
                            // alert("userid:" + data.userid);
                        }
                    });
                },
                onFail: function (err) { }


            });
            //这里写一个简单的jsapi的弹用,其它api的调用请参照钉钉开发文档-客户端开发文档
            DingTalkPC.device.notification.alert({
                message: "测试弹窗",
                title: "提示",//可传空
                buttonName: "收到",
                onSuccess: function () {
                    /*回调*/
                },
                onFail: function (err) {




                }
            });
        });
    </script>

展开
收起
ben26276777 2018-03-21 14:21:43 2008 0
1 条回答
写回答
取消 提交回答
  • RePC版免登授权没反应,大神帮忙看看
    我也碰到了,config有误造成的。当config配置和签名正确之后,就生效了。
    2018-03-31 10:56:46
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载