app翻页

var myScroll;var black_flag=true;
function pullUpAction () {
	queryParam.page =  queryParam.page+1;
	doSearch(true);
	myScroll.refresh();	
}
function loaded() {
	//myScroll = new iScroll('wrapper');
		pullUpEl = document.getElementById('pullUp');	
		pullUpOffset = pullUpEl.offsetHeight;
		myScroll = new iScroll('wrapper', {
		useTransition: false,
		checkDOMChanges: true,
	//	topOffset: pullDownOffset,
		onRefresh: function () {
			if (pullUpEl.className.match('loading')) {
				pullUpEl.className = '';
				//pullUpEl.querySelector('.pullUpLabel').innerHTML = '加载更多';
			}
			//...
		},
		onScrollMove: function () {
		//alert(this.y);
			if (this.dirY < 0  ) {
				if($("#float_action").css("display")=="none")
				{	
					this.y=this.y-193;
					$("#float_action").show();
					$("#wrapper").css("top","193px");
				}
				else if(!black_flag)
				{
					$("#float_action").css("display")=="none";
					$("#wrapper").css("top",0);
					myScroll.refresh();
					black_flag=true;
				}
				
			} else if (this.dirY > 0) {
				//alert();
				if($("#float_action").css("display")!="none")
				{this.y=this.y+193;}
				$("#float_action").hide();
				$("#wrapper").css("top",0);
			} 
			 if (this.y < (this.maxScrollY - 5) && !pullUpEl.className.match('flip')) {
				pullUpEl.className = 'flip';
				//pullUpEl.querySelector('.pullUpLabel').innerHTML = '释放刷新';
				this.maxScrollY = this.maxScrollY;
			} else if (this.y > (this.maxScrollY + 5) && pullUpEl.className.match('flip')) {
				pullUpEl.className = '';
				//pullUpEl.querySelector('.pullUpLabel').innerHTML = '加载更多';
				this.maxScrollY = pullUpOffset;
			}
		},
		onScrollEnd: function () {
			if (pullUpEl.className.match('flip')) {
				pullUpEl.className = 'loading';
				//pullUpEl.querySelector('.pullUpLabel').innerHTML = '加载中';				
				pullUpAction();	// Execute custom function (ajax call?)
			}
			myScroll.refresh();
			//....
		}
	});
}




document.getElementById("scroller").addEventListener('touchmove', function (e) { e.preventDefault();  }, false);
document.getElementById("float_action").addEventListener('touchmove',function(e){  },false);
document.getElementById("search").addEventListener('touchmove',function(e){ e.preventDefault(); },false);
document.getElementById("nav_id").addEventListener('touchmove',function(e){ e.preventDefault(); },false);
document.addEventListener('DOMContentLoaded', function () { setTimeout(loaded, 200); }, false);












//-------------------- data area -----------------


// 此项通过与阿里 webview、 通讯获得
var cur_location = "116.4264,39.9166";


var pois = null;


var queryParam = new Param();
function Param() {
	this.key = '16a7b1a85ff4b1e7ac27ab53fc27c8d2';
	this.location = '116.481478,39.990459';
	this.keywords = null; // 商家关键字, 搜索框内容有变化的时候修改此项
	this.types = '05'; // 类型, 类型更改之后修改此项
	this.radius = 1000; // 距离更改的时候修改此项
	this.sortrule = 'weight'; // 排序 更改的时候修改此项
	this.offset = 10;
	this.page = 1; // 分页的时候更改此项 可以使用 page+1;
	this.extensions = 'all';
	this.city = null; // 区域,区域选址的时候修改此项
	this.filter='groupbuy:1|discount:1';


	this.getQueryString = function() {
		var str = '';
		for ( var para in this) {
			if (typeof this[para] != 'function') {
				if (this[para] != null) {
					str = str + "&" + para + "=" + this[para];
				}
			}
		}
		return str;
	};


}


// 列表模板
var delicacy_list_tpl = Handlebars.compile($("#delicacy-list-tpl").html());
// 区域模板
var delicacy_menu_area_tpl = Handlebars.compile($("#delicacy-menu-area-tpl").html());


 var count_num=0;
function doSearch(isApped) {
	if(isApped==undefined) queryParam.page=1;
	closeall();
	if(count_num==0)	
	{
		$(".am-loading").addClass("change_loading");
	}
	$("#loading_id").show();
	 var urlAroud = ctx+"/amap/api/place/around?" + queryParam.getQueryString();	
	 var urlKeyWords = ctx+ "/amap/api/place/text?" + queryParam.getQueryString();
	 var url ;
	 if(queryParam.radius!=null)
     {
		 url =  urlAroud ;
     }else{
    	 url =  urlKeyWords; 
     }
	 
	 $.get(url, function(data, statusTxt) {
		setTimeout(function(){$("#loading_id").hide();if(count_num>=1)
		{
			$(".am-loading").removeClass("change_loading");
		}},2000);	
		if (statusTxt == "success") {
			var list_html="";
			if (data.pois!=undefined && data.pois != null && data.pois.length > 0) {
				holdCurrentPois(data.pois);
				 list_html = delicacy_list_tpl(data);
				
			}
			else 
			{
				$("#loading_id").hide();
				$("#no_data").show();
				setTimeout(function(){$("#no_data").hide();},1000);
			}
			
			if (true == isApped) {
				$("#delicacy-list-container").append(list_html);


			} else {
				
				$("#delicacy-list-container").html(list_html);


			}
		}
		else 
		{
				$("#loading_id").hide();
				$("#data_error").show();
				setTimeout(function(){$("#data_error").hide();},1000);
		}
	});
	
	
	count_num++;


}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值