index.vue 8.0 KB

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