|
@@ -3,7 +3,28 @@
|
|
|
<div class="main-title">{{title}}</div>
|
|
|
<div class="main-left">
|
|
|
<!-- 天气 -->
|
|
|
- <div v-show="isHome" class="main-home" @click="showWeather = true">天气</div>
|
|
|
+ <div v-show="isHome" class="main-home" @click="showWeather = true">
|
|
|
+ <div class="weatherBox" v-if="Object.keys(weather).length !== 0">
|
|
|
+ <div class="box-left">
|
|
|
+ <i class="qing" v-if="weather.day_weather === '晴'"></i>
|
|
|
+ <i class="duoyun" v-else-if="weather.day_weather === '多云'"></i>
|
|
|
+ <i class="yin" v-else-if="weather.day_weather === '阴'"></i>
|
|
|
+ <i class="xiaoyu" v-else-if="weather.day_weather === '小雨'"></i>
|
|
|
+ <i class="zyu" v-else-if="weather.day_weather === '中雨'"></i>
|
|
|
+ <i class="dyu" v-else-if="weather.day_weather === '大雨'"></i>
|
|
|
+ <i class="byu" v-else-if="weather.day_weather === '暴雨'"></i>
|
|
|
+ <i class="xxue" v-else-if="weather.day_weather === '小雪'"></i>
|
|
|
+ <i class="zxue" v-else-if="weather.day_weather === '中雪'"></i>
|
|
|
+ <i class="dxue" v-else-if="weather.day_weather === '大雪'"></i>
|
|
|
+ <i class="bxue" v-else-if="weather.day_weather === '暴学'"></i>
|
|
|
+ </div>
|
|
|
+ <div class="box-right">
|
|
|
+ <p class="fontSize">{{weather.day_weather}}</p>
|
|
|
+ <p class="fontSize">{{weather.min_degree}}-{{weather.max_degree}}℃</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-else @click="refresh">抓取天气数据失败,请重试</div>
|
|
|
+ </div>
|
|
|
<!-- 返回首页 -->
|
|
|
<div v-show="!isHome" class="main-back" @click="back">首页</div>
|
|
|
</div>
|
|
@@ -11,24 +32,48 @@
|
|
|
<!-- 时间 -->
|
|
|
<div v-show="isHome" class="main-time">{{currentTime}}</div>
|
|
|
<!-- 天气 -->
|
|
|
- <div v-show="!isHome" class="main-home">天气</div>
|
|
|
+ <div v-show="!isHome" class="main-home">
|
|
|
+ <div class="weatherBox" v-if="Object.keys(weather).length !== 0">
|
|
|
+ <div class="box-left">
|
|
|
+ <i class="qing" v-if="weather.day_weather === '晴'"></i>
|
|
|
+ <i class="duoyun" v-else-if="weather.day_weather === '多云'"></i>
|
|
|
+ <i class="yin" v-else-if="weather.day_weather === '阴'"></i>
|
|
|
+ <i class="xiaoyu" v-else-if="weather.day_weather === '小雨'"></i>
|
|
|
+ <i class="zyu" v-else-if="weather.day_weather === '中雨'"></i>
|
|
|
+ <i class="dyu" v-else-if="weather.day_weather === '大雨'"></i>
|
|
|
+ <i class="byu" v-else-if="weather.day_weather === '暴雨'"></i>
|
|
|
+ <i class="xxue" v-else-if="weather.day_weather === '小雪'"></i>
|
|
|
+ <i class="zxue" v-else-if="weather.day_weather === '中雪'"></i>
|
|
|
+ <i class="dxue" v-else-if="weather.day_weather === '大雪'"></i>
|
|
|
+ <i class="bxue" v-else-if="weather.day_weather === '暴学'"></i>
|
|
|
+ </div>
|
|
|
+ <div class="box-right">
|
|
|
+ <p class="fontSize">{{weather.day_weather}}</p>
|
|
|
+ <p class="fontSize">{{weather.min_degree}}-{{weather.max_degree}}℃</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-else @click="refresh">抓取天气数据失败,请重试</div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<div class="main-bottom">青莲食品</div>
|
|
|
<div class="content">
|
|
|
<router-view></router-view>
|
|
|
</div>
|
|
|
<transition name = "moveL">
|
|
|
- <div id="weather" v-show="showWeather">
|
|
|
+ <div id="weather" v-if="showWeather">
|
|
|
<div style="text-align: left">
|
|
|
- <i class="el-icon-back" style="font-size: 24px; color: #fff" @click="showWeather = false"></i>
|
|
|
+ <i class="el-icon-back" style="font-size: 24px; color: #fff; cursor: pointer" @click="showWeather = false"></i>
|
|
|
</div>
|
|
|
- <iframe style="height: 400px" src="static/weather/index.html" frameborder="0"></iframe>
|
|
|
+ <iframe style="width: 800px; height: 800px; z-index: 9999" src="static/weather/index.html" frameborder="0"></iframe>
|
|
|
</div>
|
|
|
</transition>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import {getFarmId, getWeather} from "@/utils/api";
|
|
|
+import { mapActions } from 'vuex'
|
|
|
+
|
|
|
export default {
|
|
|
name: "MainLayout",
|
|
|
data() {
|
|
@@ -37,7 +82,10 @@ export default {
|
|
|
isHome: true,
|
|
|
currentTime: '',
|
|
|
timer4: null,
|
|
|
- showWeather: false
|
|
|
+ showWeather: false,
|
|
|
+ weather: {},
|
|
|
+ // 天气报警
|
|
|
+ weatherInfo: {}
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
@@ -55,6 +103,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ ...mapActions(['GetFarm', 'setFarmIdAsync']),
|
|
|
initTime() {
|
|
|
var _this = this;
|
|
|
this.timer4 = setInterval(function() {
|
|
@@ -85,9 +134,29 @@ export default {
|
|
|
},
|
|
|
back() {
|
|
|
this.$router.push('/')
|
|
|
+ },
|
|
|
+ init() {
|
|
|
+ getFarmId().then(res => {
|
|
|
+ if(res.code === 10000) {
|
|
|
+ this.setFarmIdAsync(res.data);
|
|
|
+ localStorage.setItem('lastFarmId', res.data);
|
|
|
+ this.refresh()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 刷新拿到数据
|
|
|
+ refresh() {
|
|
|
+ getWeather({}).then(res => {
|
|
|
+ if(res.code === 10000) {
|
|
|
+ this.weather = res.data;
|
|
|
+ this.weatherInfo = JSON.parse(res.data.alarm)
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
+ this.init()
|
|
|
+ this.GetFarm()
|
|
|
this.title = this.$route.meta.title;
|
|
|
if (this.$route.name === 'Home') {
|
|
|
this.isHome = true;
|
|
@@ -186,7 +255,8 @@ export default {
|
|
|
#weather {
|
|
|
background-color: rgba(0, 0, 0, .5);
|
|
|
position: absolute;
|
|
|
- height: 450px;
|
|
|
+ width: 800px;
|
|
|
+ height: 800px;
|
|
|
top: 0;
|
|
|
left: 0;
|
|
|
}
|
|
@@ -202,4 +272,107 @@ export default {
|
|
|
.moveL-leave-to {
|
|
|
transform: translateX(-100%);
|
|
|
}
|
|
|
+ .weatherBox {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 0 20px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+ .box-left {
|
|
|
+ width: 35px;
|
|
|
+ height: 35px;
|
|
|
+ }
|
|
|
+ .box-right {
|
|
|
+ width: 60px;
|
|
|
+ height: 100%;
|
|
|
+ margin-left: 20px;
|
|
|
+ }
|
|
|
+ .qing {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: inline-block;
|
|
|
+ background: url("../assets/weather/qingtian.png") no-repeat;
|
|
|
+ background-size: 100% 100%;
|
|
|
+ }
|
|
|
+ .fontSize {
|
|
|
+ height: 20px;
|
|
|
+ margin: 0;
|
|
|
+ line-height: 20px;
|
|
|
+ text-align: left;
|
|
|
+ color: #28BCCA;
|
|
|
+ }
|
|
|
+ .duoyun {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: inline-block;
|
|
|
+ background: url("../assets/weather/qingzhuanduoyun.png") no-repeat;
|
|
|
+ background-size: 100% 100%;
|
|
|
+ }
|
|
|
+ .yin {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: inline-block;
|
|
|
+ background: url("../assets/weather/yintian.png") no-repeat;
|
|
|
+ background-size: 100% 100%;
|
|
|
+ }
|
|
|
+ .xiaoyu {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: inline-block;
|
|
|
+ background: url("../assets/weather/xiaoyu.png") no-repeat;
|
|
|
+ background-size: 100% 100%;
|
|
|
+ }
|
|
|
+ .zyu {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: inline-block;
|
|
|
+ background: url("../assets/weather/zhongyu.png") no-repeat;
|
|
|
+ background-size: 100% 100%;
|
|
|
+ }
|
|
|
+ .dyu {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: inline-block;
|
|
|
+ background: url("../assets/weather/dayu.png") no-repeat;
|
|
|
+ background-size: 100% 100%;
|
|
|
+ }
|
|
|
+ .byu {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: inline-block;
|
|
|
+ background: url("../assets/weather/baoyu.png") no-repeat;
|
|
|
+ background-size: 100% 100%;
|
|
|
+ }
|
|
|
+ .xxue{
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: inline-block;
|
|
|
+ background: url("../assets/weather/xiaoxue.png") no-repeat;
|
|
|
+ background-size: 100% 100%;
|
|
|
+ }
|
|
|
+ .zxue{
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: inline-block;
|
|
|
+ background: url("../assets/weather/zhongxue.png") no-repeat;
|
|
|
+ background-size: 100% 100%;
|
|
|
+ }
|
|
|
+ .dxue{
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: inline-block;
|
|
|
+ background: url("../assets/weather/daxue.png") no-repeat;
|
|
|
+ background-size: 100% 100%;
|
|
|
+ }
|
|
|
+ .bxue{
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: inline-block;
|
|
|
+ background: url("../assets/weather/baoxue.png") no-repeat;
|
|
|
+ background-size: 100% 100%;
|
|
|
+ }
|
|
|
</style>
|