var page = 1, pageSize = 10; var d = dialog({contentType:'load', skin:'bk-popup'}); var scroller, $mainContent = $('#mainContent'), $noData = $('.div-no-info'); var userAgent = window.localStorage.getItem(agentName); var pagetype = 45; $(function(){ checkUserAgent(); scroller = new IScrollPullUpDown('wrapper',{ probeType:2, bounceTime: 250, bounceEasing: 'quadratic', mouseWheel:false, scrollbars:true, click:true, fadeScrollbars:true, interactiveScrollbars:false },pullDownAction,pullUpAction); //下拉刷新 function pullDownAction(theScrollerTemp) { d.show(); setTimeout(function () { page=1; queryInit(); }, 100) } //上拉加载数据 function pullUpAction(theScrollerTemp) { d.show(); setTimeout(function () { page++; queryMoreData(); }, 100) } template.helper('toStatus', function(v){ if(v==60){return 'waiting'} if(v==65 || v==61 || v==62 || v==69){return 'transport'} if(v==100){return 'finish'} }) function queryMoreData(){ var data = { page:page, pagesize:pageSize }; d.show(); sendPost("patient/prescription/dispensaryCode/list", data, "json", "get", function(res){ queryFailed(res)}, function(res){ if(res.status == 200){ d.close(); if(res.result.length >0){ var html = template('list_tmp',{data:res.result}); $('#j-card-list').append(html); scroller.myScroll.refresh(); }else{ dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'无更多数据'}).show(); } }else{ queryFailed(res) } }) } $('#j-card-list').on('click','li',function(){ var code=$(this).data('id'); window.location.href ="code-detail.html?prescriptionCode="+code; }) }) function queryInit(){ var data = { page:page, pagesize:pageSize }; d.show(); sendPost("patient/prescription/dispensaryCode/list", data, "json", "get", function(res){ queryFailed(res)}, function(res){ if(res.status == 200){ d.close(); if(res.result.length >0){ var html = template('list_tmp',{data:res.result}); $('#j-card-list').html(html); $mainContent.show(); }else{ $noData.show(); } scroller.myScroll.refresh(); }else{ queryFailed(res) } }) } //失败提示 function queryFailed(res){ d.close(); if (res && res.msg) { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show(); } else { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show(); } }