1、引入相关天气图标

2、前端右上角天气显示实现以及点击预报天气实现
pull/254/head
xjs 4 years ago
parent 6b76d35abf
commit b898b9feb1

@ -0,0 +1,18 @@
import request from '@/utils/request'
//获取实时天气
export function getNowWeather() {
return request({
url: '/openapi/weather/now',
method: 'get'
})
}
//获取预报天气
export function getForecastWeather() {
return request({
url: '/openapi/weather/forecast',
method: 'get'
})
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

@ -9,6 +9,67 @@
<div class="right-menu"> <div class="right-menu">
<!--天气-->
<el-popover
placement="top"
width="400"
v-model="weatherVisible">
<table style="text-align: center">
<td v-for="(cast,index) in forecastWeatherData.casts" width="100px">
<tr>{{cast.dayweather}}</tr>
<tr>
{{cast.nighttemp+"℃~"+cast.daytemp+"℃"}}
</tr>
<tr v-if="index===0">
今天
</tr>
<tr v-if="index===1">
明天
</tr>
<tr v-if="index===2">
后天
</tr>
<tr v-if="index===3">
大后天
</tr>
<tr v-if="cast.week==='1'">
星期一
</tr>
<tr v-if="cast.week==='2'">
星期二
</tr>
<tr v-if="cast.week==='3'">
星期三
</tr>
<tr v-if="cast.week==='4'">
星期四
</tr>
<tr v-if="cast.week==='5'">
星期五
</tr>
<tr v-if="cast.week==='6'">
星期六
</tr>
<tr v-if="cast.week==='7'">
星期日
</tr>
</td>
</table>
<div class="right-menu-item weather" @click="getForecastWeather()" slot="reference">
<img :src="weather" class="img">
<span class="span1">
{{ nowWeatherData.temperature + "℃" }}
</span>
<span class="span2">
{{ nowWeatherData.weather }}
</span>
</div>
</el-popover>
<!--预警-->
<el-badge :value="warnData.count" class=" hover-effect share-button" v-hasPermi="['warning:warning:handle']"> <el-badge :value="warnData.count" class=" hover-effect share-button" v-hasPermi="['warning:warning:handle']">
<el-popover <el-popover
placement="bottom" placement="bottom"
@ -18,13 +79,12 @@
<div style="text-align: right; margin: 0"> <div style="text-align: right; margin: 0">
<el-button type="primary" size="mini" @click="haveRead"></el-button> <el-button type="primary" size="mini" @click="haveRead"></el-button>
</div> </div>
<el-button type="warning" icon="el-icon-check" <el-button type="info" icon="el-icon-check"
circle style="max-width: 22px;max-height: 22px;" circle style="max-width: 22px;max-height: 22px;"
@click="" @click=""
slot="reference" slot="reference"
></el-button> ></el-button>
</el-popover> </el-popover>
</el-badge> </el-badge>
<template v-if="device!=='mobile'"> <template v-if="device!=='mobile'">
@ -70,6 +130,9 @@ import Search from '@/components/HeaderSearch'
import RuoYiGit from '@/components/RuoYi/Git' import RuoYiGit from '@/components/RuoYi/Git'
import RuoYiDoc from '@/components/RuoYi/Doc' import RuoYiDoc from '@/components/RuoYi/Doc'
import {handleWarning} from "@/api/business/warning/apiwarning"; import {handleWarning} from "@/api/business/warning/apiwarning";
import {getNowWeather, getForecastWeather} from "@/api/business/openapi/weather";
import weather from "@/assets/icons/weather/天气.png"
export default { export default {
@ -86,9 +149,18 @@ export default {
data() { data() {
return { return {
//
warnData: {}, warnData: {},
//
nowWeatherData: {},
//
forecastWeatherData: {},
visible: false, visible: false,
weatherVisible:false,
weather,
} }
}, },
@ -126,7 +198,27 @@ export default {
this.$bus.$on('clearCount', this.clearCount) this.$bus.$on('clearCount', this.clearCount)
}, },
created() {
this.getNowWeather()
},
methods: { methods: {
//
getForecastWeather() {
console.log("点击了")
getForecastWeather().then(res => {
this.forecastWeatherData = res.data
})
},
//
getNowWeather() {
getNowWeather().then(res => {
this.nowWeatherData = res.data
})
},
// //
clearCount(data) { clearCount(data) {
if (data) { if (data) {
@ -195,10 +287,37 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.weather {
width: 120px;
margin-right: 10px;
cursor: pointer;
}
.weather img {
margin-top: 10px;
margin-left: 5px;
width: 30px;
height: 30px;
float: left;
}
.span1 {
float: left;
margin-left: 5px;
font-size: 14px;
}
.span2 {
float: left;
margin-left: 10px;
font-size: 14px;
}
.share-button { .share-button {
margin-right: 23px; margin-right: 5px;
color: #5a5e66; color: #5a5e66;
padding-bottom: 22px; padding-bottom: 23px;
&.hover-effect { &.hover-effect {
cursor: pointer; cursor: pointer;

Loading…
Cancel
Save