health-record.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /**
  2. * 健康记录添加失败处理方法
  3. */
  4. function addHealthRecordFailed(res) {
  5. if (res && res.msg) {
  6. plus.nativeUI.toast(res.msg);
  7. } else {
  8. plus.nativeUI.toast("保存失败");
  9. }
  10. }
  11. /**
  12. * 运动添加成功处理方法
  13. */
  14. function addSportSuccess(res) {
  15. if (res.status == 200) {
  16. //添加成功
  17. var val=document.getElementById("yd_val").value;
  18. var wv_history = plus.webview.getWebviewById("health-record-sport");
  19. //健康指标页面添加新数据
  20. mui.fire(wv_history, "add-item", {});
  21. //提示添加成功
  22. plus.nativeUI.toast(res.msg);
  23. } else {
  24. //非200则为失败
  25. addHealthRecordFailed(res);
  26. }
  27. }
  28. /**
  29. * 用药添加成功处理方法
  30. */
  31. function addDrugSuccess(res) {
  32. if (res.status == 200) {
  33. //添加成功
  34. // var val=document.getElementById("yd_val").value;
  35. var wv_history = plus.webview.getWebviewById("health-record-drug");
  36. //健康指标页面添加新数据
  37. mui.fire(wv_history, "add-item", {});
  38. //提示添加成功
  39. plus.nativeUI.toast(res.msg);
  40. } else {
  41. //非200则为失败
  42. addHealthRecordFailed(res);
  43. }
  44. }
  45. /**
  46. * 饮食添加成功处理方法
  47. */
  48. function addDietSuccess(res) {
  49. if (res.status == 200) {
  50. //添加成功
  51. // var val=document.getElementById("yd_val").value;
  52. var wv_history = plus.webview.getWebviewById("health-record-diet");
  53. //健康指标页面添加新数据
  54. mui.fire(wv_history, "add-item", {});
  55. //提示添加成功
  56. plus.nativeUI.toast(res.msg);
  57. } else {
  58. //非200则为失败
  59. addHealthRecordFailed(res);
  60. }
  61. }
  62. /**
  63. * 体重添加成功处理方法
  64. */
  65. function addWeightSuccess(res) {
  66. if (res.status == 200) {
  67. //添加成功
  68. var record_date = document.getElementById("date").value;
  69. var val = document.getElementById("val").value;
  70. var wv_index = plus.webview.getWebviewById("health-index");
  71. var wv_history = plus.webview.getWebviewById("health-index-weight-history-sub");
  72. var wv_chart = plus.webview.getWebviewById("health-index-weight-chart");
  73. // var option={date:date,type:type,value:val};
  74. mui.fire(wv_index, "input-index", {
  75. type: "tz",
  76. value: val
  77. });
  78. mui.fire(wv_history, "add-item", {
  79. date: record_date,
  80. value: val
  81. });
  82. mui.fire(wv_chart, "refleshList", {});
  83. //提示添加成功
  84. plus.nativeUI.toast(res.msg);
  85. //关闭当前页面
  86. var self = plus.webview.currentWebview();
  87. self.close("none");
  88. } else {
  89. //非200则为失败
  90. addHealthIndexFailed(res);
  91. }
  92. }
  93. /////////////////////////////////////////////////////////////////////////////////健康指标历史记录查询///////////////////////////////////////////////////////////////////////////
  94. /**
  95. * 健康指标历史记录查询
  96. * @param {Object} type 健康指标类型(1血糖,2血压,3体重,4腰围)
  97. * @param {Object} page 当前分页
  98. * @param {Object} pagesize 分页大小
  99. */
  100. /**
  101. * 健康指标历史记录查询失败处理方法
  102. */
  103. function queryListFailed(res) {
  104. if (res && res.msg) {
  105. plus.nativeUI.toast(res.msg);
  106. } else {
  107. plus.nativeUI.toast("数据加载失败");
  108. }
  109. plus.nativeUI.closeWaiting();
  110. }