1 function fnGetWareList(loadMore_) { 2 if (loadMore_) { 3 skip += LIMIT; 4 } else { 5 skip = 0; 6 } 7 var params = { 8 fields: {}, 9 where: { 10 supportAreaId: currentCity.id, 11 wareTypeId: wareTypeList[api.pageParam.wareTypeIndex].id 12 }, 13 skip: skip, 14 limit: LIMIT 15 } 16 params = $api.jsonToStr(params); 17 api.ajax({ 18 url: 'http://d.apicloud.com/mcm/api/ware?filter=' + params, 19 method: 'get', 20 headers: { 21 "X-APICloud-AppId": "A6914327011091", 22 "X-APICloud-AppKey": "8ac17d22e49cb7982d82796097cec52a6c7cd01d.1475375422841" 23 } 24 }, function(ret, err) { 25 if (ret) { 26 //console.log($api.jsonToStr(ret)); 27 api.refreshHeaderLoadDone(); 28 fnUpdateWareList(ret, loadMore_); 29 } else { 30 //alert(JSON.stringify(err)); 31 } 32 }); 33 }
1 function fnUpdateWareList(data_, loadMore_) { 2 var list = $api.byId('list'); 3 // 1. 编译模板函数 4 var tempFn = doT.template($api.byId('template').innerHTML); 5 // 2. 多次使用模板函数 6 var resultText = tempFn(data_); 7 if (loadMore_) { 8 $api.append(list, resultText); 9 } else { 10 $api.html(list, resultText); 11 }//parseTapmode 12 api.parseTapmode(); 13 if (loadMore_) { 14 if (data_.length < LIMIT) { 15 var pushStatus = $api.byId('pushStatus'); 16 pushStatus.innerHTML = "没有啦!"; 17 } 18 } 19 }
1 function initEventListenter() { 2 api.addEventListener({ 3 name: 'scrolltobottom', 4 extra: { 5 threshold: 300 6 } 7 }, function(ret, err) { 8 fnGetWareList(true); 9 }); 10 11 }