123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- 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();
- window.addEventListener("refreshData", function() {
- getAlalysisData();
- getJieZhiTime()
- });
- initQiehuanDom();//切换角色事件
- initData();
- getJieZhiTime();
- getAlalysisData();
- bindEvents();
- initScroll();
- });
- /*
- * 初始化处理各个数据
- */
- function initData(){
- 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);
- 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(jobName){
- $docType.html("("+jobName+")") //类别
- }
- $hospitalName.html(deptName);//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);
- }
- $('#wrapper').height($(window).height());
- }
- /*
- * 加载数据截止时间
- */
- 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);
- }
- });
- }
- /*
- * 获取统计数据
- */
- function getAlalysisData(){//level:等级(1 团队,2 科室,3 机构,4 区)此处传3
- sendGet("/statistics/getIndexTotal",{endDate:getDateFromNow(),area:srOrgCode,level:3},function(res){
- },function(res){
- if(res.status==200){
- var data = res.data;
- $("#zcjmAmount").html(data.reginNum);
- $("#jmzxlAmount").html(data.consultNum);
- $("#jmgzAmount").html(data.concernNum);
- $("#jkjyAmount").html(data.educateNum);
- $("#jkzdAmount").html(data.guideNum);
- }
- 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();
- getAlalysisData();
- 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();
- getAlalysisData();
- 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;
- });
- }
- });
-
- $(".l-qytj-barner").on('tap',"li", function(){
- var index = $(this).attr("data-index");
- openWebview("../../manager/html/comprehensive-analysis.html", {index: index});
- });
- }
- /**
- * 数字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;
- }
- var userRole = JSON.parse(plus.storage.getItem("selectedRole"));
- openWebview('../../observer/html/doctors.html', {code: userRole.code});
- }
- //获取当前时间
- function getDateFromNow(days) {
- if(!days) {
- return new Date().format("yyyy-MM-dd")
- }
- var now = new Date().getTime()
- var diff = 24 * 3600 * 1000 * days
- return new Date(now + diff).format("yyyy-MM-dd")
- }
|