开发者社区> 问答> 正文

【钉钉】dd.ready/dd.error都没执行


dd.config的值都以获取,并验证没有问题,但是dd.ready和dd.error都进不去,不知道为什么,求教!!!
代码:
html:
<script>
        var _config=null;
        var getConfig = $.ajax({
            type: 'get',
            url: '/tec_oa/mobile/main/getConfig.do',
            data: {
                queryString: location.search,
                urlString: window.location.href
            },
            dataType: 'json',
            success: function(data){
                var configvalue    = data;
                _config = eval("("+configvalue+")");
            },
            error : function(xhr, errorType, error) {
                alert("ajaxError:  "+errorType + ', :' + error+'11-------------------');
            }
        });

    </script>

    <script type="text/javascript" src="https://g.alicdn.com/dingding/open-develop/1.6.9/dingtalk.js"></script>
    <script src="mobileoa/js/dingding/demo.js"></script>
demo.js
alert(_config.agentId);

dd.config({
    agentId : _config.agentId,
    corpId : _config.corpId,
    timeStamp : _config.timeStamp,
    nonceStr : _config.nonceStr,
    signature : _config.signature,
    jsApiList : [                           //需要调用的借口列表
        'runtime.info',
        'biz.contact.choose',
        'device.notification.confirm',
        'device.notification.alert',
        'device.notification.prompt',
        'biz.ding.post',
        'biz.util.openLink']
});


dd.ready(function() {
    dd.runtime.info({
        onSuccess : function(info) {
            alert('runtime info: ' + JSON.stringify(info));
        },
        onFail : function(err) {
            alert('fail: ' + JSON.stringify(err));
        }
    });
    dd.ui.pullToRefresh.enable({
        onSuccess: function() {
        },
        onFail: function() {
        }
    })

    /*
     *获得免登授权码,需要的参数为corpid,也就是企业的ID
     *成功调用时返回onSuccess,返回值在function的参数info中,具体操作可以在function中实现
     *返回失败时调用onFail
     */
    dd.runtime.permission.requestAuthCode({
        corpId : _config.corpId,   //企业id
        onSuccess : function(info) {
            alert("info:  "+info.code);
            alert("corpId:  "+_config.corpId);
            $.ajax({
                url : 'userInfoServlet?code=' + info.code ,//+ '&corpid=' + _config.corpId
                type : 'POST',
                dataType:'json',
                success : function(data, status, xhr) {
                    if (data.errcode === 0) {
                        dd.userid = info.userid;
                        document.getElementById("userName").innerHTML = data.name;
                        document.getElementById("userId").innerHTML = data.userid;
                    }
                    else {
                        alert('auth error: ' + data+'-------------------');
                    }
                },
                error : function(xhr, errorType, error) {
                    alert("ajaxError:  "+errorType + ', :' + error+'22-------------------');
                }
            });
        },
        onFail : function(err) {
            alert(JSON.stringify(err));
        }
    });
    dd.error(function(err) {
        alert('asdasd11111'+'dd error: ' + JSON.stringify(err));
    });
})

dd.error(function(err) {
    alert('dd error: ' + JSON.stringify(err)+'-------------------');
});

第一次发帖请教,请多指点,谢谢

展开
收起
lin_jing 2018-01-08 16:33:57 5781 0
0 条回答
写回答
取消 提交回答
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
钉钉小程序——为工作方式插上翅膀 立即下载
钉钉客户端自动化的应用 立即下载
使命必达 —— 钉钉企业级 消息服务的机遇与挑战 立即下载