| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 | var scroller1 = null,roleLevel = null,docInfo = null, area=null;var userRole;var $docPhoto = $("#doc_photo"),//头像    $name = $("#doc_name"),//名称    $docType = $("#doc_type"),//类别    $jobName = $("#doc_jobName"),    $hospitalName = $("#hospitalName");//所属医院mui.plusReady(function() {    plus.nativeUI.showWaiting();    userRole = JSON.parse(plus.storage.getItem("userRole"));        area = userRole[0].code;        roleLevel = area == '361100'  ? 4 : area.length==6 ? 3 : 2;    //保存默认的角色权限信息    var selectedRole = JSON.stringify(userRole[0]);    plus.storage.setItem("selectedRole", selectedRole);    window.addEventListener("refreshData", function() {       getJieZhiTime()    });    //切换角色事件    initQiehuanDom();        var docInfo = JSON.parse(plus.storage.getItem("docInfo"));        var deptName =docInfo.deptName;    var jobName=docInfo.jobName;    var docName = docInfo.name;//姓名    var docSex = docInfo.sex;//性别    var docPhoto = docInfo.photo; //图像    var docHospitalName = docInfo.hospitalName; //医院        //图片加载失败时使用默认图片    document.getElementById("doc_photo").onerror = function(){        this.src = setDocPhoto(docSex, 10);    }    $docPhoto.attr("src", getImgUrl(docPhoto));    $name.html(docName)//名称    if(deptName || jobName){        $docType.html("("+deptName+jobName+")")   //类别    }    $hospitalName.html(userRole[0].name);//显示该医生拥有的管理员权限        if(userRole.length > 1){        $("#selectRole").show();        var html = template("role_tmp", {list: userRole});        $("#roleList").append(html);    }        $('#doc_type').css('max-width', ($('#doc-info').width() - $name.width() - 35) + 'px');        if(!isMultiRole()){        checkIdcard(docInfo.idcard);    }        getJieZhiTime();    bindEvents();    $('#wrapper').height($(window).height())    initScroll();}); /* * 加载数据截止时间 */function getJieZhiTime(){    sendPost("/statistics/time",null,function(res){    },function(res){        if(res.status=="200"){            var date = (res.data && res.data.substring(11,16)) || "";            $(".jiezhi-time").html(date);        }        plus.nativeUI.closeWaiting();    });}function initScroll() {    //阻尼系数    var deceleration = mui.os.ios?0.003:0.0009;    mui('#wrapper').scroll({        bounce: false,        indicators: true, //是否显示滚动条        deceleration:deceleration    });        mui("#wrapper .mui-scroll").pullToRefresh({        down: {            callback: function() {                var self = this;                setTimeout(function() {                    getJieZhiTime();                    self.endPullDownToRefresh();                }, 1000);            }        }    });    //角色切换模块的下拉环境scroll初始    mui("#roleWrapper").scroll({        bounce: false,        indicators: true,        deceleration: deceleration    })    mui("#roleWrapper").pullRefresh();}            function bindEvents(){    mui('#wrapper').on('tap','.wrap', function(){        var href=$(this).attr("data-href");        var hrefId = $(this).attr("data-href-id");        mui.openWindow({            url:href,            id:hrefId,            extras:{              type:$(this).attr("data-id")            },         })    });    mui('#wrapper').on('tap','.div-aitem', function(){        var href=$(this).attr("data-href");        var hrefId = $(this).attr("data-href-id");        var activeId = $(this).attr("data-id");        if(activeId=="5" && roleLevel==2){//两率分析            href = "../../manager/html/lianglvfenxi-sheguan.html";            hrefId = "lianglvfenxi-sheguan.html";        }        if(plus.os.name == "Android" && plus.device.vendor == "Meizu") {            var wv = plus.webview.create( href, hrefId, {hardwareAccelerated:false}, {                  type:$(this).attr("data-id")            } );            wv.show("slide-in-right",250);        } else {            mui.openWindow({                url:href,                id:hrefId,                extras:{                  type:$(this).attr("data-id")                },             })        }            });        mui('#wrapper').on('tap','.fwfx-ul li',function(){        var href=$(this).attr("data-href");        var hrefId = $(this).attr("data-href-id");        if(href){            mui.openWindow({                url:href,                id:hrefId,                extras:{                  type:$(this).attr("data-id")                },             })        }    });            $("#roleList").on('tap', 'li', function(){        var $this = $(this),            index = $this.data('index'),            name = $this.data('name'),            code = $this.data('code');                    $("#hospitalName").text(name);                area = code + '';        roleLevel = area == '350200'  ? 4 : area.length==6 ? 3 : 2;        if(area.indexOf(350205)==0||area.indexOf(350200)==0) {            $active.find('div').removeClass('new-hide')        	$active.find('p').removeClass('new-hide')        }else{            $active.find('div').addClass('new-hide')        	$active.find('p').addClass('new-hide')        }                getJieZhiTime();        mui('#middlePopover').popover('hide');        //保存默认的角色权限信息        var selectedRole = JSON.stringify(userRole[index]);        plus.storage.setItem("selectedRole", selectedRole);    })        $(".close-btn").on('tap', function(){        mui('#middlePopover').popover('hide');    });        //医生体验    $(".ysty").on("tap",function(){        ysty();    })        $('#li-mingyi1').on("tap",function() {        openWebview('../../mygl/html/mingyiguanli.html')    });        $('#unbind_device').on("tap",function(){        openWebview('jiebangshebei.html');    });        $('#jianjiao-tuisong').on("tap",function(){        <!--openWebview('jianjiaotuisong.html');-->        openWebview("../../jkjy/html/article-store.html", {isAdmin: true});    });        $('#device-manage').on("tap",function(){        openWebview("../../device/html/device-data.html");    });        $(".wjdc").on('tap', function(){        //根据角色权限显示对应的列表信息        // roleLevel: 级别(4:市 3:区 2:社区医院 1:团队)        var userRole = JSON.parse(plus.storage.getItem("userRole"))[0];        if(roleLevel == 4){            openWebview('../../survey/html/survey_list.html');        } else {            mui.confirm("对不起,您无操作权限","提示",                ["我知道了"], function(e){                if(e.index==0) return false;           });        }    });}/** * 数字3位加一个逗号 * @param {Object} n */function format_number(n){     var b=parseInt(n).toString();     var len=b.length;     if(len<=3){return b;}     var r=len%3;     return r>0?b.slice(0,r)+","+b.slice(r,len).match(/\d{3}/g).join(","):b.slice(r,len).match(/\d{3}/g).join(",");   }  /** * 获取多少天前的日期 */function getDateBefore(days) {    var now = new Date();    var date = new Date(now.getTime() - days * 24 * 3600 * 1000);    var year = date.getFullYear();    var month = date.getMonth() + 1;    var day = date.getDate();    var hour = date.getHours();    var minute = date.getMinutes();    var second = date.getSeconds();    return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);}function ysty(){    //观察者模式下,不可以再次观察者查看    var userAgent = JSON.parse(plus.storage.getItem("userAgent"));    if(userAgent.observer){        mui.confirm("对不起,您无操作权限","提示",            ["我知道了"], function(e){            if(e.index==0) return false;        });        return;    }    //根据角色权限显示对应的列表信息    // roleLevel: 级别(4:市 3:区 2:社区医院 1:团队)//              var userRole = JSON.parse(plus.storage.getItem("userRole"))[0];    var userRole = JSON.parse(plus.storage.getItem("selectedRole"));    if(roleLevel == 4){        openWebview('../../observer/html/district.html',{code: userRole.code});    }    if(roleLevel == 3){        openWebview('../../observer/html/hospital.html',{code: userRole.code});    }    if(roleLevel == 2){        openWebview('../../observer/html/doctors.html', {code: userRole.code});    }    if(roleLevel == undefined || roleLevel == null || roleLevel == 1){        mui.confirm("对不起,您无操作权限","提示",            ["我知道了"], function(e){            if(e.index==0) return false;       });    }}
 |