123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- <template>
- <div class="train">
- <Header @confirmExit="getExit" :showTool="false" closeClass="close2"></Header>
- <div class="menu" v-if="projectList.length" :class="projectList.length <= 12 ? 'menu1' : 'menu2'" :key="projectList.length">
- <swiper
- :slides-per-view="6"
- :modules="[Grid]"
- :grid="{
- fill: projectList.length <= 12 ? 'row' : 'column',
- rows: 2,
- }"
- :space-between="20"
- :slides-per-group="12"
- >
- <swiper-slide v-for="(item, index) in projectList " :key="index" @click="getOption(item)">
- <div class="li">
- <div>
- <div class="pic"><img :src="'static/images/train/' + item.key + '.png'" /></div>
- <div class="name">
- {{ item.name }}
- </div>
- </div>
- </div>
- </swiper-slide>
- </swiper>
- </div>
- <OptionWindow ref="optionWindowRef" :projectList="projectList" />
- </div>
- </template>
- <script setup name="TrainIndex" lang="ts">
- import { initSpeech, speckText, playMusic, controlMusic, speckCancel, chineseNumber } from '@/utils/speech';
- import { Swiper, SwiperSlide } from 'swiper/vue';
- import { Grid } from 'swiper/modules';
- import 'swiper/css';
- import 'swiper/css/grid';
- const router = useRouter();
- const { proxy } = getCurrentInstance() as any;
- const optionWindowRef = ref();
- const data = reactive<any>({
- projectList: [],
- timerManager: {},
- deviceInfo: {}
- });
- const { projectList, timerManager, deviceInfo } = toRefs(data);
- /**
- * 获取项目
- */
- const getExam = () => {
- let deviceid = localStorage.getItem('deviceid');
- let myList = deviceInfo.value?.project_list || [];
- let examList = myList.map((item: any) => {
- return item.exam_name;
- });
- proxy?.$http.train.projectList().then((res: any) => {
- projectList.value = proxy?.$utils.getProject(res.exams).filter((item: any) => {
- //只显示能开的
- if (deviceid) {
- return item.area.length > 0 && examList.includes(item.key);
- } else {
- return item.area.length > 0;
- }
- });
- });
- };
- /**
- * 弹出选项窗口
- */
- const getOption = (data: any) => {
- let deviceid = localStorage.getItem('deviceid');
- if (deviceid) {
- //设备快捷入口
- let project = data;
- if (project == undefined) {
- proxy?.$modal.msgError('获取不到项目信息');
- return false;
- }
- let obj = deviceInfo.value.project_list.find((item: any) => {
- return item.exam_name == project.key;
- });
- if (obj == undefined) {
- proxy?.$modal.msgError('该项目没有配置参数');
- return false;
- }
- let dataObj = {
- gesture: obj.gesture ? true : false,
- demo: obj?.demo || 0,
- area: obj?.area_test_id || '',
- ctrl: obj?.area_ctrl_id || '',
- time: obj?.test_time || '',
- music: obj?.music_info?.id || '',
- };
- optionWindowRef.value.getGesture(project, dataObj);
- } else {
- //弹窗选项
- optionWindowRef.value.open(data);
- }
- };
- /**
- * 清空定时任务
- */
- const getClearTimer = () => {
- for (let key in timerManager.value) {
- if (timerManager.value.hasOwnProperty(key)) {
- clearInterval(timerManager.value[key]);
- timerManager.value[key] = null;
- }
- }
- };
- /**
- * 获取设备信息
- */
- const getDeviceInfo = async () => {
- let deviceid = localStorage.getItem('deviceid') || '';
- if (deviceid) {
- //如果有设备就先查设备配置信息
- let params = {
- search_info: deviceid,
- page: 1,
- per_page: 1
- };
- await proxy?.$http.common
- .deviceInfo(params)
- .then((res: any) => {
- if (res.data.length) {
- deviceInfo.value = res.data[0];
- }
- })
- .catch(() => {})
- .finally(() => {});
- }
- };
- /**
- * 初始化项目
- */
- const getInitExam = () => {
- getExam();
- //定时刷新
- timerManager.value.exam = setInterval(() => {
- getExam();
- }, 5000);
- };
- /**
- * 退出
- */
- const getExit = () => {
- // router.go(-1);
- router.push({ path: '/home' });
- };
- onBeforeMount(async () => {
- await getDeviceInfo()
- await getInitExam();
- });
- onMounted(() => {
- //停止播报;
- speckCancel();
- });
- onBeforeUnmount(() => {
- getClearTimer();
- });
- </script>
- <style lang="scss" scoped>
- $topPadding: 5.19rem;
- $waiPadding: 6.51rem;
- .menu {
- width: calc(100% - ($waiPadding * 2));
- height: 72vh;
- padding-top: 10rem;
- margin: 0 auto;
- display: flex;
- align-items: center;
-
- .li {
- // width: calc((100% / 6) - 1rem + (1rem/6));
- // margin-right: 1rem;
- // margin-bottom: 1rem;
- width: 100%;
- height: calc((72vh / 2) - 20px);
- padding: 2.2vh 0;
- border-radius: 1.6rem;
- box-sizing: border-box;
- box-shadow: inset 0px 1px 0px 2px rgba(255, 255, 255, 0.9046), inset 0px 3px 6px 0px rgba(0, 0, 0, 0.0851);
- display: flex;
- justify-content: center;
- align-items: center;
- cursor: pointer;
- .pic {
- width: 11.36vw;
- height: 11.36vw;
- border-radius: 50%;
- background: radial-gradient(78% 78% at 53% 50%, #07121a 0%, #2a4256 49%, #5180a9 100%);
- box-shadow: 0px 0px 2px 2px #ffffff;
- margin-bottom: 2.5vh;
- overflow: hidden;
- display: flex;
- align-items: center;
- justify-content: center;
- flex-shrink: 0;
- img {
- max-width: 88%;
- max-height: 88%;
- transition: all 1s;
- }
- }
- .name {
- width: 100%;
- font-size: 2.48rem;
- color: #1a293a;
- text-align: center;
- }
- &:hover {
- img {
- transform: translateY(-0.5vw);
- }
- }
- }
- .swiper-slide {
- border-radius: 1.6rem;
- overflow: hidden;
- }
- }
- .menu1 {
- .swiper-slide {
- margin-bottom: 20px;
- .li {
- background: radial-gradient(96% 96% at 2% 32%, #ffffff 0%, #fcfdfd 54%, #e1e4e7 100%);
- }
- &:nth-child(2),
- &:nth-child(4),
- &:nth-child(6),
- &:nth-child(7),
- &:nth-child(9),
- &:nth-child(11) {
- .li {
- background: radial-gradient(167% 126% at 97% 6%, #35ffc6 0%, #00ffe8 100%);
- }
- }
- }
- }
- .menu2 {
- display: flex;
- .swiper-slide {
- &:nth-child(1),
- &:nth-child(4),
- &:nth-child(5),
- &:nth-child(8),
- &:nth-child(9),
- &:nth-child(12),
- &:nth-child(13),
- &:nth-child(16),
- &:nth-child(17),
- &:nth-child(20),
- &:nth-child(21),
- &:nth-child(24),
- &:nth-child(25),
- &:nth-child(28),
- &:nth-child(29),
- &:nth-child(32),
- &:nth-child(33),
- &:nth-child(36),
- &:nth-child(37),
- &:nth-child(40),
- &:nth-child(41),
- &:nth-child(44) {
- .li {
- background: radial-gradient(96% 96% at 2% 32%, #ffffff 0%, #fcfdfd 54%, #e1e4e7 100%);
- }
- }
- &:nth-child(2),
- &:nth-child(3),
- &:nth-child(6),
- &:nth-child(7),
- &:nth-child(10),
- &:nth-child(11),
- &:nth-child(14),
- &:nth-child(15),
- &:nth-child(18),
- &:nth-child(19),
- &:nth-child(22),
- &:nth-child(23),
- &:nth-child(26),
- &:nth-child(27),
- &:nth-child(30),
- &:nth-child(31),
- &:nth-child(34),
- &:nth-child(35),
- &:nth-child(38),
- &:nth-child(39),
- &:nth-child(42),
- &:nth-child(43) {
- .li {
- background: radial-gradient(167% 126% at 97% 6%, #35ffc6 0%, #00ffe8 100%);
- }
- }
- }
- }
- ::v-deep(.menu) {
- .swiper-horizontal {
- width: 100%;
- }
- }
- @media screen and (max-width: 1450px) {
- .menu {
- .li {
- .name {
- font-size: 1.8rem;
- }
- .pic {
- width: 10vw;
- height: 10vw;
- }
- }
- }
- }
- </style>
|