myBody-info.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. var Request = GetRequest();
  3. $(function(){
  4. checkUserAgent();
  5. var isLoad=false,
  6. dayNum = 7,
  7. page = 0,
  8. pagesize = 10;
  9. var scroller = new IScrollPullUpDown('wrapper',{
  10. probeType:2,
  11. bounceTime: 250,
  12. bounceEasing: 'quadratic',
  13. mouseWheel:false,
  14. scrollbars:true,
  15. click:true,
  16. fadeScrollbars:true,
  17. interactiveScrollbars:false
  18. },null,pullUpAction);
  19. var norTime = decodeURIComponent(Request["dateT"]),
  20. begindate = decodeURIComponent(Request["dateT"]),
  21. enddate = getDateFromCurrentDate(begindate);
  22. loadListPromise();
  23. //上拉加载数据
  24. function pullUpAction(theScrollerTemp) {
  25. $(".pullUp").show();
  26. setTimeout(function () {
  27. loadListPromise();
  28. }, 1000);
  29. }
  30. template.helper('toStatus', function(v){
  31. if(v==60){return 'waiting'}
  32. if(v==65 || v==61 || v==62 || v==69){return 'transport'}
  33. if(v==100){return 'finish'}
  34. })
  35. $(".div-add-btn").click(function(){
  36. window.open('health-index-add-weight.html?dateT='+norTime);
  37. });
  38. function queryInit(type,begindate,enddate,page,pagesize){
  39. var data = {
  40. type:type,
  41. page:page,
  42. pagesize:pagesize,
  43. start :begindate+" 00:00:00",
  44. end:enddate+" 23:59:59"
  45. };
  46. console.log(begindate);
  47. console.log(enddate);
  48. return new Promise(function(resolve, reject) {
  49. //发送ajax请求
  50. sendPost("patient/health_index/list", data, "json", "post", queryListFailed, function (res) {
  51. d.close();
  52. if (res.status == 200) {
  53. resolve(res)
  54. } else {
  55. queryListFailed(res);
  56. }
  57. });
  58. })
  59. }
  60. function loadListPromise () {
  61. page++;
  62. Promise.all([
  63. queryInit(3, getDateFromCurrentDate(norTime),norTime,page,pagesize)
  64. ])
  65. .then(function(res) {
  66. $(".pullUp").hide();
  67. var data = res[0];
  68. if (data.list.length > 0) {
  69. $('#j-card-list').append(template('list_tmp',{data:data.list}));
  70. scroller.myScroll.refresh();
  71. } else {
  72. if(!isLoad) {
  73. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'暂无数据'}).show();
  74. } else {
  75. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'暂无更多数据'}).show();
  76. }
  77. }
  78. isLoad = true;
  79. })
  80. .catch(function(e) {
  81. console && console.error(e)
  82. });
  83. }
  84. //失败提示
  85. function queryListFailed(res){
  86. d.close();
  87. if (res && res.msg) {
  88. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  89. } else {
  90. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
  91. }
  92. }
  93. })
  94. //根据sd获取n天前的时间;
  95. function getDateFromCurrentDate(fromDate){
  96. var curDate = new Date(Date.parse(fromDate.replace(/-/g,"/")));
  97. curDate.setDate(curDate.getDate());
  98. var year = curDate.getFullYear()-1;
  99. var month = (curDate.getMonth()+1)<10?"0"+(curDate.getMonth()+1):(curDate.getMonth()+1);
  100. var day = curDate.getDate()<10?"0"+curDate.getDate():curDate.getDate();
  101. console.log(year+"-"+month+"-"+day);
  102. return year+"-"+month+"-"+day;
  103. };