林旭祥 7 месяцев назад
Родитель
Сommit
11d7262a66

+ 2 - 1
.env.development

@@ -1,5 +1,6 @@
 # 开发环境
-VITE_APP_BASE_API = 'https://api-aiexamtst.tropsx.com'
+# VITE_APP_BASE_API = 'https://api-aiexamtst.tropsx.com'
+VITE_APP_BASE_API = 'https://api-aiexam.tropsx.com'
 VITE_APP_PORT = 80
 # 是否在打包时开启压缩,支持 gzip 和 brotli
 VITE_BUILD_COMPRESS = gzip

+ 5 - 4
src/utils/handWs.ts

@@ -10,6 +10,7 @@ socketHand = io(address + '/', {
     Authorization: token
   }
 });
+
 export const handWs = (callback: any) => {
   callback(testConnect);
   socketHand.on('connect', (e: any) => {
@@ -19,16 +20,16 @@ export const handWs = (callback: any) => {
     testConnect = e;
     callback(e);
   });
-  socketHand.on('handcontroller_ack', (e: any) => {
+  socketHand.on('device_login_result', (e: any) => {
     callback(e);
   });
-  socketHand.on('handcontroller_result', (e: any) => {
+  socketHand.on('fe_device_init_result', (e: any) => {
     callback(e);
   });
-  socketHand.on('device_login_result', (e: any) => {
+  socketHand.on('handcontroller_ack', (e: any) => {
     callback(e);
   });
-  socketHand.on('fe_device_init_result', (e: any) => {
+  socketHand.on('handcontroller_result', (e: any) => {
     callback(e);
   });
   socketHand.on('disconnect', (e: any) => {

+ 6 - 1
src/utils/ws.ts

@@ -13,6 +13,8 @@ let version: string = ''; //ws接口版本v2表示单ws多项目
 let examStateList: any = []; //当前状态码
 let testList: any = []; //区列表
 let wkList: any = []; //工作站列表
+let loadingTime: any = null; //记录等待时间
+
 socket = io(address + '/midexam', {
   transports: ['websocket', 'polling'],
   query: {
@@ -38,7 +40,7 @@ export const initWs = (data: any, callback: any) => {
     };
     return obj;
   });
-  let loadingTime = setTimeout(() => {
+  loadingTime = setTimeout(() => {
     //30秒还在0状态就算超时
     let list = examStateList.filter((item: any) => {
       return item.examState == 0;
@@ -121,6 +123,9 @@ export const initWs = (data: any, callback: any) => {
     }
     //断线状态
     if (e.cmd === 'disconnect_request') {
+      if (loadingTime) {
+        clearTimeout(loadingTime);
+      }
       if (testList.length == 1) {
         getExit();
         //let examId = e?.exam_id || '';

+ 15 - 19
src/views/gesture/index.vue

@@ -1,9 +1,9 @@
 <template>
   <div class="gesture">
     <Header :showTool="false" @confirmExit="getLogout"></Header>
-    <div class="menu">
-      <swiper v-if="projectList.length" :slides-per-view="5" :space-between="0" :loop="true" :centeredSlides="true"
-        :modules="[Navigation]" @swiper="onSwiper">
+    <div class="menu" v-if="projectList.length">
+      <swiper :slides-per-view="5" :space-between="0" :loop="true" :observeParents="true" :observer="true"
+        :centeredSlides="true" :modules="[Navigation]" @swiper="onSwiper">
         <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>
@@ -19,7 +19,7 @@
 </template>
 
 <script setup name="Gesture" lang="ts">
-import { handWs, startHand, closeHand, startDevice } from '@/utils/handWs'
+import { handWs, startDevice, stateHand, startHand, closeHand } from '@/utils/handWs'
 import { Swiper, SwiperSlide } from 'swiper/vue';
 import { Navigation } from 'swiper/modules';
 import 'swiper/css';
@@ -28,13 +28,13 @@ const router = useRouter();
 const route = useRoute();
 const { proxy } = getCurrentInstance() as any;
 const optionWindowRef = ref();
-const mySwiper = ref();
 const data = reactive<any>({
+  mySwiper: {},
   projectList: [],
   timerManager: {},
   device_info: {}
 });
-const { projectList, timerManager, device_info } = toRefs(data);
+const { mySwiper, projectList, timerManager, device_info } = toRefs(data);
 
 /**
  * 清空定时任务
@@ -74,7 +74,7 @@ const getExam = async () => {
       //只显示能开的
       return item.area.length > 0 && examList.includes(item.key);
     });
-    console.log("projectList.value", projectList.value)
+    // console.log("projectList.value", projectList.value)
   });
 };
 
@@ -82,7 +82,7 @@ const getExam = async () => {
  * 获取实例
 */
 const onSwiper = ($ev: any) => {
-  console.log("9999999", $ev)
+  console.log("1111111", $ev)
   mySwiper.value = $ev;
 };
 
@@ -107,12 +107,11 @@ const getOption = (data: any) => {
   confirm(data);
 };
 
-
 /**
  * 确定并进入
 */
 const confirm = (myProject?: any) => {
-  let project = myProject ? myProject : projectList.value[mySwiper.value.realIndex];
+  let project = 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)
@@ -137,13 +136,7 @@ const confirm = (myProject?: any) => {
     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);
-
+  optionWindowRef.value.getGesture(project, data);
 };
 
 /**
@@ -195,19 +188,22 @@ onBeforeMount(() => {
   handWs((e: any) => {
     //发送设备
     if (e?.wksid) {
+      console.log("111", e)
       let deviceid = localStorage.getItem("deviceid");
       startDevice({ deviceid: deviceid })
     }
     //接收参数
     if (e?.device_info) {
-      console.log("e.device_info", e.device_info)
+      console.log("222", e)
       device_info.value = e.device_info
       let handcontroller_id = device_info.value.handcontroller_id;
       startHand(handcontroller_id)
     }
     //左滑动
     if (e?.data?.result == "next_item") {
-      console.log("mySwiper.value", mySwiper.value)
+      if (projectList.value.length == 0) {
+        return false;
+      }
       if (projectList.value.length < 5) {
         slidePrev()
       } else {

+ 1 - 1
src/views/login/qrcode.vue

@@ -23,7 +23,7 @@
 
 <script setup name="QrcodeLogin" lang="ts">
 import QRCode from "qrcode";
-import { handWs, startHand, closeHand, startLogin } from '@/utils/handWs'
+import { handWs, startLogin } from '@/utils/handWs'
 const { proxy } = getCurrentInstance() as any;
 const router = useRouter();
 const route = useRoute();

+ 9 - 13
src/views/train/multiple.vue

@@ -53,7 +53,7 @@
         <div class="confirmDiaBg" v-show="examState == 43 && time.ready">
           <div class="confirmDiaWindow">
             <div class="readyBox">
-              <div class="lable">倒计时</div>
+              <div class="lable" :class="{ 'transparent': time.ready > 5 }">倒计时</div>
               <div class="value">{{ time.ready }}</div>
             </div>
           </div>
@@ -190,7 +190,8 @@ const getAgain = async () => {
  * 确认退出
 */
 const confirmExit = () => {
-  proxy?.$modal.confirm(`确定退出吗?`).then(() => {
+  let handcontroller_id = parameter.value.handcontroller;
+  proxy?.$modal.confirm(handcontroller_id ? `请举左手确认退出` : `确定退出吗?`).then(() => {
     getExit();
   }).finally(() => {
   });
@@ -203,7 +204,6 @@ const getExit = () => {
   getClearTimer();//清除计时器
   examEnds();//通知工作站关闭
   speckCancel();//停止播报
-  closeHand();//关闭手势
   window.onbeforeunload = null;//移除事件处理器
   let handcontroller_id = parameter.value.handcontroller;
   if (handcontroller_id) {
@@ -410,8 +410,7 @@ const getReady = () => {
       multipleItemRefList.value[i].getStopFace()
     }
   }
-  time.value.ready = 5;
-  speckText(time.value.ready);
+  time.value.ready = 6;
   timerManager.value.readyTimer = setInterval(() => {
     time.value.ready--;
     if (time.value.ready <= 0) {
@@ -484,14 +483,6 @@ const getAddTestList = (num: number) => {
 */
 const initHand = () => {
   handWs((e: any) => {
-    //发送设备
-    if (e?.wksid) {
-      console.log("e.wksid", e.wksid)
-      let handcontroller_id = parameter.value.handcontroller;
-      if (handcontroller_id) {
-        startHand(handcontroller_id)
-      }
-    }
     //左滑动
     if (e?.data?.result == "next_item") {
     }
@@ -766,12 +757,17 @@ $waiPadding: 6.51rem;
         margin-bottom: 1.5rem;
       }
 
+
       .value {
         font-size: 10rem;
         line-height: 1;
         font-family: 'Saira-BlackItalic';
       }
 
+      .transparent {
+        opacity: 0;
+      }
+
     }
 
   }

+ 8 - 13
src/views/train/test.vue

@@ -59,7 +59,7 @@
 
             <div v-show="examState == 43 && time.ready">
               <div class="readyBox">
-                <div class="value">{{ time.ready }}</div>
+                <div class="value" :class="{ 'transparent': time.ready > 5 }">{{ time.ready }}</div>
                 <div class="lable">倒计时</div>
               </div>
             </div>
@@ -387,7 +387,8 @@ const getAgain = async () => {
  * 确认退出
 */
 const confirmExit = () => {
-  proxy?.$modal.confirm(`确定退出吗?`).then(() => {
+  let handcontroller_id = parameter.value.handcontroller;
+  proxy?.$modal.confirm(handcontroller_id ? `请举左手确认退出` : `确定退出吗?`).then(() => {
     getExit();
   }).finally(() => {
   });
@@ -400,7 +401,6 @@ const getExit = () => {
   getClearTimer();//清除计时器
   examEnds();//通知工作站关闭
   speckCancel();//停止播报
-  closeHand();//关闭手势
   window.onbeforeunload = null;//移除事件处理器
   let handcontroller_id = parameter.value.handcontroller;
   if (handcontroller_id) {
@@ -677,8 +677,7 @@ const getReady = () => {
   if (needStart.value && examState.value == 43 && !time.value.ready && readyState.value) {
     speckCancel();
     readyState.value = false;
-    time.value.ready = 5;
-    speckText(time.value.ready);
+    time.value.ready = 6;
     timerManager.value.readyTimer = setInterval(() => {
       time.value.ready--;
       speckText(time.value.ready);
@@ -695,14 +694,6 @@ const getReady = () => {
 */
 const initHand = () => {
   handWs((e: any) => {
-    //发送设备
-    if (e?.wksid) {
-      console.log("e.wksid", e.wksid)
-      let handcontroller_id = parameter.value.handcontroller;
-      if (handcontroller_id) {
-        startHand(handcontroller_id)
-      }
-    }
     //左滑动
     if (e?.data?.result == "next_item") {
     }
@@ -1179,6 +1170,10 @@ $waiPadding: 6.51rem;
           .lable {
             font-size: 3.5rem;
           }
+
+          .transparent {
+            opacity: 0;
+          }
         }
 
         .btn {