baojinginfo.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. (function () {
  2. var page = {
  3. isScroll: false,
  4. init: function ($page,param) {
  5. $page.find('#toptab').toptab(['告警', '公告']).each(function (index) {
  6. var $this = $(this);
  7. switch (index) {
  8. case 0:
  9. var msg_html = '';
  10. msg_html += '\
  11. <div class="f-page-body f-scroll-wrapper">\
  12. <div class="f-scroll" style="overflow:auto;height: 100%;">\
  13. <div class="lr-list gaojinginfo">\
  14. </div>\
  15. </div>\
  16. <div class="f-scrollbar f-scrollbar-vertical">\
  17. <div class="f-scrollbar-indicator" style="transition-duration: 0ms; display: none; height: 830px; transform: translate3d(0px, 0px, 0px) translateZ(0px);">\
  18. </div>\
  19. </div>\
  20. </div>';
  21. $this.html(msg_html);
  22. //var baojing_info = '';
  23. userinfo = learun.storage.get('userinfo');
  24. learun.httpget(config.webapi + "/?s=api/get_baojing_info&plate="+userinfo.baseinfo.plate, {}, function(res) {
  25. if(res.success == true){
  26. var msg_html_list = '';
  27. $.each(res.data, function (_index, _item) {
  28. msg_html_list += '\
  29. <div class="lr-list-item lr-list-item-multi" style="line-height: 25px;">\
  30. <h4 id="time">'+ _item.AddTime +'</h4>\
  31. <p class="lr-ellipsis">'+ _item.LicensePlate +'<span class="" style="right: 15px;position: absolute;top: 50%;transform: translateY(-50%);">'+ _item.DeviceNumber +'</span></p>\
  32. <a class="lr-nav-right gaojingdetail">告警<span class="lr-badge lr-badge-primary lr-badge-inverted">详情</span></a>\
  33. </div>';
  34. $page.find('.gaojinginfo').html(msg_html_list);
  35. var addtime = $('#time').text();
  36. $('.gaojingdetail').on('tap', function () {
  37. learun.nav.go({ path: 'alarmdetail', title: '告警详情', type: 'right', param:'{"addtime":"'+addtime+'"}'});
  38. });
  39. });
  40. }else{
  41. msg_html += '<h4>暂无消息</h4>';
  42. $page.find('.gaojinginfo').html(msg_html);
  43. }
  44. });
  45. //msg_html += '';
  46. //刷新
  47. var pageobj = $('.gaojinginfo').lrpagination({
  48. lclass: "lr-list",
  49. rows: 10, // 每页行数
  50. getData: function (param, callback) {// 获取数据 param 分页参数,callback 异步回调
  51. // param: page: 当前页,rows:行数
  52. setTimeout(function () {
  53. var data = [];
  54. learun.httpget(config.webapi + "/?s=api/get_baojing_info&plate="+userinfo.baseinfo.plate, {}, function(res) {
  55. if(res.success == true){
  56. $.each(res.data, function (_index, _item) {
  57. data.push({ AddTime: _item.AddTime,LicensePlate: _item.LicensePlate,DeviceNumber:_item.DeviceNumber})
  58. })
  59. }
  60. })
  61. callback(data, 20);
  62. }, 1000);
  63. },
  64. renderData: function (_index, _item) {// 渲染数据模板
  65. console.log(_index);
  66. var _msg_html_list = '';
  67. _msg_html_list+= '\
  68. <div class="lr-list-item lr-list-item-multi" style="line-height: 25px;">\
  69. <h4 id="time">'+ _item.AddTime +'</h4>\
  70. <p class="lr-ellipsis">'+ _item.LicensePlate +'<span class="" style="right: 15px;position: absolute;top: 50%;transform: translateY(-50%);">'+ _item.DeviceNumber +'</span></p>\
  71. <a class="lr-nav-right gaojingdetail">告警<span class="lr-badge lr-badge-primary lr-badge-inverted">详情</span></a>\
  72. </div>';
  73. return _msg_html_list;
  74. },
  75. down: {
  76. contentinit: '下拉可以刷新',
  77. contentdown: '下拉可以刷新',
  78. contentover: '释放立即刷新',
  79. contentrefresh: '正在刷新...'
  80. },
  81. up: {
  82. contentinit: '上拉显示更多',
  83. contentdown: '上拉显示更多',
  84. contentrefresh: '正在加载...',
  85. contentnomore: '没有更多数据了'
  86. }
  87. });
  88. //刷新结束
  89. break;
  90. case 1:
  91. var msg_html = '';
  92. var msg_html = '';
  93. msg_html += '\
  94. <div class="f-page-body f-scroll-wrapper">\
  95. <div class="f-scroll" style="overflow:auto;height: 100%;">\
  96. <div class="lr-list gonggaoinfo">\
  97. </div>\
  98. </div>\
  99. <div class="f-scrollbar f-scrollbar-vertical">\
  100. <div class="f-scrollbar-indicator" style="transition-duration: 0ms; display: none; height: 830px; transform: translate3d(0px, 0px, 0px) translateZ(0px);">\
  101. </div>\
  102. </div>\
  103. </div>';
  104. $this.html(msg_html);
  105. //var baojing_info = '{"0":{"data":"1111","msg":"公告","time":"2/28"},"1":{"data":"2222","msg":"公告","time":"2/29"}}';
  106. userinfo = learun.storage.get('userinfo');
  107. learun.httpget(config.webapi + "/?s=api/get_gonggao_info&plate="+userinfo.baseinfo.plate, {}, function(res) {
  108. var msg_html_list = '';
  109. if(res.success == true){
  110. $.each(res.data, function (_index, _item) {
  111. msg_html_list += '\
  112. <div class="lr-list-item lr-list-item-multi" style="line-height: 25px;">\
  113. <h4 id="time">'+ _item.AddTime +'</h4>\
  114. <p class="lr-ellipsis">'+ _item.LicensePlate +'<span class="" style="right: 15px;position: absolute;top: 50%;transform: translateY(-50%);">'+ _item.DeviceNumber +'</span></p>\
  115. <a class="lr-nav-right gonggaodetail">公告<span class="lr-badge lr-badge-primary lr-badge-inverted">详情</span></a>\
  116. </div>';
  117. $page.find('.gonggaoinfo').html(msg_html_list);
  118. $('.gonggaodetail').on('tap', function () {
  119. var addtime = $('#time').text();
  120. learun.nav.go({ path: 'noticedetail', title: '公告详情', type: 'right', param:'{"addtime":"'+addtime+'"}'});
  121. });
  122. });
  123. }else{
  124. msg_html += '<h4>暂无消息</h4>';
  125. $page.find('.gonggaoinfo').html(msg_html);
  126. }
  127. });
  128. break;
  129. }
  130. $this = null;
  131. });
  132. }
  133. };
  134. return page;
  135. })();