index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <div class="train">
  3. <div class="logo"> <img src="@/assets/images/logo.png">
  4. </img></div>
  5. <div class="close" @click="getExit"></div>
  6. <div class="menu" :class="projectList.length <= 6 ? 'menu1' : 'menu2'">
  7. <swiper :slides-per-view="6" :modules="[Grid]" :grid="{
  8. fill: projectList.length <= 6 ? 'row' : 'column',
  9. rows: projectList.length <= 6 ? 1 : 2,
  10. }" :space-between="20" :slides-per-group="12">
  11. <swiper-slide v-for="(item, index) in projectList " :key="index" @click="getOption(item)">
  12. <div class="li">
  13. <div class="pic"><img :src="'static/images/train/' + item.key + '.png'"></div>
  14. <div class="name">
  15. {{ item.name }}
  16. </div>
  17. </div>
  18. </swiper-slide>
  19. </swiper>
  20. </div>
  21. <OptionWindow ref="optionWindowRef" :projectList="projectList" />
  22. </div>
  23. </template>
  24. <script setup name="TrainIndex" lang="ts">
  25. import { Swiper, SwiperSlide } from 'swiper/vue';
  26. import { Grid } from 'swiper/modules';
  27. import 'swiper/css';
  28. import 'swiper/css/grid';
  29. const router = useRouter();
  30. const { proxy } = getCurrentInstance() as any;
  31. const optionWindowRef = ref();
  32. const data = reactive<any>({
  33. projectList: [],
  34. timerManager: {},
  35. });
  36. const { projectList, timerManager } = toRefs(data);
  37. /**
  38. * 获取项目
  39. */
  40. const getExam = () => {
  41. proxy?.$http.train.projectList().then((res: any) => {
  42. projectList.value = proxy?.$utils.getProject(res.exams).filter((item: any) => {
  43. //只显示能开的
  44. return item.area.length > 0;
  45. });
  46. });
  47. };
  48. /**
  49. * 弹出选项窗口
  50. */
  51. const getOption = (data: any) => {
  52. optionWindowRef.value.open(data);
  53. };
  54. /**
  55. * 清空定时任务
  56. */
  57. const getClearTimer = () => {
  58. for (let key in timerManager.value) {
  59. if (timerManager.value.hasOwnProperty(key)) {
  60. clearInterval(timerManager.value[key])
  61. timerManager.value[key] = null;
  62. }
  63. }
  64. };
  65. /**
  66. * 初始化项目
  67. */
  68. const getInitExam = () => {
  69. getExam();
  70. //定时刷新
  71. timerManager.value.exam = setInterval(() => {
  72. getExam();
  73. }, 5000)
  74. };
  75. /**
  76. * 退出
  77. */
  78. const getExit = () => {
  79. router.go(-1);
  80. };
  81. onBeforeMount(() => {
  82. getInitExam();
  83. })
  84. onUnmounted(() => {
  85. getClearTimer();
  86. })
  87. </script>
  88. <style lang="scss" scoped>
  89. $topPadding: 5.19rem;
  90. $waiPadding: 6.51rem;
  91. .logo {
  92. img {
  93. width: 14.563rem;
  94. }
  95. position: absolute;
  96. left: $waiPadding;
  97. top: $topPadding;
  98. }
  99. .close {
  100. width: 3.2rem;
  101. height: 3.2rem;
  102. position: absolute;
  103. right: calc($waiPadding - 3.2rem);
  104. top: $topPadding;
  105. box-sizing: border-box;
  106. border: 1px solid #979797;
  107. background-image: url("@/assets/images/common/close.png");
  108. background-position: center;
  109. background-repeat: no-repeat;
  110. background-size: 45% 45%;
  111. background-color: rgba(216, 216, 216, 0.8);
  112. border-radius: 50%;
  113. transition: all 0.5s;
  114. cursor: pointer;
  115. &:hover {
  116. transform: rotate(180deg);
  117. background-color: rgba(216, 216, 216, 1);
  118. }
  119. }
  120. .menu {
  121. width: calc(100% - ($waiPadding * 2));
  122. height: 72vh;
  123. padding-top: 10rem;
  124. margin: 0 auto;
  125. .li {
  126. // width: calc((100% / 6) - 1rem + (1rem/6));
  127. // margin-right: 1rem;
  128. // margin-bottom: 1rem;
  129. width: 100%;
  130. height: 100%;
  131. padding: 2.2vh 0;
  132. border-radius: 1.6rem;
  133. box-sizing: border-box;
  134. box-shadow: inset 0px 1px 0px 2px rgba(255, 255, 255, 0.9046), inset 0px 3px 6px 0px rgba(0, 0, 0, 0.0851);
  135. display: flex;
  136. flex-wrap: wrap;
  137. justify-content: center;
  138. text-align: center;
  139. flex-shrink: 0;
  140. cursor: pointer;
  141. .name {
  142. width: 100%;
  143. font-size: 2.48rem;
  144. color: #1A293A;
  145. padding: 0.5rem 0;
  146. }
  147. .pic {
  148. width: 11.36vw;
  149. height: 11.36vw;
  150. border-radius: 50%;
  151. background: radial-gradient(78% 78% at 53% 50%, #07121A 0%, #2A4256 49%, #5180A9 100%);
  152. box-shadow: 0px 0px 2px 2px #FFFFFF;
  153. margin-bottom: 2vh;
  154. overflow: hidden;
  155. display: flex;
  156. align-items: center;
  157. justify-content: center;
  158. flex-shrink: 0;
  159. img {
  160. max-width: 88%;
  161. max-height: 88%;
  162. transition: all 1s;
  163. }
  164. }
  165. &:hover {
  166. img {
  167. transform: translateY(-0.5vw);
  168. }
  169. }
  170. }
  171. .swiper-slide {
  172. border-radius: 1.6rem;
  173. overflow: hidden;
  174. }
  175. }
  176. .menu1 {
  177. .swiper-slide:nth-child(odd) {
  178. background: radial-gradient(96% 96% at 2% 32%, #FFFFFF 0%, #FCFDFD 54%, #E1E4E7 100%);
  179. }
  180. .swiper-slide:nth-child(even) {
  181. background: radial-gradient(167% 126% at 97% 6%, #35FFC6 0%, #00FFE8 100%);
  182. }
  183. }
  184. .menu2 {
  185. display: flex;
  186. .swiper-slide {
  187. &:nth-child(1),
  188. &:nth-child(4),
  189. &:nth-child(5),
  190. &:nth-child(8),
  191. &:nth-child(9),
  192. &:nth-child(12),
  193. &:nth-child(13),
  194. &:nth-child(16),
  195. &:nth-child(17),
  196. &:nth-child(20),
  197. &:nth-child(21),
  198. &:nth-child(24),
  199. &:nth-child(25),
  200. &:nth-child(28),
  201. &:nth-child(29),
  202. &:nth-child(32),
  203. &:nth-child(33),
  204. &:nth-child(36),
  205. &:nth-child(37),
  206. &:nth-child(40),
  207. &:nth-child(41),
  208. &:nth-child(44) {
  209. background: radial-gradient(96% 96% at 2% 32%, #FFFFFF 0%, #FCFDFD 54%, #E1E4E7 100%);
  210. }
  211. &:nth-child(2),
  212. &:nth-child(3),
  213. &:nth-child(6),
  214. &:nth-child(7),
  215. &:nth-child(10),
  216. &:nth-child(11),
  217. &:nth-child(14),
  218. &:nth-child(15),
  219. &:nth-child(18),
  220. &:nth-child(19),
  221. &:nth-child(22),
  222. &:nth-child(23),
  223. &:nth-child(26),
  224. &:nth-child(27),
  225. &:nth-child(30),
  226. &:nth-child(31),
  227. &:nth-child(34),
  228. &:nth-child(35),
  229. &:nth-child(38),
  230. &:nth-child(39),
  231. &:nth-child(42),
  232. &:nth-child(43) {
  233. background: radial-gradient(167% 126% at 97% 6%, #35FFC6 0%, #00FFE8 100%);
  234. }
  235. }
  236. }
  237. @media screen and (max-width: 1450px) {
  238. .menu {
  239. .li {
  240. .name {
  241. font-size: 1.8rem;
  242. }
  243. .pic {
  244. width: 10vw;
  245. height: 10vw;
  246. }
  247. }
  248. }
  249. }
  250. </style>