var page = 1, pageSize = 10, dateVal = '', statusVal = '', typeVal = ''; var scroller; mui.init(); mui.plusReady(function(){ var self = plus.webview.currentWebview(); getData(true); bindEvents(); initFilterPage(self); initScroller(); }) function getData(isInit){ if(isInit){ page = 1; } var url = "doctor/device/getDevicesList", params = { noGaugeDay: dateVal,//未测量天数(1今日为测量 2七天未测量 3本月未测量 4超过一个月未测量) isBinding: statusVal, //是否绑定(1绑定 2解绑) categoryCode: typeVal, //设备类型(1血糖仪 2血压计) isSend: '', //今日是否已发送提醒消息(1已发送) page: page, pageSize: pageSize }; plus.nativeUI.showWaiting(); sendGet(url, params, null,function(res){ if(res.status == 200){ $("#count").text("("+res.data.tatalCount+")"); var list = res.data.data; if(list.length == 0){ if(isInit){ $("#result_wrapper").hide(); $("#no_result_wrap").show(); }else{ scroller.endPullupToRefresh(true); } }else{ $("#result_wrapper").show(); $("#no_result_wrap").hide(); var html = template("li-tmp", {list: list}); if(isInit){ $("#result_wrapper").empty().append(html); }else{ $("#result_wrapper").append(html); } if(list.length < pageSize){ scroller.endPullupToRefresh(true); }else{ page ++; if(isInit){ scroller.refresh(true); }else{ scroller.endPullupToRefresh(false); } } } }else{ mui.toast(res.msg); } plus.nativeUI.closeWaiting(); }, true); } function bindEvents(){ $(".header-link").on('click', function(){ openWebview("../../wdsb/html/scan2.html"); }); //提醒测量 $("#remindBtn").on('click', function(){ openWebview("choose-patient.html", { dateVal: dateVal, statusVal: statusVal, typeVal: typeVal, dateName: $(".filter-label:eq(0)").text(), statusName: $(".filter-label:eq(1)").text(), typeName: $(".filter-label:eq(2)").text() }) }); //左滑筛选区域的数据 $('#filterBtn').on("tap", function(){ var self = plus.webview.currentWebview(); mui.fire(self, "showShaiXuan"); }); //点击患者查看患者设备列表 $("#result_wrapper").on('tap', "li", function(){ var $this = $(this), jsonObj = $this.data("json"); openWebview("device-physical-records.html", { patiCode: jsonObj.patient, deviceSn: jsonObj.device_sn, type: jsonObj.category_code, deviceName: jsonObj.device_name }) }); window.addEventListener("setFilterData", function(arg){ var info = arg.detail; dateVal = info.date; statusVal = info.status; typeVal = info.type; scroller.scrollTo(0, 0, 500); getData(true); $(".filter-label:eq(0)").text(info.dateName); $(".filter-label:eq(1)").text(info.statusName); $(".filter-label:eq(2)").text(info.typeName); }) } function initFilterPage(main){ var shaixuan = plus.webview.getWebviewById('filter.html'); if(!shaixuan){ shaixuan = mui.createWindow({ id: 'filter.html', url: 'filter.html', styles: { top: 0, bottom: 0, left: '20%', width: '80%', scorllIndicator: "none" }, show:{ aniShow: "slide-in-right", duration: "400" }, extras:{ dateVal : dateVal, statusVal : statusVal, typeVal : typeVal } }); } window.addEventListener("hideShaiXuan",function(){ main.setStyle({mask:"none"}); shaixuan.hide(); }, false); window.addEventListener("showShaiXuan", function() { mui.fire(shaixuan, "setTagActive", { dateVal : dateVal, statusVal : statusVal, typeVal : typeVal }); shaixuan.show(); main.setStyle({mask:"rgba(0,0,0,0.5)"}); main.addEventListener("maskClick",function(){ main.setStyle({mask:"none"}); shaixuan.hide(); }, false); }); } function initScroller(){ //阻尼系数 var deceleration = mui.os.ios?0.003:0.0009; mui('.mui-scroll-wrapper').scroll({ bounce: false, indicators: true, //是否显示滚动条 deceleration:deceleration }); scroller = mui(".mui-scroll-wrapper").pullRefresh({ down:{ callback: function(){ getData(true); this.endPulldownToRefresh(); } }, up: { callback: function(){ getData(false); // this.endPullupToRefresh(); } } }) }