index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <template>
  2. <div class="About">
  3. <div class="ban" ref="ban">
  4. <img src="@/assets/img/bannerA.png" alt="" />
  5. <h3>About</h3>
  6. </div>
  7. <div class="main">
  8. <div class="mainBox" :class="{ curSorll: menaSon }">
  9. <div class="rowAll">
  10. <div
  11. @click="cutTab(index)"
  12. class="row"
  13. v-for="(item, index) in tabData"
  14. :key="index"
  15. :class="{ active: idMate === index }"
  16. >
  17. {{ item.name }}
  18. </div>
  19. </div>
  20. </div>
  21. <!-- 1 -->
  22. <div id="About1">
  23. <h3 class="title">From the Director</h3>
  24. <p>Welcome to the website of the Capital Museum of China.</p>
  25. <p>
  26. We are looking forward to your visit. The Capital Museum is a palace
  27. of Beijing culture. Its collections relate to the long development of
  28. the capital city, showcasing its magnificent living history of 500,000
  29. years, urban history of 3,000 years and history as the Chinese capital
  30. for 800 years. The museum also presents cultural and artistic
  31. exhibitions from different regions and displays the achievements of
  32. various ethnic groups at home and abroad. You can feel the breadth of
  33. both Chinese and world civilizations.
  34. </p>
  35. <p>
  36. Historical culture is the soul of a city and in the case of Beijing it
  37. is a great witness to the long history of Chinese civilization. We are
  38. looking forward to welcoming you to share with us the full
  39. interpretation of this glorious civilization while immersing yourself
  40. in the great wisdom of Beijing.
  41. </p>
  42. <div class="more" @click="$router.push('/Layout/AboutDirector')">
  43. See More
  44. </div>
  45. </div>
  46. <!-- 2 -->
  47. <div id="About2">
  48. <h3 class="title">History</h3>
  49. <p>
  50. The Capital Museum, located in the Confucius Temple, was prepared in
  51. 1953 and formally opened in 1981.
  52. </p>
  53. <p>
  54. As a major cultural construction project in Beijing in the "10th
  55. Five-Year Plan", the new complex of the Capital Museum, approved by
  56. the Beijing Municipal Government in 1999, further approved by the
  57. State Council after being submitted by the National Development and
  58. Reform Commission in 2001, commenced its construction in December
  59. 2001.
  60. </p>
  61. <p>
  62. The new Capital Museum had the trial operation in December 2005 and
  63. was officially opened on May 18, 2006. With its magnificent
  64. architecture, abundant exhibitions, advanced technology and complete
  65. functions, the Capital Museum contributes to Beijing's standing as a
  66. famous historical and cultural city, a cultural centre and an
  67. international metropolis and ranks among the first class museums both
  68. at home and abroad and is regarded as one of the first "State
  69. First-class Museums" in 2008.
  70. </p>
  71. </div>
  72. <!-- 3 -->
  73. <div id="About3">
  74. <h3 class="title">Partners & Connections</h3>
  75. <ul class="row">
  76. <li v-for="(item, index) in link" :key="index">
  77. <a :href="item" target="_blank">
  78. <img
  79. :src="require(`@/assets/img/Layout/link${index + 1}.jpg`)"
  80. alt=""
  81. />
  82. </a>
  83. </li>
  84. </ul>
  85. <div class="more" @click="$router.push('/Layout/AboutLink')">
  86. See More
  87. </div>
  88. </div>
  89. <!-- 4 -->
  90. <div id="About4">
  91. <h3 class="title">Contact</h3>
  92. <div class="pp">Official website of Capital Museum:</div>
  93. <p class="indexUrl">https://zzbbh.4dage.com/shouBoM/index.html</p>
  94. <div class="pp">Telephone reservation (individual visitors):</div>
  95. <p>+86 (10) 63393339</p>
  96. <div class="pp">Telephone reservation (group visitors):</div>
  97. <p>+86 (10) 63370458</p>
  98. <div class="pp">Inquiry Hotline:</div>
  99. <p>+86 (10) 63370491</p>
  100. </div>
  101. </div>
  102. </div>
  103. </template>
  104. <script>
  105. export default {
  106. name: "About",
  107. components: {},
  108. data() {
  109. //这里存放数据
  110. return {
  111. menaSon: false,
  112. idMate: 0,
  113. tabData: [
  114. { name: "From the Director", path: "/Layout/About/1" },
  115. { name: "History", path: "/Layout/About/2" },
  116. { name: "Partners & Connections", path: "/Layout/About/3" },
  117. { name: "Contact", path: "/Layout/About/4" },
  118. ],
  119. link: [
  120. "http://www.edo-tokyo-museum.or.jp/en/",
  121. "https://en.shm.ru/",
  122. "https://www.rom.on.ca/en",
  123. "https://museum.seoul.go.kr/eng/index.do",
  124. "https://museumsvictoria.com.au/",
  125. "https://www.vmfa.museum/",
  126. ],
  127. };
  128. },
  129. //监听属性 类似于data概念
  130. computed: {},
  131. //监控data中的数据变化
  132. watch: {
  133. $route() {
  134. // 获取地址栏参数id
  135. let id = this.$route.params.id;
  136. id = Number(id);
  137. this.pageSrool(id - 1);
  138. this.erjiTop(id - 1);
  139. },
  140. },
  141. //方法集合
  142. methods: {
  143. cutTab(index) {
  144. this.pageSrool(index);
  145. this.erjiTop(index);
  146. },
  147. // 封装一个二级顶部滑动的方法
  148. erjiTop(index) {
  149. this.$nextTick(() => {
  150. setTimeout(() => {
  151. this.idMate = index;
  152. // 获取二级选中元素距离左侧的距离
  153. let sonScroll = document.querySelectorAll(".rowAll .row");
  154. let sonScrollAll = document.querySelector(".mainBox");
  155. sonScrollAll.scrollTo({
  156. left: sonScroll[index].offsetLeft - 100,
  157. behavior: "smooth",
  158. });
  159. }, 100);
  160. });
  161. },
  162. // 封装一个页面的滚动
  163. pageSrool(index) {
  164. this.$nextTick(() => {
  165. setTimeout(() => {
  166. // 滚动
  167. // 获取元素距离顶部的距离
  168. let dom = document.querySelector(`#About${index + 1}`);
  169. // 获取主滚动元素
  170. let domScroll = document.querySelector(".Layout");
  171. domScroll.scrollTo({ top: dom.offsetTop - 70 });
  172. }, 100);
  173. });
  174. },
  175. },
  176. //生命周期 - 创建完成(可以访问当前this实例)
  177. created() {},
  178. //生命周期 - 挂载完成(可以访问DOM元素)
  179. mounted() {
  180. this.$nextTick(() => {
  181. setTimeout(() => {
  182. // 获取顶部元素ban的高度
  183. let banDom = this.$refs.ban;
  184. // 获取滚动的总元素
  185. let scrollDom = document.querySelector(".Layout");
  186. // 获取顶部固定栏
  187. let LayoutTop = document.querySelector(".Layout .top");
  188. // 动态改变idMate高亮效果
  189. let About1 = document.querySelector("#About1");
  190. let About2 = document.querySelector("#About2");
  191. let About3 = document.querySelector("#About3");
  192. let temp;
  193. scrollDom.onscroll = () => {
  194. if (scrollDom.scrollTop > banDom.offsetHeight) {
  195. LayoutTop.style.display = "none";
  196. this.menaSon = true;
  197. } else {
  198. LayoutTop.style.display = "flex";
  199. this.menaSon = false;
  200. }
  201. if (scrollDom.scrollTop < About1.offsetTop + About1.offsetHeight - 70)
  202. temp = 0;
  203. else if (
  204. scrollDom.scrollTop <
  205. About2.offsetTop + About2.offsetHeight - 70
  206. )
  207. temp = 1;
  208. else if (
  209. scrollDom.scrollTop <
  210. About3.offsetTop + About3.offsetHeight - 70
  211. )
  212. temp = 2;
  213. else temp = 3;
  214. this.erjiTop(temp);
  215. };
  216. // 获取地址栏参数id
  217. let id = this.$route.params.id;
  218. id = Number(id);
  219. this.pageSrool(id - 1);
  220. this.erjiTop(id - 1);
  221. }, 200);
  222. });
  223. },
  224. beforeCreate() {}, //生命周期 - 创建之前
  225. beforeMount() {}, //生命周期 - 挂载之前
  226. beforeUpdate() {}, //生命周期 - 更新之前
  227. updated() {}, //生命周期 - 更新之后
  228. beforeDestroy() {}, //生命周期 - 销毁之前
  229. destroyed() {
  230. // 获取滚动的总元素,删除滚动事件
  231. let scrollDom = document.querySelector(".Layout");
  232. scrollDom.onscroll = null;
  233. // 获取顶部固定栏
  234. let LayoutTop = document.querySelector(".Layout .top");
  235. LayoutTop.style.display = "flex";
  236. }, //生命周期 - 销毁完成
  237. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  238. };
  239. </script>
  240. <style lang='less' scoped>
  241. ::-webkit-scrollbar {
  242. height: 0;
  243. width: 0;
  244. color: transparent;
  245. }
  246. .About {
  247. width: 100%;
  248. .ban {
  249. position: relative;
  250. width: 100%;
  251. & > img {
  252. width: 100%;
  253. }
  254. & > h3 {
  255. position: absolute;
  256. font-size: 24px;
  257. color: #fff;
  258. left: 20px;
  259. bottom: 20px;
  260. border-bottom: 1px solid #fff;
  261. }
  262. }
  263. .main {
  264. padding: 0 15px;
  265. background: url("../../assets/img/bgA.png");
  266. background-size: 100% 100%;
  267. .mainBox {
  268. width: 100%;
  269. overflow-x: auto;
  270. z-index: 10;
  271. .rowAll {
  272. width: 645px;
  273. padding: 20px;
  274. background-color: #f7f6f3;
  275. .row {
  276. display: inline-block;
  277. font-size: 16px;
  278. height: 30px;
  279. line-height: 30px;
  280. margin-right: 10px;
  281. padding: 0 8px;
  282. }
  283. .active {
  284. background-color: #c1aa7b;
  285. border-radius: 15px;
  286. color: #fff;
  287. }
  288. }
  289. }
  290. .title {
  291. font-size: 22px;
  292. font-weight: 700;
  293. padding-left: 30px;
  294. background: url("../../assets/img/Layout/chosen.png") left center
  295. no-repeat;
  296. background-size: 22px 18px;
  297. margin-bottom: 20px;
  298. }
  299. p {
  300. font-size: 14px;
  301. line-height: 18px;
  302. color: #6a6a6a;
  303. margin-bottom: 15px;
  304. }
  305. .more {
  306. margin: 20px auto 10px;
  307. width: 117px;
  308. height: 37px;
  309. background: url("../../assets/img/Layout/see.png");
  310. background-size: 100% 100%;
  311. color: #c1aa7b;
  312. line-height: 40px;
  313. text-align: center;
  314. }
  315. #About1 {
  316. padding: 20px 10px 30px;
  317. border-bottom: 1px solid #ccc;
  318. }
  319. #About2 {
  320. padding: 40px 10px;
  321. border-bottom: 1px solid #ccc;
  322. }
  323. #About3 {
  324. padding: 40px 0;
  325. border-bottom: 1px solid #ccc;
  326. .row {
  327. display: flex;
  328. flex-wrap: wrap;
  329. justify-content: space-between;
  330. & > li {
  331. width: 168px;
  332. height: 62px;
  333. margin-bottom: 10px;
  334. & > a {
  335. display: block;
  336. width: 100%;
  337. height: 100%;
  338. & > img {
  339. width: 100%;
  340. }
  341. }
  342. }
  343. }
  344. }
  345. #About4 {
  346. padding: 40px 10px;
  347. .pp {
  348. font-weight: 18px;
  349. font-weight: 700;
  350. line-height: 20px;
  351. color: #bc1c24;
  352. }
  353. }
  354. }
  355. .curSorll {
  356. max-width: 500px;
  357. z-index: 99;
  358. position: fixed;
  359. top: 0;
  360. left: 50%;
  361. transform: translateX(-50%);
  362. }
  363. }
  364. @media screen and (max-width: 370px) {
  365. #About3 {
  366. .row {
  367. display: block !important;
  368. & > li {
  369. margin: 0 auto 10px !important;
  370. }
  371. }
  372. }
  373. }
  374. </style>