my-equipments.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. var pagesize = 100;
  2. var page = 1 ;
  3. var patient = null;
  4. var docInfo;
  5. mui.init();
  6. mui.plusReady(function() {
  7. plus.nativeUI.showWaiting();
  8. self = plus.webview.currentWebview();
  9. docInfo = JSON.parse(plus.storage.getItem("docInfo"));
  10. patient = self.patient;
  11. initPage();
  12. });
  13. //initTouch();
  14. function initPage(){
  15. bindEvents();
  16. getEquipments();
  17. }
  18. function getEquipments(){
  19. var params = {};
  20. params.page=page;
  21. params.pagesize = pagesize;
  22. params.patient = patient;
  23. sendGet("doctor/device/PatientDeviceList",params,queryListFailed,queryListSuccess);
  24. }
  25. function queryListSuccess(res){
  26. plus.nativeUI.closeWaiting();
  27. if(res.status==200){
  28. if(res.data&&res.data.length>0){
  29. // for(var i in res.data){
  30. showList(res.data);
  31. // }
  32. page = page+1;
  33. //initTouch();
  34. }else{
  35. if(page==1){
  36. sendGet("doctor/is_patient_signed",{patient:patient},function(res){
  37. mui.toast("签约关系获取失败!");
  38. },function(res){
  39. if(res.status==200){
  40. if(res.data==1){
  41. $(".div-tishi-info").html("该居民还未绑定体征设备");
  42. }else{
  43. $(".div-tishi-info").html("您还未帮该居民绑定过体征设备");
  44. }
  45. $(".div-no-info").show();
  46. $(".main").hide();
  47. }else{
  48. if(res.msg){
  49. mui.toast(res.msg);
  50. }else{
  51. mui.toast("签约关系获取失败!");
  52. }
  53. }
  54. });
  55. }else{
  56. mui.toast("无更多设备!");
  57. }
  58. }
  59. $(".pullUp").hide();
  60. }else{
  61. queryListFailed(res);
  62. }
  63. }
  64. function showList(data){
  65. // var img='xuetangyi_icon.png';
  66. // if(rowData.categoryCode==2){
  67. // img='xueyaji_icon.png';
  68. // }
  69. var bindUser ="患者绑定";
  70. // if(rowData.doctor){
  71. // bindUser = rowData.doctorName;
  72. // }
  73. template.helper('getImgUrl', function(str, categoryCode){
  74. var url = getImgUrl(str);
  75. if(url){
  76. return url;
  77. }else{
  78. if(categoryCode==2){
  79. url='xueyaji_icon.png';
  80. }else{
  81. url = 'xuetangyi_icon.png';
  82. }
  83. }
  84. return url;
  85. });
  86. // var showDomLi = '<li class="inp" device-id="'+rowData.deviceId+'" data-type="'+rowData.categoryCode+'" data-id="'+rowData.id+'" data-role="'+rowData.role+'">'+
  87. // '<div class="icon-div">'+
  88. // '<img src="'+getImgUrl(rowData.devicePhoto)+'">'+
  89. // '</div>'+
  90. // '<div class="div-content">'+rowData.deviceName+'</div>'+
  91. // '<div class="div-sn"><span class="bullspan">&bull; </span>绑定时间:'+rowData.czrq+'</div>'+
  92. // '<div class="div-sn" style="top: 72px;"><span class="bullspan">&bull;</span> 绑定人:'+bindUser+'</div>'+
  93. // //'<a href="javascript:void(0);" data-type="'+rowData.categoryCode+'" data-id="'+rowData.id+'" device-id="'+rowData.deviceId+'" class="edit">编辑</a>'+
  94. // //'<a href="javascript:void(0);" data-type="'+rowData.categoryCode+'" data-id="'+rowData.id+'" device-id="'+rowData.deviceId+'" class="del">解绑</a>'+
  95. // '</li>';
  96. var html = template('list-tmp', {list: data, bindUser: bindUser});
  97. $(".c-list").empty().append(html);
  98. $(".div-no-info").hide();
  99. $(".main").show();
  100. }
  101. function queryListFailed(res) {
  102. alert("Failed")
  103. plus.nativeUI.closeWaiting();
  104. if (res && res.msg) {
  105. mui.toast(res.msg);
  106. } else {
  107. mui.toast("加载设备列表失败!");
  108. }
  109. }
  110. //绑定事件
  111. function bindEvents(){
  112. //绑定编辑和删除事件
  113. $(".c-list").on("click","li div",function(){
  114. var code = $(this.parentElement).attr("data-id");
  115. var deviceId = $(this.parentElement).attr("device-id");
  116. var type = $(this.parentElement).attr("data-type");
  117. var role = $(this.parentElement).attr("data-role");
  118. var params = {};
  119. params.deviceId = deviceId;
  120. params.dataId = code;
  121. params.patient = patient;
  122. params.role = role;
  123. if(type==1){
  124. openWebviewExtras("view-xuetangyi.html",params);
  125. }else if(type==2){
  126. openWebviewExtras("view-xueyaji.html",params);
  127. }
  128. });
  129. function deleteSn(code){
  130. sendPost("doctor/device/DeletePatientDevice?id="+code,{},function(res){
  131. if (res && res.msg) {
  132. mui.toast(res.msg);
  133. } else {
  134. mui.toast("解绑设备失败!");
  135. }
  136. },function(res){
  137. if(res.status==200){
  138. $(".c-list").html("");
  139. page=1;
  140. getEquipments();
  141. mui.toast("解绑设备成功!");
  142. }else{
  143. mui.toast("解绑设备失败!");
  144. }
  145. },"DELETE")
  146. }
  147. //新增按钮事件
  148. $(".div-add-btn").on("click",function(){
  149. $(this).hide();
  150. if($(this).hasClass("active")){
  151. $(".modal-overlay").trigger("click");
  152. }else{
  153. $(this).addClass("active");
  154. $(".modal-overlay").addClass("modal-overlay-visible");
  155. $(".div-dialog-content").show();
  156. }
  157. });
  158. //点击遮罩事件
  159. $(".modal-overlay").on("click",function(){
  160. $(".modal-overlay").removeClass("modal-overlay-visible");
  161. $(".div-dialog-content").hide();
  162. $(".div-add-btn").removeClass("active");
  163. $(".div-add-btn").show();
  164. });
  165. //取消事件
  166. $(".quxiao").on("click",function(){
  167. $(".modal-overlay").trigger("click");
  168. });
  169. //点击血糖仪事件
  170. $(".xuetangyi-icon").on("click",function(){
  171. // $(this).addClass("active");
  172. var params = {};
  173. params.category_code = 1;
  174. params.patient = patient;
  175. $(".quxiao").click();
  176. if(docInfo.hospital.indexOf("350205") == 0){
  177. dialog({
  178. content: "绑定设备请前往首页->设备管理->扫码",
  179. okValue: "知道了",
  180. ok: function(){
  181. }
  182. }).showModal();
  183. }else
  184. openWebviewExtras("list-xuetangyi.html",params);
  185. });
  186. //点击血压计事件
  187. $(".xueyaji-icon").on("click",function(){
  188. // $(this).addClass("active");
  189. var params = {};
  190. params.category_code = 2;
  191. params.patient = patient;
  192. $(".quxiao").click();
  193. if(docInfo.hospital.indexOf("350205") == 0){
  194. dialog({
  195. content: "绑定设备请前往首页->设备管理->扫码",
  196. okValue: "知道了",
  197. ok: function(){
  198. }
  199. }).showModal();
  200. }else
  201. openWebviewExtras("list-xueyaji.html",params);
  202. });
  203. }
  204. //页面局部刷新
  205. window.addEventListener("refreshEquipment", function(){
  206. console.log("refreshEquipment");
  207. page=1;
  208. getEquipments()
  209. })