home.vue 3.17 KB
<template>
  <div>
    <index-Ch v-if="language ==0"/>
    <index-En v-else/>


    <div v-if="showgg" class="fixed_gg">
      <!--天气-->
      <el-icon class="cclose" @click.stop="showgg=false"><circle-close /></el-icon>
      <div class="bg-lineg pd20">
        <div class="smallToday" @click="popWeather">
          <div>
            <div class="type">
              <weather-icon :type="weatherObj.forecast[0]?.type" :width="50"/>
            </div>
          </div>
          <div>
            <h3 v-if="language == 0">无锡</h3>
            <h3 v-else>WUXI</h3>
            <div class="wd_p">{{weatherObj.forecast[0]?.low.slice(2)}}~{{weatherObj.forecast[0]?.high.slice(2)}}</div>
          </div>
        </div>
      </div>
      <el-dialog v-model="weatherdialog" width="540" :close-on-click-modal="true"
                 style="--el-dialog-padding-primary:0;--el-dialog-border-radius:15px;
                 --el-dialog-bg-color:transparent;overflow: hidden;">
        <div class="bg-lineg pd20">
          <div class="weatherbox">
            <div class="today">
              <div class="mr50">
                <h1 v-if="language == 0">无锡</h1>
                <h1 v-else>WUXI</h1>
              </div>
              <div>
                <div class="wd">{{weatherObj.wendu}}°c</div>
                <div class="wd_p">{{weatherObj.forecast[0]?.low.slice(2)}}~{{weatherObj.forecast[0]?.high.slice(2)}}</div>
                <div class="week">{{weatherObj.forecast[0]?.week}}</div>
              </div>
              <div>
                <div class="type">
                  <weather-icon :type="weatherObj.forecast[0].type" :width="64"/>
                </div>
              </div>
            </div>
            <ul class="wlist">
              <li v-for="n in weatherObj.forecast.slice(1,6)">
                <div class="type">
                  <weather-icon :type="n.type" :width="32"/>
                </div>
                <div class="wd">{{n.low.slice(2,-1)}}/{{n.high.slice(2)}}</div>
                <div class="week" v-if="language==1">
                  {{n.week=='星期一'?'Mon':n.week=='星期二'?'Tue':n.week=='星期三'?'Wed':n.week=='星期四'?'Thu':n.week=='星期五'?'Fri':n.week=='星期六'?'Sat':n.week=='星期日'?'Sun':''}}
                </div>
                <div class="week" v-else>
                  {{n.week}}
                </div>
                <div class="date mt10">{{n.ymd.slice(5,10)}}</div>
              </li>
            </ul>
          </div>
        </div>
      </el-dialog>
    </div>
  </div>

</template>

<script setup>
import IndexCh from '/src/viewsPc/index'
import IndexEn from '/src/viewsPc/index_en'
import WeatherIcon from '@/viewsPc/components/weatherIcon'

import {useStorage} from "@vueuse/core/index";
import {ref} from "vue";
import {getWeather} from "@/apiPc/webSite";
const showgg = ref(true)

const language = useStorage('language', 0)
const weatherObj = ref({
  forecast:[]
})
const weatherdialog = ref(false)
init()
function init(){
  getWeather().then(res=>{
    weatherObj.value = JSON.parse(res.data).data
    console.log(weatherObj.value)
  })
}
const popWeather = () => {
  weatherdialog.value = true
}

</script>

<style scoped lang="scss">

</style>