index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <div class="game">
  3. <Header @confirmExit="getExit" :showTool="false" closeClass="close2"></Header>
  4. <div class="menu" v-if="projectList.length" :class="projectList.length <= 12 ? 'menu1' : 'menu2'"
  5. :key="projectList.length">
  6. <swiper :slides-per-view="6" :modules="[Grid]" :grid="{
  7. fill: projectList.length <= 12 ? 'row' : 'column',
  8. rows: 2,
  9. }" :space-between="20" :slides-per-group="12">
  10. <swiper-slide v-for="(item, index) in projectList" :key="index" @click="getJump(item)">
  11. <div class="li">
  12. <div>
  13. <div class="pic"><img :src="'static/images/game/' + item.key + '.png'" /></div>
  14. <div class="name">
  15. {{ item.name }}
  16. </div>
  17. </div>
  18. </div>
  19. </swiper-slide>
  20. </swiper>
  21. </div>
  22. </div>
  23. </template>
  24. <script setup name="TrainIndex" lang="ts">
  25. import { initSpeech, speckText, playMusic, controlMusic, speckCancel, chineseNumber } from '@/utils/speech';
  26. import { Swiper, SwiperSlide } from 'swiper/vue';
  27. import { Grid } from 'swiper/modules';
  28. import 'swiper/css';
  29. import 'swiper/css/grid';
  30. const router = useRouter();
  31. const { proxy } = getCurrentInstance() as any;
  32. const data = reactive<any>({
  33. projectList: [],
  34. });
  35. const { projectList } = toRefs(data);
  36. //跳转
  37. const getJump = (data: any) => {
  38. if (data.key == 'square') {
  39. router.push({
  40. path: `/game/${data.key}`, query: {
  41. project: 'jumprope',
  42. time: 60,
  43. area: 29,
  44. gesture: 'true',
  45. classes: '1'
  46. }
  47. });
  48. } else {
  49. router.push({ path: `/game/${data.key}`, query: {} });
  50. }
  51. };
  52. /**
  53. * 退出
  54. */
  55. const getExit = () => {
  56. // router.go(-1);
  57. router.push({ path: '/home' });
  58. };
  59. onBeforeMount(async () => {
  60. });
  61. onMounted(() => {
  62. //停止播报;
  63. speckCancel();
  64. projectList.value = [{ name: "方块跳一跳", key: "square" }, { name: "水果忍者", key: "fruit" }, { name: "17点位", key: "humanBody" }]
  65. });
  66. onBeforeUnmount(() => {
  67. });
  68. </script>
  69. <style lang="scss" scoped>
  70. $topPadding: 5.19rem;
  71. $waiPadding: 6.51rem;
  72. .menu {
  73. width: calc(100% - ($waiPadding * 2));
  74. height: 72vh;
  75. padding-top: 10rem;
  76. margin: 0 auto;
  77. display: flex;
  78. .li {
  79. // width: calc((100% / 6) - 1rem + (1rem/6));
  80. // margin-right: 1rem;
  81. // margin-bottom: 1rem;
  82. width: 100%;
  83. height: calc((72vh / 2) - 20px);
  84. padding: 2.2vh 0;
  85. border-radius: 1.6rem;
  86. box-sizing: border-box;
  87. box-shadow: inset 0px 1px 0px 2px rgba(255, 255, 255, 0.9046), inset 0px 3px 6px 0px rgba(0, 0, 0, 0.0851);
  88. display: flex;
  89. justify-content: center;
  90. align-items: center;
  91. cursor: pointer;
  92. .pic {
  93. width: 11.36vw;
  94. height: 11.36vw;
  95. border-radius: 50%;
  96. background: radial-gradient(78% 78% at 53% 50%, #07121a 0%, #2a4256 49%, #5180a9 100%);
  97. box-shadow: 0px 0px 2px 2px #ffffff;
  98. margin-bottom: 2.5vh;
  99. overflow: hidden;
  100. display: flex;
  101. align-items: center;
  102. justify-content: center;
  103. flex-shrink: 0;
  104. img {
  105. max-width: 88%;
  106. max-height: 88%;
  107. transition: all 1s;
  108. }
  109. }
  110. .name {
  111. width: 100%;
  112. font-size: 2.48rem;
  113. color: #1a293a;
  114. text-align: center;
  115. }
  116. &:hover {
  117. img {
  118. transform: translateY(-0.5vw);
  119. }
  120. }
  121. }
  122. .swiper-slide {
  123. border-radius: 1.6rem;
  124. overflow: hidden;
  125. }
  126. }
  127. .menu1 {
  128. align-items: center;
  129. .swiper-slide {
  130. margin-bottom: 20px;
  131. .li {
  132. background: radial-gradient(96% 96% at 2% 32%, #ffffff 0%, #fcfdfd 54%, #e1e4e7 100%);
  133. }
  134. &:nth-child(2),
  135. &:nth-child(4),
  136. &:nth-child(6),
  137. &:nth-child(7),
  138. &:nth-child(9),
  139. &:nth-child(11) {
  140. .li {
  141. background: radial-gradient(167% 126% at 97% 6%, #35ffc6 0%, #00ffe8 100%);
  142. }
  143. }
  144. }
  145. }
  146. .menu2 {
  147. display: flex;
  148. .swiper-slide {
  149. &:nth-child(1),
  150. &:nth-child(4),
  151. &:nth-child(5),
  152. &:nth-child(8),
  153. &:nth-child(9),
  154. &:nth-child(12),
  155. &:nth-child(13),
  156. &:nth-child(16),
  157. &:nth-child(17),
  158. &:nth-child(20),
  159. &:nth-child(21),
  160. &:nth-child(24),
  161. &:nth-child(25),
  162. &:nth-child(28),
  163. &:nth-child(29),
  164. &:nth-child(32),
  165. &:nth-child(33),
  166. &:nth-child(36),
  167. &:nth-child(37),
  168. &:nth-child(40),
  169. &:nth-child(41),
  170. &:nth-child(44) {
  171. .li {
  172. background: radial-gradient(96% 96% at 2% 32%, #ffffff 0%, #fcfdfd 54%, #e1e4e7 100%);
  173. }
  174. }
  175. &:nth-child(2),
  176. &:nth-child(3),
  177. &:nth-child(6),
  178. &:nth-child(7),
  179. &:nth-child(10),
  180. &:nth-child(11),
  181. &:nth-child(14),
  182. &:nth-child(15),
  183. &:nth-child(18),
  184. &:nth-child(19),
  185. &:nth-child(22),
  186. &:nth-child(23),
  187. &:nth-child(26),
  188. &:nth-child(27),
  189. &:nth-child(30),
  190. &:nth-child(31),
  191. &:nth-child(34),
  192. &:nth-child(35),
  193. &:nth-child(38),
  194. &:nth-child(39),
  195. &:nth-child(42),
  196. &:nth-child(43) {
  197. .li {
  198. background: radial-gradient(167% 126% at 97% 6%, #35ffc6 0%, #00ffe8 100%);
  199. }
  200. }
  201. }
  202. }
  203. ::v-deep(.menu) {
  204. .swiper-horizontal {
  205. width: 100%;
  206. }
  207. }
  208. @media screen and (max-width: 1450px) {
  209. .menu {
  210. .li {
  211. .name {
  212. font-size: 1.8rem;
  213. }
  214. .pic {
  215. width: 10vw;
  216. height: 10vw;
  217. }
  218. }
  219. }
  220. }
  221. </style>