view-xuetangyi.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. var rowData={};
  2. var sn="";//记录sn码
  3. var dataId = null;
  4. var type = null;
  5. var name = null;
  6. var photoUrl = null;
  7. var deviceId = null;
  8. var patient = null;
  9. var role = null; // 1.可删除编辑,0不可以删除编辑"
  10. var oldSn="";//旧sn
  11. var self;
  12. mui.init();
  13. mui.plusReady(function() {
  14. plus.nativeUI.showWaiting();
  15. self = plus.webview.currentWebview();
  16. dataId = self.dataId;
  17. deviceId = self.deviceId;
  18. patient = self.patient;
  19. role = self.role;
  20. initPage();
  21. });
  22. $(function(){
  23. //添加isrcoll
  24. var scroller1 = new IScrollPullUpDown('wrapper',{
  25. probeType:2,
  26. bounceTime: 250,
  27. bounceEasing: 'quadratic',
  28. mouseWheel:false,
  29. scrollbars:true,
  30. click:true,
  31. fadeScrollbars:true,
  32. interactiveScrollbars:false
  33. },null,null);
  34. })
  35. function initPage(){
  36. getDeviceInfo(deviceId);
  37. bindEvents();
  38. }
  39. function initData(dataId){
  40. var params = {};
  41. params.id=dataId;
  42. sendGet("doctor/device/PatientDeviceInfo",params,
  43. function(res){
  44. if(res.msg){
  45. mui.toast(res.msg);
  46. }else{
  47. mui.toast("设备信息初始化失败!");
  48. }
  49. },
  50. function(res){
  51. if(res.status==200){
  52. rowData = res.data;
  53. docInfo= JSON.parse(plus.storage.getItem("docInfo"));
  54. // if(rowData.doctor==docInfo.code){
  55. // $("#footer").show();
  56. // }
  57. if(role=="1") {
  58. $("#footer").show();
  59. }
  60. oldSn = rowData.deviceSn;
  61. $("#sncode").val(rowData.deviceSn);
  62. }else{
  63. mui.toast("设备信息初始化失败!");
  64. }
  65. })
  66. }
  67. //绑定事件
  68. function bindEvents(){
  69. //保存方法
  70. //保存方法
  71. $("#del-btn").bind("click",function(){
  72. mui.confirm("设备解绑后,将无法自动从设备获取相关数据。是否继续解绑?", "提示", ["继续解绑","不了,谢谢"], function(e) {
  73. if(e.index==0){
  74. deleteSn(dataId);
  75. return;
  76. }else{
  77. return;
  78. }
  79. });
  80. })
  81. $("#edit-btn").bind("click",function(){
  82. editXuetangyi();
  83. })
  84. }
  85. function getDeviceInfo(deviceId){
  86. sendGet("common/device/DeviceInfo?id="+deviceId,{},
  87. function(res){
  88. plus.nativeUI.closeWaiting();
  89. mui.toast("设备信息获取失败!");
  90. },
  91. function(res){
  92. plus.nativeUI.closeWaiting();
  93. if(res.status==200){
  94. var rowData1 = res.data;
  95. type = rowData1.categoryCode;
  96. name = rowData1.name;
  97. photoUrl = rowData1.photo;
  98. $(".deviceName").html(name);
  99. $(".div-xuetangyi-img img").attr("src",getImgUrl(photoUrl));
  100. initData(dataId);
  101. }else{
  102. mui.toast("设备信息获取失败!");
  103. }
  104. })
  105. }
  106. function editXuetangyi(){
  107. var params = {};
  108. params.deviceId = deviceId;
  109. params.dataId = dataId;
  110. params.patient = patient;
  111. openWebviewExtras("edit-xuetangyi.html",params);
  112. }
  113. function deleteSn(code){
  114. plus.nativeUI.showWaiting();
  115. sendPost("doctor/device/DeletePatientDevice?id="+code,{},function(res){
  116. plus.nativeUI.closeWaiting();
  117. if (res && res.msg) {
  118. mui.toast(res.msg);
  119. } else {
  120. mui.toast("解绑设备失败!");
  121. }
  122. },function(res){
  123. if(res.status==200){
  124. $(".c-list").html("");
  125. openwdsb();
  126. mui.toast("解绑设备成功!");
  127. }else{
  128. plus.nativeUI.closeWaiting();
  129. mui.toast("解绑设备失败!");
  130. }
  131. },"GET")
  132. }
  133. function openwdsb(){
  134. var page = plus.webview.getWebviewById("health-record");
  135. if(page){
  136. mui.fire(page,'refreshEquipment')
  137. }
  138. var page2 = plus.webview.getWebviewById("my-equipments");
  139. if(page2){
  140. mui.fire(page2,'refreshEquipment')
  141. }
  142. setTimeout(function(){
  143. var pa1 = plus.webview.getWebviewById("list-xueyaji.html");
  144. if(pa1){pa1.close()}
  145. var pa2 = plus.webview.getWebviewById("list-xuetangyi.html");
  146. if(pa2){pa2.close()}
  147. var pa3 = plus.webview.getWebviewById("edit-xueyaji");
  148. if(pa3){pa3.close()}
  149. var pa4 = plus.webview.getWebviewById("edit-xuetangyi");
  150. if(pa4){pa4.close()}
  151. var pa5 = plus.webview.getWebviewById("view-xueyaji.html");
  152. if(pa5){pa5.close()}
  153. var pa6 = plus.webview.getWebviewById("view-xuetangyi");
  154. if(pa6){pa6.close()}
  155. plus.nativeUI.closeWaiting();
  156. mui.back()
  157. },1000)
  158. }