var page = 1, pageSize = 10, docInfo; mui.init(); mui.plusReady(function(){ docInfo = JSON.parse(plus.storage.getItem("docInfo")); initScroller(); bindEvents(); }) function getDoctorList(isInit){ if(isInit){ page = 1; } var url = "/doctor/specialist/getDoctorInHospital", params = { doctor: docInfo.code, page: page, size: pageSize, name: $("#searchPut").val() }; plus.nativeUI.showWaiting(); sendGet(url, params, null, function(res){ $(".mui-scroll-wrapper").show(); if(res.status == 200){ var list = res.data; if(list.length == 0){ if(isInit){ $("#docList").hide(); $("#docList").siblings().show(); }else{ mui('.mui-scroll-wrapper').pullRefresh().endPullupToRefresh(true); } }else{ $("#docList").show(); $("#docList").siblings().hide(); var html = template("member-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{ page ++; mui('.mui-scroll-wrapper').pullRefresh().endPullupToRefresh(false); } } plus.nativeUI.closeWaiting(); }else{ plus.nativeUI.closeWaiting(); mui.toast(res.msg); } }, true); } function bindEvents(){ $("#searchPut").on("input", function(e){ var $this = $(this); //解决在ios设备中compositionend在input事件后执行的问题 setTimeout(function(){ if($this.prop("comstart")){ return false; } var text = $.trim($this.val()); if(text.length > 0){ $(".search_suggest_text").show(); $(".mui-scroll-wrapper").hide(); $(".search_suggest_text").text("搜索:"+text); }else{ $(".search_suggest_text").hide(); // getDoctorList(true); } }, 0); }).on('compositionstart', function(){ $(this).prop('comstart', true); // console.log('中文输入:开始'); }).on('compositionend', function(){ $(this).prop('comstart', false); // console.log('中文输入:结束'); }) $(".search_suggest_text").on('click', function(){ $(this).hide(); getDoctorList(true); }) $(".cancel-btn").on('click', function(){ mui.back(); }); template.helper("getPhoto", function(str){ return getImgUrl(str); }); //查看团队成员信息 $("#docList").on('tap', "li", function(){ var oCode = $(this).attr("data-code"); openWebview("doctor-info.html", {docCode: oCode}); }); } function initScroller(){ 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(){ getDoctorList(true); this.endPulldownToRefresh(); } }, up: { callback: function(){ getDoctorList(false); } } }) }