AppHeader.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <header class="app-header">
  3. <!-- 头部线条及标题 -->
  4. <div class="app-header__main">
  5. <div class="app-header__main--left"></div>
  6. <div class="app-header__main--right"></div>
  7. <div class="app-header__main--leftBottom"></div>
  8. <div class="app-header__main--rightBottom"></div>
  9. <h1 class="app-header__title">
  10. <img class="app-header__logo" :src="faviconUrl">
  11. {{logoTitle}}
  12. </h1>
  13. </div>
  14. <!-- /头部线条及标题 -->
  15. <div class="app-header__content">
  16. <!-- 今日新冠送检,标本运输数,患者陪检 -->
  17. <AppToday></AppToday>
  18. <!-- /今日新冠送检,标本运输数,患者陪检 -->
  19. <!-- 时间 -->
  20. <div class="app-header__contentTime">{{time|weekFormat}}<time>{{time|timeFormat}}</time></div>
  21. <!-- /时间 -->
  22. </div>
  23. </header>
  24. </template>
  25. <script>
  26. import { get } from './../http/http'
  27. import AppToday from './AppToday'
  28. export default {
  29. name: 'AppHeader',
  30. components: {
  31. AppToday
  32. },
  33. data () {
  34. return {
  35. logoTitle: '',
  36. faviconUrl: '',
  37. time: new Date().getTime(), // 时间戳
  38. timer: null, // 时间定时器
  39. week: ''// 星期
  40. }
  41. },
  42. filters: {
  43. // 格式化时间
  44. timeFormat (time) {
  45. const newDate = new Date(time)
  46. const hours = newDate.getHours().toString().padStart(2, '0')
  47. const minutes = newDate.getMinutes().toString().padStart(2, '0')
  48. const seconds = newDate.getSeconds().toString().padStart(2, '0')
  49. return `${hours}${minutes}${seconds}`
  50. },
  51. // 获得当前的星期
  52. weekFormat (time) {
  53. const newDate = new Date(time)
  54. const week = newDate.getDay()
  55. const weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
  56. return `${weeks[week]}`
  57. }
  58. },
  59. methods: {
  60. // 时间日期
  61. runTime () {
  62. // const t1 = Date.now()
  63. clearTimeout(this.timer)
  64. this.timer = setTimeout(() => {
  65. // const t2 = Date.now()
  66. // console.log(t2 - t1)
  67. // this.time += 1000
  68. this.time = Date.now()
  69. this.runTime()
  70. }, 500)
  71. },
  72. getSysNameAndLogo () {
  73. get('/auth/getSysNameAndLogo')
  74. .then((result) => {
  75. this.logoTitle = result.largeScreenName || ''
  76. this.faviconUrl = location.origin + '/file' + result.favicon || ''
  77. document.querySelector('#favicon').href = this.faviconUrl
  78. document.title = this.logoTitle
  79. })
  80. }
  81. },
  82. mounted () {
  83. this.runTime()
  84. this.getSysNameAndLogo()
  85. },
  86. beforeDestroy () {
  87. clearTimeout(this.timer)
  88. }
  89. }
  90. </script>
  91. <style lang="less">
  92. .app-header {
  93. position: relative;
  94. height: 1.375rem;
  95. padding-top: 0.2rem;
  96. // 边框线
  97. .app-header__main {
  98. width: 5.15rem;
  99. height: 0.675rem;
  100. margin: 0 auto;
  101. border-bottom: 1px solid #68ffff;
  102. position: relative;
  103. .app-header__title{
  104. display: flex;
  105. justify-content: center;
  106. align-items: center;
  107. .app-header__logo{
  108. max-height: .6125rem;
  109. max-width: .6125rem;
  110. margin-right: 0.1rem;
  111. }
  112. }
  113. .app-header__main--left {
  114. position: absolute;
  115. width: calc(50vw - 3.17rem);
  116. height: 1px;
  117. background-image: linear-gradient(#30c8ff, #68f8ff);
  118. top: 1px;
  119. left: calc(2.81rem - 50vw);
  120. }
  121. .app-header__main--right {
  122. position: absolute;
  123. width: calc(50vw - 3.17rem);
  124. height: 1px;
  125. background-image: linear-gradient(#68f8ff, #30c8ff);
  126. top: 1px;
  127. right: calc(2.81rem - 50vw);
  128. }
  129. .app-header__main--leftBottom {
  130. position: absolute;
  131. left: -5.7rem;
  132. top: 0.15rem;
  133. width: 5.2375rem;
  134. height: 0.075rem;
  135. background-color: rgba(253, 255, 250, 0.2);
  136. transform: skewX(45deg);
  137. border-top: 1px solid #489ec9;
  138. }
  139. .app-header__main--rightBottom {
  140. position: absolute;
  141. right: -5.7rem;
  142. top: 0.15rem;
  143. width: 5.2375rem;
  144. height: 0.075rem;
  145. background-color: rgba(253, 255, 250, 0.2);
  146. transform: skewX(-45deg);
  147. border-top: 1px solid #489ec9;
  148. }
  149. &::before {
  150. content: "";
  151. position: absolute;
  152. left: -0.61rem;
  153. bottom: 0.21rem;
  154. width: 0.75rem;
  155. height: 0.125rem;
  156. border-top: 1px solid #5ceef9;
  157. transform: rotate(60deg);
  158. }
  159. &::after {
  160. content: "";
  161. position: absolute;
  162. right: -0.61rem;
  163. bottom: 0.21rem;
  164. width: 0.75rem;
  165. height: 0.125rem;
  166. border-top: 1px solid #5ceef9;
  167. transform: rotate(-60deg);
  168. }
  169. .app-header__title {
  170. position: relative;
  171. bottom: 0.125rem;
  172. font-size: 0.425rem;
  173. color: #fff;
  174. height: 0.75rem;
  175. display: flex;
  176. justify-content: center;
  177. align-items: center;
  178. }
  179. }
  180. // 头部内容
  181. .app-header__content{
  182. position: absolute;
  183. left: 0;
  184. top: 0.4rem;
  185. display: flex;
  186. justify-content: space-between;
  187. align-items: center;
  188. width: 100%;
  189. height: 0.475rem;
  190. .app-header__contentNews{
  191. display: flex;
  192. justify-content: space-between;
  193. align-items: center;
  194. .app-header__contentNewsItem{
  195. font-size: .2rem;
  196. color: #fff;
  197. margin-right: .4rem;
  198. em{
  199. color: #70c2ab;
  200. margin-left: .2rem;
  201. i{
  202. color: #c27073;
  203. }
  204. }
  205. }
  206. }
  207. .app-header__contentTime{
  208. color: #fff;
  209. font-size: .3rem;
  210. time{
  211. margin-left: .2rem;
  212. }
  213. }
  214. }
  215. }
  216. </style>