Ver código fonte

日常开发

林旭祥 7 meses atrás
pai
commit
2f8aae9f56
1 arquivos alterados com 34 adições e 18 exclusões
  1. 34 18
      src/views/gesture/index.vue

+ 34 - 18
src/views/gesture/index.vue

@@ -4,7 +4,7 @@
     <div class="menu">
       <swiper v-if="projectList.length" :slides-per-view="5" :space-between="0" :initialSlide="2" :loop="true"
         :centeredSlides="true" :modules="[Navigation]" @swiper="onSwiper">
-        <swiper-slide v-for="(item, index) in projectList" :key="index">
+        <swiper-slide v-for="(item, index) in projectList" :key="index" @click="getOption(item)">
           <div class="li">
             <div class="pic"><img :src="'static/images/train/' + item.key + '.png'"></div>
             <div class="name">
@@ -67,17 +67,13 @@ const getInitExam = () => {
   }, 5000)
 };
 
-/**
- * 弹出选项窗口
-*/
-const getOption = (data: any) => {
-  optionWindowRef.value.open(data);
-};
-
 /**
  * 获取项目
 */
 const getExam = async () => {
+  if (device_info.value.project_list == undefined) {
+    return false;
+  }
   let examList = device_info.value?.project_list.map((item: any) => {
     return item.exam_name;
   })
@@ -93,7 +89,8 @@ const getExam = async () => {
 /**
  * 获取实例
 */
-const onSwiper = ($ev) => {
+const onSwiper = ($ev: any) => {
+  console.log("9999999", $ev)
   mySwiper.value = $ev;
 };
 
@@ -111,12 +108,27 @@ const slideNext = () => {
   mySwiper.value.slideNext();
 };
 
+/**
+ * 进入项目
+*/
+const getOption = (data: any) => {
+  confirm(data);
+};
+
+
 /**
  * 确定并进入
 */
-const confirm = () => {
-  let project = projectList.value[mySwiper.value.realIndex];
+const confirm = (myProject?: any) => {
+  let project = myProject ? myProject : projectList.value[mySwiper.value.realIndex];
+  console.log("projectList.value", projectList.value)
+  console.log("mySwiper.value", mySwiper.value)
+  console.log("mySwiper.value.realIndex", mySwiper.value.realIndex)
   console.log("project", project)
+  if (project == undefined) {
+    proxy?.$modal.msgError("获取不到项目信息请刷新重试");
+    return false;
+  }
   let obj = device_info.value.project_list.find((item: any) => {
     return item.exam_name == project.key;
   })
@@ -126,15 +138,20 @@ const confirm = () => {
   }
   let data = {
     gesture: obj.gesture ? true : false,
-    demo: obj.demo,
-    area: obj.area_test_id,
-    ctrl: obj.area_ctrl_id,
-    time: obj.test_time,
-    music: obj.music_info.url,
+    demo: obj?.demo || '',
+    area: obj?.area_test_id || '',
+    ctrl: obj?.area_ctrl_id || '',
+    time: obj?.test_time || '',
+    music: obj?.music_info?.url || '',
     handcontroller: device_info.value.handcontroller_id,
   }
   console.log("111", project)
+  let handcontroller_id = device_info.value.handcontroller_id;
+  if (handcontroller_id) {
+    closeHand(handcontroller_id)
+  }
   optionWindowRef.value.getGesture(JSON.parse(JSON.stringify(project)), data);
+
 };
 
 /**
@@ -227,13 +244,12 @@ onBeforeMount(() => {
     if (e?.device_info) {
       console.log("e.device_info", e.device_info)
       device_info.value = e.device_info
-      getInitExam();
       getHandWs();
     }
   });
 })
 onMounted(() => {
-
+  getInitExam();
 })
 onBeforeUnmount(() => {
   getClearTimer();