yongyao-view.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. var switchery = null;
  2. var date = new Date();
  3. var year = date.getFullYear();
  4. var begindate;
  5. var enddate;
  6. var page = 1;
  7. var pagesize = 10;
  8. var pagetype = 5;
  9. var patientCode = "";
  10. var charType = 1;
  11. var scroller1 = null;
  12. var self = null;
  13. var type = null;
  14. var charts = [];
  15. var $duringList = $('#duringList'),
  16. $qushiView = $('#qushiView'),
  17. $liebiaoView = $('#liebiaoView'),
  18. $xtEdit = $('.xt-edit'),
  19. $btns = $('.btns'),
  20. $cancelBtn = $('.cancel-btn'),
  21. $okBtn = $('.ok-btn'),
  22. $xtAdd = $('.xt-add'),
  23. $popMain = $('.pop-main'),
  24. $popBtns = $('.pop-btns'),
  25. $popEditBtn = $('.pop-edit-btn'),
  26. $popDelBtn = $('.pop-del-btn'),
  27. $popCancelBtn = $('.pop-cancel-btn'),
  28. isTrue = false,
  29. page = 0,
  30. pagesize = 10,
  31. $xyList = $('.xy-list-con'),
  32. $xyTmp = $('#xyTmp');
  33. mui.plusReady(function() {
  34. self = plus.webview.currentWebview();
  35. patientCode = self.code;
  36. begindate = self.dateT;
  37. type = self.type;
  38. plus.nativeUI.showWaiting();
  39. scroller1 = new IScrollPullUpDown('wrapper6', {
  40. probeType: 2,
  41. bounceTime: 250,
  42. bounceEasing: 'quadratic',
  43. mouseWheel: false,
  44. scrollbars: true,
  45. fadeScrollbars: true,
  46. interactiveScrollbars: false,
  47. click: true,
  48. }, null, pullUpAction);
  49. loadData();
  50. });
  51. var render = function(tmpl, data) {
  52. return tmpl.replace(/\{\{(\w+)\}\}/g, function(m, $1) {
  53. return data[$1];
  54. });
  55. },
  56. //根据sd获取n天前的时间
  57. getBeforeDate = function(sd, n) {
  58. var n = n;
  59. var d = new Date(sd.replace(/\-/g, "/"));
  60. var year = d.getFullYear();
  61. var mon = d.getMonth() + 1;
  62. var day = d.getDate();
  63. if(day <= n) {
  64. if(mon > 1) {
  65. mon = mon - 1;
  66. } else {
  67. year = year - 1;
  68. mon = 12;
  69. }
  70. }
  71. d.setDate(d.getDate() - n);
  72. year = d.getFullYear();
  73. mon = d.getMonth() + 1;
  74. day = d.getDate();
  75. s = year + "-" + (mon < 10 ? ('0' + mon) : mon) + "-" + (day < 10 ? ('0' + day) : day);
  76. return s;
  77. };
  78. //上拉加载数据
  79. function pullUpAction(theScrollerTemp) {
  80. $(".pullUp").show();
  81. setTimeout(function() {
  82. loadListPromise();
  83. }, 1000);
  84. }
  85. function querySportList(page, pagesize, begindate, enddate, code) {
  86. //拼请求内容
  87. var params = {};
  88. params.page = page;
  89. params.pagesize = pagesize;
  90. params.start = begindate + " 00:00:00";
  91. params.end = enddate + " 23:59:59";
  92. params.patient = code;
  93. return new Promise(function(resolve, reject) {
  94. //发送ajax请求
  95. sendPost("doctor/health_record/list_medication", params, function(res) {
  96. resolve(res)
  97. console.log(res);
  98. plus.nativeUI.closeWaiting();
  99. }, function(res) {
  100. if(res.status == 200) {
  101. plus.nativeUI.closeWaiting();
  102. console.log(res);
  103. resolve(res)
  104. } else {
  105. queryListFailed(res);
  106. }
  107. });
  108. })
  109. }
  110. //上拉加载数据
  111. function pullUpAction(theScrollerTemp) {
  112. $(".pullUp").show();
  113. setTimeout(function() {
  114. loadData();
  115. }, 1000);
  116. }
  117. function loadData() {
  118. page++;
  119. Promise.all([
  120. querySportList(page, pagesize, getBeforeDate(begindate, 1000), begindate,patientCode)
  121. ])
  122. .then(function(res) {
  123. var data = res[0];
  124. $(".pullUp").hide();
  125. $('#no_result_wrap').hide()
  126. if (data.list.length > 0) {
  127. $xyList.append(template('xyTmp', {
  128. data: data.list
  129. }));
  130. $('j-control').show()
  131. scroller1.myScroll.refresh();
  132. } else {
  133. if(!isTrue) {
  134. $('#no_result_wrap').show()
  135. } else {
  136. mui.toast("暂无更多数据!");
  137. }
  138. }
  139. isTrue = true;
  140. })
  141. .catch(function(e) {
  142. console && console.error(e)
  143. });
  144. }