| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <template>
- <view class="pest-discern">
- <view class="pest-discern__header">
- <view class="pest-discern__title">
- 虫害识别
- </view>
- </view>
- <view class="pest-discern__content">
- <view class="pest-discern__item" v-for="(item,index) in pests" :key="index">
- <view class="pest-discern__item-title">
- {{ item.name }}
- </view>
- <view class="pest-discern__item-content">
- <u-line-progress :active-color="item.color" :percent="item.percent" :show-percent="false" height="8"></u-line-progress>
- </view>
- <view class="pest-discern__item-count">
- {{ total }}
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- props: {
- total: {
- type: Number,
- default: 0
- },
- pest_order: {
- type: Object,
- default: () => ({})
- }
- },
- watch:{
- pest_order:{
- handler(val){
- this.pests = [];
- let index = 0;
- for(let key in val){
- index++;
- this.pests.push({
- color: this.colors[index],
- name: key,
- percent: (val[key] / this.total) * 100
- })
- }
- },
- deep: true
- }
- },
- data() {
- return {
- colors:[
- '#FF5951',
- '#66EDED',
- '#E67B3E',
- '#6DE28B',
- '#FFC97A',
- '#E7EB4B',
- '#1561F3',
- '#FA73F5',
- '#159AFF',
- '#FA73F5'
- ],
- pests: []
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .pest-discern {
- width: 100%;
- padding: 32rpx;
- box-sizing: border-box;
- background: #fff;
- border-radius: 16rpx;
- }
- .pest-discern__header {
- padding: 20rpx 0rpx;
- font-size: 32rpx;
- color: #042118;
- font-family: 'Source Han Sans CN VF';
- font-weight: 700;
- }
- .pest-discern__title {
- font-size: 32rpx;
- color: #042118;
- font-family: 'Source Han Sans CN VF';
- font-weight: 700;
- }
- .pest-discern__item {
- display: flex;
- width: 100%;
- margin-bottom: 20rpx;
- align-items: center;
- .pest-discern__item-title{
- width: 120rpx;
- font-size: 28rpx;
- color: #042118;
- font-family: 'Source Han Sans CN VF';
- font-weight: 400;
- // 超出隐藏
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .pest-discern__item-content{
- flex: 1;
- margin: 0 20rpx;
- }
- .pest-discern__item-count{
- width: 80rpx;
- font-size: 28rpx;
- color: #042118;
- text-align: right;
- }
- }
- </style>
|