Compare commits

...

6 Commits

View File

@ -73,6 +73,20 @@ struct UserInfo {
@State FaceOpenStatue: string = '0'; //是否开启人脸识别 @State FaceOpenStatue: string = '0'; //是否开启人脸识别
subscriber; subscriber;
@State faceCatchImg: string = '' @State faceCatchImg: string = ''
// 过程照片拍照
getPhoto = async (empty?: boolean) => {
const singlePlay = globalThis.singlePlay
//单机模式返回空照片
if (singlePlay) {
return ''
} else {
const {filePhoto} = this;
const photoBase64 = await filePhoto.getPhoto();
return photoBase64
}
}
private filePhoto: FilePhoto
private avPlayer
private AccountTable = new AccountTable(() => { private AccountTable = new AccountTable(() => {
}, USER); }, USER);
private context = getContext(this) as common.UIAbilityContext; private context = getContext(this) as common.UIAbilityContext;
@ -87,7 +101,7 @@ struct UserInfo {
async onPageShow() { async onPageShow() {
const mediaTest = new FilePhoto(this.context); const mediaTest = new FilePhoto(this.context);
this.filePhoto = new FilePhoto(this.context); this.filePhoto = new FilePhoto(this.context);
//语音功能 //语音功能
new WebRTCVoice(this.context); new WebRTCVoice(this.context);
//初始化数据 //初始化数据
@ -140,10 +154,10 @@ struct UserInfo {
this.stopDeviceById() this.stopDeviceById()
// globalThis.statue=4 // globalThis.statue=4
router.pushUrl({ router.pushUrl({
url: examSubject == 3 ? 'pages/Roads':'pages/Judge', url: examSubject == 3 ? 'pages/Roads' : 'pages/Judge',
params:{ params: {
sczb:Number(this.isBoardPrePareSetPopupOpen), sczb: Number(this.isBoardPrePareSetPopupOpen),
kfdm:this.sczbkf kfdm: this.sczbkf
} }
}, router.RouterMode.Single); }, router.RouterMode.Single);
return return
@ -246,9 +260,9 @@ struct UserInfo {
//@ts-ignore //@ts-ignore
syssetParams.forEach(sys => { syssetParams.forEach(sys => {
//364 绕车一周评判时机(1-开始考试后判 2-开始考试前判) //364 绕车一周评判时机(1-开始考试后判 2-开始考试前判)
if(sys.v_no === '364'){ if (sys.v_no === '364') {
this.isBoardPrePareSetPopupOpen = true; this.isBoardPrePareSetPopupOpen = true;
} }
}) })
} }
@ -345,6 +359,13 @@ struct UserInfo {
} }
this.pageIndex++; this.pageIndex++;
this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4)
this.dataList.forEach(listData => {
for (let i in listData) {
listData[i] = decodeURI(listData[i])
}
listData.kszp = this.photo + listData.kszp
listData.ksmjzp = this.photo + listData.ksmjzp
})
} }
prevClick() { prevClick() {
@ -353,6 +374,13 @@ struct UserInfo {
} }
this.pageIndex--; this.pageIndex--;
this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4)
this.dataList.forEach(listData => {
for (let i in listData) {
listData[i] = decodeURI(listData[i])
}
listData.kszp = this.photo + listData.kszp
listData.ksmjzp = this.photo + listData.ksmjzp
})
} }
//获取下载考生 //获取下载考生
@ -474,8 +502,8 @@ struct UserInfo {
const carInfo = globalThis.carInfo; const carInfo = globalThis.carInfo;
const {carId,examinationRoomId} = carInfo; const {carId,examinationRoomId} = carInfo;
this.showFaceCompare = false this.showFaceCompare = false
let examItems = {getExaminationItemRsp:{body:{ykxx:''}}}; let examItems = { getExaminationItemRsp: { body: { ykxx: '' } } };
if(!globalThis.singlePlay){ if (!globalThis.singlePlay) {
//获取已考项目 //获取已考项目
examItems = await getExaminationItem({ examItems = await getExaminationItem({
time: getCurrentTime(), time: getCurrentTime(),
@ -487,90 +515,55 @@ struct UserInfo {
this.currentUser.id = '1' this.currentUser.id = '1'
//是否已经开始考试 //是否已经开始考试
// if(!this.isExamStart){ // if(!this.isExamStart){
const code = await this.beginExam(); const code = await this.beginExam();
if (code != 1) { if (code != 1) {
return return
}
// }
this.AccountTable.query('0', (result) => {
if (result.length == 0) {
this.isExamStart = true
this.AccountTable.insertData(this.currentUser, (id) => {
this.AccountTable.query('0', (result) => {
globalThis.statue = 4
this.stepFlag = false
router.pushUrl({
url: 'pages/Judge',
params: {
examItems: examItems?.getExaminationItemRsp?.body?.ykxx ,
sczb:Number(this.isBoardPrePareSetPopupOpen),
kfdm:this.sczbkf
}
}, router.RouterMode.Single);
this.stopDeviceById()
})
})
} else {
this.AccountTable.updateData(this.currentUser, (id) => {
this.AccountTable.query('0', (result) => {
this.stepFlag = false
router.pushUrl({
url:'pages/Judge',
params: {
examItems: examItems?.getExaminationItemRsp?.body?.ykxx ,
sczb:Number(this.isBoardPrePareSetPopupOpen),
kfdm:this.sczbkf
}
}, router.RouterMode.Single);
globalThis.statue = 4
this.stopDeviceById()
})
})
}
})
this.stepFlag = false
}
// 过程照片拍照
getPhoto = async (empty?: boolean) => {
const singlePlay = globalThis.singlePlay
//单机模式返回空照片
if (singlePlay) {
return ''
} else {
const {filePhoto} = this;
const photoBase64 = await filePhoto.getPhoto();
return photoBase64
} }
// }
await upDateTableByArray('USER', [this.currentUser])
globalThis.statue = 4
this.stepFlag = false
router.pushUrl({
url: 'pages/Judge',
params: {
examItems: examItems?.getExaminationItemRsp?.body?.ykxx,
sczb: Number(this.isBoardPrePareSetPopupOpen),
kfdm: this.sczbkf
}
}, router.RouterMode.Single);
this.stopDeviceById()
this.stepFlag = false
} }
// 检测车门、熄火信号 // 检测车门、熄火信号
async checkSignal():Promise<boolean>{ async checkSignal(): Promise<boolean> {
const {isCheckFireOpen} = judgeConfig const {isCheckFireOpen} = judgeConfig
return new Promise((resolve,reject)=>{ return new Promise((resolve, reject) => {
if(isCheckFireOpen){ if (isCheckFireOpen) {
resolve(true) resolve(true)
} }
globalThis.udpClient.onMessage_1(async (msg) => { globalThis.udpClient.onMessage_1(async (msg) => {
const msgArr = msg.split(',') const msgArr = msg.split(',')
const mkg = msgArr[14]; const mkg = msgArr[14];
const fdjzs = msgArr[25]; const fdjzs = msgArr[25];
globalThis.udpClient.onMessage_1(()=>{}); globalThis.udpClient.onMessage_1(() => {
});
//TODO //TODO
console.info('surenjun mkg=>', mkg) console.info('surenjun mkg=>', mkg)
console.info('surenjun fdjzs=>', fdjzs) console.info('surenjun fdjzs=>', fdjzs)
if(mkg == 1){ if (mkg == 1) {
this.avPlayer.playAudio(['voice/关门.mp3']) this.avPlayer.playAudio(['voice/关门.mp3'])
promptAction.showToast({ promptAction.showToast({
message:'请关闭车门', message: '请关闭车门',
duration:4000 duration: 4000
}) })
reject(false) reject(false)
} }
if(fdjzs*1 > 0){ if (fdjzs * 1 > 0) {
this.avPlayer.playAudio(['voice/熄火.mp3']) this.avPlayer.playAudio(['voice/熄火.mp3'])
promptAction.showToast({ promptAction.showToast({
message:'请熄火', message: '请熄火',
duration:4000 duration: 4000
}) })
reject(false) reject(false)
} }
@ -578,22 +571,23 @@ struct UserInfo {
}) })
}) })
} }
// 开始考试 // 开始考试
async beginExam(){ async beginExam() {
const carInfo = globalThis.carInfo; const carInfo = globalThis.carInfo;
const {carId,examinationRoomId} = carInfo; const {carId,examinationRoomId} = carInfo;
const { examSubject,plateNo } = carInfo; const { examSubject,plateNo } = carInfo;
const date = new Date() const date = new Date()
console.info('surenjun','photoBase64') console.info('surenjun', 'photoBase64')
const photoBase64 = await this.getPhoto(); const photoBase64 = await this.getPhoto();
console.info('surenjun','photoBase64End') console.info('surenjun', 'photoBase64End')
const drvexam = { const drvexam = {
lsh: this.currentUser.lsh || '', lsh: this.currentUser.lsh || '',
kskm: examSubject, kskm: examSubject,
ksxtbh: this.ksxtbh || '222', ksxtbh: this.ksxtbh || '222',
sfzmhm: this.currentUser.sfzmhm || '', sfzmhm: this.currentUser.sfzmhm || '',
ksysfzmhm: this.currentUser.ksy1sfzmhm || '', ksysfzmhm: this.currentUser.ksy1sfzmhm || '',
ksxl:this.currentUser.ksxl, ksxl: this.currentUser.ksxl,
zp: photoBase64, zp: photoBase64,
kssj: dateFormat(date) || '', kssj: dateFormat(date) || '',
kchp: decodeURI(plateNo), kchp: decodeURI(plateNo),
@ -734,23 +728,23 @@ struct UserInfo {
this.qkFlag = true this.qkFlag = true
}) })
if( this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow){ if (this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow) {
//上车准备 //上车准备
Image($r('app.media.sczb_btn')).commStyle().onClick(async ()=>{ Image($r('app.media.sczb_btn')).commStyle().onClick(async () => {
try { try {
await this.checkSignal() await this.checkSignal()
this.isExamStart = true this.isExamStart = true
await upDateTableByArray('USER',[this.currentUser]) await upDateTableByArray('USER', [this.currentUser])
globalThis.statue = 4 globalThis.statue = 4
this.isBoardPrePareSetPopupShow = true; this.isBoardPrePareSetPopupShow = true;
this.isFirstBoardPrePareSetPopupBtnShow = true; this.isFirstBoardPrePareSetPopupBtnShow = true;
this.stepFlag = false this.stepFlag = false
this.stopDeviceById() this.stopDeviceById()
}catch (e){ } catch (e) {
} }
}) })
}else{ } else {
Image($r('app.media.ksks_btn')) Image($r('app.media.ksks_btn'))
.commStyle() .commStyle()
.onClick(async () => { .onClick(async () => {
@ -768,39 +762,19 @@ struct UserInfo {
// }); // });
// return // return
// } // }
console.info('surenjun currentUser',JSON.stringify(this.currentUser)) console.info('surenjun currentUser', JSON.stringify(this.currentUser))
if (globalThis.singlePlay) { if (globalThis.singlePlay) {
const {examSubject} = globalThis.carInfo; const {examSubject} = globalThis.carInfo;
console.info('surenjun => sczbkf',JSON.stringify(this.sczbkf)) console.info('surenjun => sczbkf', JSON.stringify(this.sczbkf))
this.AccountTable.query('0', (result) => { await upDateTableByArray('USER', [this.currentUser])
if (result.length == 0) { router.pushUrl({
this.AccountTable.insertData(this.currentUser, (id) => { url: examSubject == 3 ? 'pages/Roads' : 'pages/Judge',
this.AccountTable.query('0', (result) => { params: {
router.pushUrl({ sczb: Number(this.isBoardPrePareSetPopupOpen),
url: examSubject == 3 ? 'pages/Roads':'pages/Judge', kfdm: this.sczbkf
params:{
sczb:Number(this.isBoardPrePareSetPopupOpen),
kfdm:this.sczbkf
}
}, router.RouterMode.Single);
this.stopDeviceById()
})
})
} else {
this.AccountTable.updateData(this.currentUser, (id) => {
this.AccountTable.query('0', (result) => {
router.pushUrl({
url: examSubject == 3?'pages/Roads':'pages/Judge',
params:{
sczb:Number(this.isBoardPrePareSetPopupOpen),
kfdm:this.sczbkf
}
}, router.RouterMode.Single);
this.stopDeviceById()
})
})
} }
}) }, router.RouterMode.Single);
this.stopDeviceById()
return return
} }
if (this.FaceOpenStatue != '0') { if (this.FaceOpenStatue != '0') {
@ -808,7 +782,7 @@ struct UserInfo {
} else { } else {
this.sfbdinterfaceFn() this.sfbdinterfaceFn()
} }
}catch (e){ } catch (e) {
} }
@ -860,9 +834,9 @@ struct UserInfo {
} }
// 上车准备弹窗 // 上车准备弹窗
if(this.isBoardPrePareSetPopupShow){ if (this.isBoardPrePareSetPopupShow) {
BoardPrePareSetPopup({ BoardPrePareSetPopup({
closePopup:(bool)=>{ closePopup: (bool) => {
this.isBoardPrePareSetPopupShow = false; this.isBoardPrePareSetPopupShow = false;
// if(!globalThis.singlePlay){ // if(!globalThis.singlePlay){
// this.isFirstBoardPrePareSetPopupBtnShow = !bool; // this.isFirstBoardPrePareSetPopupBtnShow = !bool;
@ -874,7 +848,7 @@ struct UserInfo {
// this.numCount = 0 // this.numCount = 0
// this.getExaminationStudentInfoFn() // this.getExaminationStudentInfoFn()
// }, // },
confirmMark:(kfdm)=>{ confirmMark: (kfdm) => {
this.sczbkf = kfdm this.sczbkf = kfdm
} }
}) })