var page = 1, pagesize = 15; var $notext = $('#wushuju'); var $scroll = $('.mui-scroll-wrapper'); var $list = $('#show_content'); mui.plusReady(function(){ backParent() queryListData(); bindEvents(); }) function backParent() { var old_back = mui.back; mui.back = function() { var self = plus.webview.currentWebview(); if(self.opener && self.opener()) { mui.fire(self.opener(), "refresh"); } old_back(); } } function queryListData(fun,text){ var params ={ page:page, pagesize:pagesize } sendGet("doctor/pcCustomer/getCallServiceMes",params, function(){ plus.nativeUI.closeWaiting(); fun&&fun.call(this,false) mui.toast("请求失败"); }, function(res){ plus.nativeUI.closeWaiting(); if(res.status == 200){ var html = template('list_tmp',{list:res.data}) if(page == 1 && res.data.length==0){ $notext.show(); $scroll.hide(); }else{ $notext.hide(); $scroll.show(); if(text == 'down'){ $list.empty(); fun&&fun.call(this,false) }else{ if(res.data.length < pagesize){ fun&&fun.call(this,true) }else{ fun&&fun.call(this,false) } } $list.append(html); } }else{ fun&&fun.call(this,false) mui.toast("获取数据失败"); } }) } mui.init({ pullRefresh : { container:'.mui-scroll-wrapper', down : { height:50, auto: false, contentdown : "下拉可以刷新", contentover : "释放立即刷新", contentrefresh : "正在刷新...", callback: function() { var self = this; page = 1; queryListData(function(value){ setTimeout(function(){ self.endPulldownToRefresh(false); mui('.mui-scroll-wrapper').pullRefresh().enablePullupToRefresh(); },500) },'down') } }, up : { height:50, contentrefresh : "正在加载...", contentnomore:'没有更多数据了', callback: function() { var self = this; page++; queryListData(function(value){ setTimeout(function(){ self.endPullupToRefresh(value); },500) },'up') } } } }) function bindEvents(){ $(".mui-scroll").on('tap', '.list-item', function(){ var $this = $(this), xtCode = $this.attr("data-code"); openWebview("xietongfuwu-detail.html", { code: xtCode }) }) } //整体刷新 function reloadPageData(){ plus.nativeUI.showWaiting(); page = 1; $list.empty(); queryListData(); } window.addEventListener("refreshXTmsg", function(){ reloadPageData() })