(function($) {
//阻尼系数
var deceleration = mui.os.ios?0.003:0.0009;
$('.mui-scroll-wrapper').scroll({
bounce: false,
indicators: false, //是否显示滚动条
deceleration:deceleration
});
$.ready(function() {
//循环初始化所有上拉加载。
$.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function(index, pullRefreshEl) {
//console.log(pullRefreshEl);
$(pullRefreshEl).pullToRefresh({
up: {
contentrefresh : "正在加载...",//可选,正在加载状态时,上拉加载控件上显示的标题内容
contentnomore:'没有更多数据了',//可选,请求完毕若没有更多数据时显示的提醒内容;
callback: function() {
var self = this;
var divType = pullRefreshEl.getAttribute('id');
setTimeout(function() {
var str = '';
var fragment = document.createDocumentFragment();
var li;
if(divType == "company_list"){
var keyword = document.getElementById('kw-c').getAttribute('title');
var linum = mui('.kw-c li').length;
}else{
var keyword = document.getElementById('kw-p').getAttribute('title');
var linum = mui('.kw-p li').length;
}
mui.ajax({
url:urlCell,
type:'post',
data:{type:"search",kw:keyword,size:'8',offset:linum,cityNow:cityNow},
dataType:'json',
success:function(result){
if(result['company'] && divType == "company_list"){
mui.each(result['company'],function(index,item){
li = document.createElement('li');
li.className = 'mui-table-view-cell mui-media';
str = "<a href='javascript:;' id='"+item['userid']+"' title='cinfo'>"+
"<img class='mui-media-object mui-pull-left' src='";
if(item['thumb']){
str += item['thumb'];
}else{
str += "../images/default_photo.png";
}
str +="'>";
str += "<div class='mui-media-body tse-mb'>"+
item['company']+
"<p class='mui-ellipsis tse-mg-tb'>"+item['business']+"</p>"+
"<p class='mui-ellipsis'>"+item['sname']+"/"+item['cname']+"</p>";
if(item['validated']==1){
str += "<img src='../images/badge_official.png' class='mui-media-objec tse-mb-img'/>";
}
str += "</div></a>";
li.innerHTML = str;
fragment.appendChild(li);
});
document.querySelector('#kw-c').appendChild(fragment);
self.endPullUpToRefresh();
}else if(result['product'] && divType == "product_list"){
mui.each(result['product'],function(index,item){
li = document.createElement('li');
li.className = 'mui-table-view-cell mui-media';
str = "<a href='javascript:;' id='"+item['itemid']+"' title='pinfo'>"+
"<img class='mui-media-object mui-pull-left' src='";
if(item['thumb']){
str += item['thumb'];
}else{
str += "../images/default_photo.png";
}
str +="'>";
str += "<div class='mui-media-body'>"+
item['title']+'-'+item['itemid']+
"<p class='mui-ellipsis'>价格:<span class='tse-font-red'>"+item['price']+"</span>"+
"销量:"+item['sales']+"</p>"+
"</div></a>";
li.innerHTML = str;
fragment.appendChild(li);
});
document.querySelector('#kw-p').appendChild(fragment);
self.endPullUpToRefresh();
}else{
self.endPullUpToRefresh(true);
}
}
});
}, 1000);
}
}
});
});
});
})(mui);
3 个回复
TseWayne (作者)
求指导!
DCloud_UNI_FXY
每次搜索自己将页面滚动到顶部,并重置一下下拉刷新,上拉加载。
TseWayne (作者)
怎么滚到顶部?并重置上拉加载?
ios:mui('#pullrefresh').pullRefresh().scrollTo(0,0);
mui('#pullup-container').pullRefresh().refresh(true);
2016-03-04 08:33
TseWayne (作者)