var d = dialog({contentType:'load', skin:'bk-popup'}); var page1 = 0, page2 = 0, pagesize = 10, idcard; mui.init(); (function($) { //阻尼系数 var deceleration = mui.os.ios?0.003:0.0009; $('.mui-scroll-wrapper').scroll({ bounce: false, indicators: true, //是否显示滚动条 deceleration:deceleration }); $.ready(function() { //循环初始化所有下拉刷新,上拉加载。 $.each(document.querySelectorAll('.mui-slider-group .mui-scroll-wrapper'), function(index, pullRefreshEl) { $(pullRefreshEl).pullRefresh({ up: { callback: function() { var self = this; setTimeout(function() { if(index == 0){ getAccountBackData(false); }else{ getFeedbackData(false); } self.endPullupToRefresh(); }, 1000); } } }); }); getPatientInfo(); bindEvents(); }); })(mui) function getPatientInfo(){ var url = "/patient/baseinfo"; sendPost(url, {}, 'json', 'post', queryFailed, function(res){ if(res.status == 200){ idcard = res.data.idcardAll; getAccountBackData(true); getFeedbackData(true); }else{ queryFailed(res); } }); } function getAccountBackData(isInit){ if(isInit){ page1 = 0; } var url = "/patientFeedback/feedback/findByIdcard", params = { idcard: idcard, page: page1, 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_wrap1").show(); $("#result_wraper1").hide(); }else{ mui('#result_wraper1').pullRefresh().disablePullupToRefresh(); } }else{ $("#no_result_wrap1").hide(); $("#result_wraper1").show(); var html = template("list_tmp", {list: res.list, type: 1}); if(isInit){ $("#listPanel1").empty().append(html); }else{ $("#listPanel1").append(html); } if(res.list.length < pagesize){ mui('#result_wraper1').pullRefresh().disablePullupToRefresh(); }else{ page1 ++; mui('#result_wraper1').pullRefresh().enablePullupToRefresh(); } } d.close(); }else{ queryFailed(res); } }) } function getFeedbackData(isInit){ if(isInit){ page2 = 0; } var url = "/patient/feedback/findByCreater", params = { page: page2, 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_wrap2").show(); $("#result_wraper2").hide(); }else{ mui('#result_wraper2').pullRefresh().disablePullupToRefresh(); } }else{ $("#no_result_wrap2").hide(); $("#result_wraper2").show(); var html = template("list_tmp", {list: res.list, type: 2}); if(isInit){ $("#listPanel2").empty().append(html); }else{ $("#listPanel2").append(html); } if(res.list.length < pagesize){ mui('#result_wraper2').pullRefresh().disablePullupToRefresh(); }else{ page2 ++; mui('#result_wraper2').pullRefresh().enablePullupToRefresh(); } } d.close(); }else{ queryFailed(res); } }); } function bindEvents(){ $(".mui-control-item").on('tap', function(){ var $this = $(this); if($this.hasClass("mui-active")){ return false; } var index = $this.data("index"); if(index == 1){ getAccountBackData(true); }else{ getFeedbackData(true); } }); $(".mui-scroll-wrapper").on('tap', '.list-item', function(){ var $this = $(this), type = $this.data('type'), // 1-账号申诉,2-意见反馈 code = $this.data('code'); window.location.href = "feedback-detail.html?type="+type+"&fdCode="+code; }); template.helper('formatDate', function(time){ if(time){ return time.substr(0,16); } return ""; }); template.helper('getTypeValue', function(type, fdType){ if(fdType == 1){ switch(type){ case 1: return "手机号变更"; break; case 2: return "重置密码"; break; case 3: return "其他"; break; default: return ""; break; } }else{ switch(type){ case 1: return "优化建议"; break; case 2: return "提交bug"; break; case 3: return "新功能建议"; break; case 4: 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(); } }