common-headerB.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <div style="position: relative">
  3. <div class="screen-header">{{ title }}</div>
  4. <div class="right">
  5. <div class="show-time">
  6. <div class="time">
  7. {{ times.date }}
  8. </div>
  9. <div class="date">
  10. <span>
  11. {{ times.week }}
  12. </span>
  13. </div>
  14. </div>
  15. <div class="temperature">32<span style="font-size: 1vw">℃</span></div>
  16. </div>
  17. </div>
  18. </template>
  19. <script setup>
  20. import moment from "moment";
  21. defineProps({
  22. title: {
  23. type: String,
  24. default: "",
  25. },
  26. });
  27. const times = ref({ time: "", date: "", week: "" });
  28. const timer = ref(null);
  29. const getTime = () => {
  30. timer.value = setInterval(() => {
  31. times.value.time = moment().format("HH:mm:ss");
  32. times.value.date = moment().format("YYYY/MM/DD");
  33. times.value.week = "星期" + "日一二三四五六".charAt(new Date().getDay());
  34. }, 1000);
  35. };
  36. onMounted(() => {
  37. getTime();
  38. });
  39. </script>
  40. <style lang="scss" scoped>
  41. .screen-header {
  42. display: flex;
  43. justify-content: center;
  44. align-items: center;
  45. height: 8vh;
  46. font-weight: 600;
  47. font-size: 4vh;
  48. color: #ffffff;
  49. line-height: 4.6vh;
  50. background-image: url("@/assets/images/top.png");
  51. background-size: 100% 30%;
  52. background-position: bottom;
  53. background-repeat: no-repeat;
  54. }
  55. .right {
  56. position: absolute;
  57. right: 1.042vw;
  58. top: 50%;
  59. transform: translateY(-50%);
  60. display: flex;
  61. align-items: center;
  62. font-family: "Furore";
  63. .temperature {
  64. margin-right: 0.78125vw;
  65. font-size: 1.25vw;
  66. font-weight: 500;
  67. color: white;
  68. span {
  69. color: #babebe;
  70. font-size: 0.625vw;
  71. vertical-align: super;
  72. }
  73. }
  74. .show-time {
  75. margin-right: 1vw;
  76. .time {
  77. font-size: 1.25vw;
  78. font-weight: 500;
  79. color: white;
  80. }
  81. .date {
  82. color: #babebe;
  83. & span:nth-child(1) {
  84. margin-right: 0.26vw;
  85. }
  86. }
  87. }
  88. }
  89. </style>