warn.vue 2.0 KB

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