health-index.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. function getNowDate() {
  2. var date = new Date();
  3. var year = date.getFullYear();
  4. var month = date.getMonth() + 1;
  5. var day = date.getDate();
  6. var hour = date.getHours();
  7. var minute = date.getMinutes();
  8. var second = date.getSeconds();
  9. return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
  10. }
  11. /**
  12. * 获取多少天前的日期
  13. */
  14. function getDateBefore(days) {
  15. var now = new Date();
  16. var date = new Date(now.getTime() - days * 24 * 3600 * 1000);
  17. var year = date.getFullYear();
  18. var month = date.getMonth() + 1;
  19. var day = date.getDate();
  20. var hour = date.getHours();
  21. var minute = date.getMinutes();
  22. var second = date.getSeconds();
  23. return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
  24. }
  25. /**
  26. * 添加健康指标到服务器
  27. * intervene 干预标志
  28. * time 记录时间
  29. * value1 血糖/收缩压/体重/腰围
  30. * value2 舒张压
  31. * point 血糖测量点标识
  32. * type 健康指标类型(1血糖,2血压,3体重,4腰围)
  33. */
  34. function addHealthIndex(intervene, operTime, value1, value2, value3, value4, value5, value6, value7, type, successFunction) {
  35. //拼请求内容
  36. var params = {};
  37. params.intervene = intervene;
  38. params.time = operTime;
  39. params.value1 = value1;
  40. params.value2 = value2;
  41. params.value3 = value3;
  42. params.value4 = value4;
  43. params.value5 = value5;
  44. params.value6 = value6;
  45. params.value7 = value7;
  46. params.type = type;
  47. //发送ajax请求
  48. sendPost("patient/health_index/add",params,addHealthIndexFailed, successFunction);
  49. }
  50. /**
  51. * 健康指标添加失败处理方法
  52. */
  53. function addHealthIndexFailed(res) {
  54. if (res && res.msg) {
  55. plus.nativeUI.toast(res.msg);
  56. } else {
  57. plus.nativeUI.toast("保存失败");
  58. }
  59. }
  60. /**
  61. * 血压添加成功处理方法
  62. */
  63. function addBloodPressureSuccess(res) {
  64. if (res.status == 200) {
  65. //添加成功
  66. var record_date = document.getElementById("date").value;
  67. var val_h = document.getElementById("val_h").value;
  68. var val_l = document.getElementById("val_l").value;
  69. var wv_index = plus.webview.getWebviewById("health-index");
  70. var wv_history = plus.webview.getWebviewById("health-index-bloodpressure-history");
  71. var wv_chart = plus.webview.getWebviewById("health-index-bloodpressure-chart");
  72. //更新健康指标首页显示数据
  73. mui.fire(wv_index, "input-index", {
  74. type: "xy",
  75. value: "收缩压:" + val_h + "<br/>舒张压" + val_l
  76. });
  77. //健康指标页面添加新数据
  78. mui.fire(wv_history, "add-item", {
  79. date: record_date,
  80. val_high: val_h,
  81. val_low: val_l
  82. });
  83. mui.fire(wv_chart, "refleshList", {});
  84. //提示添加成功
  85. plus.nativeUI.toast(res.msg);
  86. //关闭当前页面
  87. var self = plus.webview.currentWebview();
  88. self.close("none");
  89. } else {
  90. //非200则为失败
  91. addHealthIndexFailed(res);
  92. }
  93. }
  94. /**
  95. * 血糖添加成功处理方法
  96. */
  97. function addBloodSugarSuccess(res) {
  98. if (res.status == 200) {
  99. //添加成功
  100. var record_date = document.getElementById("date").value;
  101. var type_str = document.getElementById("type").value;
  102. var val = document.getElementById("val").value;
  103. var type;
  104. switch (type_str) {
  105. case "空腹血糖":
  106. type = ".bb";
  107. break;
  108. case "早餐后血糖":
  109. type = ".ba";
  110. break;
  111. case "午餐前血糖":
  112. type = ".lb";
  113. break;
  114. case "午餐后血糖":
  115. type = ".la";
  116. break;
  117. case "晚餐前血糖":
  118. type = ".db";
  119. break;
  120. case "晚餐后血糖":
  121. type = ".da";
  122. break;
  123. case "睡前血糖":
  124. type = ".sb";
  125. break;
  126. }
  127. var wv_index = plus.webview.getWebviewById("health-index");
  128. var wv_history = plus.webview.getWebviewById("health-index-bloodsugar-history");
  129. // var option={date:date,type:type,value:val};
  130. var wv_chart = plus.webview.getWebviewById("health-index-bloodsugar-chart");
  131. mui.fire(wv_index, "input-index", {
  132. type: "xt",
  133. value: type_str + "值 :" + val
  134. });
  135. mui.fire(wv_history, "add-item", {
  136. date: record_date,
  137. type: type,
  138. value: val
  139. });
  140. mui.fire(wv_chart, "refleshList", {});
  141. //提示添加成功
  142. plus.nativeUI.toast(res.msg);
  143. //关闭当前页面
  144. var self = plus.webview.currentWebview();
  145. self.close("none");
  146. } else {
  147. //非200则为失败
  148. addHealthIndexFailed(res);
  149. }
  150. }
  151. /**
  152. * 腰围添加成功处理方法
  153. */
  154. function addWaistlineSuccess(res) {
  155. if (res.status == 200) {
  156. //添加成功
  157. var record_date = document.getElementById("date").value;
  158. var val = document.getElementById("val").value;
  159. var wv_index = plus.webview.getWebviewById("health-index");
  160. var wv_history = plus.webview.getWebviewById("health-index-waistline-history");
  161. var wv_chart = plus.webview.getWebviewById("health-index-waistline-chart");
  162. // var option={date:date,type:type,value:val};
  163. mui.fire(wv_index, "input-index", {
  164. type: "yw",
  165. value: val
  166. });
  167. mui.fire(wv_history, "add-item", {
  168. date: record_date,
  169. value: val
  170. });
  171. mui.fire(wv_chart, "refleshList", {});
  172. //提示添加成功
  173. plus.nativeUI.toast(res.msg);
  174. //关闭当前页面
  175. var self = plus.webview.currentWebview();
  176. self.close("none");
  177. } else {
  178. //非200则为失败
  179. addHealthIndexFailed(res);
  180. }
  181. }
  182. /**
  183. * 体重添加成功处理方法
  184. */
  185. function addWeightSuccess(res) {
  186. if (res.status == 200) {
  187. //添加成功
  188. var record_date = document.getElementById("date").value;
  189. var val = document.getElementById("val").value;
  190. var wv_index = plus.webview.getWebviewById("health-index");
  191. var wv_history = plus.webview.getWebviewById("health-index-weight-history");
  192. var wv_chart = plus.webview.getWebviewById("health-index-weight-chart");
  193. // var option={date:date,type:type,value:val};
  194. mui.fire(wv_index, "input-index", {
  195. type: "tz",
  196. value: val
  197. });
  198. mui.fire(wv_history, "add-item", {
  199. date: record_date,
  200. value: val
  201. });
  202. mui.fire(wv_chart, "refleshList", {});
  203. //提示添加成功
  204. plus.nativeUI.toast(res.msg);
  205. //关闭当前页面
  206. var self = plus.webview.currentWebview();
  207. self.close("none");
  208. } else {
  209. //非200则为失败
  210. addHealthIndexFailed(res);
  211. }
  212. }
  213. /////////////////////////////////////////////////////////////////////////////////健康指标图表数据查询///////////////////////////////////////////////////////////////////////////
  214. /**
  215. * 查询健康指标图表
  216. * @param {Object} type 健康指标类型(1血糖,2血压,3体重,4腰围)
  217. * @param {Object} begin 记录开始时间
  218. * @param {Object} end 记录结束时间
  219. */
  220. function queryChatByType(patient,type, begin, end, successFunction) {
  221. //拼请求内容
  222. var params = {};
  223. params.patient = patient;
  224. params.type = type;
  225. params.begin = begin;
  226. params.end = end;
  227. //发送ajax请求
  228. sendPost("doctor/health_index/chart", params,queryChartFailed, successFunction);
  229. }
  230. /**
  231. * 健康指标图表查询失败处理方法
  232. */
  233. function queryChartFailed(res) {
  234. if (res && res.msg) {
  235. plus.nativeUI.toast(res.msg);
  236. } else {
  237. plus.nativeUI.toast("数据加载失败");
  238. }
  239. plus.nativeUI.closeWaiting();
  240. }
  241. /////////////////////////////////////////////////////////////////////////////////健康指标历史记录查询///////////////////////////////////////////////////////////////////////////
  242. /**
  243. * 健康指标历史记录查询
  244. * @param {Object} type 健康指标类型(1血糖,2血压,3体重,4腰围)
  245. * @param {Object} page 当前分页
  246. * @param {Object} pagesize 分页大小
  247. */
  248. function queryListByType(patient,type, beginDate, endDate, successFunction) {
  249. //拼请求内容
  250. var params = {};
  251. params.type = type;
  252. params.patient = patient;
  253. params.begin = beginDate;
  254. params.end = endDate;
  255. params.pagesize=999;
  256. //发送ajax请求
  257. sendPost("doctor/health_index/chart", params, queryListFailed, successFunction);
  258. }
  259. /**
  260. * 健康指标历史记录查询失败处理方法
  261. */
  262. function queryListFailed(res) {
  263. if (res && res.msg) {
  264. plus.nativeUI.toast(res.msg);
  265. } else {
  266. plus.nativeUI.toast("数据加载失败");
  267. }
  268. plus.nativeUI.closeWaiting();
  269. }