Browse Source

feat: 更新天气组件以显示温度范围并修正活动计数显示逻辑

ShangHai_LongXiang
jiannibang 1 year ago
parent
commit
02fb18a0ac
  1. 2
      src/base/Temperature/Temperature.vue
  2. 4
      src/components/PublicComponent/Tabs.vue
  3. 6
      src/composables/useWeather.js

2
src/base/Temperature/Temperature.vue

@ -1,6 +1,6 @@
<template>
<div class="Temperature-wrapper">
<div class="temperature">{{ weather.temperature_Now }}°</div>
<div class="temperature">{{ weather.temperatureLow }}~{{ weather.temperatureHigh }}°</div>
<i class="iconfont weather-icon" :class="icon.icon"></i>
</div>
</template>

4
src/components/PublicComponent/Tabs.vue

@ -1,9 +1,9 @@
<template>
<div class="tabs" v-if="menuList.find(({ routePath }) => routePath === path)">
<div :class="['item', tab.routePath === path ? 'active' : '']" v-for="(tab, i) of menuList" :key="tab.moduleCode" @click="goPage(tab)">
<div :class="['item', tab.routePath === path ? 'active' : '']" v-for="tab of menuList" :key="tab.moduleCode" @click="goPage(tab)">
<div class="icon"><img :src="theme.images[tab.routePath.slice(1)]" /></div>
<div class="title">{{ tab.moduleName }}</div>
<div class="count" v-if="i === 0 && activityCount">{{ activityCount }}</div>
<div class="count" v-if="tab.routePath === '/activity' && activityCount">{{ activityCount }}</div>
</div>
</div>
</template>

6
src/composables/useWeather.js

@ -10,7 +10,11 @@ export const useWeather = () => {
{ icon: 'icon-duoyunzhuanyin', status: '阴' }
]
const store = useStore()
const weather = computed(() => ({ temperature_Now: store.indexList.temperatureNow, status: store.indexList.weather }))
const weather = computed(() => ({
temperatureLow: Math.floor(Number(store.indexList.temperatureLow)),
temperatureHigh: Math.floor(Number(store.indexList.temperatureHigh)),
status: store.indexList.weather
}))
const icon = computed(() => status.find(item => weather.value?.status?.includes(item.status)) ?? status[0])
return { weather, icon }

Loading…
Cancel
Save