Top.vue 3.94 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
<!--
 * @Author: 纪泽龙 jizelong@qq.com
 * @Date: 2022-09-03 11:38:15
 * @LastEditors: 纪泽龙 jizelong@qq.com
 * @LastEditTime: 2022-09-13 10:01:00
 * @FilePath: /danger-manage-web/src/components/indexComponents/Top.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="top-wrapper flex">
    <div class="left flex">
      <div>
        <div class="weather">
          <iframe
            scrolling="no"
            src="https://tianqiapi.com/api.php?style=tz&skin=pitaya&color=339CC9"
            frameborder="0"
            width="450"
            height="30"
            allowtransparency="true"
          ></iframe>
        </div>
      </div>
    </div>
    <div class="middle flex">
      <div></div>
    </div>
    <div class="right flex">
      <div>
        <div class="right-time">
          <div class="time">
            <span> {{ nowDate }}</span>
            <span> {{ nowtime }}</span>
            <span> {{ nowweek }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import topCenter from "@/assets/indexImages/topCenter.png";
export default {
  name: "",
  data() {
    return {
      topCenter,
      nowDate: "",
      nowtime: "",
      nowweek: "",
    };
  },
  created() {
    this.formatDate();
  },
  mounted() {},
  methods: {
    formatDate() {
      let date = new Date();
      let year = date.getFullYear(); // 年
      let month = date.getMonth() + 1; // 月
      let day = date.getDate(); // 日
      let week = date.getDay(); // 星期
      let weekArr = [
        "星期日",
        "星期一",
        "星期二",
        "星期三",
        "星期四",
        "星期五",
        "星期六",
      ];
      let hour = date.getHours(); // 时
      hour = hour < 10 ? "0" + hour : hour; // 如果只有一位,则前面补零
      let minute = date.getMinutes(); // 分
      minute = minute < 10 ? "0" + minute : minute; // 如果只有一位,则前面补零
      let second = date.getSeconds(); // 秒
      second = second < 10 ? "0" + second : second; // 如果只有一位,则前面补零
      this.nowtime = `${hour}:${minute}:${second}`;
      this.nowweek = `${weekArr[week]}`;
      this.nowDate = `${year}${month}${day}日`;
    },
  },
};
</script>
<style lang="scss" scoped>
.top-wrapper {
  position: absolute;
    z-index:1;
  width: 100%;
  height: 9.35%;
  max-height: 101px;
  // background-color: blue;
  top: 0px;
  justify-content: space-between;
  > div {
    flex: 1;
    max-width: 465px;
    align-items: center;
  }
  .middle {
    flex: initial;
    width: 47.7%;
    height: 100%;
    max-width: 917px;
    justify-content: space-around;
    > div {
      position: relative;
      width: 100%;
      height: 100%;
      background: url("~@/assets/indexImages/topCenter.png") no-repeat;
      background-size: 100% 100%;
    }
    // img{
    //   width: 100%;
    //   height: 100%;
    // }
  }
  .left {
    > div {
      width: 100%;
      height: 100%;
      background: url("~@/assets/indexImages/top-l.png") no-repeat;
      background-position: center 30%;
      background-size: 100%;
      overflow: hidden;
      .weather {
        width: 100%;
        margin-top: 4.5%;
        margin-left: 30%;
        iframe {
          width: 100%;
        }
      }
    }
  }
  .right {
    justify-content: right;
    > div {
      width: 100%;
      height: 100%;
      background: url("~@/assets/indexImages/top-r.png") no-repeat;
      background-position: center 30%;
      background-size: 100%;
      .right-time {
        width: 100%;
        margin-top: 4.5%;
        padding-right: 30%;
        color: #339cc9;
        .time {
          height: 20px;
          // width: 100%;
          float: right;
          font-size: 14px;
          > span {
            margin-left: 5px;
          }
        }
      }
    }
  }
}
</style>