123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363 |
- 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('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;
- });
- }
- });
- }
- // 设备登记入口(海沧)
- 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 = '<span class="data-lv" style="color: #12b7f5; border-bottom: 1px solid #12b7f5;">'+res.signRate.sign+'</span>'+
- '<p>'+res.signRate.people+'</p>';
- $(".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 = '<span class="data-lv" style="color: #4ECD70; border-bottom: 1px solid #4ECD70;">'+res.signTaskRate.sign+'</span>'+
- '<p>'+res.signTaskRate.people+'</p>';
- $(".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 = '<span class="data-lv" style="color: #19d5c5; border-bottom: 1px solid #19d5c5;">'+renew[0]+'</span>'+
- '<p>'+renew[1]+'</p>';
- $(".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;
- });
- }
- }
|