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