index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <div class="LearnEngage">
  3. <div class="banWrapper"
  4. tabindex="0"
  5. data-aria-viewport-area
  6. aria-label
  7. :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.`"
  8. >
  9. <div class="ban"
  10. tabindex="0"
  11. aria-label="Image"
  12. aria-description="Learn & Engage"
  13. ></div>
  14. </div>
  15. <div class="nav_2" data-aria-viewport-area tabindex="0"
  16. aria-label 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."
  17. >
  18. <ul>
  19. <li
  20. :class="{ cur: topId === item.url }"
  21. v-for="(item, index) in topLi"
  22. :key="index"
  23. @click="skip(item.url)"
  24. @keydown.enter.passive="skip(item.url)"
  25. tabindex="0"
  26. aria-label="Link"
  27. :aria-description="item.name"
  28. >
  29. <img :src="`/data/LearnEngage/${index + 1}.png`" alt="" />
  30. <p>{{ item.name }}</p>
  31. </li>
  32. </ul>
  33. </div>
  34. <!-- 面包屑 -->
  35. <div class="pos" data-aria-viewport-area tabindex="0"
  36. aria-label aria-description="You've reached the path area, please use the tab key to navigate through the content."
  37. >
  38. <span class="pos1" tabindex="0">Your Position:&nbsp;</span>
  39. <Router-link
  40. replace
  41. to="/Layout/Home"
  42. tabindex="0"
  43. aria-description="Home"
  44. >
  45. Home>
  46. </Router-link>
  47. <Router-link
  48. replace
  49. to="/Layout/LearnEngage/Students"
  50. tabindex="0"
  51. aria-description="Learn & Engage"
  52. >
  53. Learn & Engage>
  54. </Router-link>
  55. <Router-link
  56. replace
  57. to=""
  58. tabindex="0"
  59. :aria-description="currentTabText"
  60. >
  61. {{currentTabText}}
  62. </Router-link>
  63. </div>
  64. <!-- 内容 -->
  65. <div class="conten" data-aria-viewport-area tabindex="0"
  66. aria-label :aria-description="`You've reached the content area of the ${currentTabText} page, please use the tab key to go through the content.`"
  67. >
  68. <div
  69. class="row"
  70. v-for="item in data[pageSize - 1]"
  71. :key="item.id"
  72. @click="toInfo(item.id)"
  73. @keydown.enter.passive="toInfo(item.id)"
  74. >
  75. <div class="left">
  76. <h3 tabindex="0" aria-label="Link">{{ item.h3 }}</h3>
  77. <p tabindex="0" aria-label="Link">{{ item.p }}</p>
  78. <h4 v-html="item.h4" tabindex="0" aria-label="Link"></h4>
  79. </div>
  80. <div class="right">
  81. <img :src="`/data/LearnEngage/sm/${item.id}.png`"
  82. :alt="item.h3"
  83. tabindex="0" aria-label="Image link"
  84. :aria-description="item.h3"
  85. />
  86. </div>
  87. </div>
  88. <!-- 分页 -->
  89. <div class="page">
  90. <span
  91. :class="{ active: pageSize === i }"
  92. v-for="i in pageNum"
  93. :key="i"
  94. @click="pageChange(i)"
  95. @keydown.enter.passive="pageChange(i)"
  96. tabindex="0"
  97. aria-label="Link"
  98. :aria-description="`page ${i}`"
  99. >
  100. {{ i }}
  101. </span>
  102. </div>
  103. </div>
  104. </div>
  105. </template>
  106. <script>
  107. import { LearnEngage } from "@/views/dataAll";
  108. export default {
  109. name: "LearnEngage",
  110. components: {},
  111. data() {
  112. return {
  113. topId: "Students",
  114. topLi: [
  115. { name: "For Students", url: "Students" },
  116. { name: "For Adults", url: "Adults" },
  117. { name: "For Families & Children", url: "Families" },
  118. ],
  119. data: [],
  120. pageNum: 0,
  121. pageSize: 1,
  122. };
  123. },
  124. computed: {
  125. currentTabText() {
  126. return `For ${this.topId === "Families" ? "Families & Children" : this.topId }`
  127. }
  128. },
  129. watch: {
  130. // 监听地址栏参数变化
  131. $route() {
  132. this.getData();
  133. },
  134. },
  135. methods: {
  136. // 跳转到info页面
  137. toInfo(id) {
  138. this.$router.replace({
  139. name: "LearnEngageInfo",
  140. query: { id, k:this.topId,m:this.pageSize},
  141. });
  142. },
  143. // 切换页码
  144. pageChange(val) {
  145. this.pageSize = val;
  146. window.scrollTo({ top: 300, behavior: "smooth" });
  147. },
  148. skip(url) {
  149. this.$router.replace(url).catch(() => {});
  150. },
  151. // 封装一个处理数据的方法
  152. getData() {
  153. this.pageSize = 1;
  154. // 拿到路由参数id
  155. this.topId = this.$route.params.id;
  156. let temp = LearnEngage[this.topId];
  157. // 判断有多少页
  158. this.pageNum = Math.ceil(temp.length / 8);
  159. let tempArrAll = [];
  160. for (let i = 0; i < this.pageNum; i++) {
  161. tempArrAll.push(temp.slice(i * 8, (i + 1) * 8));
  162. }
  163. this.data = tempArrAll;
  164. let keyword = ''
  165. switch (this.topId) {
  166. case 'Students':
  167. keyword = 'For Students'
  168. break;
  169. case 'Adults':
  170. keyword = 'For Adults'
  171. break;
  172. case 'Families':
  173. keyword = 'For Families & Children'
  174. break;
  175. default:
  176. break;
  177. }
  178. this.$eventBus.$emit('request-read', `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.`)
  179. },
  180. },
  181. //生命周期 - 创建完成(可以访问当前this实例)
  182. created() {
  183. this.getData();
  184. // 记录分页
  185. let mm =this.$route.query.m
  186. if(mm){
  187. this.pageSize =Number(mm)
  188. }
  189. },
  190. //生命周期 - 挂载完成(可以访问DOM元素)
  191. mounted() {},
  192. beforeCreate() {}, //生命周期 - 创建之前
  193. beforeMount() {}, //生命周期 - 挂载之前
  194. beforeUpdate() {}, //生命周期 - 更新之前
  195. updated() {}, //生命周期 - 更新之后
  196. beforeDestroy() {}, //生命周期 - 销毁之前
  197. destroyed() {}, //生命周期 - 销毁完成
  198. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  199. };
  200. </script>
  201. <style lang='less' scoped>
  202. .LearnEngage {
  203. background-color: #fff;
  204. .ban {
  205. width: 100%;
  206. margin: auto;
  207. background: url("/data/LearnEngage/topBan.jpg") no-repeat center top #000000;
  208. height: 300px;
  209. }
  210. .nav_2 {
  211. width: 100%;
  212. padding-bottom: 8px;
  213. background: url("../../assets/images/Visit/bg_3.png") left bottom repeat-x
  214. #f1f1f1;
  215. overflow: hidden;
  216. zoom: 1;
  217. & > ul {
  218. display: flex;
  219. width: 1180px;
  220. margin: 0 auto;
  221. & > li {
  222. background: #f1f1f1;
  223. cursor: pointer;
  224. width: 168px;
  225. height: 108px;
  226. text-align: center;
  227. & > img {
  228. margin-top: 25px;
  229. // width: 49px;
  230. // height: 39px;
  231. }
  232. & > p {
  233. margin-top: 5px;
  234. font-size: 14px;
  235. line-height: 18px;
  236. }
  237. }
  238. .cur {
  239. background: url("../../assets/images/Visit/bg_1.jpg") center top
  240. no-repeat #f1f1f1;
  241. }
  242. }
  243. }
  244. .pos {
  245. height: 28px;
  246. line-height: 28px;
  247. font-size: 12px;
  248. margin: 0 auto 10px auto;
  249. width: 1180px;
  250. .pos1 {
  251. color: #c20e11;
  252. }
  253. }
  254. .conten {
  255. width: 1178px;
  256. margin: 0 auto;
  257. .row {
  258. cursor: pointer;
  259. padding: 20px;
  260. border: solid 1px #c7c7c7;
  261. border-right: 0;
  262. height: 295px;
  263. margin-bottom: 20px;
  264. .left {
  265. width: 730px;
  266. float: left;
  267. & > h3 {
  268. font-weight: 700;
  269. font-size: 18px;
  270. line-height: 22px;
  271. }
  272. & > p {
  273. color: #a5a5a5;
  274. font-size: 14px;
  275. line-height: 20px;
  276. font-weight: normal;
  277. padding: 10px 0 40px 0;
  278. }
  279. & > h4 {
  280. font-size: 14px;
  281. line-height: 24px;
  282. font-weight: 700;
  283. }
  284. }
  285. .right {
  286. width: 375px;
  287. float: right;
  288. & > img {
  289. width: 375px;
  290. height: 255px;
  291. object-fit: cover;
  292. }
  293. }
  294. }
  295. .page {
  296. display: flex;
  297. justify-content: center;
  298. padding-bottom: 30px;
  299. & > span {
  300. margin-right: 8px;
  301. cursor: pointer;
  302. }
  303. .active {
  304. color: #bf2323;
  305. pointer-events: none;
  306. }
  307. }
  308. }
  309. }
  310. </style>