baojinginfo.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. (function () {
  2. var page = {
  3. isScroll: false,
  4. init: function ($page,param) {
  5. var url = '/?s=api/get_baojing_info&plate=';
  6. var pageobj = $('#gaojinginfo').lrpagination({
  7. lclass: "lr-list",
  8. rows: 10,
  9. // 每页行数
  10. getData: function (param, callback) {// 获取数据 param 分页参数,callback 异步回调
  11. // param: page: 当前页,rows:行数
  12. setTimeout(function () {
  13. var data = [];
  14. var count = 0;
  15. var page = param.page-1;
  16. renlian.httpget(config.webapi + url + userinfo.baseinfo.plate+'&pagesize='+param.rows+'&page='+page+'&cityid='+userinfo.baseinfo.cityid, {}, function(res) {
  17. var length = 0;
  18. //console.log(res);
  19. if(res.success == true){
  20. length = res.data.length;
  21. for (var i = 0; i < length; i++) {
  22. // $.each(res.data, function (_index, _item) {
  23. if(res.data[i].Type != '9'){
  24. data.push({ ID: res.data[i].ID,AddTime: res.data[i].AddTime,LicensePlate: res.data[i].LicensePlate,DeviceNumber:res.data[i].DeviceNumber, Title:res.data[i].Title,Type:res.data[i].Type})
  25. }else{
  26. data.push({ ID: res.data[i].ID,AddTime: res.data[i].AddTime,Title:res.data[i].Title,Type:res.data[i].Type})
  27. }
  28. // })
  29. count = (param.page-1) * param.rows + i + 1;
  30. }
  31. }
  32. if(page === 0 && data.length === 0){
  33. $('#no-message').show();
  34. }else{
  35. $('#no-message').hide();
  36. }
  37. callback(data, count+1);
  38. })
  39. }, 300);
  40. },
  41. renderData: function (_index, _item) {// 渲染数据模板
  42. //console.log(_item);
  43. var _msg_html_list = '';
  44. if(_item.Type=='9'){//公告类型
  45. _msg_html_list+= '\
  46. <div class="lr-list-item lr-list-item-multi" style="line-height: 25px;">\
  47. <h4 id="time">'+ _item.AddTime +'</h4>\
  48. <a class="lr-nav-right" id="gaojingdetail'+_item.AddTime+'">'+_item.Title+'<span class="lr-badge lr-badge-primary lr-badge-inverted">详情</span></a>\
  49. </div>';
  50. }else{//其他告警类型
  51. _msg_html_list+= '\
  52. <div class="lr-list-item lr-list-item-multi" style="line-height: 25px;">\
  53. <h4 id="time">'+ _item.AddTime +'</h4>\
  54. <p class="lr-ellipsis">'+ _item.LicensePlate +'<span class="" style="right: 15px;position: absolute;top: 50%;transform: translateY(-50%);">'+ (_item.DeviceNumber || "无标签") +'</span></p>\
  55. <a class="lr-nav-right" id="gaojingdetail'+_item.AddTime+'">'+_item.Title+'<span class="lr-badge lr-badge-primary lr-badge-inverted">详情</span></a>\
  56. </div>';
  57. }
  58. // $('#gaojingdetail'+_item.AddTime).on('tap', function () {
  59. // renlian.nav.go({ path: 'alarmdetail', title: '告警详情', type: 'right', param:'{"addtime":"'+_item.Addtime+'"}'});
  60. // });
  61. return _msg_html_list;
  62. },
  63. click: function(item, $item){
  64. if(item.Type != '9'){
  65. renlian.nav.go({ path: 'alarmdetail', title: '告警详情', type: 'right', param:'{"ID":"'+item.ID+'"}'});
  66. }else{
  67. renlian.nav.go({ path: 'articledetail', title: '公告详情', type: 'right', param:'{"ID":"'+item.ID+'"}'});
  68. }
  69. },
  70. down: {
  71. contentinit: '下拉可以刷新',
  72. contentdown: '下拉可以刷新',
  73. contentover: '释放立即刷新',
  74. contentrefresh: '正在刷新...'
  75. },
  76. up: {
  77. contentinit: '上拉显示更多',
  78. contentdown: '上拉显示更多',
  79. contentrefresh: '正在加载...',
  80. contentnomore: '没有更多数据了'
  81. }
  82. });
  83. var pullrefresh = function(index){
  84. if(Number(index) === 0){
  85. url = '/?s=api/get_baojing_info&plate=';
  86. }else{
  87. url = '/?s=api/get_article_info&plate=';
  88. // url = '/?s=api/get_baojing_info&plate=';
  89. }
  90. pageobj.reload();
  91. // return pageobj;
  92. }
  93. userinfo = renlian.storage.get('userinfo');
  94. $page.find('#toptab').rltoptab(['告警', '公告'], pullrefresh ).each(function (index) {
  95. var $this = $(this);
  96. switch (index) {
  97. case 0:
  98. break;
  99. case 1:
  100. break;
  101. }
  102. $this = null;
  103. });
  104. }
  105. };
  106. return page;
  107. })();