index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <template>
  2. <div class="LearnEngage">
  3. <div
  4. class="banWrapper"
  5. tabindex="0"
  6. data-aria-viewport-area
  7. aria-label
  8. :aria-description="`You've reached the banner area of the ${currentTabText} page; this section has one image; please use the tab key to go through the content.`"
  9. >
  10. <div
  11. class="ban aria-theme-independent"
  12. tabindex="0"
  13. aria-label="Image"
  14. aria-description="Learn & Engage"
  15. ></div>
  16. </div>
  17. <div
  18. class="nav_2"
  19. data-aria-viewport-area
  20. tabindex="0"
  21. aria-label
  22. aria-description="You've reached the secondary menu of the Learn & Engage section; this menu has three options; please use the tab key to go through the menu."
  23. >
  24. <ul>
  25. <li
  26. :class="{
  27. cur: topId === item.url,
  28. 'aria-inverse-theme': topId === item.url,
  29. }"
  30. v-for="(item, index) in topLi"
  31. :key="index"
  32. @click="skip(item.url)"
  33. @keydown.enter.passive="skip(item.url)"
  34. tabindex="0"
  35. aria-label="Link"
  36. :aria-description="item.name"
  37. >
  38. <div class="imgBox">
  39. <img :src="`/data/LearnEngage/${index + 1}.png`" alt="" />
  40. </div>
  41. <p
  42. :class="{
  43. 'aria-inverse-theme': topId === item.url,
  44. }"
  45. >
  46. {{ item.name }}
  47. </p>
  48. </li>
  49. </ul>
  50. </div>
  51. <!-- 面包屑 -->
  52. <div
  53. class="pos"
  54. data-aria-viewport-area
  55. tabindex="0"
  56. aria-label
  57. aria-description="You've reached the path area, please use the tab key to navigate through the content."
  58. >
  59. <span class="pos1" tabindex="0">Your Position:&nbsp;</span>
  60. <Router-link
  61. replace
  62. to="/Layout/Home"
  63. tabindex="0"
  64. aria-description="Home"
  65. >
  66. Home>
  67. </Router-link>
  68. <Router-link
  69. replace
  70. to="/Layout/LearnEngage/Students"
  71. tabindex="0"
  72. aria-description="Learn & Engage"
  73. >
  74. Learn & Engage>
  75. </Router-link>
  76. <Router-link
  77. replace
  78. to=""
  79. tabindex="0"
  80. :aria-description="currentTabText"
  81. >
  82. {{ currentTabText }}
  83. </Router-link>
  84. </div>
  85. <!-- 内容 -->
  86. <div
  87. class="conten"
  88. data-aria-viewport-area
  89. tabindex="0"
  90. aria-label
  91. :aria-description="`You've reached the content area of the ${currentTabText} page, please use the tab key to go through the content.`"
  92. >
  93. <div
  94. class="row"
  95. v-for="item in data[pageSize - 1]"
  96. :key="item.id"
  97. @click="toInfo(item.id)"
  98. @keydown.enter.passive="toInfo(item.id)"
  99. >
  100. <!-- 右下角的更多 -->
  101. <div class="rightMoer">
  102. <img src="../../assets/images/MORE.png" alt="" />
  103. </div>
  104. <div class="topImg">
  105. <img
  106. :src="`/data/LearnEngage/sm/${item.id}.png`"
  107. :alt="item.h3"
  108. tabindex="0"
  109. aria-label="Image link"
  110. :aria-description="item.h3"
  111. />
  112. </div>
  113. <div class="bottomTxt" v-if="item.info">
  114. <h3 tabindex="0" aria-label="Link">{{ item.h3 }}</h3>
  115. <p tabindex="0" aria-label="Link">Venue:{{ item.info.loc }}</p>
  116. <p tabindex="0" aria-label="Link">Date:{{ item.info.time }}</p>
  117. <p tabindex="0" aria-label="Link">Limit:{{ item.info.ren }}</p>
  118. </div>
  119. </div>
  120. </div>
  121. <!-- 分页 -->
  122. <div class="page">
  123. <span
  124. :class="{ active: pageSize === i }"
  125. v-for="i in pageNum"
  126. :key="i"
  127. @click="pageChange(i)"
  128. @keydown.enter.passive="pageChange(i)"
  129. tabindex="0"
  130. aria-label="Link"
  131. :aria-description="`page ${i}`"
  132. >
  133. {{ i }}
  134. </span>
  135. </div>
  136. </div>
  137. </template>
  138. <script>
  139. import { LearnEngage } from "@/views/dataAll";
  140. export default {
  141. name: "LearnEngage",
  142. components: {},
  143. data() {
  144. return {
  145. topId: "Students",
  146. topLi: [
  147. { name: "For Students", url: "Students" },
  148. { name: "For Adults", url: "Adults" },
  149. { name: "For Families & Children", url: "Families" },
  150. ],
  151. data: [],
  152. pageNum: 0,
  153. pageSize: 1,
  154. };
  155. },
  156. computed: {
  157. currentTabText() {
  158. return `For ${
  159. this.topId === "Families" ? "Families & Children" : this.topId
  160. }`;
  161. },
  162. },
  163. watch: {
  164. // 监听地址栏参数变化
  165. $route() {
  166. this.getData();
  167. },
  168. },
  169. methods: {
  170. // 跳转到info页面
  171. toInfo(id) {
  172. this.$router.push({
  173. name: "LearnEngageInfo",
  174. query: { id, k: this.topId, m: this.pageSize },
  175. });
  176. },
  177. // 切换页码
  178. pageChange(val) {
  179. this.pageSize = val;
  180. window.scrollTo({ top: 300, behavior: "smooth" });
  181. },
  182. skip(url) {
  183. this.$router.push(url).catch(() => {});
  184. },
  185. // 封装一个处理数据的方法
  186. getData() {
  187. this.pageSize = 1;
  188. // 拿到路由参数id
  189. this.topId = this.$route.params.id;
  190. let temp = LearnEngage[this.topId];
  191. // 判断有多少页
  192. this.pageNum = Math.ceil(temp.length / 8);
  193. let tempArrAll = [];
  194. for (let i = 0; i < this.pageNum; i++) {
  195. tempArrAll.push(temp.slice(i * 8, (i + 1) * 8));
  196. }
  197. this.data = tempArrAll;
  198. let keyword = "";
  199. switch (this.topId) {
  200. case "Students":
  201. keyword = "For Students";
  202. break;
  203. case "Adults":
  204. keyword = "For Adults";
  205. break;
  206. case "Families":
  207. keyword = "For Families & Children";
  208. break;
  209. default:
  210. break;
  211. }
  212. this.$eventBus.$emit(
  213. "request-read",
  214. `You've reached the ${keyword} page of the Learn & Engage section. This page contains one navigation section, six window sections, and one interactive section. To choose a section, please hit the shortcut key.`
  215. );
  216. },
  217. },
  218. //生命周期 - 创建完成(可以访问当前this实例)
  219. created() {
  220. this.getData();
  221. // 记录分页
  222. let mm = this.$route.query.m;
  223. if (mm) {
  224. this.pageSize = Number(mm);
  225. }
  226. },
  227. //生命周期 - 挂载完成(可以访问DOM元素)
  228. mounted() {},
  229. beforeCreate() {}, //生命周期 - 创建之前
  230. beforeMount() {}, //生命周期 - 挂载之前
  231. beforeUpdate() {}, //生命周期 - 更新之前
  232. updated() {}, //生命周期 - 更新之后
  233. beforeDestroy() {}, //生命周期 - 销毁之前
  234. destroyed() {}, //生命周期 - 销毁完成
  235. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  236. };
  237. </script>
  238. <style lang='less' scoped>
  239. .LearnEngage {
  240. background-color: #f1f1f1;
  241. .ban {
  242. width: 100%;
  243. margin: auto;
  244. background: url("/data/LearnEngage/topBan.jpg") no-repeat center top #000000;
  245. height: 300px;
  246. }
  247. .nav_2 {
  248. position: relative;
  249. top: -15px;
  250. width: 100%;
  251. overflow: hidden;
  252. zoom: 1;
  253. & > ul {
  254. background-color: #fff;
  255. padding-top: 5px;
  256. width: 1300px;
  257. padding: 5px 60px;
  258. display: flex;
  259. justify-content: space-around;
  260. margin: 0 auto;
  261. border-radius: 5px;
  262. & > li {
  263. cursor: pointer;
  264. width: 168px;
  265. height: 108px;
  266. text-align: center;
  267. padding-top: 8px;
  268. .imgBox {
  269. width: 50px;
  270. height: 50px;
  271. border-radius: 50%;
  272. overflow: hidden;
  273. background-color: black;
  274. margin: 10px auto;
  275. & > img {
  276. width: 50px;
  277. height: 50px;
  278. }
  279. }
  280. & > p {
  281. margin-top: 5px;
  282. font-size: 14px;
  283. line-height: 18px;
  284. color: black;
  285. }
  286. }
  287. .cur {
  288. .imgBox {
  289. background-color: #cd1425;
  290. }
  291. & > p {
  292. color: #cd1425;
  293. }
  294. }
  295. }
  296. }
  297. .pos {
  298. height: 28px;
  299. line-height: 28px;
  300. font-size: 12px;
  301. margin: 0 auto 10px auto;
  302. width: 1180px;
  303. .pos1 {
  304. color: #c20e11;
  305. }
  306. }
  307. .conten {
  308. width: 1178px;
  309. margin: 0 auto;
  310. display: flex;
  311. flex-wrap: wrap;
  312. .row {
  313. width: 31%;
  314. height: 350px;
  315. cursor: pointer;
  316. border-radius: 5px;
  317. overflow: hidden;
  318. margin: 0 2% 2% 0;
  319. transition: all 0.3s;
  320. position: relative;
  321. .rightMoer {
  322. position: absolute;
  323. bottom: 10px;
  324. right: 8px;
  325. width: 50px;
  326. & > img {
  327. width: 100%;
  328. }
  329. }
  330. .topImg {
  331. width: 100%;
  332. height: 220px;
  333. & > img {
  334. width: 100%;
  335. height: 100%;
  336. object-fit: cover;
  337. }
  338. }
  339. .bottomTxt {
  340. width: 100%;
  341. height: 130px;
  342. padding: 15px 20px 0;
  343. & > h3 {
  344. font-weight: 700;
  345. font-size: 18px;
  346. line-height: 22px;
  347. overflow: hidden;
  348. text-overflow: ellipsis;
  349. white-space: nowrap;
  350. }
  351. & > p {
  352. overflow: hidden;
  353. text-overflow: ellipsis;
  354. white-space: nowrap;
  355. color: #8b8b8b;
  356. font-size: 14px;
  357. line-height: 20px;
  358. font-weight: normal;
  359. }
  360. }
  361. &:nth-of-type(3n) {
  362. margin-right: 0;
  363. }
  364. &:hover {
  365. box-shadow: 0px 0px 5px 4px #ccc;
  366. background-color: #fff;
  367. }
  368. }
  369. }
  370. .page {
  371. display: flex;
  372. justify-content: center;
  373. padding-bottom: 30px;
  374. & > span {
  375. width: 30px;
  376. height: 30px;
  377. text-align: center;
  378. line-height: 30px;
  379. margin-right: 15px;
  380. border-radius: 50%;
  381. cursor: pointer;
  382. }
  383. .active {
  384. background-color: #bf2323;
  385. color: #fff;
  386. pointer-events: none;
  387. }
  388. }
  389. }
  390. </style>