index.vue 5.6 KB

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