var d = dialog({contentType:'load', skin:'bk-popup'}); var page = 0, pageSize = 10, userAgent = window.localStorage.getItem(agentName), pagetype = 2; // 获取链接带参 var request = GetRequest(), deptId =request["deptId"] || null; $(function(){ checkUserAgent(); }); function queryInit(){ userAgent = JSON.parse(userAgent); initScroller(); getDoctorList(true); bindEvents(); getTemplateHelper(); } function getDoctorList(isInit){ d.show(); if(isInit){ page = 0; } var url = "/patient/concern/getConcernDoctors", params = { patient: userAgent.uid, page: page, pageSize: pageSize }; sendPost(url, params, 'JSON', 'GET', queryFailed, function(res){ if(res.status == 200){ d.close(); var list = res.data; if(list.length>0){ page ++; var html = template("doctor_tmp", {list: list}); if(isInit){ $("#docList").empty().append(html); }else{ $("#docList").append(html); } if(list.length < pageSize){ mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true); }else{ mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(false); } }else{ if(isInit){ $(".main").hide(); $(".div-no-search-info").show(); mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true); }else{ mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true); } } }else{ queryFailed(res); } }) } function bindEvents(){ //单个医生点击 $("#docList").on("tap", "li", function(){ var doctorCode = $(this).attr("data-code"); window.location.href = "doctor-homepage.html?doctor="+doctorCode; }) } function getTemplateHelper(){ template.helper("getImgUrl", function(str){ return getImgUrl(str); }); } function initScroller(){ //阻尼系数 var deceleration = mui.os.ios?0.003:0.0009; mui('.mui-scroll-wrapper').scroll({ bounce: false, indicators: true, //是否显示滚动条 deceleration:deceleration }); mui.ready(function() { mui(".mui-scroll-wrapper").pullRefresh({ down:{ callback: function(){ getDoctorList(true); this.endPulldownToRefresh(); } }, up: { callback: function() { var self = this; setTimeout(function() { getDoctorList(false); // self.endPullupToRefresh(); }, 1000); } } }); }); } //请求失败处理事件 function queryFailed(res, message){ d.close(); if(message){ dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content: message}).show(); }else{ if (res && res.msg) { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show(); } else { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show(); } } }