xuetang.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. function queryList1(page,pageSize) {
  2. //显示进度条
  3. // plus.nativeUI.showWaiting();
  4. //发送请求
  5. queryListByType(1,page, pageSize, queryListSuccesss,begindate,enddate);
  6. }
  7. /**
  8. * 血糖查询列表
  9. * 健康指标图表查询成功处理方法
  10. */
  11. function queryListSuccesss(res) {
  12. if (res.status == 200) {
  13. d.close();
  14. if (res.list.length > 0) {
  15. //成功
  16. showListXue(res.list);
  17. if(res.list.length<10){
  18. $("#view_more1").hide();
  19. }else{
  20. $("#view_more1").show();
  21. }
  22. }else{
  23. //无更多数据
  24. $("#view_more1").hide();
  25. }
  26. } else {
  27. //非200则为失败
  28. queryListFailed(res);
  29. }
  30. }
  31. /**
  32. * 显示查询结果
  33. * @param {Object} list
  34. */
  35. function showListXue(list) {
  36. page = page+1;
  37. for (var i = 0; i < list.length; i++) {
  38. var data = list[i];
  39. if (!data) {
  40. continue;
  41. }
  42. 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));
  43. }
  44. //表格宽度调整
  45. //修改活动表格子格子的宽度
  46. $('.date').css('width','69px');
  47. $('.bb').css('width','69px');
  48. $('.ba').css('width','43px');
  49. $('.lb').css('width','42px');
  50. $('.la').css('width','43px');
  51. $('.db').css('width','44px');
  52. $('.da').css('width','43px');
  53. $('.sb').css('width','70px');
  54. setTimeout(function () {
  55. scroller1.myScroll.refresh();
  56. }, 1000);
  57. }
  58. /**
  59. * 血糖
  60. * tbody添加一行tr
  61. * @param {Object} dateStr
  62. * @param {Object} value1
  63. * @param {Object} value2
  64. */
  65. function addRow(dateStr, value1, value2, value3, value4, value5, value6, value7) {
  66. if(dateStr.length > 5){
  67. dateStr = dateStr.substr(5, 5);
  68. }
  69. if(dateStr){
  70. dateStr = dateStr.replace("-",".");
  71. }
  72. var tb = document.querySelector("#item");
  73. var tr = document.createElement("tr");
  74. var html = '<td class="date">'+dateStr+'</td>';
  75. html += getTD(value1, 6.1, 3.9, "bb");
  76. html += getTD(value2, 7.8, 4.4, "ba");
  77. html += getTD(value3, 6.1, 3.9, "lb");
  78. html += getTD(value4, 7.8, 4.4, "la");
  79. html += getTD(value5, 6.1, 3.9, "db");
  80. html += getTD(value6, 7.8, 4.4, "da");
  81. html += getTD(value7, 6.1, 3.9, "sb");
  82. tr.innerHTML = html;
  83. $("#item").append(tr);
  84. }
  85. function getTD(value, max, min, styleName){
  86. if(value == 0|| isNaN(value)){
  87. return '<td class="'+styleName+'"></td>';
  88. }
  89. if(value > max){
  90. return '<td class="'+styleName+' c-f00">'+value+'</td>';
  91. }else if(value < min){
  92. return '<td class="'+styleName+' c-007cd9">'+value+'</td>';
  93. }else{
  94. return '<td class="'+styleName+'">'+value+'</td>';
  95. }
  96. }