index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <template>
  2. <div class="Layout" ref="Layout" @scroll="scrollEvent">
  3. <!-- 顶部top -->
  4. <div class="top" :style="`background-color:${$route.meta.topColor}`">
  5. <div class="left">
  6. <img
  7. src="@/assets/img/Layout/mean.png"
  8. alt=""
  9. @click="meanPage = true"
  10. />
  11. </div>
  12. <div class="right">
  13. <img
  14. src="@/assets/img/Layout/logo.png"
  15. alt=""
  16. @click="$router.push('/').catch(() => {})"
  17. />
  18. <img src="@/assets/img/Layout/zhong.png" alt="" @click="toZhong" />
  19. <img src="@/assets/img/Layout/search.png" alt="" @click="searcShow=true"/>
  20. </div>
  21. </div>
  22. <!-- 子页面 -->
  23. <Router-view />
  24. <!-- 点击菜单 -->
  25. <div class="meanPage" v-show="meanPage">
  26. <div class="conten">
  27. <div class="searchTop">
  28. <div class="back">
  29. <van-icon name="arrow-left" @click="meanPage = false" />
  30. </div>
  31. <img
  32. src="@/assets/img/Layout/logo2.png"
  33. alt=""
  34. @click="$router.push('/').catch(() => {})"
  35. />
  36. <img src="@/assets/img/Layout/zhong2.png" alt="" @click="toZhong" />
  37. <img src="@/assets/img/Layout/search2.png" alt="" @click="searcShow=true"/>
  38. </div>
  39. <div class="rowAll">
  40. <div
  41. :class="{
  42. active: index === 4 || index === 6,
  43. accOne: $route.meta.myTitle === item.acc,
  44. }"
  45. @click="menaSonFu(index)"
  46. class="row"
  47. v-for="(item, index) in menaData"
  48. :key="index"
  49. >
  50. <span>{{ item.name }}</span>
  51. <template
  52. v-if="menaSon === index || $route.meta.myTitle === item.acc"
  53. >
  54. <div
  55. class="rowSon"
  56. v-for="(val, valInd) in item.son"
  57. :key="valInd"
  58. :class="{ acc: menaInd === val.path }"
  59. @click="skip(val.path)"
  60. >
  61. {{ val.name }}
  62. </div>
  63. </template>
  64. </div>
  65. </div>
  66. <div class="erwei">
  67. <img src="@/assets/img/Layout/erwei1.png" alt="" />
  68. <img src="@/assets/img/Layout/erwei2.png" alt="" />
  69. </div>
  70. </div>
  71. </div>
  72. <!-- 点击搜索 -->
  73. <div class="searchBox" v-if="searcShow">
  74. <div class="searcTop" @keyup.enter="searcBtn">
  75. <div class="inco" @click="searcBtn"></div>
  76. <input type="text" v-model="txt" placeholder="search......" />
  77. <div class="Cancel" @click="searcShow=false">Cancel</div>
  78. </div>
  79. </div>
  80. <!-- 回到顶部 -->
  81. <div class="toTop" v-show="srocllShow" @click="toTop">
  82. <van-icon name="back-top" />
  83. </div>
  84. <!-- 底部 -->
  85. <div class="bottom">
  86. <div class="logo">
  87. <img src="@/assets/img/Layout/logo.png" alt="" />
  88. </div>
  89. <div class="erwei">
  90. <img src="@/assets/img/Layout/erwei1.png" alt="" />
  91. <img src="@/assets/img/Layout/erwei2.png" alt="" />
  92. </div>
  93. <div class="txt">
  94. <p>
  95. Capital Museum. China 16 Fuxingmenwai Street, Xicheng District,
  96. Beijing 100045, P.R.China.
  97. </p>
  98. </div>
  99. <div class="link">
  100. <span>Terms of Use</span>
  101. <span>Events</span>
  102. <span>Employmen</span>
  103. </div>
  104. </div>
  105. </div>
  106. </template>
  107. <script>
  108. export default {
  109. name: "Layout",
  110. components: {},
  111. data() {
  112. //这里存放数据
  113. return {
  114. // 搜索的变量
  115. searcShow: false,
  116. txt: "",
  117. // 控制二级菜单的高亮
  118. menaInd: null,
  119. // 控制二级菜单的显示
  120. menaSon: null,
  121. srocllShow: false,
  122. meanPage: true,
  123. menaData: [
  124. {
  125. acc: "Visit",
  126. name: "Visit",
  127. path: "",
  128. son: [
  129. { name: "Hours, Direction & Admission", path: "/Layout/Visit/1" },
  130. { name: "Reservation", path: "/Layout/Visit/2" },
  131. { name: "Floor Plans", path: "/Layout/Visit/3" },
  132. { name: "Audio Guide & Tour", path: "/Layout/Visit/4" },
  133. { name: "Accessibility", path: "/Layout/Visit/5" },
  134. { name: "Café & Shop", path: "/Layout/Visit/6" },
  135. { name: "Visitor Guidelines", path: "/Layout/Visit/7" },
  136. ],
  137. },
  138. {
  139. name: "Exhibitions",
  140. path: "",
  141. son: [
  142. { name: "Current Exhibitions", path: "" },
  143. { name: "Permanent Exhibitions", path: "" },
  144. { name: "Past Exhibitions", path: "" },
  145. { name: "Overseas Exhibitions", path: "" },
  146. ],
  147. },
  148. {
  149. name: "Collections",
  150. path: "",
  151. son: [
  152. { name: "Bronzes", path: "" },
  153. { name: "Ceramics", path: "" },
  154. { name: "Buddhist Statues", path: "" },
  155. { name: "Jadewares", path: "" },
  156. { name: "Calligraphies", path: "" },
  157. { name: "Paintings", path: "" },
  158. { name: "Gold & Silverwares", path: "" },
  159. { name: "Coins & Banknotes", path: "" },
  160. { name: "Brocades & Embroideries", path: "" },
  161. { name: "Cultural Supplies", path: "" },
  162. { name: "Miscellaneous", path: "" },
  163. ],
  164. },
  165. {
  166. name: "Learn & Engage",
  167. path: "",
  168. son: [
  169. { name: "For Students", path: "" },
  170. { name: "For Adults", path: "" },
  171. { name: "For Families & Children", path: "" },
  172. ],
  173. },
  174. {
  175. name: "Publications",
  176. path: "",
  177. son: [
  178. { name: "Magazines", path: "" },
  179. { name: "Exhibition Catalogues", path: "" },
  180. { name: "Research", path: "" },
  181. ],
  182. },
  183. {
  184. name: "Join & Support",
  185. path: "",
  186. son: [
  187. { name: "Ways to Volunteer", path: "" },
  188. { name: "Ways to Give", path: "" },
  189. ],
  190. },
  191. {
  192. name: "About",
  193. path: "",
  194. son: [
  195. { name: "From the Director", path: "" },
  196. { name: "History", path: "" },
  197. { name: "Partners & Connections", path: "" },
  198. { name: "Contact", path: "" },
  199. ],
  200. },
  201. ],
  202. };
  203. },
  204. //监听属性 类似于data概念
  205. computed: {},
  206. //监控data中的数据变化
  207. watch: {
  208. $route() {
  209. this.menaInd = this.$route.path;
  210. this.meanPage = false;
  211. },
  212. searcShow(){
  213. this.txt=''
  214. }
  215. },
  216. //方法集合
  217. methods: {
  218. searcBtn(){
  219. console.log('搜索~');
  220. },
  221. menaSonFu(index) {
  222. if (this.menaSon === index) this.menaSon = null;
  223. else this.menaSon = index;
  224. },
  225. skip(path) {
  226. this.$router.push(path).catch(() => {});
  227. },
  228. toTop() {
  229. let dom = this.$refs.Layout;
  230. dom.scrollTo({ top: 0, behavior: "smooth" });
  231. },
  232. toZhong() {
  233. window.open("https://www.capitalmuseum.org.cn/", "_blank");
  234. },
  235. // 监听主元素滚动
  236. scrollEvent() {
  237. let dom = this.$refs.Layout;
  238. if (dom.scrollTop > 400) this.srocllShow = true;
  239. else this.srocllShow = false;
  240. },
  241. },
  242. //生命周期 - 创建完成(可以访问当前this实例)
  243. created() {
  244. this.menaInd = this.$route.path;
  245. this.meanPage = false;
  246. },
  247. //生命周期 - 挂载完成(可以访问DOM元素)
  248. mounted() {},
  249. beforeCreate() {}, //生命周期 - 创建之前
  250. beforeMount() {}, //生命周期 - 挂载之前
  251. beforeUpdate() {}, //生命周期 - 更新之前
  252. updated() {}, //生命周期 - 更新之后
  253. beforeDestroy() {}, //生命周期 - 销毁之前
  254. destroyed() {}, //生命周期 - 销毁完成
  255. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  256. };
  257. </script>
  258. <style lang='less' scoped>
  259. ::-webkit-scrollbar {
  260. height: 0;
  261. width: 0;
  262. color: transparent;
  263. }
  264. .Layout {
  265. position: relative;
  266. padding-top: 50px;
  267. height: 100vh;
  268. overflow-y: auto;
  269. .top {
  270. z-index: 990;
  271. display: flex;
  272. justify-content: space-between;
  273. padding: 0 10px;
  274. align-items: center;
  275. width: 100%;
  276. top: 0;
  277. left: 0;
  278. position: fixed;
  279. height: 50px;
  280. .left {
  281. width: 20px;
  282. height: 20px;
  283. & > img {
  284. width: 100%;
  285. height: 100%;
  286. }
  287. }
  288. .right {
  289. display: flex;
  290. align-items: center;
  291. & > img {
  292. width: 20px;
  293. height: 20px;
  294. &:nth-of-type(1) {
  295. margin-right: 20px;
  296. width: 160px;
  297. height: 32px;
  298. }
  299. &:nth-of-type(2) {
  300. margin-right: 15px;
  301. }
  302. }
  303. }
  304. }
  305. .erwei {
  306. margin-top: 30px;
  307. margin-bottom: 20px;
  308. display: flex;
  309. padding: 0 10px;
  310. justify-content: space-between;
  311. & > img {
  312. width: 40%;
  313. }
  314. }
  315. .bottom {
  316. padding: 20px;
  317. padding-bottom: 0;
  318. width: 100%;
  319. background-color: #c1aa7b;
  320. .txt {
  321. padding: 0 10px 20px;
  322. font-size: 14px;
  323. color: #fff;
  324. border-bottom: 1px solid #d1d1d1;
  325. }
  326. .link {
  327. height: 50px;
  328. display: flex;
  329. justify-content: center;
  330. align-items: center;
  331. padding: 0 10px;
  332. font-size: 14px;
  333. color: #fff;
  334. & > span {
  335. padding-right: 15px;
  336. border-right: 1px solid #fff;
  337. margin-right: 15px;
  338. &:last-child {
  339. border-right: none;
  340. margin-right: 0;
  341. }
  342. }
  343. }
  344. }
  345. .toTop {
  346. position: fixed;
  347. width: 48px;
  348. height: 48px;
  349. text-align: center;
  350. line-height: 48px;
  351. border-radius: 50%;
  352. background-color: rgba(193, 170, 123, 0.5);
  353. color: #fff;
  354. font-size: 30px;
  355. right: 10px;
  356. bottom: 200px;
  357. }
  358. // 搜索页面
  359. .searchBox {
  360. padding: 10px;
  361. position: fixed;
  362. top: 0;
  363. left: 0;
  364. z-index: 992;
  365. width: 100vw;
  366. height: 100vh;
  367. background-color: #f9f8f5;
  368. .searcTop {
  369. position: relative;
  370. display: flex;
  371. align-items: center;
  372. justify-content: space-between;
  373. height: 40px;
  374. .inco {
  375. position: absolute;
  376. z-index: 10;
  377. content: "";
  378. display: block;
  379. position: absolute;
  380. top: 9px;
  381. left: 10px;
  382. background: url("../../assets/img/Layout/search2.png");
  383. background-size: 20px, 20px;
  384. width: 20px;
  385. height: 20px;
  386. }
  387. & > input {
  388. width: 80%;
  389. height: 38px;
  390. border-radius: 19px;
  391. padding-left: 40px;
  392. border: 1px solid #d2b986;
  393. background-color: transparent;
  394. }
  395. .Cancel {
  396. font-weight: 700;
  397. min-width: 50px;
  398. width: 15%;
  399. }
  400. }
  401. }
  402. // 菜单页面
  403. .meanPage {
  404. position: fixed;
  405. top: 0;
  406. left: 0;
  407. z-index: 991;
  408. width: 100vw;
  409. height: 100vh;
  410. overflow-y: auto;
  411. background-color: rgba(255, 255, 255, 0.9);
  412. .conten {
  413. width: 90%;
  414. background-color: #f6f4f1;
  415. .searchTop {
  416. width: 100%;
  417. display: flex;
  418. align-items: center;
  419. justify-content: space-around;
  420. height: 50px;
  421. .back {
  422. margin-right: 15px;
  423. font-size: 28px;
  424. }
  425. & > img {
  426. width: 20px;
  427. height: 20px;
  428. &:nth-of-type(1) {
  429. margin-right: 15px;
  430. width: 160px;
  431. height: 32px;
  432. }
  433. }
  434. }
  435. .rowAll {
  436. margin-top: 20px;
  437. padding: 0 30px;
  438. .row {
  439. font-weight: 700;
  440. color: #c1aa7b;
  441. font-size: 20px;
  442. padding-bottom: 20px;
  443. .rowSon {
  444. padding-left: 30px;
  445. font-size: 16px;
  446. margin-top: 20px;
  447. color: #c1aa7b;
  448. font-weight: 400;
  449. }
  450. .acc {
  451. color: #bc1c24;
  452. background: url("../../assets/img/Layout/chosen.png") no-repeat left
  453. top;
  454. background-size: 22px 18px;
  455. }
  456. }
  457. .active {
  458. border-bottom: 1px solid #c1aa7b;
  459. margin-bottom: 20px;
  460. }
  461. .accOne {
  462. color: #bc1c24;
  463. }
  464. }
  465. }
  466. .erwei {
  467. margin-bottom: 0;
  468. padding-bottom: 20px;
  469. padding-left: 30px;
  470. padding-right: 30px;
  471. }
  472. }
  473. }
  474. </style>