yundong-view.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. $xtAdd = $('.xt-add'),
  20. $btns = $('.btns'),
  21. $cancelBtn = $('.cancel-btn'),
  22. $okBtn = $('.ok-btn'),
  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. console.log(1);
  50. loadData();
  51. });
  52. var render = function(tmpl, data) {
  53. return tmpl.replace(/\{\{(\w+)\}\}/g, function(m, $1) {
  54. return data[$1];
  55. });
  56. },
  57. //根据sd获取n天前的时间
  58. getBeforeDate = function(sd, n) {
  59. var n = n;
  60. var d = new Date(sd.replace(/\-/g, "/"));
  61. var year = d.getFullYear();
  62. var mon = d.getMonth() + 1;
  63. var day = d.getDate();
  64. if(day <= n) {
  65. if(mon > 1) {
  66. mon = mon - 1;
  67. } else {
  68. year = year - 1;
  69. mon = 12;
  70. }
  71. }
  72. d.setDate(d.getDate() - n);
  73. year = d.getFullYear();
  74. mon = d.getMonth() + 1;
  75. day = d.getDate();
  76. s = year + "-" + (mon < 10 ? ('0' + mon) : mon) + "-" + (day < 10 ? ('0' + day) : day);
  77. return s;
  78. };
  79. function changeTabCon() {
  80. var qsv = $qushiView.css('display'),
  81. lbv = $liebiaoView.css('display');
  82. if(qsv === 'block') {
  83. lbv.hide();
  84. }
  85. }
  86. //加载运动记录
  87. function querySportList(page, pagesize, begindate, enddate,code) {
  88. //拼请求内容
  89. var params = {};
  90. params.page = page;
  91. params.pagesize = pagesize;
  92. params.start = begindate + " 00:00:00";
  93. params.end = enddate + " 23:59:59";
  94. params.patient = code;
  95. return new Promise(function(resolve, reject) {
  96. //发送ajax请求
  97. sendPost("doctor/health_record/list_sports", params, function(res) {
  98. resolve(res)
  99. console.log(res);
  100. plus.nativeUI.closeWaiting();
  101. }, function(res) {
  102. plus.nativeUI.closeWaiting();
  103. if(res.status == 200) {
  104. resolve(res)
  105. } else {
  106. queryListFailed(res);
  107. }
  108. });
  109. })
  110. }
  111. //上拉加载数据
  112. function pullUpAction(theScrollerTemp) {
  113. $(".pullUp").show();
  114. setTimeout(function() {
  115. loadData();
  116. }, 1000);
  117. }
  118. function loadData() {
  119. page++;
  120. Promise.all([
  121. querySportList(page, pagesize, getBeforeDate(begindate, 1000), begindate,patientCode)
  122. ])
  123. .then(function(res) {
  124. var data = res[0];
  125. $(".pullUp").hide();
  126. if (data.list.length > 0) {
  127. $xyList.append(template('xyTmp', {
  128. data: data.list
  129. }));
  130. $('#no_result_wrap').hide()
  131. $('.j-control').show()
  132. scroller1.myScroll.refresh();
  133. } else {
  134. if(!isTrue) {
  135. $('.j-control').hide()
  136. $('#no_result_wrap').show()
  137. } else {
  138. mui.toast("暂无更多数据!");
  139. }
  140. }
  141. isTrue = true;
  142. })
  143. .catch(function(e) {
  144. console && console.error(e)
  145. });
  146. }