index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <div class="Layout">
  3. <!-- 公共头部 -->
  4. <div class="topNav">
  5. <div class="mainbav_wrap">
  6. <h1 class="logo">
  7. <img src="@/assets/images/logo.png" alt="" />
  8. </h1>
  9. <ul class="mainbav">
  10. <li
  11. @click="skipOne(item.url)"
  12. :class="{ active: $route.meta.myName === item.name }"
  13. v-for="item in topData"
  14. :key="item.id"
  15. >
  16. <span>{{ item.name }}</span>
  17. <ul class="mainbav_sub">
  18. <li
  19. :class="{ active2: menaInd === val.url }"
  20. v-for="(val, index) in item.children"
  21. :key="index"
  22. @click.stop="skipTow(val.url)"
  23. >
  24. {{ val.name }}
  25. </li>
  26. </ul>
  27. </li>
  28. <!-- 中文网 -->
  29. <li class="language">
  30. <a href="http://www.capitalmuseum.org.cn/" target="_blank">中文</a>
  31. </li>
  32. <!-- 爱心模式 -->
  33. <li class="love">
  34. <span>Caring Mode</span>&nbsp;
  35. <el-switch v-model="loveFalg" active-color="#AB3434"> </el-switch>
  36. </li>
  37. </ul>
  38. </div>
  39. <!-- 右侧的输入框 -->
  40. <div class="search">
  41. <el-input
  42. placeholder="search..."
  43. suffix-icon="el-icon-search"
  44. v-model="searchTxt"
  45. >
  46. </el-input>
  47. </div>
  48. </div>
  49. <!-- 固定的二维码和游戏 -->
  50. <div class="rightNav">
  51. <ul class="rightIco">
  52. <li title="game">
  53. <img src="@/assets/images/game.png" alt="" />
  54. </li>
  55. <li>
  56. <img src="@/assets/images/code.png" alt="" />
  57. <div>
  58. <img src="@/assets/images/index_ewm1.png" alt="" />
  59. <img src="@/assets/images/index_ewm.jpg" alt="" />
  60. </div>
  61. </li>
  62. </ul>
  63. </div>
  64. <!-- 嵌套路由 -->
  65. <Router-view />
  66. <!-- 底部固定栏 -->
  67. <div class="footer">
  68. <div>
  69. <span
  70. v-for="item in footerData"
  71. :key="item.name"
  72. v-html="item.name"
  73. ></span>
  74. </div>
  75. <p>
  76. Capital Museum. China 16 Fuxingmenwai Street, Xicheng District, Beijing
  77. 100045, P.R.China.
  78. </p>
  79. </div>
  80. </div>
  81. </template>
  82. <script>
  83. import { topData } from "./data";
  84. export default {
  85. name: "Layout",
  86. components: {},
  87. data() {
  88. //这里存放数据
  89. return {
  90. topData,
  91. loveFalg: false,
  92. searchTxt: "",
  93. footerData: [
  94. { name: "|&emsp; Site Index", path: "" },
  95. { name: "|&emsp; Terms of Use", path: "" },
  96. { name: "|&emsp; Events", path: "" },
  97. { name: "|&emsp; Employment", path: "" },
  98. ],
  99. // 控制二级菜单的高亮
  100. menaInd: null,
  101. };
  102. },
  103. //监听属性 类似于data概念
  104. computed: {},
  105. //监控data中的数据变化
  106. watch: {
  107. $route() {
  108. this.menaInd = this.$route.path;
  109. // console.log('------',this.menaInd);
  110. },
  111. },
  112. //方法集合
  113. methods: {
  114. // 第一级的跳转
  115. skipOne(url) {
  116. this.$router.push("/Layout/" + url).catch(() => {});
  117. },
  118. // 第二级的跳转
  119. skipTow(url) {
  120. this.$router.push(url).catch(() => {});
  121. },
  122. },
  123. //生命周期 - 创建完成(可以访问当前this实例)
  124. created() {
  125. this.menaInd = this.$route.path;
  126. },
  127. //生命周期 - 挂载完成(可以访问DOM元素)
  128. mounted() {},
  129. beforeCreate() {}, //生命周期 - 创建之前
  130. beforeMount() {}, //生命周期 - 挂载之前
  131. beforeUpdate() {}, //生命周期 - 更新之前
  132. updated() {}, //生命周期 - 更新之后
  133. beforeDestroy() {}, //生命周期 - 销毁之前
  134. destroyed() {}, //生命周期 - 销毁完成
  135. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  136. };
  137. </script>
  138. <style lang='less' scoped>
  139. .Layout {
  140. position: relative;
  141. width: 100%;
  142. }
  143. .topNav {
  144. background-color: rgba(0, 0, 0, 0.8);
  145. width: 100%;
  146. height: 60px;
  147. position: absolute;
  148. top: 0;
  149. left: 0;
  150. z-index: 990;
  151. .mainbav_wrap {
  152. width: 1300px;
  153. margin: 0 auto;
  154. & > h1 {
  155. float: left;
  156. display: inherit;
  157. margin: 10px 70px 0 0;
  158. & > img {
  159. border: none;
  160. vertical-align: top;
  161. }
  162. }
  163. .mainbav {
  164. font-size: 14px;
  165. color: #fff;
  166. line-height: 60px;
  167. & > li {
  168. cursor: pointer;
  169. float: left;
  170. display: inline;
  171. margin-right: 25px;
  172. position: relative;
  173. &:hover {
  174. & > span {
  175. border-bottom: 2px solid #ca000a;
  176. }
  177. .mainbav_sub {
  178. display: block;
  179. }
  180. }
  181. .mainbav_sub {
  182. display: none;
  183. position: absolute;
  184. & > li {
  185. border-left: 2px solid #660005;
  186. font-size: 14px;
  187. color: #fff;
  188. line-height: 40px;
  189. background-color: rgba(0, 0, 0, 0.8);
  190. white-space: nowrap;
  191. float: none;
  192. display: block;
  193. margin: 0;
  194. padding: 0 20px 0 10px;
  195. &:hover {
  196. background-color: rgba(204, 0, 3, 0.8);
  197. border-left: 2px solid #cc0003;
  198. }
  199. }
  200. .active2 {
  201. background-color: rgba(204, 0, 3, 0.8);
  202. border-left: 2px solid #cc0003;
  203. }
  204. }
  205. }
  206. .language {
  207. background: url("../../assets/images/dh1.png") no-repeat 0 18px;
  208. width: 73px;
  209. text-indent: 41px;
  210. & > a {
  211. color: #fff;
  212. text-decoration: none;
  213. &:hover {
  214. border-bottom: 2px solid #ca000a;
  215. }
  216. }
  217. }
  218. .love {
  219. margin-right: 0;
  220. &:hover {
  221. & > span {
  222. border-bottom: none;
  223. }
  224. }
  225. }
  226. .active {
  227. & > span {
  228. border-bottom: 2px solid #ca000a;
  229. }
  230. }
  231. }
  232. }
  233. .search {
  234. width: 240px;
  235. height: 30px;
  236. position: absolute;
  237. top: 50%;
  238. right: 40px;
  239. transform: translateY(-50%);
  240. ::-webkit-input-placeholder {
  241. color: #000000;
  242. }
  243. /deep/.el-input__icon {
  244. font-size: 20px;
  245. line-height: 30px;
  246. color: #ca000a;
  247. }
  248. }
  249. }
  250. .rightNav {
  251. width: 60px;
  252. height: 164px;
  253. position: fixed;
  254. bottom: 150px;
  255. right: 0;
  256. z-index: 990;
  257. .rightIco {
  258. width: 100%;
  259. height: 100%;
  260. & > li {
  261. background-color: rgba(0, 0, 0, 0.8);
  262. text-align: center;
  263. width: 60px;
  264. padding: 10px 0;
  265. position: relative;
  266. cursor: pointer;
  267. & > div {
  268. display: none;
  269. width: 252px;
  270. position: absolute;
  271. top: 0;
  272. right: 0;
  273. & > img {
  274. float: left;
  275. }
  276. }
  277. &:hover {
  278. background-color: #c20e11;
  279. & > div {
  280. display: block;
  281. }
  282. }
  283. }
  284. }
  285. }
  286. .footer {
  287. padding: 0 100px;
  288. display: flex;
  289. justify-content: space-between;
  290. width: 100%;
  291. height: 45px;
  292. font-size: 14px;
  293. color: #fff;
  294. line-height: 45px;
  295. background: url(../../assets/images/footer_bg.png) center top;
  296. & > div {
  297. & > span {
  298. cursor: pointer;
  299. margin-right: 15px;
  300. }
  301. }
  302. }
  303. </style>