warn.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. const {
  50. data,
  51. nusm
  52. } = await getPestWarningList(this.params);
  53. this.warningList = [...this.warningList, ...data];
  54. this.total = nusm ?? 0;
  55. },
  56. }
  57. }
  58. </script>
  59. <style lang="scss">
  60. .warn-item {
  61. padding: 26rpx 24rpx;
  62. .title {
  63. font-size: $font-size-title;
  64. color: $color-title;
  65. line-height: $line-height-title;
  66. }
  67. .subtitle {
  68. margin-top: 10rpx;
  69. font-size: $font-size-subtitle;
  70. color: $color-subtitle;
  71. line-height: $line-height-subtitle;
  72. }
  73. .paragraph {
  74. margin: 10rpx 0 18rpx;
  75. font-size: $font-size-paragraph;
  76. color: $color-paragraph;
  77. line-height: $line-height-paragraph;
  78. }
  79. .time {
  80. padding: 6rpx 15rpx;
  81. font-size: 28rpx;
  82. color: #317AFD;
  83. line-height: 1;
  84. background: rgba(49, 122, 253, .3);
  85. border-radius: 4rpx;
  86. }
  87. }
  88. </style>