device-management.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. var page = 1,
  2. pageSize = 10,
  3. dateVal = '',
  4. statusVal = '',
  5. typeVal = '';
  6. var scroller;
  7. mui.init();
  8. mui.plusReady(function(){
  9. var self = plus.webview.currentWebview();
  10. getData(true);
  11. bindEvents();
  12. initFilterPage(self);
  13. initScroller();
  14. })
  15. function getData(isInit){
  16. if(isInit){
  17. page = 1;
  18. }
  19. var url = "doctor/device/getDevicesList",
  20. params = {
  21. noGaugeDay: dateVal,//未测量天数(1今日为测量 2七天未测量 3本月未测量 4超过一个月未测量)
  22. isBinding: statusVal, //是否绑定(1绑定 2解绑)
  23. categoryCode: typeVal, //设备类型(1血糖仪 2血压计)
  24. isSend: '', //今日是否已发送提醒消息(1已发送)
  25. page: page,
  26. pageSize: pageSize
  27. };
  28. plus.nativeUI.showWaiting();
  29. sendGet(url, params, null,function(res){
  30. if(res.status == 200){
  31. $("#count").text("("+res.data.tatalCount+")");
  32. var list = res.data.data;
  33. if(list.length == 0){
  34. if(isInit){
  35. $("#result_wrapper").hide();
  36. $("#no_result_wrap").show();
  37. }else{
  38. scroller.endPullupToRefresh(true);
  39. }
  40. }else{
  41. $("#result_wrapper").show();
  42. $("#no_result_wrap").hide();
  43. var html = template("li-tmp", {list: list});
  44. if(isInit){
  45. $("#result_wrapper").empty().append(html);
  46. }else{
  47. $("#result_wrapper").append(html);
  48. }
  49. if(list.length < pageSize){
  50. scroller.endPullupToRefresh(true);
  51. }else{
  52. page ++;
  53. if(isInit){
  54. scroller.refresh(true);
  55. }else{
  56. scroller.endPullupToRefresh(false);
  57. }
  58. }
  59. }
  60. }else{
  61. mui.toast(res.msg);
  62. }
  63. plus.nativeUI.closeWaiting();
  64. }, true);
  65. }
  66. function bindEvents(){
  67. $(".header-link").on('click', function(){
  68. openWebview("../../wdsb/html/scan2.html");
  69. });
  70. //提醒测量
  71. $("#remindBtn").on('click', function(){
  72. openWebview("choose-patient.html", {
  73. dateVal: dateVal,
  74. statusVal: statusVal,
  75. typeVal: typeVal,
  76. dateName: $(".filter-label:eq(0)").text(),
  77. statusName: $(".filter-label:eq(1)").text(),
  78. typeName: $(".filter-label:eq(2)").text()
  79. })
  80. });
  81. //左滑筛选区域的数据
  82. $('#filterBtn').on("tap", function(){
  83. var self = plus.webview.currentWebview();
  84. mui.fire(self, "showShaiXuan");
  85. });
  86. //点击患者查看患者设备列表
  87. $("#result_wrapper").on('tap', "li", function(){
  88. var $this = $(this),
  89. jsonObj = $this.data("json");
  90. openWebview("device-physical-records.html", {
  91. patiCode: jsonObj.patient,
  92. deviceSn: jsonObj.device_sn,
  93. type: jsonObj.category_code,
  94. deviceName: jsonObj.device_name
  95. })
  96. });
  97. window.addEventListener("setFilterData", function(arg){
  98. var info = arg.detail;
  99. dateVal = info.date;
  100. statusVal = info.status;
  101. typeVal = info.type;
  102. scroller.scrollTo(0, 0, 500);
  103. getData(true);
  104. $(".filter-label:eq(0)").text(info.dateName);
  105. $(".filter-label:eq(1)").text(info.statusName);
  106. $(".filter-label:eq(2)").text(info.typeName);
  107. })
  108. }
  109. function initFilterPage(main){
  110. var shaixuan = plus.webview.getWebviewById('filter.html');
  111. if(!shaixuan){
  112. shaixuan = mui.createWindow({
  113. id: 'filter.html',
  114. url: 'filter.html',
  115. styles: {
  116. top: 0,
  117. bottom: 0,
  118. left: '20%',
  119. width: '80%',
  120. scorllIndicator: "none"
  121. },
  122. show:{
  123. aniShow: "slide-in-right",
  124. duration: "400"
  125. },
  126. extras:{
  127. dateVal : dateVal,
  128. statusVal : statusVal,
  129. typeVal : typeVal
  130. }
  131. });
  132. }
  133. window.addEventListener("hideShaiXuan",function(){
  134. main.setStyle({mask:"none"});
  135. shaixuan.hide();
  136. }, false);
  137. window.addEventListener("showShaiXuan", function() {
  138. mui.fire(shaixuan, "setTagActive", {
  139. dateVal : dateVal,
  140. statusVal : statusVal,
  141. typeVal : typeVal
  142. });
  143. shaixuan.show();
  144. main.setStyle({mask:"rgba(0,0,0,0.5)"});
  145. main.addEventListener("maskClick",function(){
  146. main.setStyle({mask:"none"});
  147. shaixuan.hide();
  148. }, false);
  149. });
  150. }
  151. function initScroller(){
  152. //阻尼系数
  153. var deceleration = mui.os.ios?0.003:0.0009;
  154. mui('.mui-scroll-wrapper').scroll({
  155. bounce: false,
  156. indicators: true, //是否显示滚动条
  157. deceleration:deceleration
  158. });
  159. scroller = mui(".mui-scroll-wrapper").pullRefresh({
  160. down:{
  161. callback: function(){
  162. getData(true);
  163. this.endPulldownToRefresh();
  164. }
  165. },
  166. up: {
  167. callback: function(){
  168. getData(false);
  169. // this.endPullupToRefresh();
  170. }
  171. }
  172. })
  173. }