var scroller1 = null,roleLevel = null,docInfo = null, area=null; var userRole; var $docPhoto = $("#doc_photo"),//头像 $active = $('.active'), $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 == CITY_CODE ? 4 : area.length==6 ? 3 : 2; //保存默认的角色权限信息 var selectedRole = JSON.stringify(userRole[0]); plus.storage.setItem("selectedRole", selectedRole); window.addEventListener("refreshData", function() { getSignInfo(); }); //切换角色事件 initQiehuanDom(); // 设备登记入口 judgeCityCode(area) //非海沧屏蔽 if(area.indexOf(350205)==0||area.indexOf(CITY_CODE)==0) { $active.find('div').removeClass('new-hide') $active.find('p').removeClass('new-hide') } 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); } getSignInfo();//获取签约量、签约率、完成率 bindEvents(); $('#wrapper').height($(window).height()) initScroll(); }); 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() { getSignInfo(); self.endPullDownToRefresh(); }, 1000); } } }); //角色切换模块的下拉环境scroll初始 mui("#roleWrapper").scroll({ bounce: false, indicators: true, deceleration: deceleration }) mui("#roleWrapper").pullRefresh(); } //获取签约量、签约率、完成率 function getSignInfo(){ var endDate = getDateBefore(0); if(roleLevel!=4){ $("#li-mingyi2").show(); $("#li-mingyi1").hide(); } sendPost("/statistics/sign_info", {endDate:endDate,area: area,level:roleLevel}, null, countHandle, 'POST', '', true); } 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") }, }) } }); //说明信息相关事件 $("#closeBtn").on("tap", function(){ $(".information").parent().hide(); scroller1.refresh(); }); $("#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 == CITY_CODE ? 4 : area.length==6 ? 3 : 2; if(area.indexOf(350205)==0||area.indexOf(CITY_CODE)==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') } getSignInfo(); mui('#middlePopover').popover('hide'); // 设备登记入口(海沧) judgeCityCode(code) //保存默认的角色权限信息 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("../../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; }); } }); } // 设备登记入口(海沧) function judgeCityCode(code) { code += ""; if(code.indexOf("350205") == 0){ //海沧区的医生才能够看到设备绑定的入口 $("#device-manage").show() } else { $("#device-manage").hide() } } function countHandle(res){ if(res.status == 200) { res = res.data; //console.log(JSON.stringify(res)) var rate = res.signRate.rate; $('#qieyuelv').waterbubble({ txt: parseFloat(rate).toFixed(2) + "%", data: res.signRate.rate/100, waterColor: '#12B7F5', lineWidth:0, radius: 60, textColor: 'rgba(0, 0, 0, 0.8)', font: 'bold 32px arial' }); var qylvHtml = ''+res.signRate.sign+''+ '
'+res.signRate.people+'
'; $(".p-qianyuelv").html(qylvHtml); var taskRate = res.signTaskRate.rate; $('#dabiaolv').waterbubble({ txt: parseFloat(taskRate).toFixed(2) + "%", data: res.signTaskRate.rate/100, waterColor: '#4ECD70', lineWidth:0, radius: 60, textColor: 'rgba(0, 0, 0, 0.8)', font: 'bold 32px arial' }); var dclvHtml = ''+res.signTaskRate.sign+''+ ''+res.signTaskRate.people+'
'; $(".p-dachenglv").html(dclvHtml); //添加续签 $('#xuqianlv').waterbubble({ txt: res.renewRange, data: parseFloat(res.renewRange)/100, waterColor: '#19d5c5', lineWidth:0, radius: 60, textColor: 'rgba(0, 0, 0, 0.8)', font: 'bold 32px arial' }); var renew = res.renew.split("/"); var xqlvHtml = ''+renew[0]+''+ ''+renew[1]+'
'; $(".p-xuqianlv").html(xqlvHtml); $(".div-qyl").html(format_number(res.sign)); $(".div-qianyuelv").html(res.signRate.rate.substring(0,4) + "%"); $(".div-dachenglv").html(res.signTaskRate.rate.substring(0,4) + "%"); } else { mui.toast(res.msg); } // $(".pullDown").hide(); plus.nativeUI.closeWaiting(); } /** * 数字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; }); } }