jumin-manbingdangan.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. mui.init();
  2. var patient,
  3. isManbing = false, //标记是否是慢病病人
  4. oPatiInfo,
  5. isTrack, //标记是否关注
  6. xueyaLoaded = false; //标记是否已经加载过血压值
  7. mui.plusReady(function(){
  8. var self = plus.webview.currentWebview();
  9. patient = self.patient;
  10. getPatientInfo();
  11. getWeekXTInfo(0); //获得近一周血糖血压数据
  12. //获得运动情况和检测方案等信息
  13. getSection3Info();
  14. //获得控制目标信息
  15. getTargetInfo();
  16. bindEvents();
  17. templateHelper();
  18. })
  19. function getPatientInfo(){
  20. var url = "/doctor/patient_label_info/patient",
  21. params = {patient: patient};
  22. plus.nativeUI.showWaiting();
  23. sendGet(url, params, null, function(res){
  24. plus.nativeUI.closeWaiting();
  25. if(res.status == 200){
  26. oPatiInfo = res.data;
  27. $("#header-title").text(res.data.name+"_慢病档案");
  28. //TODO 判断是否关注现实隐藏”取消关注“按钮
  29. isTrack = res.data.isTrack;
  30. if(isTrack == '1'){
  31. $(".header-link a").attr("data-val", '1').text("取消关注");
  32. }else{
  33. $(".header-link a").attr("data-val", '0').text("重点关注");
  34. }
  35. //判断居民类型 如果是慢病病人 则续方管理模块出现否则隐藏
  36. for(var i in res.data.serverTypes){
  37. var type = res.data.serverTypes[i];
  38. if(type.server_type == 4 || type.server_type == 5){
  39. isManbing = true;
  40. break;
  41. }
  42. }
  43. if(isManbing){
  44. $("#xfjl").show();
  45. }
  46. var html = template("pati_info_tmp", res.data);
  47. $(".patiInfo-section").append(html);
  48. }else if(res.status == -1){
  49. mui.toast(res.msg);
  50. }
  51. }, true);
  52. }
  53. //获得近一周血糖血压数据
  54. function getWeekXTInfo(type){
  55. var sdate = new Date(),
  56. edate = new Date();
  57. sdate.setDate(edate.getDate() - 6);
  58. var url = "/doctor/scheme/getPatientHealthIndex",
  59. params = {
  60. patient: patient,
  61. startDate: sdate.format('yyyy-MM-dd'),
  62. endDate: edate.format('yyyy-MM-dd'),
  63. type: type //0:血糖, 1:血压
  64. };
  65. if(type == 1){
  66. xueyaLoaded = true;
  67. }
  68. sendGet(url, params, null, function(res){
  69. if(res.status == 200){
  70. var html = template('xt-tmp', res.data);
  71. if(type == 0){
  72. $(".xuetang-info .mui-loading").remove();
  73. $(".xuetang-info").append(html);
  74. }else{
  75. $(".xueya-info .mui-loading").remove();
  76. $(".xueya-info").append(html);
  77. }
  78. }else{
  79. mui.toast(res.msg);
  80. }
  81. }, true);
  82. }
  83. function getSection3Info(){
  84. var url = "/doctor/scheme/getTrackPatientInfo",
  85. params = {patient: patient};
  86. plus.nativeUI.showWaiting();
  87. sendGet(url, params, null, function(res){
  88. if(res.status == 200){
  89. var html = template('section3-tmp', res.data);
  90. $(".mb-info").empty().append(html);
  91. }else{
  92. mui.toast(res.msg);
  93. }
  94. plus.nativeUI.closeWaiting();
  95. }, true);
  96. }
  97. function getTargetInfo(){
  98. var url = "/doctor/scheme/getControlObjectives",
  99. params = {patient: patient};
  100. plus.nativeUI.showWaiting();
  101. sendGet(url, params, null, function(res){
  102. if(res.status == 200){
  103. var html = template("target-tmp", res.data);
  104. $("#targetInfo").empty().append(html);
  105. }else{
  106. mui.toast(res.msg);
  107. }
  108. plus.nativeUI.closeWaiting();
  109. }, true);
  110. }
  111. //添加重点关注
  112. function setTrack(state){
  113. var url = '/doctor/patient_label_info/setTrackPatient',
  114. params = {
  115. patient: patient,
  116. state: state // 1:开启, 0:删除
  117. };
  118. plus.nativeUI.showWaiting();
  119. sendPost(url, params, null, function(res){
  120. if(res.status == 200){
  121. if(state == 1){
  122. $(".track-flag").show();
  123. $(".header-link a").attr("data-val", '1').text("取消关注");
  124. }else{
  125. $(".track-flag").hide();
  126. $(".header-link a").attr("data-val", '0').text("重点关注");
  127. }
  128. mui.toast("设置成功");
  129. }else{
  130. mui.toast(res.msg);
  131. }
  132. plus.nativeUI.closeWaiting();
  133. });
  134. }
  135. function templateHelper(){
  136. template.helper("getImgUrl", function(str){
  137. if(str){
  138. return getImgUrl(str);
  139. }
  140. if(str.length == 0){
  141. return "../../../images/p-female.png";
  142. }
  143. })
  144. }
  145. function bindEvents(){
  146. //重点关注和取消关注控制
  147. $(".header-link").on('click', function(){
  148. var $a = $(this).find("a"),
  149. val = $a.attr("data-val");
  150. if(val == '1'){ //即当前已关注,点击调用取消关注接口
  151. setTrack(0);
  152. }else{//即当前未关注,点击调用关注接口
  153. setTrack(1);
  154. }
  155. })
  156. $(".patiInfo-section").on('click', ".sbbind-flag", function(e){
  157. e.stopPropagation();
  158. mui.openWindow('../../jkjl/html/health-record.html', 'health-record', {
  159. extras: {
  160. patientCode: patient,
  161. tagType: 1
  162. }
  163. })
  164. });
  165. $(".patiInfo-section").on('click', "#patiInfo", function(){
  166. openWebview("../../huanzhe/html/huanzhexinxi.html", {
  167. patiCode: patient
  168. });
  169. });
  170. //血压血糖按钮切换
  171. $(".switch-box").on('click', "span", function(){
  172. var $this = $(this),
  173. val = $this.attr("data-val"),
  174. index = $this.index();
  175. if($this.hasClass("active")){
  176. return false;
  177. }
  178. $this.siblings().removeClass("active");
  179. $this.addClass("active");
  180. mui('.mui-slider').slider().gotoItem(parseInt(index));
  181. if(val == "xt"){
  182. $("#xtName").text("血糖");
  183. }else if(val == "xy"){
  184. if(!xueyaLoaded){
  185. getWeekXTInfo(1);
  186. }
  187. $("#xtName").text("血压");
  188. }
  189. });
  190. //监听血压,血糖情况滚动切换
  191. document.querySelector('.mui-slider').addEventListener('slide', function(event) {
  192. if (event.detail.slideNumber === 0) {
  193. $(".switch-box span").eq(0).addClass("active");
  194. $(".switch-box span").eq(1).removeClass("active");
  195. $("#xtName").text("血糖");
  196. } else if (event.detail.slideNumber === 1) {
  197. if(!xueyaLoaded){
  198. getWeekXTInfo(1);
  199. }
  200. $(".switch-box span").eq(0).removeClass("active");
  201. $(".switch-box span").eq(1).addClass("active");
  202. $("#xtName").text("血压");
  203. }
  204. });
  205. //查看血糖情况
  206. $("body").on('tap', ".xuetang-info .cycle-div", function(){
  207. var dat = new Date();
  208. mui.openWindow('../../jkjl/html/xuetang-view.html', 'xuetang-view.html', {
  209. extras: {
  210. code: patient,
  211. dateT: dat.format("yyyy-MM-dd"),
  212. }
  213. });
  214. });
  215. //查看血压情况
  216. $("body").on('tap', ".xueya-info .cycle-div", function(){
  217. var dat = new Date();
  218. mui.openWindow('../../jkjl/html/xueya-view.html', 'xueya-view.html', {
  219. extras: {
  220. code: patient,
  221. dateT: dat.format("yyyy-MM-dd")
  222. }
  223. });
  224. });
  225. //查看体重信息
  226. $("body").on('click', ".tizhong", function(){
  227. var dat = new Date();
  228. mui.openWindow('../../jkjl/html/tizhong-view.html', 'tizhong-view.html', {
  229. extras: {
  230. code: patient,
  231. dateT: dat.format("yyyy-MM-dd")
  232. }
  233. });
  234. });
  235. //查看监测方案
  236. $("body").on('click', ".jc-method", function(){
  237. var $this = $(this),
  238. val = $this.data("val"),
  239. xtCode = $(".jc-method[data-val=xt]").data("code"),
  240. xyCode = $(".jc-method[data-val=xy]").data("code");
  241. openWebview("jc-xuanzefangan.html",{
  242. pCodes: [patient],
  243. selectedTab: val=='xy' ? 2 : 1,
  244. xtCode: xtCode,
  245. xyCode: xyCode,
  246. comeFrom: 'jumindangan'
  247. })
  248. });
  249. //查看控制目标
  250. $("#targetInfo").on('click', function(){
  251. openWebview("control-goal.html",{pCodes: patient, pName: oPatiInfo.name});
  252. });
  253. //查看运动情况
  254. $('.mb-info').on('click', ".sports", function(){
  255. openWebview("sports.html", {patient: patient});
  256. });
  257. //用药记录
  258. $("#yyjl").on('click', function(){
  259. openWebview("../../huanzhe/html/yongyaojilu.html",{patiInfo: {code: patient}})
  260. });
  261. $("#xfjl").on('click', function(){
  262. mui.openWindow('../../prescription/html/juminxufangjilu.html', 'juminxufangjilu', {
  263. extras: {
  264. teamCode:oPatiInfo.jtAdminTeam,
  265. patiCode: patient,
  266. patiName: oPatiInfo.name
  267. }
  268. })
  269. });
  270. window.addEventListener("reloadJiance", function(e){
  271. //刷新检测方案内容
  272. getSection3Info();
  273. });
  274. window.addEventListener('refreshTargetData', function(e){
  275. //刷新控制目标内容
  276. getTargetInfo();
  277. });
  278. }