TASK:110956 添加天气状态空气质量传值时判断逻辑

This commit is contained in:
lvxiangcong 2022-10-26 11:19:30 +08:00
parent f90b00640e
commit 8d01cd5309
2 changed files with 22 additions and 5 deletions

View File

@ -105,8 +105,7 @@ export class StarWeather extends LitElement {
<span class="detail-today-item-top"></span>
<span class="detail-today-item-bottom">
${(this.dataBoo() &&
this.data.weatherInfo[0]?.airQuality?.value +
this.data.weatherInfo[0]?.airQuality?.type) ||
this.fun(this.data.weatherInfo[0]?.airQuality?.value)) ||
''}
</span>
</span>
@ -175,7 +174,7 @@ export class StarWeather extends LitElement {
</span>
<span>
${(this.dataBoo() &&
this.data.weatherInfo[0]?.airQuality?.type) ||
this.fun(this.data.weatherInfo[0]?.airQuality?.value)) ||
''}
</span>
</span>
@ -246,6 +245,25 @@ export class StarWeather extends LitElement {
this.resize()
})
}
fun(value: any) {
let airQualityType = ''
if (value > 0 && value <= 50) {
airQualityType = '优'
} else if (value <= 100) {
airQualityType = '良'
} else if (value <= 150) {
airQualityType = '轻度污染'
} else if (value <= 200) {
airQualityType = '中度污染'
} else if (value <= 300) {
airQualityType = '重度污染'
} else if (value > 300) {
airQualityType = '严重污染'
} else {
airQualityType = 'null'
}
return airQualityType
}
protected resize() {
let width = this.starWeather?.clientWidth || 10
let height = this.starWeather?.clientHeight || 10

View File

@ -18,8 +18,7 @@ export const weatherData = {
humidity: '40%',
airQuality: {
label: '空气质量',
value: '26',
type: '优',
value: '400',
},
somatosensoryTemperature: '32°C',
visibility: '33km',