逻辑优化
This commit is contained in:
		
							parent
							
								
									b446c9442a
								
							
						
					
					
						commit
						7645ab8c14
					
				| @ -134,10 +134,13 @@ struct Index { | ||||
|               }, router.RouterMode.Single) | ||||
|             } | ||||
|           }) | ||||
|         }).finally(() => { | ||||
|           this.loading = false | ||||
|         }); | ||||
| 
 | ||||
|       } | ||||
|     }) | ||||
|     }).finally(() => { | ||||
|       this.loading = false | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   async heartMsg() { | ||||
|  | ||||
| @ -884,14 +884,25 @@ struct UserInfo { | ||||
|     const {carId,examinationRoomId} = carInfo; | ||||
|     let examItems = { getExaminationItemRsp: { body: { ykxx: '', jdxx: '' } } }; | ||||
|     if (!globalThis.singlePlay) { | ||||
|       //获取已考项目 | ||||
|       // @ts-ignore | ||||
|       examItems = await getExaminationItem({ | ||||
|         time: getCurrentTime(), | ||||
|         carId, | ||||
|         lsh: this.currentUser.lsh || '', | ||||
|         examinationRoomId | ||||
|       }); | ||||
|       try { | ||||
| 
 | ||||
|         //获取已考项目 | ||||
|         // @ts-ignore | ||||
|         examItems = await getExaminationItem({ | ||||
|           time: getCurrentTime(), | ||||
|           carId, | ||||
|           lsh: this.currentUser.lsh || '', | ||||
|           examinationRoomId | ||||
|         }); | ||||
|       } catch (e) { | ||||
|         promptAction.showToast({ | ||||
|           message: "获取考试信息失败,请重试", | ||||
|           duration: 3000 | ||||
|         }) | ||||
|         this.isLoadingPopupVisible = false | ||||
|         this.isExamStart = false | ||||
|         return | ||||
|       } | ||||
|     } | ||||
|     this.currentUser.id = '1' | ||||
|     const avPlayer = this.avPlayer; | ||||
| @ -899,66 +910,74 @@ struct UserInfo { | ||||
| 
 | ||||
|     avPlayer.playAudio([`voice/监管通信中.mp3`], false, async () => { | ||||
|       console.info('surenjun', '播放结束开始考试接口调用') | ||||
|       const {code,keystr,message} = await this.beginExam() || {}; | ||||
|       console.info('surenjun', '开始考试接口调用结束') | ||||
|       // console.info('surenjun',code +'') | ||||
|       //@ts-ignore TODO code转换 | ||||
|       try { | ||||
|         const {code,keystr,message} = await this.beginExam() || {}; | ||||
|         console.info('surenjun', '开始考试接口调用结束') | ||||
| 
 | ||||
|       if (code != 1) { | ||||
|         avPlayer.playAudio([code == -200 ? 'voice/photo_error.mp3' : 'voice/监管审核未通过.mp3']); | ||||
|         if (code != 1) { | ||||
|           avPlayer.playAudio([code == -200 ? 'voice/photo_error.mp3' : 'voice/监管审核未通过.mp3']); | ||||
|           this.isLoadingPopupVisible = false | ||||
|           this.isExamStart = false | ||||
|           promptAction.showToast({ | ||||
|             message, | ||||
|             duration: 4000 | ||||
|           }) | ||||
|           return | ||||
|         } | ||||
|         this.currentUser.id = '0' | ||||
|         await upDateTableByArray('USER', [this.currentUser]) | ||||
|         this.stepFlag = false | ||||
|         this.isLoadingPopupVisible = false | ||||
|         let kStringArr = decodeURIComponent(keystr || '').split(",").filter(item => item) | ||||
|         console.log("lixiao kStringArr", JSON.stringify(kStringArr)) | ||||
|         await this.getExamMode(kStringArr) | ||||
|         console.log("lixiao mode", this.mode) | ||||
|         let score = Number(this.currentUser.jdxx?.split("^")[0]) | ||||
|         let kfxm = this.currentUser.jdxx?.split("^")[1] | ||||
|         if (this.mode === 2 && !this.currentUser.jdxx) { | ||||
|           promptAction.showToast({ | ||||
|             message: "当前尚未进行白考,无法开始夜考!" | ||||
|           }) | ||||
|           this.updateTimeLimit = false | ||||
|           this.stopDeviceById() | ||||
|           this.stepFlag = false | ||||
|           this.ksksLimit = false | ||||
|           return | ||||
|         } else if (this.mode === 1 && this.currentUser.jdxx) { | ||||
|           promptAction.showToast({ | ||||
|             message: "当前尚未进入夜考时间,无法开始夜考!" | ||||
|           }) | ||||
|           this.updateTimeLimit = false | ||||
|           this.stopDeviceById() | ||||
|           this.stepFlag = false | ||||
|           this.ksksLimit = false | ||||
|           return | ||||
|         } | ||||
|         router.pushUrl({ | ||||
|           url: 'pages/Judge', | ||||
|           params: { | ||||
|             examItems: [examItems?.getExaminationItemRsp?.body?.ykxx, kfxm], | ||||
|             sczb: Number(this.isBoardPrePareSetPopupOpen), | ||||
|             kfdm: this.sczbkf, | ||||
|             mode: this.mode, | ||||
|             //真实监管项目 | ||||
|             kString: decodeURIComponent(keystr || ''), | ||||
|             // 白考分数 | ||||
|             score | ||||
|           } | ||||
|         }, router.RouterMode.Single); | ||||
|         this.updateTimeLimit = false | ||||
|         this.stopDeviceById() | ||||
|         this.stepFlag = false | ||||
|       } catch (e) { | ||||
|         promptAction.showToast({ | ||||
|           message: "监管审核失败,请重试", | ||||
|           duration: 3000 | ||||
|         }) | ||||
|         this.isLoadingPopupVisible = false | ||||
|         this.isExamStart = false | ||||
|         promptAction.showToast({ | ||||
|           message, | ||||
|           duration: 4000 | ||||
|         }) | ||||
|         return | ||||
|       } | ||||
|       this.currentUser.id = '0' | ||||
|       await upDateTableByArray('USER', [this.currentUser]) | ||||
|       this.stepFlag = false | ||||
|       this.isLoadingPopupVisible = false | ||||
|       let kStringArr = decodeURIComponent(keystr || '').split(",").filter(item => item) | ||||
|       console.log("lixiao kStringArr", JSON.stringify(kStringArr)) | ||||
|       await this.getExamMode(kStringArr) | ||||
|       console.log("lixiao mode", this.mode) | ||||
|       let score = Number(this.currentUser.jdxx?.split("^")[0]) | ||||
|       let kfxm = this.currentUser.jdxx?.split("^")[1] | ||||
|       if (this.mode === 2 && !this.currentUser.jdxx) { | ||||
|         promptAction.showToast({ | ||||
|           message: "当前尚未进行白考,无法开始夜考!" | ||||
|         }) | ||||
|         this.updateTimeLimit = false | ||||
|         this.stopDeviceById() | ||||
|         this.stepFlag = false | ||||
|         this.ksksLimit = false | ||||
|         return | ||||
|       } else if (this.mode === 1 && this.currentUser.jdxx) { | ||||
|         promptAction.showToast({ | ||||
|           message: "当前尚未进入夜考时间,无法开始夜考!" | ||||
|         }) | ||||
|         this.updateTimeLimit = false | ||||
|         this.stopDeviceById() | ||||
|         this.stepFlag = false | ||||
|         this.ksksLimit = false | ||||
|         return | ||||
|       } | ||||
|       router.pushUrl({ | ||||
|         url: 'pages/Judge', | ||||
|         params: { | ||||
|           examItems: [examItems?.getExaminationItemRsp?.body?.ykxx, kfxm], | ||||
|           sczb: Number(this.isBoardPrePareSetPopupOpen), | ||||
|           kfdm: this.sczbkf, | ||||
|           mode: this.mode, | ||||
|           //真实监管项目 | ||||
|           kString: decodeURIComponent(keystr || ''), | ||||
|           // 白考分数 | ||||
|           score | ||||
|         } | ||||
|       }, router.RouterMode.Single); | ||||
|       this.updateTimeLimit = false | ||||
|       this.stopDeviceById() | ||||
|       this.stepFlag = false | ||||
|     }) | ||||
|   } | ||||
| 
 | ||||
|  | ||||
| @ -1320,122 +1320,132 @@ export default class Judge { | ||||
|     const {lsh,idCard,serialNumber,kssycs,totalScore,judgeConfigObj,isAllProjectsEnd,passingScore} = judgeUI | ||||
|     //TODO 断网考试结束补传
 | ||||
|     // await uploadDisConnectData();
 | ||||
|     const time = await getCurrentTime(); | ||||
|     const photoBase64 = await getPhoto(); | ||||
|     const {d1,d2,d3,d4,d5} = ksjs | ||||
|     const data = { | ||||
|       xtlb: '17', jkxlh: serialNumber, jkid: '17C56', | ||||
|       drvexam: { | ||||
|         lsh, | ||||
|         kchp: encodeURI(plateNo), | ||||
|         kskm: examSubject, | ||||
|         sfzmhm: idCard, | ||||
|         //@ts-ignore
 | ||||
|         zp: photoBase64, | ||||
|         jssj: time, | ||||
|         kscj: (totalScore * 1) > 0 ? totalScore : 0, | ||||
|         kslc: Math.ceil(((ksjs?.qjjl + ksjs?.dcjl) || 0) / 100), | ||||
|         // 1,22;2,560;3,128;4,0;5,0;
 | ||||
|         dwlc: [d1, d2, d3, d4, d5].map((d, index) => `${index + 1},${Math.floor(d / 100)}`).join(';'), | ||||
|     try { | ||||
|       const time = await getCurrentTime(); | ||||
|       const photoBase64 = await getPhoto(); | ||||
|       const {d1,d2,d3,d4,d5} = ksjs | ||||
|       const data = { | ||||
|         xtlb: '17', jkxlh: serialNumber, jkid: '17C56', | ||||
|         drvexam: { | ||||
|           lsh, | ||||
|           kchp: encodeURI(plateNo), | ||||
|           kskm: examSubject, | ||||
|           sfzmhm: idCard, | ||||
|           //@ts-ignore
 | ||||
|           zp: photoBase64, | ||||
|           jssj: time, | ||||
|           kscj: (totalScore * 1) > 0 ? totalScore : 0, | ||||
|           kslc: Math.ceil(((ksjs?.qjjl + ksjs?.dcjl) || 0) / 100), | ||||
|           // 1,22;2,560;3,128;4,0;5,0;
 | ||||
|           dwlc: [d1, d2, d3, d4, d5].map((d, index) => `${index + 1},${Math.floor(d / 100)}`).join(';'), | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|     let backTimeOut = setTimeout(() => { | ||||
|       router.back() | ||||
|     }, 90 * 1000) | ||||
|     const {code,keystr,message} = await this.sendWriteObjectOut(data, filePath); | ||||
|     promptWxCode('17C56', code) | ||||
|       let backTimeOut = setTimeout(() => { | ||||
|         router.back() | ||||
|       }, 90 * 1000) | ||||
|       const {code,keystr,message} = await this.sendWriteObjectOut(data, filePath); | ||||
|       promptWxCode('17C56', code) | ||||
| 
 | ||||
|     if (code != 1) { | ||||
|       avPlayer.playAudio(['voice/监管失败.mp3']) | ||||
|       this.judgeUI.errorMsg = decodeURIComponent(message) | ||||
|       if (code != 1) { | ||||
|         avPlayer.playAudio(['voice/监管失败.mp3']) | ||||
|         this.judgeUI.errorMsg = decodeURIComponent(message) | ||||
| 
 | ||||
|       if (code == 2300028 || code == 2300007) { | ||||
|         this.judgeUI.errorMsg = '当前的考试过程信息监管审核未通过,程序将退出!' | ||||
|         if (code == 2300028 || code == 2300007) { | ||||
|           this.judgeUI.errorMsg = '当前的考试过程信息监管审核未通过,程序将退出!' | ||||
|         } | ||||
|         this.isUdpEnd = true; | ||||
|         closeAllFiles() | ||||
|         this.judgeUI.loadingPopupVisible = false; | ||||
|         return | ||||
|       } | ||||
|       this.isUdpEnd = true; | ||||
|       closeAllFiles() | ||||
|       this.judgeUI.loadingPopupVisible = false; | ||||
|       return | ||||
|     } | ||||
|     console.info(judgeTag, '考试结束 end') | ||||
|     const param302 = judgeConfigObj['302']; | ||||
|     judgeUI.loadingPopupVisible = true; | ||||
|     let currentKssycs = 0; | ||||
|     let voiceURL = '' | ||||
|     if (examSubject == 2) { | ||||
|       if (isAllProjectsEnd) { | ||||
|         voiceURL = (totalScore < passingScore ? `voice/unqualified_${kssycs == 1 ? 'one' : 'two'}.wav` : 'voice/qualified.mp3') | ||||
|       } else { | ||||
|         voiceURL = `voice/unqualified_${kssycs == 1 ? 'one' : 'two'}.wav` | ||||
|         currentKssycs = kssycs == 1 ? 0 : 1 | ||||
|       } | ||||
|       switch (voiceURL) { | ||||
|         case 'voice/unqualified_one.wav': | ||||
|           currentKssycs = 0; | ||||
|           break; | ||||
|       console.info(judgeTag, '考试结束 end') | ||||
|       const param302 = judgeConfigObj['302']; | ||||
|       judgeUI.loadingPopupVisible = true; | ||||
|       let currentKssycs = 0; | ||||
|       let voiceURL = '' | ||||
|       if (examSubject == 2) { | ||||
|         if (isAllProjectsEnd) { | ||||
|           voiceURL = (totalScore < passingScore ? `voice/unqualified_${kssycs == 1 ? 'one' : 'two'}.wav` : 'voice/qualified.mp3') | ||||
|         } else { | ||||
|           voiceURL = `voice/unqualified_${kssycs == 1 ? 'one' : 'two'}.wav` | ||||
|           currentKssycs = kssycs == 1 ? 0 : 1 | ||||
|         } | ||||
|         switch (voiceURL) { | ||||
|           case 'voice/unqualified_one.wav': | ||||
|             currentKssycs = 0; | ||||
|             break; | ||||
| 
 | ||||
|         case 'voice/unqualified_two.wav': | ||||
|           currentKssycs = 1; | ||||
|           break; | ||||
|           case 'voice/unqualified_two.wav': | ||||
|             currentKssycs = 1; | ||||
|             break; | ||||
| 
 | ||||
|         case 'voice/qualified.mp3': | ||||
|           currentKssycs = 0; | ||||
|           break; | ||||
|           case 'voice/qualified.mp3': | ||||
|             currentKssycs = 0; | ||||
|             break; | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|     if (examSubject == 3) { | ||||
|       console.log(judgeTag, "exam end", isAllProjectsEnd); | ||||
|       if (isAllProjectsEnd) { | ||||
|         if (totalScore < passingScore) { | ||||
|       if (examSubject == 3) { | ||||
|         console.log(judgeTag, "exam end", isAllProjectsEnd); | ||||
|         if (isAllProjectsEnd) { | ||||
|           if (totalScore < passingScore) { | ||||
|             voiceURL = `voice/${kssycs == 1 ? 'exam_no_pass_finish' : 'exam_no_pass'}.mp3` | ||||
|             currentKssycs = kssycs == 1 ? 0 : 1 | ||||
|           } else { | ||||
|             voiceURL = 'voice/exam_pass.mp3' | ||||
|             currentKssycs = 0 | ||||
|           } | ||||
|         } else { | ||||
|           voiceURL = `voice/${kssycs == 1 ? 'exam_no_pass_finish' : 'exam_no_pass'}.mp3` | ||||
|           currentKssycs = kssycs == 1 ? 0 : 1 | ||||
|         } else { | ||||
|           voiceURL = 'voice/exam_pass.mp3' | ||||
|           currentKssycs = 0 | ||||
|         } | ||||
|       } else { | ||||
|         voiceURL = `voice/${kssycs == 1 ? 'exam_no_pass_finish' : 'exam_no_pass'}.mp3` | ||||
|         currentKssycs = kssycs == 1 ? 0 : 1 | ||||
|         switch (voiceURL) { | ||||
|           case 'voice/exam_no_pass_finish.mp3': | ||||
|             currentKssycs = 0; | ||||
|             break; | ||||
| 
 | ||||
|           case 'voice/exam_no_pass.mp3': | ||||
|             currentKssycs = 1; | ||||
|             break; | ||||
| 
 | ||||
|           case 'voice/exam_pass.mp3': | ||||
|             currentKssycs = 0; | ||||
|             break; | ||||
| 
 | ||||
|         } | ||||
|       } | ||||
|       switch (voiceURL) { | ||||
|         case 'voice/exam_no_pass_finish.mp3': | ||||
|           currentKssycs = 0; | ||||
|           break; | ||||
| 
 | ||||
|         case 'voice/exam_no_pass.mp3': | ||||
|           currentKssycs = 1; | ||||
|           break; | ||||
| 
 | ||||
|         case 'voice/exam_pass.mp3': | ||||
|           currentKssycs = 0; | ||||
|           break; | ||||
|       const USER = await getSyncData('USER'); | ||||
|       await upDateTableByArray('USER', [{ | ||||
|         ...USER[0], | ||||
|         kssycs: currentKssycs | ||||
|       }]) | ||||
| 
 | ||||
|       console.info(judgeTag, `考试成绩:${totalScore}`) | ||||
|       if (!singlePlay) { | ||||
|         // await uploadProgressData();
 | ||||
|       } | ||||
|     } | ||||
| 
 | ||||
|     const USER = await getSyncData('USER'); | ||||
|     await upDateTableByArray('USER', [{ | ||||
|       ...USER[0], | ||||
|       kssycs: currentKssycs | ||||
|     }]) | ||||
| 
 | ||||
|     console.info(judgeTag, `考试成绩:${totalScore}`) | ||||
|     if (!singlePlay) { | ||||
|       // await uploadProgressData();
 | ||||
|     } | ||||
|     clearTimeout(backTimeOut) | ||||
|     //语音播放扣分项
 | ||||
|     let score = 0; | ||||
|     //结束考试时候是否播报一遍所有扣分
 | ||||
|     const param634 = judgeConfigObj['634']; | ||||
|     if (kfArr.length && ((examSubject == 2 && param634 == 1) || examSubject == 3)) { | ||||
|       avPlayer.playAudio([`voice/kfdesc.mp3`], false, () => { | ||||
|         try { | ||||
|           kfArr.forEach((kf, index) => { | ||||
|             score += Math.abs(Number(kf.score)); | ||||
|             //TODO 考试分数待替换
 | ||||
|             if (score <= (examSubject == 3 ? 10 : 20)) { | ||||
|               if (kfArr.length - 1 === index) { | ||||
|       clearTimeout(backTimeOut) | ||||
|       //语音播放扣分项
 | ||||
|       let score = 0; | ||||
|       //结束考试时候是否播报一遍所有扣分
 | ||||
|       const param634 = judgeConfigObj['634']; | ||||
|       if (kfArr.length && ((examSubject == 2 && param634 == 1) || examSubject == 3)) { | ||||
|         avPlayer.playAudio([`voice/kfdesc.mp3`], false, () => { | ||||
|           try { | ||||
|             kfArr.forEach((kf, index) => { | ||||
|               score += Math.abs(Number(kf.score)); | ||||
|               //TODO 考试分数待替换
 | ||||
|               if (score <= (examSubject == 3 ? 10 : 20)) { | ||||
|                 if (kfArr.length - 1 === index) { | ||||
|                   avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`, voiceURL], false, () => { | ||||
|                     this.isUdpEnd = true; | ||||
|                     closeAllFiles() | ||||
|                     router.back(); | ||||
|                   }) | ||||
|                   throw new Error('End Loop') | ||||
|                 } | ||||
|                 avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`]) | ||||
|               } else { | ||||
|                 avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`, voiceURL], false, () => { | ||||
|                   this.isUdpEnd = true; | ||||
|                   closeAllFiles() | ||||
| @ -1443,30 +1453,27 @@ export default class Judge { | ||||
|                 }) | ||||
|                 throw new Error('End Loop') | ||||
|               } | ||||
|               avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`]) | ||||
|             } else { | ||||
|               avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`, voiceURL], false, () => { | ||||
|                 this.isUdpEnd = true; | ||||
|                 closeAllFiles() | ||||
|                 router.back(); | ||||
|               }) | ||||
|               throw new Error('End Loop') | ||||
|             } | ||||
|           }) | ||||
|         } catch (e) { | ||||
|           console.info(judgeTag, JSON.stringify(e)) | ||||
|         } | ||||
|       }) | ||||
|     } else { | ||||
|       avPlayer.playAudio([voiceURL], true, () => { | ||||
|         setTimeout(() => { | ||||
|           this.isUdpEnd = true | ||||
|           closeAllFiles() | ||||
|           router.back(); | ||||
|         }, param302 == 8 ? 3000 : 0) | ||||
|             }) | ||||
|           } catch (e) { | ||||
|             console.info(judgeTag, JSON.stringify(e)) | ||||
|           } | ||||
|         }) | ||||
|       } else { | ||||
|         avPlayer.playAudio([voiceURL], true, () => { | ||||
|           setTimeout(() => { | ||||
|             this.isUdpEnd = true | ||||
|             closeAllFiles() | ||||
|             router.back(); | ||||
|           }, param302 == 8 ? 3000 : 0) | ||||
|         }) | ||||
|       } | ||||
|     } catch (e) { | ||||
|       promptAction.showToast({ | ||||
|         message: "考试结束异常,请尝试重新结束", | ||||
|         duration: 3000 | ||||
|       }) | ||||
|       judgeUI.loadingPopupVisible = false | ||||
|     } | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
|   // 当前项目转换
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user