mui.init({ pullRefresh: { container: '#pullrefresh', up: { height: 50, contentrefresh: '正在加载...', callback: pullupRefresh }, down: { auto:true, callback: pulldownRefresh } } }); var Num=1; function pulldownRefresh() { setTimeout(function() { demandOnePase(); mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); }, 1500); } function pullupRefresh() { setTimeout(function() { Num = ++Num; myDemandList(10,Num); mui('#pullrefresh').pullRefresh().endPullupToRefresh(); }, 1500); } mui.plusReady(function() { mui("#myneedList").on("tap", "li", function() { var oDemandId = this.getAttribute("data-id"); plus.nativeUI.showWaiting(); plus.webview.create("../html/needShow.html", 'needShow.html', {}, { demanid: oDemandId }); }) }) function myDemandList(pageSize, pageNo) { mui.plusReady(function() { mui.ajax(baseUrl + '/ajax/demand/pq', { dataType: 'json', //数据格式类型 type: 'GET', //http请求类型 timeout: 10000, //超时设置 data: { "uid": plus.storage.getItem('userid'), "pageNo": pageNo, "pageSize": pageSize }, success: function(data) { if(data.success) { var ws=plus.webview.getWebviewById("../html/needList.html"); plus.nativeUI.closeWaiting(); ws.show("slide-in-right", 150); if(pageNo!=data.data.pageNo) { data.data.data=[]; } var $info = data.data.data; console.log(JSON.stringify(data)) if($info.length > 0){ for(var i = 0; i < $info.length; i++) { var liStr=document.createElement("li"); liStr.className="mui-table-view-cell flexCenter"; liStr.setAttribute( "data-id",$info[i].id); document.getElementById("myneedList").appendChild(liStr); demandHtml($info[i],liStr); } } if(pageNo < Math.ceil(data.data.total / data.data.pageSize)) { mui('#pullrefresh').pullRefresh().endPullupToRefresh(false); /*能上拉*/ } else { mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); /*不能上拉*/ } } }, error: function() { plus.nativeUI.toast("服务器链接超时", toastStyle); mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); return; } }); }) } function demandOnePase() { mui.plusReady(function() { Num=1; mui.ajax(baseUrl + '/ajax/demand/pq', { dataType: 'json', //数据格式类型 type: 'GET', //http请求类型 timeout: 10000, //超时设置 data: { "uid": plus.storage.getItem('userid'), "pageNo": 1, "pageSize": 10 }, success: function(data) { if(data.success) { mui('#pullrefresh').pullRefresh().refresh(true); var ws=plus.webview.getWebviewById("../html/needList.html"); plus.nativeUI.closeWaiting(); ws.show("slide-in-right", 150); document.getElementById("myneedList").innerHTML=""; var $info = data.data.data; console.log(JSON.stringify(data)) if($info.length > 0){ for(var i = 0; i < $info.length; i++) { var liStr=document.createElement("li"); liStr.className="mui-table-view-cell flexCenter"; liStr.setAttribute( "data-id",$info[i].id); document.getElementById("myneedList").appendChild(liStr); demandHtml($info[i],liStr); } } if(1 < Math.ceil(data.data.total / data.data.pageSize)) { mui('#pullrefresh').pullRefresh().endPullupToRefresh(false); /*能上拉*/ } else { mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); /*不能上拉*/ } } }, error: function() { plus.nativeUI.toast("服务器链接超时", toastStyle); return; } }); }) } function demandHtml($data,liStr) { var statusU=""; var dateGap = delayDay($data.invalidDay); if($data.state==1 && dateGap=="1"){ statusU='即将于 '+TimeTr($data.invalidDay)+' 过期' } if($data.state==0){ statusU='已于 '+TimeTr($data.invalidDay)+' 过期' }else if($data.state==2){ statusU='已于 '+TimeTr($data.modifyTime)+' 完成' }else if($data.state==3){ statusU='已于 '+TimeTr($data.modifyTime)+' 关闭' } var strCon=''; strCon+='
'+ $data.title +'
' strCon+='