123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- var sortDate="";
- var pageSize = 10;
- $(function() {
- //加载本地数据
- // var temp = plus.storage.getItem("bloodsugar_history");
- // if (temp) {
- // document.getElementById("item").innerHTML = temp;
- // }
- clearHTML();
- queryList(sortDate,pageSize);
- //点击加载更多
- $("#view_more").on("tap", function() {
- queryList(sortDate,pageSize);
- console.log("加载更多");
- });
- });
- function queryList(sortDate,pageSize) {
- //显示进度条
- // plus.nativeUI.showWaiting();
- //发送请求
- queryListByType(1,sortDate, pageSize, queryListSuccesss);
- }
- /**
- * 健康指标图表查询成功处理方法
- */
- function queryListSuccesss(res) {
- if (res.status == 200) {
- d.close();
- if (res.list.length > 0) {
- //成功
- showList(res.list);
- }else{
- //无更多数据
- document.querySelector("#view_more").innerText = "已无更多数据";
-
- }
- } else {
- //非200则为失败
- queryListFailed(res);
- }
- }
- /**
- * 显示查询结果
- * @param {Object} list
- */
- function showList(list) {
- // clearHTML();
- for (var i = 0; i < list.length; i++) {
- var data = list[i];
- if (!data) {
- continue;
- }
- addRow(data.date.substr(5, 5), toIntValue(data.value1), toIntValue(data.value2), toIntValue(data.value3), toIntValue(data.value4), toIntValue(data.value5), toIntValue(data.value6), toIntValue(data.value7));
- sortDate = list[i].sortDate;
- }
- //表格宽度调整
- //修改活动表格子格子的宽度
- $('.date').css('width','69px');
- $('.bb').css('width','69px');
- $('.ba').css('width','43px');
- $('.lb').css('width','42px');
- $('.la').css('width','43px');
- $('.db').css('width','44px');
- $('.da').css('width','43px');
- $('.sb').css('width','70px');
- }
- function toIntValue(value){
- if(parseInt(value) == value){
- return parseInt(value);
- }else{
- return Math.round(value*Math.pow(10, 1))/Math.pow(10, 1);
- }
- }
- /**
- * 清空tbody
- */
- function clearHTML() {
- $("#item").html("");
- }
- /**
- * tbody添加一行tr
- * @param {Object} dateStr
- * @param {Object} value1
- * @param {Object} value2
- */
- function addRow(dateStr, value1, value2, value3, value4, value5, value6, value7) {
- if(dateStr.length > 5){
- dateStr = dateStr.substr(5, 5);
- }
- var tb = document.querySelector("#item");
- var tr = document.createElement("tr");
- var html = '<td class="date">'+dateStr+'</td>';
- html += getTD(value1, 6.1, 3.9, "bb");
- html += getTD(value2, 7.8, 4.4, "ba");
- html += getTD(value3, 6.1, 3.9, "lb");
- html += getTD(value4, 7.8, 4.4, "la");
- html += getTD(value5, 6.1, 3.9, "db");
- html += getTD(value6, 7.8, 4.4, "da");
- html += getTD(value7, 6.1, 3.9, "sb");
-
- tr.innerHTML = html;
- tb.appendChild(tr);
- }
- function getTD(value, max, min, styleName){
- if(value == 0|| isNaN(value)){
- return '<td class="'+styleName+'"></td>';
- }
- if(value > max){
- return '<td class="'+styleName+' c-f00">'+value+'</td>';
- }else if(value < min){
- return '<td class="'+styleName+' c-007cd9">'+value+'</td>';
- }else{
- return '<td class="'+styleName+'">'+value+'</td>';
- }
- }
- //添加数据添加监听
- window.addEventListener("add-item", function(e) {
- // mui('#pullrefresh').pullRefresh().refresh(true);
- //openWebview("health-index-bloodsugar-history.html");
- // delete
-
- // $("#pullrefresh").remove();
- // var _html="";
- //
- // _html+="<div id='pullrefresh' class='mui-content mui-scroll-wrapper'>"
- // _html+= "<div id='pullScroll' class='mui-scroll'>"
- // _html+= "<table class='c-table pos c-border-tb GLU-tab' id='table1'>"
- // _html+= "<tbody class='bg-fff c-f14' id='item'>"
- // _html+= "</tbody>"
- // _html+= "</table>"
- // _html+= "</div>"
- // _html+="</div>"
- //
- // $('#sub_body').html(_html);
- //
- // console.log(_html);
- // console.log("监听到了");
- //
- // V_refresh();
- // clearHTML();
- //刷新列表
- // queryList();
- //
- // mui.init({
- // pullRefresh: {
- // container: '#pullrefresh',
- // up: {
- // contentrefresh: '正在加载...',
- // callback: pullupRefresh,
- // // auto:true
- // }
- // }
- // });
-
-
- //添加一行
- // addRow(e.detail.date, e.detail.val_high, e.detail.val_low);
- //存储到本地
- // plus.storage.setItem("bloodpressure_history", con);
- });
- //
- //function V_refresh(){
- //
- //
- //
- //}
|