var page = 0, pagesize = 10; mui.init(); mui.plusReady(function(){ initScroller(); bindEvents(); }); function getList(isInit){ if(isInit){ page = 0; } var idcard = $.trim($(".search-bar input").val()); var url = "/doctorFeedback/feedback/findByIdcard", params = { idcard: idcard, page: page, pagesize: pagesize }; plus.nativeUI.showWaiting(); sendGet(url, params, null, function(res){ if(res.status == 200){ if(res.list.length == 0){ if(isInit){ $("#no_result_wrap").show(); $(".mui-scroll-wrapper").hide(); }else{ mui('.mui-scroll-wrapper').pullRefresh().disablePullupToRefresh(); } }else{ $("#no_result_wrap").hide(); $(".mui-scroll-wrapper").show(); var html = template("item_temp", {list: res.list}); if(isInit){ $("#result_wrap").empty().append(html); }else{ $("#result_wrap").append(html); } if(res.list.length < pagesize){ mui('.mui-scroll-wrapper').pullRefresh().disablePullupToRefresh(); }else{ mui('.mui-scroll-wrapper').pullRefresh().enablePullupToRefresh(); page ++; } } }else{ mui.toast(res.msg); } plus.nativeUI.closeWaiting(); }, true); } 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({ up: { callback: function() { var self = this; setTimeout(function() { getList(false); self.endPullupToRefresh(); }, 1000); } } }); } function bindEvents(){ $("#search").on('tap', function(){ var idcard = $(".search-bar input").val(); if(idcard.length == 0){ mui.toast("请输入身份证号"); return false; } if (!/^[1-9][0-9]{5}(19[0-9]{2}|200[0-9]|2010)(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01])[0-9]{3}[0-9xX]$/i.test(idcard)) { mui.toast("身份证号格式错误"); return false; } getList(true); }); $("body").on("tap", ".list-item", function(){ var $this = $(this), code = $this.data("code"); openWebview("feedback-detail.html", { type: 1, code: code }); }); template.helper('formatDate', function(time){ if(time){ return time.substr(0,16); } return ""; }); template.helper('getTypeValue', function(type){ switch(type){ case 1: return "手机号变更"; break; case 2: return "重置密码"; break; case 3: return "其他"; break; default: return ""; break; } }); template.helper("getStatus", function(status){ switch(status){ case 0: return "未读"; break; case 1: return "待处理"; break; case 2: return "已处理"; break; } }) }