var switchery = null; var date = new Date(); var year = date.getFullYear(); var begindate; var enddate; var page = 1; var pagesize = 10; var pagetype = 5; var patientCode = ""; var charType = 1; var scroller1 = null; var self = null; var type = null; var charts = []; var $duringList = $('#duringList'), $qushiView = $('#qushiView'), $liebiaoView = $('#liebiaoView'), $xtEdit = $('.xt-edit'), $btns = $('.btns'), $cancelBtn = $('.cancel-btn'), $okBtn = $('.ok-btn'), $popMain = $('.pop-main'), $xtAdd = $('.xt-add'), $popBtns = $('.pop-btns'), $popEditBtn = $('.pop-edit-btn'), $popDelBtn = $('.pop-del-btn'), $popCancelBtn = $('.pop-cancel-btn'), isTrue = false, page = 0, pagesize = 10, $xyList = $('.xy-list-con'), $xyTmp = $('#xyTmp'); mui.plusReady(function() { self = plus.webview.currentWebview(); patientCode = self.code; begindate = self.dateT; type = self.type; plus.nativeUI.showWaiting(); scroller1 = new IScrollPullUpDown('wrapper6', { probeType: 2, bounceTime: 250, bounceEasing: 'quadratic', mouseWheel: false, scrollbars: true, fadeScrollbars: true, interactiveScrollbars: false, click: true, }, null, pullUpAction); loadData(); }); var render = function(tmpl, data) { return tmpl.replace(/\{\{(\w+)\}\}/g, function(m, $1) { return data[$1]; }); }, //根据sd获取n天前的时间 getBeforeDate = function(sd, n) { var n = n; var d = new Date(sd.replace(/\-/g, "/")); var year = d.getFullYear(); var mon = d.getMonth() + 1; var day = d.getDate(); if(day <= n) { if(mon > 1) { mon = mon - 1; } else { year = year - 1; mon = 12; } } d.setDate(d.getDate() - n); year = d.getFullYear(); mon = d.getMonth() + 1; day = d.getDate(); s = year + "-" + (mon < 10 ? ('0' + mon) : mon) + "-" + (day < 10 ? ('0' + day) : day); return s; }; function changeTabCon() { var qsv = $qushiView.css('display'), lbv = $liebiaoView.css('display'); if(qsv === 'block') { lbv.hide(); } } function querySportList(page, pagesize, begindate, enddate, code) { //拼请求内容 var params = {}; params.page = page; params.pagesize = pagesize; params.start = begindate + " 00:00:00"; params.end = enddate + " 23:59:59"; params.patient = code; return new Promise(function(resolve, reject) { //发送ajax请求 sendPost("doctor/health_record/list_diet", params, function(res) { resolve(res) console.log(res); plus.nativeUI.closeWaiting(); console.log('2'); }, function(res) { console.log('3'); plus.nativeUI.closeWaiting(); console.log(res); if(res.status == 200) { resolve(res) } else { queryListFailed(res); } }); }) } //上拉加载数据 function pullUpAction(theScrollerTemp) { $(".pullUp").show(); setTimeout(function() { loadData(); }, 1000); } function loadData() { page++; Promise.all([ querySportList(page, pagesize, getBeforeDate(begindate, 1000), begindate, patientCode) ]) .then(function(res) { $(".pullUp").hide(); var data = res[0]; if (data.list.length > 0) { $xyList.append(template('xyTmp', { data: data.list })); $('#no_result_wrap').hide() $('.j-control').show() scroller1.myScroll.refresh(); } else { if(!isTrue) { $('#no_result_wrap').show() $('.j-control').hide() } else { mui.toast("暂无更多数据!"); } } isTrue = true; }) .catch(function(e) { console && console.error(e) }); }