yinshi-view.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. $popMain = $('.pop-main'),
  23. $xtAdd = $('.xt-add'),
  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. function changeTabCon() {
  79. var qsv = $qushiView.css('display'),
  80. lbv = $liebiaoView.css('display');
  81. if(qsv === 'block') {
  82. lbv.hide();
  83. }
  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_diet", params, function(res) {
  96. resolve(res)
  97. console.log(res);
  98. plus.nativeUI.closeWaiting();
  99. console.log('2');
  100. }, function(res) {
  101. console.log('3');
  102. plus.nativeUI.closeWaiting();
  103. console.log(res);
  104. if(res.status == 200) {
  105. resolve(res)
  106. } else {
  107. queryListFailed(res);
  108. }
  109. });
  110. })
  111. }
  112. //上拉加载数据
  113. function pullUpAction(theScrollerTemp) {
  114. $(".pullUp").show();
  115. setTimeout(function() {
  116. loadData();
  117. }, 1000);
  118. }
  119. function loadData() {
  120. page++;
  121. Promise.all([
  122. querySportList(page, pagesize, getBeforeDate(begindate, 1000), begindate, patientCode)
  123. ])
  124. .then(function(res) {
  125. $(".pullUp").hide();
  126. var data = res[0];
  127. if (data.list.length > 0) {
  128. $xyList.append(template('xyTmp', {
  129. data: data.list
  130. }));
  131. $('#no_result_wrap').hide()
  132. $('.j-control').show()
  133. scroller1.myScroll.refresh();
  134. } else {
  135. if(!isTrue) {
  136. $('#no_result_wrap').show()
  137. $('.j-control').hide()
  138. } else {
  139. mui.toast("暂无更多数据!");
  140. }
  141. }
  142. isTrue = true;
  143. })
  144. .catch(function(e) {
  145. console && console.error(e)
  146. });
  147. }