baojinginfo.js 6.3 KB

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