var d = dialog({contentType:'load', skin:'bk-popup'}); var page = 0, pagesize = 10; mui.init(); (function($) { //阻尼系数 var deceleration = mui.os.ios?0.003:0.0009; $('.mui-scroll-wrapper').scroll({ bounce: false, indicators: true, //是否显示滚动条 deceleration:deceleration }); $('.mui-scroll-wrapper').pullRefresh({ up: { callback: function() { var self = this; setTimeout(function() { getList(false); self.endPullupToRefresh(); }, 1000); } } }); bindEvents(); })(mui); function getList(isInit){ var idcard = $.trim($(".search-bar input").val()); var url = "/patientFeedback/feedback/findByIdcard", params = { idcard: idcard, page: page, pagesize: pagesize }; d.show(); sendPost(url, params, 'json', 'get', queryFailed, 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 ++; } } d.close(); }else{ queryFailed(res); } }); } function bindEvents(){ $("#search").on('tap', function(){ var idcard = $(".search-bar input").val(); if(idcard.length == 0){ dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请输入身份证号'}).show(); 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)) { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'身份证号格式错误'}).show(); return false; } getList(true); }); $("body").on("tap", ".list-item", function(){ var $this = $(this), code = $this.data("code"); window.location.href = "feedback-detail.html?type=1&fdCode="+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; } }) } function queryFailed(res){ d.close(); 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(); } }