raise-card.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <!-- 时期卡片组件-->
  3. <view class="ui-card px-13">
  4. <!-- 选项框 -->
  5. <view class="row-end mb">
  6. <picker mode="date" fields="year" @change="changePestDate" class="picker mr">
  7. <view class="picker-wrapper">
  8. <view>{{pestDate}}</view>
  9. <uni-icons type="bottom" :size="12" color="#DDDDDD"></uni-icons>
  10. </view>
  11. </picker>
  12. <picker class="picker" @change="changePestList" :range="pestList">
  13. <view class="picker-wrapper">
  14. <view>{{pestItem}}</view>
  15. <uni-icons type="bottom" :size="12" color="#DDDDDD"></uni-icons>
  16. </view>
  17. </picker>
  18. </view>
  19. <!-- 时期列表 -->
  20. <view class="period-navs" v-if="pestInfo[pestItem]">
  21. <view class="period-item start-time">
  22. <view class="icon"></view>
  23. <view class="title">始见期</view>
  24. <view class="text">{{pestInfo[pestItem].startTime}}</view>
  25. <view class="text"></view>
  26. </view>
  27. <view class="period-item high-time">
  28. <view class="icon"></view>
  29. <view class="title">高峰期</view>
  30. <view class="text">{{pestInfo[pestItem].highTime}}</view>
  31. <view class="text">数量:{{pestInfo[pestItem].highNum}}</view>
  32. </view>
  33. <view class="period-item end-time">
  34. <view class="icon"></view>
  35. <view class="title">终见期</view>
  36. <view class="text">{{pestInfo[pestItem].endTime}}</view>
  37. <view class="text"></view>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. /**
  44. * 虫害始见期数据卡片
  45. */
  46. import {
  47. getPestRaiseInfo
  48. } from '@/api/worm.js'
  49. export default {
  50. name: 'w-raise-card',
  51. data() {
  52. return {
  53. pestList: [], //始见期选项
  54. pestInfo: {},
  55. pestDate: (new Date()).getUTCFullYear(),
  56. pestItem: '',
  57. }
  58. },
  59. props: {
  60. // 设备id
  61. deviceId: [String, Number]
  62. },
  63. mounted() {
  64. this.getPestRaiseInfo();
  65. },
  66. methods: {
  67. // 获取始见期数据
  68. async getPestRaiseInfo() {
  69. const res = await getPestRaiseInfo({
  70. year: this.pestDate,
  71. d_ids: this.deviceId,
  72. });
  73. this.pestList = res.pest_list; //始见期选项
  74. this.pestInfo = res.pest_info;
  75. this.pestItem = this.pestList[0];
  76. },
  77. // 选择年份
  78. changePestDate(e) {
  79. this.pestDate=e.detail.value;
  80. this.getPestRaiseInfo();
  81. },
  82. // 选择始见期类型
  83. changePestList(e) {
  84. this.pestItem = this.pestList[e.detail.value];
  85. },
  86. }
  87. };
  88. </script>
  89. <style lang="scss">
  90. // 时期样式
  91. .period-navs {
  92. display: flex;
  93. justify-content: space-between;
  94. }
  95. .period-item {
  96. width: 200rpx;
  97. height: 264rpx;
  98. padding: 122rpx 24rpx 24rpx;
  99. background: url('/static/img/startTime.png') center center no-repeat;
  100. background-size: 200rpx 264rpx;
  101. &.high-time {
  102. background-image: url('/static/img/highTime.png');
  103. }
  104. &.end-time {
  105. background-image: url('/static/img/endTime.png');
  106. }
  107. .title {
  108. font-size: 32rpx;
  109. font-weight: normal;
  110. color: #333333;
  111. line-height: 44rpx;
  112. }
  113. .text {
  114. margin-top: 10rpx;
  115. font-size: 24rpx;
  116. font-weight: normal;
  117. color: #999999;
  118. line-height: 34rpx;
  119. }
  120. }
  121. </style>