var scrollers = [], teamInfo, docInfo, isTeamLeader; mui.init(); mui.plusReady(function(){ docInfo = JSON.parse(plus.storage.getItem("docInfo")); getTeamInfo(); initScroller(); bindEvents(); getTemplateHelper(); }) function getTeamInfo(){ var info = JSON.parse(plus.storage.getItem("teamInfo")); teamInfo = _.map(info.data, function(o){ if(o.leaderCode == docInfo.code){ //是团队长 isTeamLeader = true; o.isTeamOwner = 1; }else{ o.isTeamOwner = 0; } return o; }); if(isTeamLeader){ $(".header-link").show(); } var html = template("team-tmp", {list: teamInfo}); $("#teamList").append(html); } function getTeamMembers(id, isLeader){ plus.nativeUI.showWaiting(); var url = "/doctor/admin-teams/"+ id +"/members"; sendGet(url, {}, null, function(res){ plus.nativeUI.closeWaiting(); if(res.status == 200){ var html = template("member-tmp", {list: res.data, teamCode: id, isTeamOwner: isLeader}); $("#team_"+id).append(html); $(".team-expand[data-code="+id+"]").attr("showed", "1"); }else{ mui.toast(res.msg); } }, true); } function bindEvents(){ $(".lin-search").on('tap', function(){ //跳转去搜索页面 openWebview("search-doctor.html"); }); document.querySelector('.mui-slider').addEventListener('slide', function(event) { if(event.detail.slideNumber != 0){ $(".header-link").hide(); }else{ if(isTeamLeader){ $(".header-link").show(); } } }); $("#teamList").on('tap', ".team-expand", function(){ var $this = $(this), teamCode = $this.attr("data-code"), isTeamOwner = $this.attr("data-leader"); if($this.attr("showed")){ return false; }else{ getTeamMembers(teamCode, isTeamOwner); } }); //团队群聊 $("#teamList").on('tap', ".link-team-chart", function(){ var teamCode = $(this).attr("data-code"), teamName = $(this).attr("data-name"); mui.openWindow({ url: "../../message/html/tuanduiqunliao.html", id: "tuanduiqunliao.html", extras: { info: { teamCode: teamCode, teamName: teamName, code: teamCode } } }) }); //查看团队成员信息 $("#teamList").on('tap', ".t-doctor", function(){ var oCode = $(this).attr("data-code"), teamCode = $(this).attr("data-team"), isLeader = $(this).attr("data-leader"); mui.openWindow('../../mine/html/zuyuanziliao.html', 'zuyuanziliao', { extras: { docCode: oCode, teamCode: teamCode, isTeamOwner: isLeader } }); }); //转移居民 $("#teamList").on('tap', ".zyjm", function(e){ e.stopPropagation(); var $this = $(this), $li = $(this).parent().parent(), level = $this.attr("data-level"), code = $li.attr("data-code"), teamId = $li.attr("data-team"); if(level == 3){ mui.openWindow({ id: "zhuanyijumin", url: "../../search/html/zhuanyijumin.html", extras: { level: level, teamCode: teamId, docCode: code, type:'转移' } }); } else { mui.openWindow({ id: "zyjm-layer.html", url: "../../tuandui/html/zyjm-layer.html", styles: { background: 'transparent' }, show:{aniShow: "none"}, waiting:{autoShow: false}, extras: { teamCode: teamId, docCode: code, type:'转移' } }) } }) } function getTemplateHelper(){ template.helper("getPhoto", function(str){ return getImgUrl(str); }); template.helper("getLevelName", function(level){ switch(parseInt(level)){ case 1: return "专科医生"; break; case 2: return "全科医生"; break; case 3: return "健康管理师"; break; default: return ""; break; } }) } function initScroller(){ var deceleration = mui.os.ios?0.003:0.0009; mui('.mui-scroll-wrapper').scroll({ bounce: false, indicators: true, //是否显示滚动条 deceleration:deceleration }); $.each(document.querySelectorAll('.mui-slider-group .mui-scroll-wrapper'), function(index, pullRefreshEl){ //目前只有第3个tab的社区中心的医生需要分页,其他两个tab的页面不分页 var scroller; if(index != 2){ scroller = mui(pullRefreshEl).pullRefresh({ down: { callback: function(){ this.endPulldownToRefresh(); } }, }); }else{ scroller = mui(pullRefreshEl).pullRefresh({ down: { callback: function(){ this.endPulldownToRefresh(); } }, up: { callback: function(){ var self = this; } } }) } scrollers.push(scroller); }) }