H894752662
1329丶H
2017-10-12 08:56

钉钉微应用,使用免登,偶尔会在跳转页面卡死,需要退出钉钉账号后才恢复正常,求解,跳转代码如下:

  • html5
  • js

<!DOCTYPE html>


跳转中,请稍等...
<script src="http://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>

<script src="js/jquerysession.js"></script>
<!--钉钉js-->
<!--  手机端 -->
<script src="https://g.alicdn.com/dingding/open-develop/1.6.9/dingtalk.js"></script>
<!-- PC端 -->
<!-- <script src="https://g.alicdn.com/dingding/dingtalk-pc-api/2.7.0/index.js"></script> -->

<script src="js/first.js"></script>


first.js

var resDing;

    var mdc;
    var Uid;


    if($.session.get("uname") == null){

    //手机端
    dd.ready(function() {


        //获取免登码
        dd.runtime.permission.requestAuthCode({
                corpId: "ding5c848c3aca581fa635c2f4657eb6378f",
                onSuccess: function(result) {
                    //alert(result.code);
                    mdc = result.code;

                    //alert("111");
                    $.post("${pageContext.request.contextPath}/text!sendMDcode.action",
                            {mdCode:mdc},
                            function(jo){

                                Uid = eval("(" + JSON.stringify(jo) + ")");
                                if(Uid.truename == null || Uid.idcard == null || Uid.lvid==null || Uid.dpt==null  ){
                                    window.location.href = "nobody.html";
                                }
                                else{
                                $.session.set("userid", Uid.userid);

                                //又userid获取的数据库 姓名、等级、身份证号码、部门
                                $.session.set("uname", Uid.truename);//truename
                                $.session.set("idcard", Uid.idcard);//idcard
                                $.session.set("lvid", Uid.lvid);//lvid
                                $.session.set("dpt", Uid.dpt);//dpt

                                window.location.href = "index.html";
                                }
                            },
                            "json");

                },
                onFail : function(err) {
                    alert('fail: ' + JSON.stringify(err));
                }

            });

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


        }else{

            window.location.href = "index.html";
        }
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答