123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- var sortDate="";
- var pageSize = 10;
- $(function() {
- //加载本地数据
- // var temp = plus.storage.getItem("bloodpressure_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(4, 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);
- }
- // plus.nativeUI.closeWaiting();
- }
- /**
- * 显示查询结果
- * @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));
- sortDate = list[i].sortDate;
- }
- }
- 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) {
- if (dateStr.length > 5) {
- dateStr = dateStr.substr(5, 5);
- }
- var tb = document.querySelector("#item");
- var tr = document.createElement("tr");
- var html = '<td class="width-30">' + dateStr + '</td>';
- html += '<td class="width-70">' + value1 + '</td>';
- tr.innerHTML = html;
- tb.appendChild(tr);
- }
- //添加数据添加监听
- window.addEventListener("add-item", function(e) {
- clearHTML();
- //刷新列表
- queryList();
- //添加一行
- // addRow(e.detail.date, e.detail.val_high, e.detail.val_low);
- //存储到本地
- // plus.storage.setItem("bloodpressure_history", con);
- });
|