index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <div class="train">
  3. <Header @confirmExit="getExit" :showTool="false" closeClass="close2"></Header>
  4. <div class="main">
  5. <div class="left">
  6. <div class="title"></div>
  7. <ul>
  8. <li>初一春季体育测试</li>
  9. <li>初一春季体育测试</li>
  10. <li>初一春季体育测试</li>
  11. <li>初一春季体育测试</li>
  12. <li>初一春季体育测试</li>
  13. <li>初一春季体育测试</li>
  14. <li>初一春季体育测试</li>
  15. <li>初一春季体育测试</li>
  16. <li>初一春季体育测试</li>
  17. <li>初一春季体育测试</li>
  18. <li>初一春季体育测试</li>
  19. <li>初一春季体育测试</li>
  20. <li>初一春季体育测试</li>
  21. <li>初一春季体育测试</li>
  22. <li>初一春季体育测试</li>
  23. <li>初一春季体育测试</li>
  24. <li>初一春季体育测试</li>
  25. </ul>
  26. </div>
  27. <div class="menu" v-if="projectList.length" :class="projectList.length <= 10 ? 'menu1' : 'menu2'">
  28. <swiper :slides-per-view="5" :modules="[Grid]" :grid="{
  29. fill: projectList.length <= 10 ? 'row' : 'column',
  30. rows: 2,
  31. }" :space-between="20" :slides-per-group="10">
  32. <swiper-slide v-for="(item, index) in projectList " :key="index" @click="getOption(item)">
  33. <div class="li">
  34. <div class="pic"><img :src="'static/images/train/' + item.key + '.png'"></div>
  35. <div class="name">
  36. {{ item.name }}
  37. </div>
  38. </div>
  39. </swiper-slide>
  40. </swiper>
  41. </div>
  42. </div>
  43. <OptionWindow ref="optionWindowRef" :projectList="projectList" />
  44. </div>
  45. </template>
  46. <script setup name="TrainIndex" lang="ts">
  47. import { Swiper, SwiperSlide } from 'swiper/vue';
  48. import { Grid } from 'swiper/modules';
  49. import 'swiper/css';
  50. import 'swiper/css/grid';
  51. const router = useRouter();
  52. const { proxy } = getCurrentInstance() as any;
  53. const optionWindowRef = ref();
  54. const data = reactive<any>({
  55. projectList: [],
  56. timerManager: {},
  57. });
  58. const { projectList, timerManager } = toRefs(data);
  59. /**
  60. * 获取项目
  61. */
  62. const getExam = () => {
  63. proxy?.$http.train.projectList().then((res: any) => {
  64. projectList.value = proxy?.$utils.getProject(res.exams).filter((item: any) => {
  65. //只显示能开的
  66. return item.area.length > 0;
  67. });
  68. });
  69. };
  70. /**
  71. * 弹出选项窗口
  72. */
  73. const getOption = (data: any) => {
  74. optionWindowRef.value.open(data);
  75. };
  76. /**
  77. * 清空定时任务
  78. */
  79. const getClearTimer = () => {
  80. for (let key in timerManager.value) {
  81. if (timerManager.value.hasOwnProperty(key)) {
  82. clearInterval(timerManager.value[key])
  83. timerManager.value[key] = null;
  84. }
  85. }
  86. };
  87. /**
  88. * 初始化项目
  89. */
  90. const getInitExam = () => {
  91. getExam();
  92. //定时刷新
  93. timerManager.value.exam = setInterval(() => {
  94. getExam();
  95. }, 5000)
  96. };
  97. /**
  98. * 退出
  99. */
  100. const getExit = () => {
  101. router.go(-1);
  102. };
  103. onBeforeMount(() => {
  104. getInitExam();
  105. })
  106. onBeforeUnmount(() => {
  107. getClearTimer();
  108. })
  109. </script>
  110. <style lang="scss" scoped>
  111. $topPadding: 5.19rem;
  112. $waiPadding: 6.51rem;
  113. .main {
  114. width: calc(100% - ($waiPadding * 2));
  115. height: 72vh;
  116. padding-top: 10rem;
  117. margin: 0 auto;
  118. display: flex;
  119. justify-content: space-between;
  120. }
  121. .left {
  122. width: calc(23.4% - 20px);
  123. height: 72vh;
  124. display: flex;
  125. flex-direction: column;
  126. overflow: hidden;
  127. .title {
  128. height: 7.05vh;
  129. line-height: 7.05vh;
  130. width: 100%;
  131. text-align: center;
  132. color: #1A293A;
  133. font-size: 1.65rem;
  134. background: radial-gradient(120% 126% at 5% 93%, #8EFFA9 0%, #07FFE7 100%);
  135. border-top-left-radius: 1.6rem;
  136. border-top-right-radius: 1.6rem;
  137. }
  138. ul {
  139. height: 100%;
  140. overflow-y: scroll;
  141. border: 1px solid #48677E;
  142. border-bottom-left-radius: 1.6rem;
  143. border-bottom-right-radius: 1.6rem;
  144. background: linear-gradient(27deg, #092941 -82%, #2A484B 94%);
  145. li {
  146. border-bottom: 1px solid #48677E;
  147. font-size: 1.6rem;
  148. color: #ffffff;
  149. padding: 1.6vh 0 1.6vh 1.5rem;
  150. &:last-child {
  151. border-bottom: none;
  152. }
  153. }
  154. &::-webkit-scrollbar {
  155. width: 0px;
  156. }
  157. &::-webkit-scrollbar-thumb {
  158. border-width: 2px;
  159. border-radius: 4px;
  160. border-style: dashed;
  161. border-color: transparent;
  162. background-color: rgba(216, 216, 216, 0.8);
  163. background-clip: padding-box;
  164. }
  165. &::-webkit-scrollbar-button:hover {
  166. border-radius: 6px;
  167. background: rgba(216, 216, 216, 0.8);
  168. }
  169. }
  170. }
  171. .menu {
  172. width: calc(100% - 23.4%);
  173. height: 72vh;
  174. .li {
  175. // width: calc((100% / 6) - 1rem + (1rem/6));
  176. // margin-right: 1rem;
  177. // margin-bottom: 1rem;
  178. width: 100%;
  179. height: calc((72vh / 2) - 10px);
  180. padding: 2.2vh 0;
  181. border-radius: 1.6rem;
  182. box-sizing: border-box;
  183. box-shadow: inset 0px 1px 0px 2px rgba(255, 255, 255, 0.9046), inset 0px 3px 6px 0px rgba(0, 0, 0, 0.0851);
  184. display: flex;
  185. flex-wrap: wrap;
  186. justify-content: center;
  187. text-align: center;
  188. flex-shrink: 0;
  189. cursor: pointer;
  190. .name {
  191. width: 100%;
  192. font-size: 2.48rem;
  193. color: #1A293A;
  194. padding: 0.5rem 0;
  195. }
  196. .pic {
  197. width: 11.36vw;
  198. height: 11.36vw;
  199. border-radius: 50%;
  200. background: radial-gradient(78% 78% at 53% 50%, #07121A 0%, #2A4256 49%, #5180A9 100%);
  201. box-shadow: 0px 0px 2px 2px #FFFFFF;
  202. margin-bottom: 2vh;
  203. overflow: hidden;
  204. display: flex;
  205. align-items: center;
  206. justify-content: center;
  207. flex-shrink: 0;
  208. img {
  209. max-width: 88%;
  210. max-height: 88%;
  211. transition: all 1s;
  212. }
  213. }
  214. &:hover {
  215. img {
  216. transform: translateY(-0.5vw);
  217. }
  218. }
  219. }
  220. .swiper-slide {
  221. border-radius: 1.6rem;
  222. overflow: hidden;
  223. }
  224. }
  225. .menu1 {
  226. .swiper-slide {
  227. margin-bottom: 20px;
  228. .li {
  229. background: radial-gradient(96% 96% at 2% 32%, #FFFFFF 0%, #FCFDFD 54%, #E1E4E7 100%);
  230. }
  231. &:nth-child(2),
  232. &:nth-child(4),
  233. &:nth-child(6),
  234. &:nth-child(7),
  235. &:nth-child(9),
  236. &:nth-child(11) {
  237. .li {
  238. background: radial-gradient(167% 126% at 97% 6%, #35FFC6 0%, #00FFE8 100%);
  239. }
  240. }
  241. }
  242. }
  243. .menu2 {
  244. display: flex;
  245. .swiper-slide {
  246. &:nth-child(1),
  247. &:nth-child(4),
  248. &:nth-child(5),
  249. &:nth-child(8),
  250. &:nth-child(9),
  251. &:nth-child(12),
  252. &:nth-child(13),
  253. &:nth-child(16),
  254. &:nth-child(17),
  255. &:nth-child(20),
  256. &:nth-child(21),
  257. &:nth-child(24),
  258. &:nth-child(25),
  259. &:nth-child(28),
  260. &:nth-child(29),
  261. &:nth-child(32),
  262. &:nth-child(33),
  263. &:nth-child(36),
  264. &:nth-child(37),
  265. &:nth-child(40),
  266. &:nth-child(41),
  267. &:nth-child(44) {
  268. .li {
  269. background: radial-gradient(96% 96% at 2% 32%, #FFFFFF 0%, #FCFDFD 54%, #E1E4E7 100%);
  270. }
  271. }
  272. &:nth-child(2),
  273. &:nth-child(3),
  274. &:nth-child(6),
  275. &:nth-child(7),
  276. &:nth-child(10),
  277. &:nth-child(11),
  278. &:nth-child(14),
  279. &:nth-child(15),
  280. &:nth-child(18),
  281. &:nth-child(19),
  282. &:nth-child(22),
  283. &:nth-child(23),
  284. &:nth-child(26),
  285. &:nth-child(27),
  286. &:nth-child(30),
  287. &:nth-child(31),
  288. &:nth-child(34),
  289. &:nth-child(35),
  290. &:nth-child(38),
  291. &:nth-child(39),
  292. &:nth-child(42),
  293. &:nth-child(43) {
  294. .li {
  295. background: radial-gradient(167% 126% at 97% 6%, #35FFC6 0%, #00FFE8 100%);
  296. }
  297. }
  298. }
  299. }
  300. ::v-deep(.menu) {
  301. .swiper-horizontal {
  302. width: 100%;
  303. }
  304. }
  305. @media screen and (max-width: 1450px) {
  306. .menu {
  307. .li {
  308. .name {
  309. font-size: 1.8rem;
  310. }
  311. .pic {
  312. width: 10vw;
  313. height: 10vw;
  314. }
  315. }
  316. }
  317. }
  318. </style>