首页 > 代码库 > 上拉刷新后台完整版

上拉刷新后台完整版

// 上拉刷新

mui.init({ pullRefresh: { container: ‘#pullrefresh‘, up: { contentrefresh: ‘正在加载...‘, callback: pullupRefresh } } });

var count = 0;

function pullupRefresh() { setTimeout(function() { var table = document.body.querySelector(‘.mui-table-view‘);

var cells = document.body.querySelectorAll(‘.mui-table-view-cell‘); var cat_id=sessionStorage.getItem(‘cat_id‘);

//console.log(count);

mui.ajax(‘http://127.0.1.......‘,{ data:{ cat_id:cat_id, page:cells.length },

dataType:‘json‘, type:‘post‘, timeout:7000,

success:function(data){ //console.log(data.the_page);

mui(‘#pullrefresh‘).pullRefresh().endPullupToRefresh((++count > data.the_page));

if(data.cat_name){ document.getElementById(‘cat_name‘).innerHTML=data.cat_name; }else{ document.getElementById(‘cat_name‘).innerHTML=‘所有新闻‘; }

var news_list = data.newslist; var htmls = ‘‘;

for (var i = 0; i < news_list.length; i++)

{ var li = document.createElement(‘li‘); li.className=‘mui-table-view-cell‘; li.innerHTML = “”

 

table.appendChild(li);

} },

error:function(){ mui.alert(‘网络异常.‘); }, }); }, 1500); } if (mui.os.plus) { mui.plusReady(function() { setTimeout(function() { mui(‘#pullrefresh‘).pullRefresh().pullupLoading(); }, 1000); }); }else{ mui.ready(function() { mui(‘#pullrefresh‘).pullRefresh().pullupLoading(); }); }

上拉刷新后台完整版