homeWeatherBar.vue
3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<template>
<div class="box weatherLine">
<el-row :gutter="20" align="middle" style="height: 100%;">
<el-col :sm="24" :lg="10">
<!--天气-->
<div class="leftFlex">
<div class="smallToday">
<div class="type">
<weather-icon :type="weatherObj.forecast[0]?.type" :width="50"/>
</div>
<div class="wd_p">
<!-- {{ weatherObj.forecast[0]?.low.slice(2) }}~-->
{{ weatherObj.forecast[0]?.high.slice(2) }}
</div>
</div>
<div>{{ language ==0?'无锡':'Wuxi' }}</div>
<div>{{dayjs().month()<9?'0':''}}{{dayjs().month()+1}} / {{dayjs().date()}}</div>
<div v-if="language ==0">{{week[dayjs().day()]}}</div>
<div v-else>{{weekEn[dayjs().day()]}}</div>
<div class="forPc">{{dayjs().hour()<10?'0':''}}{{dayjs().hour()}}:{{dayjs().minute()<10?'0':''}}{{dayjs().minute()}}</div>
</div>
</el-col>
<el-col :sm="24" :lg="14">
<el-button round class="searchfw" @click="goSearch">
<el-icon class="mr20">
<Search/>
</el-icon>
{{ language ==0?'服务查询':'Service Query' }}
</el-button>
</el-col>
</el-row>
</div>
</template>
<script setup>
import {onMounted, ref} from "vue"
import useUserStore from '@/store/modules/user'
import WeatherIcon from '@/viewsPc/components/weatherIcon'
import {getWeather} from "@/apiPc/webSite"
import dayjs from "dayjs"
import router from "@/routerPc/en";
const language = ref('0')
const weatherObj = ref({
forecast:[]
})
const week = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六']
const weekEn = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']
const props = defineProps({
lang: {
type: String,
required: true,
default: '0'
}
})
onMounted(()=>{
if(useUserStore().weather == null){
init()
}
language.value = props.lang
})
function init(){
getWeather().then(res=>{
weatherObj.value = JSON.parse(res.data).data
useUserStore().setWeather(weatherObj.value)
})
}
function goSearch() {
router.push({path: '/serverSearch'})
}
</script>
<style scoped lang="scss">
.weatherLine {padding: 12px;
background: linear-gradient(90deg, #0557EC, #0540EC, #013499);
border-radius: 45px;
color: #fff;
}
.leftFlex{display: flex;align-items: center;justify-content: space-between;
> div{background: url("@/assets/dance/line.png") no-repeat right;width: 20%;
justify-content: center;
min-height: 56px;
display: flex;
align-items: center;}
.smallToday{
width: 30%;
.wd_p{font-size: 18px;}
}
}
.smallToday{display: flex;align-items: center;
.type{margin-right: 10px;}
h3{margin: 0 0 10px;}
}
.searchfw{width: 100%;height:65px;border-radius: 100px;font-size: 24px;}
@media screen and (max-width: 768px) {
.forPc{display: none;}
.weatherLine{border-radius: 15px}
.leftFlex {margin-bottom: 15px;
.smallToday{width: 40%;
}
}
.leftFlex > div{font-size: 12px; width: 15%;}
.searchfw{font-size: 18px;height: 40px;}
}
</style>