移動先js改ページ

2756 ワード

移動先js改ページ:
1、ページスクロールの設定
var flag = true;
init : function () {
	//         
	window.onscroll = spotList.scrollEvent;
},
/**
 *     
 * @returns
 */
scrollEvent : function () {
	var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
	var clientHeight = document.documentElement.clientHeight;
	var scrollHeight = document.documentElement.scrollHeight;
	if ((scrollTop + clientHeight) > (scrollHeight - 300)) {
		if (flag && spotList.defaultOption.pages < spotList.defaultOption.totalPage) {
			spotList.defaultOption.pages ++;
			spotList.getSpotList();
		}
	}
},
2、取得リストからページ総数を算出する
/*
 *     
 */
defaultOption : {
	pages: 1,		//   
	count: 10,		//     
	totalPage: '',	//    
	county: '',	//     
},
/*
 *       
 */
getSpotList : function (pages) {
	flag = false;
	var loading = layer.open({type: 2,content: '   '});
	var map = {
			pages : spotList.defaultOption.pages,
			count : spotList.defaultOption.count,	
			themeId : '',
			county : spotList.defaultOption.county,
	};
	commonAjax.ajaxSubmit("../masView/getViewList.do","POST",map,function(result){
		layer.close(loading);
		if(result.resCode == '0'){
			var data = result.resData;
			var sum = data.count;
			if(sum > 0) {
				var list = data.list;
				var html = '';
				for (var i = 0; i < list.length; i++) {
					html += formatHtml.replace('{0}',list[i].poiId)
									  .replace('{1}',list[i].thumbNail)
									  .replace('{2}',list[i].poiName)
									  .replace('{3}',list[i].area)
									  .replace('{4}',list[i].city)
									  .replace('{5}',list[i].county)
									  .replace('{6}',list[i].poiAddress);
				}
				$('#f_list').append(html);
				
				//       
				$("img.lazy").lazyload({
					placeholder : "../../img/default.png",
					threshold : 20,
					failurelimit : 10,
					effect : "show"
				});
				flag=true;
				/**        */
				var count=spotList.defaultOption.count;
				if (sum % count == 0) {
					spotList.defaultOption.totalPage = sum / count;
				} else {
					spotList.defaultOption.totalPage = parseInt(sum / count) + 1;
				}
				$('.no-result').hide();
				$('html,body').css('background-color','#E4E4E4');
			} else {
				//       
				$('.no-result').show();
				$('html,body').css('background-color','#fff');
			}
		} else {
			errMsg.showError(result.errCode);
		}
	});
},