patient-device-list.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. var page = 1,
  2. pageSize = 100,
  3. patientCode;
  4. mui.init();
  5. mui.plusReady(function(){
  6. var self = plus.webview.currentWebview();
  7. patientCode = self.patientCode;
  8. getPatientDeviceList(true);
  9. initScroller();
  10. bindEvents();
  11. })
  12. function getPatientDeviceList(isInit){
  13. if(isInit){
  14. page = 1;
  15. }
  16. var url = "doctor/device/PatientDeviceList",
  17. params = {
  18. page: page,
  19. pagesize: pageSize,
  20. patient: patientCode
  21. };
  22. plus.nativeUI.showWaiting();
  23. sendGet(url, params, null, function(res){
  24. plus.nativeUI.closeWaiting();
  25. if(res.status == 200){
  26. var list = res.data;
  27. if(list.length == 0){
  28. if(isInit){
  29. $("#deviceList").empty().hide();
  30. $("#no_result_wrap").show();
  31. }else{
  32. mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
  33. }
  34. }else{
  35. $("#deviceList").show();
  36. $("#no_result_wrap").hide();
  37. var html = template("device-tmp", {list: list});
  38. if(isInit){
  39. $("#deviceList").empty().append(html);
  40. }else{
  41. $("#deviceList").append(html);
  42. }
  43. if(list.length < pageSize){
  44. mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
  45. }else{
  46. mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(false);
  47. }
  48. }
  49. }else{
  50. mui.toast(res.msg)
  51. }
  52. }, true);
  53. }
  54. function bindEvents(){
  55. template.helper("getBindUser", function(obj){
  56. if(obj.doctor){
  57. return obj.doctorName;
  58. }else{
  59. return "患者绑定";
  60. }
  61. });
  62. template.helper("getJsonStr", function(obj){
  63. return JSON.stringify(obj);
  64. });
  65. template.helper("getPhoto", function(str){
  66. return getImgUrl(str);
  67. });
  68. $("#deviceList").on('tap', ".device-box", function(){
  69. var $this = $(this),
  70. jsonObj = $this.data("json");
  71. if(jsonObj.type==1){
  72. mui.openWindow('../../wdsb/html/view-xuetangyi.html', 'view-xuetangyi.html', {
  73. extras: {
  74. deviceId: jsonObj.deviceId,
  75. dataId: jsonObj.code,
  76. patient: patientCode,
  77. role: jsonObj.role
  78. }
  79. })
  80. }else if(jsonObj.type==2){
  81. mui.openWindow('../../wdsb/html/view-xueyaji.html', 'view-xueyaji.html', {
  82. extras: {
  83. deviceId: jsonObj.deviceId,
  84. dataId: jsonObj.code,
  85. patient: patientCode,
  86. role: jsonObj.role
  87. }
  88. })
  89. }
  90. })
  91. }
  92. function initScroller(){
  93. //阻尼系数
  94. var deceleration = mui.os.ios?0.003:0.0009;
  95. mui('.mui-scroll-wrapper').scroll({
  96. bounce: false,
  97. indicators: true, //是否显示滚动条
  98. deceleration:deceleration
  99. });
  100. mui(".mui-scroll-wrapper").pullRefresh({
  101. down:{
  102. callback: function(){
  103. getPatientDeviceList(true);
  104. this.endPulldownToRefresh();
  105. }
  106. },
  107. up: {
  108. callback: function(){
  109. getPatientDeviceList(false);
  110. }
  111. }
  112. })
  113. }