var page = 1, pagesize = 15, hasMore = true; mui.init(); mui.plusReady(function(){ getTemplateLabel(); getTemplateList(true); initScroll(); bindEvents(); }); function initScroll(){ //阻尼系数 var deceleration = mui.os.ios?0.003:0.0009; mui('.mui-scroll-wrapper').scroll({ bounce: false, indicators: true, //是否显示滚动条 deceleration:deceleration }); mui('.mui-scroll-wrapper').pullRefresh({ down: { callback: function() { setTimeout(function() { getTemplateList(true); mui('.mui-scroll-wrapper').pullRefresh().endPulldownToRefresh(); }, 1000); } }, up:{ contentrefresh: '正在加载...', callback: function(){ var self = this; setTimeout(function() { getTemplateList(false); mui('.mui-scroll-wrapper').pullRefresh().endPullupToRefresh(!hasMore); }, 1000); } } }); } function getTemplateLabel(){ plus.nativeUI.showWaiting(); var url = "/doctor/questionnaire/getTemplateLabel"; sendGet(url, {}, null, function(res){ if(res.status == 200){ if(res.data.length == 0){ $(".header-link").hide(); }else{ var html = template("label_tmp", {list: res.data}); $("#group_label_list").append(html); } }else{ $(".header-link").hide(); } plus.nativeUI.closeWaiting(); }, true); } function getTemplateList(isInit, label){ page = isInit ? 1: page; var url = "/doctor/questionnaire/getTemplateByLabel", labels = label ? label.join(",") : "", params = {labels: labels, pageNo: page, pageSize: pagesize}; plus.nativeUI.showWaiting(); sendGet(url, params, null, function(res){ if(res.status == 200){ page ++; if(isInit && res.data.length == 0){ $("#no_result_wrap").show(); $("#search_bar").hide(); $(".mui-scroll-wrapper").hide(); // $("#newTemplate").hide(); $(".header-link").hide(); }else{ $("#no_result_wrap").hide(); $("#search_bar").show(); $(".mui-scroll-wrapper").show(); $("#newTemplate").show(); if(res.data.length < pagesize){ hasMore = false; isInit && mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(!hasMore); }else{ hasMore = true; } var list = _.map(res.data, function(o){ o.jsonStr = JSON.stringify(o); return o; }); var html = template("list_tmp", {list: list}); if(isInit){ $(".mui-scroll").empty().append(html); }else{ $(".mui-scroll").append(html); } } }else{ mui.toast(res.msg); } plus.nativeUI.closeWaiting(); }, true); } function bindEvents(){ $(".header-link").on('tap', function(){ showGroupSel(); }); $(".sel-group").on("click",'.icon-checkbox', function(){ //发送请求 var $labels = $(".icon-checkbox:checked"), len = $labels.length, ids = []; for(i=0; i