warn.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <!-- 测报灯预警信息 -->
  3. <view>
  4. <block v-for="(item,index) in warningList" :key="index">
  5. <view class="ui-card warn-item">
  6. <view class="title">{{item.ekey}}</view>
  7. <view class="subtitle">设备ID:{{item.device_id}}</view>
  8. <view class="paragraph">
  9. <text v-for="(val,key,i) in item.warning_content" :key="i">
  10. {{key+':'+val}},
  11. </text>
  12. </view>
  13. <text class="time">{{item.upltime | timeFrom}}</text>
  14. </view>
  15. </block>
  16. <ui-empty v-if="warningList.length==0" text="暂无预警信息"></ui-empty>
  17. </view>
  18. </template>
  19. <script>
  20. import {
  21. getPestWarningList
  22. } from '@/api/warning.js'
  23. export default {
  24. data() {
  25. return {
  26. // 预警列表
  27. warningList: [],
  28. params: {
  29. page: 1, //页数 默认为1
  30. page_size: 10, //数据条数据 默认为10
  31. },
  32. total: 0,
  33. }
  34. },
  35. onLoad(options) {
  36. this.getWarningList();
  37. },
  38. // 触底请求
  39. onReachBottom(e) {
  40. if (this.warningList.length >= this.total) {
  41. return;
  42. }
  43. this.params.page += 1;
  44. this.getWarningList();
  45. },
  46. methods: {
  47. // 获取设备列表
  48. async getWarningList() {
  49. this.$api.loading('加载中...');
  50. const {
  51. data,
  52. nusm
  53. } = await getPestWarningList(this.params);
  54. this.$api.hide();
  55. this.warningList = [...this.warningList, ...data];
  56. this.total = nusm ?? 0;
  57. },
  58. }
  59. }
  60. </script>
  61. <style lang="scss">
  62. .warn-item {
  63. padding: 26rpx 24rpx;
  64. .title {
  65. font-size: $font-size-title;
  66. color: $color-title;
  67. line-height: $line-height-title;
  68. }
  69. .subtitle {
  70. margin-top: 10rpx;
  71. font-size: $font-size-subtitle;
  72. color: $color-subtitle;
  73. line-height: $line-height-subtitle;
  74. }
  75. .paragraph {
  76. margin: 10rpx 0 18rpx;
  77. font-size: $font-size-paragraph;
  78. color: $color-paragraph;
  79. line-height: $line-height-paragraph;
  80. }
  81. .time {
  82. padding: 6rpx 15rpx;
  83. font-size: 28rpx;
  84. color: #317AFD;
  85. line-height: 1;
  86. background: rgba(49, 122, 253, .3);
  87. border-radius: 4rpx;
  88. }
  89. }
  90. </style>