head.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <el-row class="content">
  3. <!-- <el-row class="weather">
  4. <img
  5. v-if="weatherObj.weather_pic"
  6. :src="weatherObj.weather_pic || ''"
  7. alt=""
  8. />
  9. <span v-if="weatherObj.weather"
  10. >{{ weatherObj.weather }} {{ weatherObj.temperature }}℃</span
  11. >
  12. </el-row> -->
  13. <el-row class="title">闵行区消防管理与应急救援数字平台</el-row>
  14. <div class="nowTime">
  15. <div class="day">{{ dateDay }}</div>
  16. <div class="time">{{ dataTime }}</div>
  17. </div>
  18. <el-row class="nav">
  19. <el-row class="btnBox btnBoxLeft">
  20. <el-col
  21. class="btn btn1"
  22. v-for="(item, index) in btnList.slice(0, 4)"
  23. @click="btnClick(item)"
  24. :key="index"
  25. :class="{
  26. active: public_store.$state.routeInfo === item.router,
  27. }"
  28. >
  29. {{ item.name }}
  30. </el-col>
  31. </el-row>
  32. <el-row class="btnBox btnBoxRight">
  33. <el-col
  34. class="btn btn2"
  35. v-for="(item, index) in btnList.slice(4)"
  36. @click="btnClick(item)"
  37. :key="index"
  38. :class="{
  39. active: public_store.$state.routeInfo === item.router,
  40. }"
  41. >
  42. {{ item.name }}
  43. </el-col>
  44. </el-row>
  45. </el-row>
  46. <!-- <div class="homeIcon" v-if="$route.fullPath !== '/'">
  47. <img src="~@a/img/icon/close.png" alt="" class="timeImage2" @click="fanhui" />
  48. </div> -->
  49. </el-row>
  50. </template>
  51. <script setup>
  52. import { useStore, mapGetters } from "vuex";
  53. import publicStore from "@/store/modules/public.js";
  54. import { useRoute, useRouter } from "vue-router";
  55. import {
  56. defineAsyncComponent,
  57. defineComponent,
  58. ref,
  59. onMounted,
  60. watch,
  61. } from "vue";
  62. import { ElMessage, ElMessageBox } from "element-plus";
  63. const public_store = publicStore(); //公共store
  64. const route = useRoute();
  65. const router = useRouter();
  66. const dateDay = ref("");
  67. const dataTime = ref("");
  68. const weatherObj = ref({});
  69. const dataWeekList = ref(["一", "二", "三", "四", "五", "六", "七"]);
  70. const valueTime = ref([]);
  71. const defaultTime = ref([
  72. new Date(2000, 1, 1, 0, 0, 0),
  73. new Date(2000, 2, 1, 23, 59, 59),
  74. ]); // '00:00:00', '23:59:59'
  75. const btnList = ref([])
  76. console.log(window.location.href.split("#"))
  77. if(
  78. window.location.href.indexOf("fire-signs") ||
  79. window.location.href.indexOf("self-management") ||
  80. window.location.href.indexOf("enforcement-dynamic") ||
  81. window.location.href.indexOf("fire-data-analysis") ||
  82. window.location.href.indexOf("rescue-station") ||
  83. window.location.href.indexOf("water-sources") ||
  84. window.location.href.indexOf("comprehensive-disposal") ||
  85. window.location.href.indexOf("security-plan") ||
  86. window.location.href.split("#")[1] == "/"
  87. ){
  88. btnList.value = [
  89. { name: "城市消防体征", router: "/fire-signs" },
  90. { name: "企业自主管理", router: "/self-management" },
  91. { name: "消防执法动态", router: "/enforcement-dynamic" },
  92. { name: "火灾数据分析", router: "/fire-data-analysis" },
  93. { name: "消防救援站点", router: "/rescue-station" },
  94. { name: "消防水源情况", router: "/water-sources" },
  95. { name: "警情综合处置", router: "/comprehensive-disposal" },
  96. { name: "大型安保预案", router: "/security-plan" },
  97. ]
  98. }else{
  99. btnList.value = []
  100. }
  101. valueTime.value = public_store.$state.timeList.map((val) => {
  102. return val;
  103. });
  104. //返回
  105. function fanhui() {
  106. router.go(-1);
  107. }
  108. //天气
  109. async function getWeather() {
  110. // let res = await this.$axios.get("/service-fire/aliWeather");
  111. // if (JSON.parse(res.data).showapi_res_code === 0) {
  112. // weatherObj.value = JSON.parse(res.data).showapi_res_body.now;
  113. // }
  114. }
  115. //路由跳转
  116. function btnClick(val) {
  117. if (val.router === public_store.$state.routeInfo) {
  118. router.push({
  119. path: "/",
  120. });
  121. } else {
  122. router.push({
  123. path: val.router,
  124. });
  125. }
  126. }
  127. onMounted(() => {
  128. //当前年月日时分秒
  129. setInterval(() => {
  130. let day = new Date();
  131. dateDay.value =
  132. day.getFullYear() +
  133. "-" +
  134. (day.getMonth() + 1 < 10
  135. ? "0" + (day.getMonth() + 1)
  136. : "" + (day.getMonth() + 1)) +
  137. "-" +
  138. (day.getDate() < 10 ? "0" + day.getDate() : day.getDate());
  139. dataTime.value =
  140. (day.getHours() < 10 ? "0" + day.getHours() : day.getHours()) +
  141. ":" +
  142. (day.getMinutes() < 10
  143. ? "0" + day.getMinutes()
  144. : day.getMinutes()) +
  145. ":" +
  146. (day.getSeconds() < 10 ? "0" + day.getSeconds() : day.getSeconds());
  147. }, 1000);
  148. });
  149. watch(
  150. () => route,
  151. (to, from) => {
  152. // console.log(from); //从哪来
  153. // console.log(to); //到哪去
  154. public_store.$state.routeInfo = to.path;
  155. },
  156. { deep: true, immediate: true }
  157. );
  158. watch(
  159. () => public_store.$state.timeList,
  160. (val) => {
  161. valueTime.value = val.map((value) => {
  162. return value;
  163. });
  164. },
  165. { deep: true, immediate: true }
  166. );
  167. </script>
  168. <style lang="scss" scoped>
  169. @import "@/assets/scss/color.scss";
  170. .content {
  171. width: 100%;
  172. height: 0.9375rem;
  173. position: relative;
  174. background-image: url(~@a/img/topBackground.png);
  175. background-size: 100% 100%;
  176. background-color: transparent;
  177. z-index: 100;
  178. .weather {
  179. position: absolute;
  180. left: 0.375rem;
  181. top: 0.18rem;
  182. display: flex;
  183. justify-content: center;
  184. align-items: center;
  185. img {
  186. width: 0.375rem;
  187. }
  188. span {
  189. font-size: 0.2rem;
  190. margin-left: 0.135rem;
  191. @include color_primary($color-primary2);
  192. }
  193. }
  194. .nowTime {
  195. .day {
  196. position: absolute;
  197. top: 0.16rem;
  198. left: 0.125rem;
  199. width: auto;
  200. height: auto;
  201. font-size: 0.2rem;
  202. font-weight: 400;
  203. @include color_primary($color-primary3);
  204. }
  205. .time {
  206. position: absolute;
  207. top: 0.16rem;
  208. left: 1.3rem;
  209. font-size: 0.2rem;
  210. //font-weight: 700;
  211. @include color_primary($color-primary3);
  212. }
  213. }
  214. .title {
  215. position: absolute;
  216. left: 0;
  217. right: 0;
  218. margin: auto;
  219. top: 0.1rem;
  220. font-size: 0.375rem;
  221. font-weight: 700;
  222. width: fit-content;
  223. @include color_primary($color-primary1);
  224. background: linear-gradient(to bottom, #b4dffc, #fbfeff);
  225. -webkit-background-clip: text;
  226. color: transparent;
  227. font-family: syhtB !important;
  228. // 转变为行内块元素 文字
  229. }
  230. .nav {
  231. .btnBox {
  232. display: flex;
  233. justify-content: space-between;
  234. flex: none;
  235. // background: red;
  236. .btn {
  237. overflow: hidden !important;
  238. white-space: nowrap !important;
  239. text-overflow: ellipsis !important;
  240. width: 1.325rem;
  241. // height: 0.3rem;
  242. // background: blue;
  243. background-size: 100% 100%;
  244. font-size: 0.2rem;
  245. @include color_primary($color-primary3);
  246. text-align: center;
  247. // line-height: 0.625rem;
  248. line-height: 0.6rem;
  249. flex: none;
  250. cursor: pointer;
  251. @include user_select();
  252. }
  253. .btn1 {
  254. margin: 0rem 0 0 0.275rem;
  255. }
  256. .btn2 {
  257. margin: 0rem 0.275rem 0 0;
  258. }
  259. .active {
  260. @include color_primary($color-primary1);
  261. border-bottom: 0.025rem solid #01d1ff;
  262. border-image: linear-gradient(to right, #01d1ff, #2969e8) 1;
  263. }
  264. }
  265. .btnBoxLeft {
  266. position: fixed;
  267. left: 9.8%;
  268. }
  269. .btnBoxRight {
  270. position: fixed;
  271. right: 9.8%;
  272. }
  273. }
  274. .homeIcon {
  275. position: absolute;
  276. right: 0.6875rem;
  277. top: 0.0625rem;
  278. font-size: 0.625rem;
  279. color: #28bcfa;
  280. i {
  281. cursor: pointer;
  282. }
  283. }
  284. }
  285. .timeImage2 {
  286. width: 0.5rem;
  287. }
  288. </style>