slow-disease-manage.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. var pagetype = 47,
  2. userAgent,
  3. patient,
  4. xueyaLoaded = false; //标记是否已经加载过血压值
  5. var d = dialog({
  6. contentType: 'load',
  7. skin: 'bk-popup'
  8. });
  9. checkUserAgent();
  10. //封装好的入口函数
  11. function queryInit() {
  12. userAgent = window.localStorage.getItem(agentName)
  13. patient = JSON.parse(userAgent).uid;;
  14. getPatientInfo();
  15. getWeekXTInfo(0);//获得近一周血糖血压数据
  16. getTrackPatientInfo();//获得运动情况和检测方案等信息
  17. getControlObjectives();//获取控制目标,血压,血糖
  18. bindEvents();
  19. }
  20. function getPatientInfo(){
  21. var url = "/patient/scheme/patient",
  22. params = {
  23. patient: patient
  24. };
  25. sendPost(url, params, 'JSON', 'GET', queryFailed, function(res) {
  26. if(res.status == 200) {
  27. if( res.data && res.data.photo){
  28. var photo = res.data.photo;
  29. var reg=/group1\//g;
  30. photo = photo.replace(reg,imgUrlDomain+ 'group1/');
  31. res.data.photo = photo;
  32. }
  33. var html = template('patientInfo-tmp', res.data);
  34. $("#patientInfo").append(html);
  35. } else {
  36. queryFailed(res);
  37. }
  38. });
  39. }
  40. function getWeekXTInfo(type){
  41. var sdate = new Date(),
  42. edate = new Date();
  43. sdate.setDate(edate.getDate() - 6);
  44. var url = "/patient/scheme/getPatientHealthIndex",
  45. params = {
  46. patient: patient,
  47. startDate: sdate.Format('yyyy-MM-dd'),
  48. endDate: edate.Format('yyyy-MM-dd'),
  49. type: type //0:血糖, 1:血压
  50. };
  51. if(type == 1){
  52. xueyaLoaded = true;
  53. }
  54. sendPost(url, params, 'JSON', 'GET', queryFailed, function(res) {
  55. if(res.status == 200) {
  56. var html = template('xt-tmp', res.data);
  57. if(type == 0){
  58. $("#xtPanel").empty().append(html);
  59. }else{
  60. $(".xueya-info").empty().append(html);
  61. }
  62. } else {
  63. queryFailed(res);
  64. }
  65. });
  66. }
  67. function getTrackPatientInfo(){
  68. var url = "/patient/scheme/getTrackPatientInfo",
  69. params = {
  70. patient: patient
  71. };
  72. sendPost(url, params, 'JSON', 'GET', queryFailed, function(res) {
  73. if(res.status == 200) {
  74. var html = template('trackPatientInfo-tmp', res.data);
  75. $("#trackPatientInfo").append(html);
  76. } else {
  77. queryFailed(res);
  78. }
  79. });
  80. }
  81. function getControlObjectives(){
  82. var url = "/patient/scheme/getControlObjectives",
  83. params = {
  84. patient: patient
  85. };
  86. sendPost(url, params, 'JSON', 'GET', queryFailed, function(res) {
  87. if(res.status == 200) {
  88. var html = template('controlObjectives-tmp', res.data);
  89. $("#controlObjectives").append(html);
  90. } else {
  91. queryFailed(res);
  92. }
  93. });
  94. }
  95. function queryFailed(res) {
  96. d.close();
  97. if(res && res.msg) {
  98. dialog({
  99. contentType: 'tipsbox',
  100. skin: 'bk-popup',
  101. content: res.msg
  102. }).show();
  103. } else {
  104. dialog({
  105. contentType: 'tipsbox',
  106. skin: 'bk-popup',
  107. content: '加载失败'
  108. }).show();
  109. }
  110. }
  111. function bindEvents(){
  112. //点击“智能测量”跳转”健康记录——体征设备“页。
  113. $("#patientInfo").on("tap",'.zhinengceliang',function(){
  114. window.location.href ="../../jkjl/html/health-record.html?charType=5&tagType=1";
  115. })
  116. //点击“最近一周血糖”跳转 血糖情况页。
  117. $("#xtPanel").on("tap",'.ui-col-1',function(){
  118. var dat = new Date();
  119. window.location.href ="../../jkjl/html/xuetang-view.html?type=0&dateT=" + (dat.Format("yyyy-MM-dd"));
  120. })
  121. //点击“最近一周血压”跳转 血压情况页。
  122. $("#xyPanel").on("tap",'.ui-col-1',function(){
  123. var dat = new Date();
  124. window.location.href ="../../jkjl/html/xueya-view.html?type=0&dateT=" + (dat.Format("yyyy-MM-dd"));
  125. })
  126. //点击“今日运动情况”跳转 运动情况页。
  127. $("#trackPatientInfo").on("tap",'.sportSituation',function(){
  128. window.location.href = '../html/sports.html';
  129. })
  130. //点击“身高体重”跳转 运动情况页。
  131. $("#trackPatientInfo").on("tap",'.tizhong',function(){
  132. var dat = new Date();
  133. window.location.href = '../../jkjl/html/tizhong-view.html?dateT=' + (dat.Format("yyyy-MM-dd"));
  134. })
  135. //点击“血压/血糖监测方案”跳转到相应的监测方案。
  136. $("#trackPatientInfo").on("tap",'.jc-method',function(){
  137. var $this = $(this),
  138. val = $this.data("val");
  139. if(val == 'xt'){
  140. selectedTab = 1
  141. }else{
  142. selectedTab = 2
  143. }
  144. window.location.href = '../html/monitor-program.html?selectedTab='+(selectedTab);
  145. })
  146. //点击“控制目标”跳转 控制目标页。
  147. $("#controlObjectives").on("tap",function(){
  148. window.location.href = '../html/control-target.html';
  149. })
  150. //点击“处方记录”跳转 处方记录页。
  151. $(".cfjl").on("tap",function(){
  152. window.location.href = '../../prescription/html/prescription_records.html';
  153. })
  154. //点击“疾病社区”跳转 疾病社区页。
  155. $(".jbsq").on("tap",function(){
  156. window.location.href = '../html/disease-community.html';
  157. })
  158. //点击“热量查询”跳转 热量查询页。
  159. $(".rlcx").on("tap",function(){
  160. window.location.href = '../../rlcx/html/serach-index.html';
  161. })
  162. //血压血糖按钮切换
  163. $("body").on('tap', ".switch-box span", function(){
  164. var $this = $(this),
  165. val = $this.attr("data-val"),
  166. index = $this.index();
  167. if($this.hasClass("active")){
  168. return false;
  169. }
  170. $this.siblings().removeClass("active");
  171. $this.addClass("active");
  172. mui('.mui-slider').slider().gotoItem(parseInt(index));
  173. if(val == "xt"){
  174. $("#xtName").text("血糖");
  175. }else if(val == "xy"){
  176. if(!xueyaLoaded){
  177. getWeekXTInfo(1);
  178. }
  179. $("#xtName").text("血压");
  180. }
  181. });
  182. //监听血压,血糖情况滚动切换
  183. document.querySelector('.mui-slider').addEventListener('slide', function(event) {
  184. if (event.detail.slideNumber === 0) {
  185. $(".switch-box span").eq(0).addClass("active");
  186. $(".switch-box span").eq(1).removeClass("active");
  187. $("#xtName").text("血糖");
  188. } else if (event.detail.slideNumber === 1) {
  189. if(!xueyaLoaded){
  190. getWeekXTInfo(1);
  191. }
  192. $(".switch-box span").eq(0).removeClass("active");
  193. $(".switch-box span").eq(1).addClass("active");
  194. $("#xtName").text("血压");
  195. }
  196. });
  197. }
  198. function templateHelper(){
  199. template.helper("getImgUrl", function(str){
  200. if(str){
  201. return getImgUrl(str);
  202. }
  203. return "";
  204. })
  205. }