123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- var d = dialog({contentType:'load', skin:'bk-popup'});
- var sortDate = "";
- var pageSize = 5;
- $(function() {
- clearHTML();
- queryList(sortDate,pageSize);
- //点击加载更多
- $("#view_more").on("tap", function() {
- queryList(sortDate,pageSize);
- });
- });
- function queryList(sortDate,pagesize) {
- //拼请求内容
- d.show();
- var params = {};
- params.sortDate = sortDate;
- params.pagesize = pagesize;
- //发送ajax请求
- sendPost("patient/health_record/list_sports", params, "json", "post", queryListFailed, 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 {
- queryListFailed(res);
- }
- }
- function queryListFailed(res) {
- d.close().remove();
- if (res && res.msg) {
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
- } else {
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:'加载失败'}).show();
- }
- }
- /**
- * 显示查询结果
- * @param {Object} list
- */
- function showList(list) {
- for (var i = 0; i < list.length; i++) {
- var data = list[i];
- if (!data) {
- continue;
- }
- addRow(data.record_date, data.sports_time,data.sports_type,data.sports);
- sortDate = list[i].sortDate;
- }
- }
- /**
- * 清空tbody
- */
- function clearHTML() {
- $("#sport_list").html("");
- }
- /**
- * tbody添加一行tr
- * @param {Object} dateStr
- * @param {Object} value1
- * @param {Object} value2
- */
- function addRow(dateStr, sports_time,sports_type,sports) {
- var tb = document.querySelector("#sport_list");
- var tr = document.createElement("tr");
- var html ="";
- html+= "<td class='width-20 '>"+dateStr+"</td>";
- html+= "<td class='width-20 '>"+sports_time+"</td>";
- html+= "<td class='width-30 '>"+sports_type+"</td>";
- html+= "<td class='width-30 '>"+sports+"</td>";
- tr.innerHTML = html;
- tb.appendChild(tr);
- }
- //添加数据添加监听
- window.addEventListener("add-item", function(e) {
- clearHTML();
- queryList();
- });
|