123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <template>
- <div
- class="header"
- :style="{ background: `url(${headImg}) no-repeat center` }"
- >
- <img class="logo" :src="headLogo" alt="" />
- <div class="title">智慧教室IOC平台</div>
- <!-- <img :src="headImg" alt="" /> -->
- <!-- <div></div> -->
- <div class="weather">
- <div class="left-time">
- <div class="time">{{ currentTime }}</div>
- <div class="year">{{ getCurrentYMD }}</div>
- </div>
- <el-divider direction="vertical" />
- <div class="right-weatherInfo">
- <img class="weather-icon" :src="sun" alt="" />
- <div class="info">
- <div class="text">{{ weatherInfo.text }}</div>
- <div class="temp">{{ weatherInfo.temp }} <span>°C</span></div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script setup>
- import { ref, computed, onBeforeUnmount, onUnmounted, onMounted } from "vue";
- import axios from "axios";
- onMounted(() => {
- // 开启时间定时器获取当前时间
- starttimeInterval();
- // 获取天气信息
- // getWeatherInfo();
- });
- // 获取当前年月日计算属性
- const getCurrentYMD = computed(() => {
- const now = new Date();
- const year = now.getFullYear();
- const month = String(now.getMonth() + 1).padStart(2, "0");
- const day = String(now.getDate()).padStart(2, "0");
- return `${year}-${month}-${day}`;
- });
- // 获取当前时间 umbRQyjXTsyAsbzT4zLI3GNgnPrTBYGD
- let currentTime = ref(new Date().toLocaleTimeString());
- let timeInterval = ref(null);
- const starttimeInterval = () => {
- clearTimeout(timeInterval.value);
- timeInterval.value = setInterval(() => {
- currentTime.value = new Date().toLocaleTimeString();
- }, 1000);
- };
- let weatherInfo = ref({});
- const getWeatherInfo = (latitude, Longitude) => {
- const key = "UFwchof57SfCeYaiWXj1F2XBx0w8hKtB";
- //https://api.map.baidu.com/weather/v1/?location=${latitude},${Longitude}&data_type=all&ak=${key}
- axios
- .get(
- `https://api.map.baidu.com/weather/v1/?district_id=222405&data_type=all&ak=${key}`
- )
- .then((res) => {
- weatherInfo.value = res.data.result.now;
- console.log("天气信息", res.data.result.now);
- });
- };
- onBeforeUnmount(() => {
- clearTimeout(timeInterval.value);
- });
- onUnmounted(() => {
- clearTimeout(timeInterval.value);
- });
- const headImg = ref("./img/head.png");
- const headLogo = ref("./img/logo.png");
- const sun = ref("./img/sun.png");
- </script>
- <style scoped lang="scss">
- .header {
- position: absolute;
- z-index: 555;
- margin-bottom: 20px;
- height: 70px;
- width: 100%;
- display: flex;
- background-size: cover !important;
- background-position: center !important;
- background-repeat: no-repeat !important;
- .logo {
- width: 162px;
- height: 50px;
- position: absolute;
- left: 28px;
- top: 50%;
- transform: translateY(-50%);
-
- }
- .title {
- flex: 1;
- text-align: center;
- color: #fff;
- font-family: FZCuHeiSongS-B-GB;
- font-size: 40px;
- font-weight: 400;
- line-height: 70px;
- letter-spacing: 8px;
- }
- .weather {
- position: absolute;
- right: 10px;
- top: 50%;
- transform: translateY(-50%);
- display: flex;
- align-items: center;
- height: 38px;
- .left-time {
- margin-right: 12px;
- height: 38px;
- .time {
- color: #bfdfff;
- text-shadow: 0px 1px 3px rgba(5, 12, 25, 0.54);
- font-family: PangMenZhengDao;
- font-size: 24px;
- font-style: normal;
- font-weight: 600;
- }
- .year {
- color: #bfdfff;
- text-align: right;
- text-shadow: 0px 1px 3px rgba(5, 12, 25, 0.54);
- font-family: PangMenZhengDao;
- font-size: 12px;
- font-style: normal;
- font-weight: 400;
- line-height: normal;
- }
- }
- .right-weatherInfo {
- display: flex;
- align-items: center;
- height: 38px;
- .weather-icon {
- width: 30px;
- height: 30px;
- }
- .info {
- flex: 1;
- margin-left: 12px;
- height: 38px;
- .text {
- color: #bfdfff;
- text-shadow: 0px 1px 3px rgba(5, 12, 25, 0.54);
- /* text/pc/03-55-Regular */
- font-family: "Alibaba PuHuiTi 2.0";
- font-size: 12px;
- font-style: normal;
- font-weight: 400;
- line-height: normal;
- }
- .temp {
- color: #bfdfff;
- text-shadow: 0px 1px 3px rgba(5, 12, 25, 0.54);
- font-family: PangMenZhengDao;
- font-size: 16px;
- font-style: normal;
- font-weight: 400;
- line-height: normal;
- span {
- color: #bfdfff;
- font-family: "Alibaba PuHuiTi 2.0";
- font-size: 16px;
- font-style: normal;
- font-weight: 400;
- line-height: normal;
- }
- }
- }
- }
- }
- }
- :deep(.el-divider--vertical){
- height: 34px;
- }
- </style>
|