开发者社区> 问答> 正文

这个页面授权不成功,敬请大神告知!!script里代码已贴出来。


<script>
var myConfig;
        $(function(){
            //发送ajax请求,先认证一下此网页
             $.ajax({
                url:common.currentPath+"/loginAction.do",
                type:"post",
                data:"urlString="+common.localUrl+"&type=byDingding2&queryString=dd_nav_bgcolor=38adff",
                success:function(data){
                    var _config=eval("("+data+")");
                    myConfig=eval("("+_config.data+")");
                    alert(JSON.stringify(myConfig));
                        dd.config({
                            appId: '6086319',
                            corpId:myConfig.corpId,
                            timeStamp: myConfig.timeStamp,
                            nonceStr: myConfig.nonceStr,
                            signature: myConfig.signature,
                            jsApiList: ['runtime.info',
                            'biz.contact.choose',
                            'device.notification.confirm',
                            'device.notification.alert',
                            'device.notification.prompt',
                            'biz.navigation.setTitle',
                            'device.notification.showPreloader',
                            'biz.telephone.call',
                            'biz.navigation.setRight',
                            'biz.ding.post']
                     });
                },
                error:function(err){
                    console.info(JSON.stringify(err)+"dd。configl里的");
                }
             })
        })
         dd.ready(function() {
            console.info('dd.ready rocks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
            dd.runtime.info({
                onSuccess: function (info) {
                    console.info('runtime info: ' + JSON.stringify(info));
                },
                onFail: function (err) {
                    console.info('fail: ' + JSON.stringify(err));
                }
            });


            dd.runtime.permission.requestAuthCode({
                corpId:myConfig.corpId,
                onSuccess: function (info) {
                    console.info('authcode: ' + info.code);


                    $.ajax({
                        url: 'userInfo?code=' + info.code,
                        type: 'GET',
                        success: function (data, status, xhr) {
                            var info = JSON.parse(data);
                            if (info.errcode === 0) {
                                console.info('user id: ' + info.userid);
                            }
                            else {
                               console.info('auth error: ' + data);
                            }
                        },
                        error: function (xhr, errorType, error) {
                            alert("yinyien");
                            console.info(errorType + ', ' + error);
                        }
                    });
                },
                onFail: function (err) {
                    alert(JSON.stringify(err)+"perssion里的");
                }
            });
        });
</script>

展开
收起
依然狂舞 2015-12-11 14:59:22 5329 0
1 条回答
写回答
取消 提交回答
  • 请您将报错信息贴出来,便于查错;您是在免登出错,还是免登正确后,使用提供的jsapi时报错
    2015-12-13 22:20:40
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

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