fix: 优化多个组件中的类型声明和逻辑,提升代码一致性
This commit is contained in:
		
							parent
							
								
									a34b4549a9
								
							
						
					
					
						commit
						b1264c19e8
					
				| @ -94,7 +94,7 @@ struct Index { | ||||
|                     if (this.limit) { | ||||
|                       return | ||||
|                     } | ||||
|                     const carInfo: CarInfoType = AppStorage.get<CarInfoType>('carInfo') | ||||
|                     const carInfo: CarInfoType = AppStorage.get<CarInfoType>('carInfo')! | ||||
|                     let password: string = CryptoJS.MD5(this.inputTextArr[1]).toString(); | ||||
|                     const param: UserLoginType = { | ||||
|                       carId: carInfo.carId as string, | ||||
|  | ||||
| @ -41,9 +41,9 @@ export default struct FaceCompare { | ||||
|   @State carInfo: CarInfoType = {}; | ||||
|   @State param: VideoConfig = VideoConfigData | ||||
|   private times = 1; //人脸比对失败次数, 超过3次将不会自动比对,需要点击重新打开重新触发 | ||||
|   private vocObj: voiceService = null; | ||||
|   private vocObj!: voiceService; | ||||
|   private controller: VideoController = new VideoController() | ||||
|   private fileUtil: FileUtils | ||||
|   private fileUtil!: FileUtils | ||||
|   private interval: number = -1 | ||||
|   private context = getContext(this) as common.UIAbilityContext; | ||||
| 
 | ||||
| @ -175,7 +175,7 @@ export default struct FaceCompare { | ||||
| 
 | ||||
|   async aboutToAppear() { | ||||
|     const fileUtil = new FileUtils(this.context) | ||||
|     this.carInfo = AppStorage.get<CarInfoType>('carInfo') | ||||
|     this.carInfo = AppStorage.get<CarInfoType>('carInfo')! | ||||
|     this.fileUtil = fileUtil | ||||
|     this.getVideoConfig() | ||||
|   } | ||||
| @ -195,13 +195,13 @@ export default struct FaceCompare { | ||||
|     faceCompare({ | ||||
|       sfzh: this.sfzh, | ||||
|       firstImage: this.firstImage.substr(22), | ||||
|       secondImage: data.base64, | ||||
|       secondImage: data.base64 || "", | ||||
|       type: "2", | ||||
|       verifyType: "1" | ||||
|     }) | ||||
|       .then(res => { | ||||
|         console.log('mmmmm8', JSON.stringify(res)) | ||||
|         if (res.imageCompareRsp.head.resultCode == '0') { | ||||
|         if (res.imageCompareRsp?.head?.resultCode == '0') { | ||||
|           this.controller.stop() | ||||
|           this.showFaceCompare = !this.showFaceCompare | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag | ||||
| @ -231,7 +231,9 @@ export default struct FaceCompare { | ||||
|     const str = this.lsh | ||||
|     console.log('this.lshbitbit', this.lsh, this.carInfo.carNo, this.carInfo.examinationRoomId) | ||||
|     for (let i = 0; i < str.length; i++) { | ||||
|       tmpList.push(NumberToByteArray(str.charCodeAt(i), 1 * 8)[0]) | ||||
|       if (str && str.charCodeAt(i) !== undefined) { | ||||
|         tmpList.push(NumberToByteArray(str.charCodeAt(i), 1 * 8)[0]); | ||||
|       } | ||||
|     } | ||||
|     const param: UDPParamType = { | ||||
|       id: 46, | ||||
| @ -282,34 +284,33 @@ export default struct FaceCompare { | ||||
| 
 | ||||
|   async getVideoConfig() { | ||||
|     console.log('faceEnterIn') | ||||
|     this.vocObj = new voiceService(async (status: string, val: string) => { | ||||
|     this.vocObj = new voiceService(async (status: string, val?: string) => { | ||||
|       if (status == 'idle') { | ||||
|         if (val == 'face_check.mp3' || val == 'face_fail.mp3') { | ||||
|         if (val === 'face_check.mp3' || val === 'face_fail.mp3') { | ||||
|           if (this.times >= 3) { | ||||
|             AppStorage.setOrCreate('statue', 3) | ||||
|             AppStorage.setOrCreate('statue', 3); | ||||
|             this.faceCompareSucess = -1; | ||||
|             this.vocObj && this.vocObj.playAudio({ | ||||
|               type: 1, | ||||
|               name: 'face_checking.wav' | ||||
|             }) | ||||
|             this.heartMsg() | ||||
|               name: 'face_checking.wav', | ||||
|             }); | ||||
|             this.heartMsg(); | ||||
|           } else { | ||||
|             setTimeout(() => { | ||||
|               this.faceComparFn() | ||||
|             }, 2000) | ||||
|               this.faceComparFn(); | ||||
|             }, 2000); | ||||
|           } | ||||
|         } else if (val == 'yzcg.wav') { | ||||
|           this.showFaceCompare = !this.showFaceCompare | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag | ||||
|           AppStorage.setOrCreate('statue', 4) | ||||
|         } else if (val === 'yzcg.wav') { | ||||
|           this.showFaceCompare = !this.showFaceCompare; | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag; | ||||
|           AppStorage.setOrCreate('statue', 4); | ||||
|           this.faceCompareSucess = 1; | ||||
|           this.vocObj && this.vocObj.releasePlayer() | ||||
| 
 | ||||
|         } else if (val == 'face_chekc_fail.wav') { | ||||
|           this.vocObj && this.vocObj.releasePlayer() | ||||
|           this.faceCompareSucess = -1 | ||||
|           this.showFaceCompare = !this.showFaceCompare | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag | ||||
|           this.vocObj && this.vocObj.releasePlayer(); | ||||
|         } else if (val === 'face_chekc_fail.wav') { | ||||
|           this.vocObj && this.vocObj.releasePlayer(); | ||||
|           this.faceCompareSucess = -1; | ||||
|           this.showFaceCompare = !this.showFaceCompare; | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag; | ||||
|         } | ||||
|       } | ||||
|     }, this.context); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user