var page = 10, pagesize = 10, patiCode = "", teamCode; var noResultWrap = '
'+ ''+ // '
暂无医学知识记录~
'+ '
'; mui.init(); mui.plusReady(function(){ var self = plus.webview.currentWebview(); patiCode = self.patientCode; initScroll(); initTemplateHelper(); getTeamInfo(); bindEvents(); }); function initScroll(){ //阻尼系数 var deceleration = mui.os.ios?0.003:0.0009; mui('.mui-scroll-wrapper').scroll({ bounce: false, indicators: true, //是否显示滚动条 deceleration:deceleration }); mui('.mui-scroll-wrapper').pullRefresh({ down: { callback: function() { var self = this; setTimeout(function() { getList(true); self.endPulldownToRefresh(); }, 1000); } }, up: { callback: function() { var self = this; setTimeout(function() { getList(false); self.endPullupToRefresh(); }, 1000); } } }); } function getTeamInfo(){ plus.nativeUI.showWaiting(); // TODO 团队选择 return getReqPromise("doctor/family_contract/patient_doctor_teams",{ patient: patiCode }).then(function(res) { if(res.status == 200) { var data = res.data,teams = []; // 是否有签约关系 1:有 0:无,此时jtTeam与ssTeam都没有 if(data.hasSign=="1") { data.ssTeam && (function() { var team = data.ssTeam.team; team.hasSign = data.ssTeam.hasSign; // 医生与患者是否有签约关系 team.isLeader = data.ssTeam.isLeader; // 是否是团队长 teams.push(team) })(); data.jtTeam && (function() { var team = data.jtTeam.team; team.hasSign = data.jtTeam.hasSign; // 医生与患者是否有签约关系 team.isLeader = data.jtTeam.isLeader; // 是否是团队长 teams.push(team) })(); } } $('.lin-sel-group').html(template('teams_tmpl', {data:teams})); //初始默认选中第一个团队信息 var $select = $(".lin-sel-group li").eq(0); var code = parseInt($select.attr("data-code")); $(".lin-sel-group li").removeClass("checked"); $select.addClass("checked"); teamCode = code; $("#Dtitle").html($select.find("label").html()).attr("data-index",code); }).then(function(){ getList(true); }); } function getList(isInit){ page = isInit? 1: page; var url = "third/guahao/GetPatientReservationList", params = { patient: patiCode, teamCode: teamCode || "", pageIndex: page, pageSize: pagesize, }; plus.nativeUI.showWaiting(); sendPost(url, params, null, function(res){ if(res.status == 200){ var list = res.list || res.data; if(list.length > 0){ $(".mui-scroll-wrapper").show(); $("#no_result_wrap").hide(); page++; var html = template('daiyuyue_tmpl', {list: list}); if(isInit){ $(".mui-scroll").empty().append(html); }else{ $(".mui-scroll").append(html); } if(list.length < pagesize){ mui('.mui-scroll-wrapper').pullRefresh().endPullupToRefresh(true); } }else{ //无数据 if(isInit){ $(".mui-scroll-wrapper").hide(); $("#no_result_wrap").show(); } } }else{ mui.toast(res.msg); } plus.nativeUI.closeWaiting(); }, 'POST', '', true); } function bindEvents(){ $('body').on("tap", ".dyy_detail", function(){ chooseItem(this) }); $(".demo-comtop").on("click","h1",function(){ $(".lin-mask").show(); $(".lin-sel-group").show(); }); $(".lin-mask").on("click",function(){ $(".lin-mask").hide(); $(".lin-sel-group").hide(); }); $(".lin-sel-group").on("click","li",function(){ var index = parseInt($(this).attr("data-index")); $(".lin-sel-group li").removeClass("checked"); $(this).addClass("checked"); $(".lin-mask").trigger("click"); $("#Dtitle").html($(this).find("label").html()).attr("data-index",index); teamCode = $(this).attr("data-code"); //重新加载数据 getList(true); }); } function chooseItem(ele){ var info = $(ele).closest(".n-list").attr("data-info"), self = plus.webview.currentWebview(); var questionaires = plus.webview.getWebviewById("questionaires"); mui.fire(questionaires, "filldyy", {info: info}); questionaires.show(); mui.later(function(){ self.close(); }, 300); } function initTemplateHelper(){ template.helper('toInfo', function(v){ return JSON.stringify(v); }); template.helper("setSex", function(s) { if(s == 1) { return "男" } else if(s == 2) { return "女" } }); template.helper("setPhoto", function(p) { if(!p || p.length == 0) { return "../../../images/p-default.png"; } else { return getImgUrl(p); } }); template.helper("setTime", function(p) { // 为了防止类似“2016-12-21 14:08:10.0”在IOS上无法识别问题 if(p){ p = p.split('.')[0]; return new Date(Date.parse(p.replace(/-/g, "/"))).format("yyyy-MM-dd hh:mm:ss") }else{ return ""; } }); }