diff --git a/entry/src/main/ets/common/service/CameraModel.ts b/entry/src/main/ets/common/service/CameraModel.ets similarity index 100% rename from entry/src/main/ets/common/service/CameraModel.ts rename to entry/src/main/ets/common/service/CameraModel.ets diff --git a/entry/src/main/ets/common/utils/DateTimeUtil2.ts b/entry/src/main/ets/common/utils/DateTimeUtil2.ts deleted file mode 100644 index 59091622..00000000 --- a/entry/src/main/ets/common/utils/DateTimeUtil2.ts +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file 日期工具 - */ - -const NINE = 9; // 这是数字9 - -export default class DateTimeUtil { - /** - * 时分秒 - */ - getTime(): string { - const DATETIME = new Date(); - return this.concatTime( - DATETIME.getHours(), - DATETIME.getMinutes(), - DATETIME.getSeconds() - ); - } - - /** - * 年月日 - */ - getDate(): string { - const DATETIME = new Date(); - return this.concatDate( - DATETIME.getFullYear(), - DATETIME.getMonth() + 1, - DATETIME.getDate() - ); - } - - /** - * 日期不足两位补充0 - * @param value-数据值 - */ - fill(value: number): string { - return (value > NINE ? '' : '0') + value; - } - - /** - * 年月日格式修饰 - * @param year - * @param month - * @param date - */ - concatDate(year: number, month: number, date: number): string { - return `${year}${this.fill(month)}${this.fill(date)}`; - } - - /** - * 时分秒格式修饰 - * @param hours - * @param minutes - * @param seconds - */ - concatTime(hours: number, minutes: number, seconds: number): string { - return `${this.fill(hours)}${this.fill(minutes)}${this.fill(seconds)}`; - } -} diff --git a/entry/src/main/ets/common/utils/GlobleTcp.ts b/entry/src/main/ets/common/utils/GlobalTcp.ts similarity index 100% rename from entry/src/main/ets/common/utils/GlobleTcp.ts rename to entry/src/main/ets/common/utils/GlobalTcp.ts diff --git a/entry/src/main/ets/common/utils/GlobleUdp.ts b/entry/src/main/ets/common/utils/GlobalUdp.ts similarity index 100% rename from entry/src/main/ets/common/utils/GlobleUdp.ts rename to entry/src/main/ets/common/utils/GlobalUdp.ts diff --git a/entry/src/main/ets/common/utils/MediaModel.ts b/entry/src/main/ets/common/utils/MediaModel.ets similarity index 95% rename from entry/src/main/ets/common/utils/MediaModel.ts rename to entry/src/main/ets/common/utils/MediaModel.ets index 1c40d930..e5d5702e 100644 --- a/entry/src/main/ets/common/utils/MediaModel.ts +++ b/entry/src/main/ets/common/utils/MediaModel.ets @@ -14,7 +14,7 @@ */ import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import DateTimeUtil from './DateTimeUtil2'; +import DateTimeUtil from './DateTimeUtil'; type FileInfo = { @@ -24,8 +24,8 @@ type FileInfo = { }; export default class MediaModel { - private mediaLibraryTest: mediaLibrary.MediaLibrary = undefined; private static mediaInstance: MediaModel = undefined; + private mediaLibraryTest: mediaLibrary.MediaLibrary = undefined; constructor() { this.mediaLibraryTest = mediaLibrary.getMediaLibrary(globalThis.cameraContext); @@ -38,11 +38,11 @@ export default class MediaModel { return this.mediaInstance; } - async createAndGetUri(mediaType: mediaLibrary.MediaType,fileName): Promise { + async createAndGetUri(mediaType: mediaLibrary.MediaType, fileName): Promise { let dateTimeUtil: DateTimeUtil = new DateTimeUtil(); let info: FileInfo = this.getInfoFromMediaType(mediaType); let name: string = `${dateTimeUtil.getDate()}_${dateTimeUtil.getTime()}`; - let displayName: string =fileName?fileName:`${info.prefix}${name}${info.suffix}`; + let displayName: string = fileName ? fileName : `${info.prefix}${name}${info.suffix}`; let publicPath: string = await this.mediaLibraryTest.getPublicDirectory( info.directory ); diff --git a/entry/src/main/ets/common/utils/UdpJudge.ts b/entry/src/main/ets/common/utils/UdpJudge.ts index 439f7f1e..d5443865 100644 --- a/entry/src/main/ets/common/utils/UdpJudge.ts +++ b/entry/src/main/ets/common/utils/UdpJudge.ts @@ -1,8 +1,8 @@ import systemTime from '@ohos.systemDateTime'; -import {deepClone,getCurrentTime,stringToASC,string2Bytes,fillZero,Array2Byte} from '../../common/utils/tools' -import {testMarkRules,testAllitems,testRealExam,testUIAllitems,testKmItems} from '../../pages/judgeSDK/dataTest/index' -import {setJudgeUdp,setTopLineUdp} from './GlobleUdp' -import {convertGpsCoord2} from '../utils/tools' +import { Array2Byte, fillZero, string2Bytes, stringToASC } from '../../common/utils/tools'; +import { testKmItems } from '../../pages/judgeSDK/dataTest/index'; +import { setJudgeUdp, setTopLineUdp } from './GlobalUdp'; +import { convertGpsCoord2 } from '../utils/tools'; export const initJudgeUdp = async () => { @@ -12,27 +12,27 @@ export const initJudgeUdp = async () => { globalThis.judgeUdp = udp const arrBlue = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]; - const arrBlueBuffer= Array2Byte(arrBlue).buffer + const arrBlueBuffer = Array2Byte(arrBlue).buffer const lightLineUdp = await setTopLineUdp(); - if(lightLineUdp){ + if (lightLineUdp) { lightLineUdp.send(arrBlueBuffer); } globalThis.lightLineUdp = lightLineUdp /*******************************************/ globalThis.udpClient.onMessage(async (msg) => { - const stachArr= msg.split(',') + const stachArr = msg.split(',') if (stachArr[0] != '#DN_GD') { return } const udpIndex = globalThis.udpIndex; const isJudge = globalThis.isJudge; - if(udpIndex % 5 === 0 && !isJudge){ + if (udpIndex % 5 === 0 && !isJudge) { const bytes = await getMessageHeartbeat(msg); udp.send(bytes) } - globalThis.udpIndex+=1 + globalThis.udpIndex += 1 }) } @@ -40,8 +40,8 @@ export const getMessageHeartbeat = async (msg) => { const carInfo = globalThis.carInfo; const { examSubject,plateNo,ksyh } = carInfo; - const asclshArr = stringToASC(fillZero(globalThis.lsh|| 0 , 13)); - const ascksyhArr = stringToASC(fillZero(globalThis.ksyh|| 0, 13)) + const asclshArr = stringToASC(fillZero(globalThis.lsh || 0, 13)); + const ascksyhArr = stringToASC(fillZero(globalThis.ksyh || 0, 13)) const ascsbxhArr = stringToASC('0000000000') const serialIndex = globalThis.serialIndex const tempData = await getPlcData(msg); @@ -49,140 +49,185 @@ export const getMessageHeartbeat = async (msg) => { const {zfxd,yfxd,shtd,ygd,jgd,skd,dh1,dh2,lhq,jsc,ssc,fsc,lb,mkg,aqd,ygq,cs,fdjzs} = sensor const {jd,wd, hxj, fyj, hbg,} = gps const translateSignals = getTranslateSignals( - [zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc,ssc,fsc, lb, mkg, aqd, 0,0,0,0 , 0,0, ygq, sensor.wd, 0 ] + [zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd, 0, 0, 0, 0, 0, 0, ygq, sensor.wd, 0] ) const translateProject = getTranslateProject(); //@ts-ignore - const translateJd = convertGpsCoord2(wd).toFixed(7) * Math.pow(10,7) + const translateJd = convertGpsCoord2(wd).toFixed(7) * Math.pow(10, 7) //@ts-ignore - const translateWd = convertGpsCoord2(jd).toFixed(7) * Math.pow(10,7) + const translateWd = convertGpsCoord2(jd).toFixed(7) * Math.pow(10, 7) //@ts-ignore - const translateProjects= translateProject.map(numStr => string2Bytes(parseInt(numStr,2),8)[0]) + const translateProjects = translateProject.map(numStr => string2Bytes(parseInt(numStr, 2), 8)[0]) const arr = [ - //考生号 - asclshArr.map(lsh => string2Bytes(lsh,8)[0]), - //考试员号 - ascksyhArr.map(ksyh => string2Bytes(ksyh,8)[0]), - // 科目类型(0:未考试 1:科目二 2:科目三) + 考试开始时间 - string2Bytes('00000000000',4 * 8), - // 消息序号 - string2Bytes(serialIndex,2 * 8), + //考生号 + asclshArr.map(lsh => string2Bytes(lsh, 8)[0]), + //考试员号 + ascksyhArr.map(ksyh => string2Bytes(ksyh, 8)[0]), + // 科目类型(0:未考试 1:科目二 2:科目三) + 考试开始时间 + string2Bytes('00000000000', 4 * 8), + // 消息序号 + string2Bytes(serialIndex, 2 * 8), translateSignals, - //@ts-ignore - string2Bytes(cs,2*8), string2Bytes(fdjzs / 60,8), string2Bytes(translateJd,4*8), string2Bytes(translateWd,4*8), string2Bytes(1,8), - //GPS东向距离 - string2Bytes(0,4*8), - //GPS北向距离 - string2Bytes(0,4*8), - //航向角 俯仰角 高程(海拔) - //@ts-ignore - string2Bytes((hxj+90) * 100,2*8), string2Bytes(fyj*100,2*8), string2Bytes(hbg*100,4*8), + //@ts-ignore + string2Bytes(cs, 2 * 8), string2Bytes(fdjzs / 60, 8), string2Bytes(translateJd, 4 * 8), string2Bytes(translateWd, 4 * 8), string2Bytes(1, 8), + //GPS东向距离 + string2Bytes(0, 4 * 8), + //GPS北向距离 + string2Bytes(0, 4 * 8), + //航向角 俯仰角 高程(海拔) + //@ts-ignore + string2Bytes((hxj + 90) * 100, 2 * 8), string2Bytes(fyj * 100, 2 * 8), string2Bytes(hbg * 100, 4 * 8), translateProjects, - //当前项目编号 - string2Bytes(0,8), - //场地设备编号 - ascsbxhArr.map(sbxh => string2Bytes(sbxh,8)[0]), - //本次考试行驶距离 - string2Bytes(0,2*8), - //扣分 - string2Bytes(0,2*8), - //扣分项数量 - string2Bytes(0,8), - //n个扣分序号 - [].map(kf => string2Bytes(kf.markcatalog,8)) + //当前项目编号 + string2Bytes(0, 8), + //场地设备编号 + ascsbxhArr.map(sbxh => string2Bytes(sbxh, 8)[0]), + //本次考试行驶距离 + string2Bytes(0, 2 * 8), + //扣分 + string2Bytes(0, 2 * 8), + //扣分项数量 + string2Bytes(0, 8), + //n个扣分序号 + [].map(kf => string2Bytes(kf.markcatalog, 8)) ] let tempArr = []; - arr.forEach(itemArr =>{ tempArr = tempArr.concat(itemArr)}) + arr.forEach(itemArr => { + tempArr = tempArr.concat(itemArr) + }) globalThis.serialIndex = 0; return Array2Byte(tempArr) } // 中心plc实时信号转换成字节 -const getTranslateSignals = (tempItems) => { +const getTranslateSignals = (tempItems) => { const len = Math.floor(tempItems.length / 8); const arr = []; - for(let i = 0;i < len;i++){ - const temp = tempItems.slice( i*8 , (i+1)*8 ); + for (let i = 0; i < len; i++) { + const temp = tempItems.slice(i * 8, (i + 1) * 8); arr.push(temp.join('')); } - const temp = arr.map(numStr => parseInt(numStr,2)) - return temp.map(item => string2Bytes(item , 8)[0]) + const temp = arr.map(numStr => parseInt(numStr, 2)) + return temp.map(item => string2Bytes(item, 8)[0]) } // 中心所有项目转换 -const getTranslateProject = () => { +const getTranslateProject = () => { const allKmItemsObj = {}; testKmItems.forEach(item => { allKmItemsObj[item.code] = item; }) - const tempItems = testKmItems.map(item=>{ + const tempItems = testKmItems.map(item => { const current = allKmItemsObj[item.code]; return { - code:item.code, - status:getCenterProjectStatus(current.status) + code: item.code, + status: getCenterProjectStatus(current.status) } }) const len = Math.floor(tempItems.length / 4); const arr = []; - for(let i = 0;i <= len;i++){ - const temp = tempItems.slice( i*4 , (i+1)*4 ); + for (let i = 0; i <= len; i++) { + const temp = tempItems.slice(i * 4, (i + 1) * 4); let tempArr = temp.map(item => item.status) - if(i === 4){ - tempArr = tempArr.concat(['00','00']) + if (i === 4) { + tempArr = tempArr.concat(['00', '00']) } arr.push(tempArr.join('')); } - return arr.map(numStr => parseInt(numStr,2)); + return arr.map(numStr => parseInt(numStr, 2)); } // 中心实时项目状态转换 const getCenterProjectStatus = (status) => { - switch (status){ + switch (status) { //不考 - case 0:return '00' + case 0: + return '00' //未考 - case 1:return '01' + case 1: + return '01' //已考 - case 2:return '10' + case 2: + return '10' } } // plc数据转换成对象 -const getPlcData = async (plc:string) => { +const getPlcData = async (plc: string) => { const time = await systemTime.getCurrentTime() - const p = plc.split(',').map((val,key)=>{ - if(key !== 27 && key !== 92){ + const p = plc.split(',').map((val, key) => { + if (key !== 27 && key !== 92) { //@ts-ignore - return val*1 - }else{ + return val * 1 + } else { return val } }); const tempData = { - sensor:{ + sensor: { //安全带 车门门开关 手刹 脚刹 副刹 离合器 喇叭 示宽灯 近光灯 远光灯 - aqd:p[19], mkg:p[14], ssc:p[13], jsc:p[12], fsc:p[18], lhq:p[17], lb:p[4], skd:p[9], jgd:p[7], ygd:p[8], + aqd: p[19], + mkg: p[14], + ssc: p[13], + jsc: p[12], + fsc: p[18], + lhq: p[17], + lb: p[4], + skd: p[9], + jgd: p[7], + ygd: p[8], //左方向灯 右方向灯 双跳灯 雾灯 雨刮器 点火1 点火2 发动机转速 档位 车速 - zfxd:p[2], yfxd:p[3], shtd:p[20],wd:p[10], ygq:p[11], dh1:p[5], dh2:p[6], fdjzs:p[25], dw:p[28], cs:p[23], + zfxd: p[2], + yfxd: p[3], + shtd: p[20], + wd: p[10], + ygq: p[11], + dh1: p[5], + dh2: p[6], + fdjzs: p[25], + dw: p[28], + cs: p[23], //@ts-ignore 方向盘 - fxp:p[27].split('_')[0]*1, + fxp: p[27].split('_')[0] * 1, //累计脉冲 溜车脉冲 超声波左后 超声波右后 超声波右前 超声波左前 座椅 仪表盘 后视镜 倒车镜 光照 雨量 - ljmc:p[24], lcmc:0, csbzh:p[32], csbyh:p[30], csbyq:p[31], csbzq:p[29], zy:0, tbp:0, hsj:0, dcj:0, gx:0, yl:0 + ljmc: p[24], + lcmc: 0, + csbzh: p[32], + csbyh: p[30], + csbyq: p[31], + csbzq: p[29], + zy: 0, + tbp: 0, + hsj: 0, + dcj: 0, + gx: 0, + yl: 0 }, - gps:{ + gps: { //TODO 办卡类型 定位差分状态 - bklx:p[56], dwzt:p[83], + bklx: p[56], + dwzt: p[83], //@ts-ignore 角度差分状态 - jdzt:p[92].split('-')[0]*1, + jdzt: p[92].split('-')[0] * 1, //TODO gps数据 //gps时间 经度 纬度 航向角 俯仰角 海拔高 高度差 速度 - sj:time, jd:p[96], wd:p[95], hxj:p[90], fyj:p[91], hbg:p[85], gdc:p[86], sd:p[97], + sj: time, + jd: p[96], + wd: p[95], + hxj: p[90], + fyj: p[91], + hbg: p[85], + gdc: p[86], + sd: p[97], //龄期 经度因子 纬度因子 定位搜星数 - age:p[87], jdyz:p[89], wdyz:p[88], dwsxs:p[84], + age: p[87], + jdyz: p[89], + wdyz: p[88], + dwsxs: p[84], //@ts-ignore 角度搜星数 - jdsxs:p[92].split('-')[1]*1 + jdsxs: p[92].split('-')[1] * 1 }, } diff --git a/entry/src/main/ets/pages/CarCheck.ets b/entry/src/main/ets/pages/CarCheck.ets index 8b056419..56b86e87 100644 --- a/entry/src/main/ets/pages/CarCheck.ets +++ b/entry/src/main/ets/pages/CarCheck.ets @@ -1,14 +1,13 @@ -import UdpClient from '../common/utils/UdpClient'; -import { voiceService } from '../common/service/voiceService' -import router from '@ohos.router' -import { carConfigurationInfo, uploadExamCarCheckResult } from '../api/checkCar' -import TopLogo from './compontents/topLogo' -import testNapi from '@ohos.hiserialsdk' +import { voiceService } from '../common/service/voiceService'; +import router from '@ohos.router'; +import { carConfigurationInfo, uploadExamCarCheckResult } from '../api/checkCar'; +import TopLogo from './compontents/topLogo'; +import testNapi from '@ohos.hiserialsdk'; import { dateFormat } from '../common/utils/tools'; @Entry @Component -struct Index { +export default struct Index { @State angle: number = 0 @State ratio: number = 1700 / 960 @State index: number = -1 @@ -20,22 +19,21 @@ struct Index { @State breakFlag: boolean = false @State checkFlag: boolean = false @State msgFlag: boolean = false - @State confimDialogFlag: boolean = false - private vocObj = null; + @State confirmDialogFlag: boolean = false @State checkList: Array = [] @State subFlag: boolean = true @State signArr: Array = [] @State checkListCopy: Array = [] @State warnFlag: object = { - 1:'0', - 2:'0', - 3:'0', - 4:'0', - 5:'0', - 6:'0', - 7:'0', - 8:'0', - 9:'0', + 1: '0', + 2: '0', + 3: '0', + 4: '0', + 5: '0', + 6: '0', + 7: '0', + 8: '0', + 9: '0', 10: '0', 11: '0', 12: '0', @@ -187,12 +185,11 @@ struct Index { 19: '9', 20: '0' } - @State len: any = '' @State fd: number = -1; @State devPath: string = "/dev/ttyS3" - @State interval: any="" - @State chuankouFlag: any="" - @State stopFlag: boolean=false + @State stopFlag: boolean = false + private vocObj = null; + // private AccountTable = new AccountTable(()=>{},CommonConstants); onPageShow() { const that = this @@ -238,32 +235,31 @@ struct Index { let databuff = [0x61, 0xAA, 0x0A, 0X15, 0X00]; // send ABCDE let ret = testNapi.SerialSend(this.fd, databuff); - console.log('mmmm',ret) + console.log('mmmm', ret) let revTestInfo = testNapi?.SerialRecv(this.fd, timeout); - console.log('revTestInfo',revTestInfo.recevedBuf.length) + console.log('revTestInfo', revTestInfo.recevedBuf.length) const message = revTestInfo?.recevedBuf?.toString() - console.log('chuankou',this.index,message) + console.log('chuankou', this.index, message) if (message == '') { - this.stopFlag=true + this.stopFlag = true return } const msg = message?.split(',') - if(!msg?.length){ + if (!msg?.length) { return } if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) { return } - globalThis.chuankoMsg=msg[9] + globalThis.chuankoMsg = msg[9] if (msg[9] == this.dwMap[this.index]) { this.warnFlag[this.index] = '2' } } - async xhxs() { this.vocObj.avPlayerStop() this.vocObj.releasePlayer() @@ -273,6 +269,7 @@ struct Index { // clearInterval(this.interval) } + // carConfigurationInfoFn() { if (globalThis.singlePlay) { @@ -419,9 +416,10 @@ struct Index { name: 'kszj.wav' }) } - getPLCInfo(){ - const that=this - globalThis.udpClient&&globalThis.udpClient.onMessage((msg) => { + + getPLCInfo() { + const that = this + globalThis.udpClient && globalThis.udpClient.onMessage((msg) => { if (!this.breakFlag) { return } @@ -433,7 +431,7 @@ struct Index { const dw = [14, 15, 16, 17, 18, 19, 20]; const dwArr = [14, 15, 16, 17, 18, 19, 20] - if(dwArr.indexOf(this.index)>=0){ + if (dwArr.indexOf(this.index) >= 0) { if (stachArr[28] == this.dwMap[this.index]) { this.warnFlag[this.index] = '2' } @@ -490,7 +488,7 @@ struct Index { setTimeout(() => { if (this.warnFlag[this.index] != '2') { this.warnFlag[this.index] = '1' - this.warnFlag=JSON.parse(JSON.stringify(this.warnFlag)) + this.warnFlag = JSON.parse(JSON.stringify(this.warnFlag)) } if (!this.breakFlag) { return @@ -537,7 +535,7 @@ struct Index { } this.index = this.checkListCopy[0].key this.passArray[this.index] = true - this.passArray=JSON.parse(JSON.stringify(this.passArray)) + this.passArray = JSON.parse(JSON.stringify(this.passArray)) this.subFlag = true if (this.warnFlagTip[this.index].length == 1) { this.vocObj.playAudio({ @@ -562,7 +560,7 @@ struct Index { } outClick() { - this.vocObj&& this.vocObj.releasePlayer() + this.vocObj && this.vocObj.releasePlayer() this.breakFlag = false // clearInterval(this.interval) } @@ -660,6 +658,7 @@ struct Index { .backgroundImageSize({ width: '100%', height: '100%' }) .width(206 * this.ratio) .height(235.5 * this.ratio) + //档位 Column() { Image(this.warnFlag[14] == '1' ? $r('app.media.1_r') : this.warnFlag[14] == '2' ? $r('app.media.1') : '') diff --git a/entry/src/main/ets/pages/ExaminerLogin.ets b/entry/src/main/ets/pages/ExaminerLogin.ets index ff6de14f..5cee42c7 100644 --- a/entry/src/main/ets/pages/ExaminerLogin.ets +++ b/entry/src/main/ets/pages/ExaminerLogin.ets @@ -1,61 +1,63 @@ -import router from '@ohos.router' -import TopLogo from './compontents/topLogo' -import { examinerLoginService } from '../common/service/ExaminerService' -import Md5 from '../common/utils/md5'; -import promptAction from '@ohos.promptAction' +import router from '@ohos.router'; +import TopLogo from './compontents/topLogo'; +import { examinerLoginService } from '../common/service/ExaminerService'; +import Md5 from '../common/utils/md5'; +import promptAction from '@ohos.promptAction'; @Entry @Component -struct Index { +export default struct Index { @State ratio: number = 1700 / 960 @State url: string = '' - @State inputPlaceholderArr: string[] = ['用户账户','密码']; - @State inputTextArr: string[] = ['','']; - @State imgArr1: Resource[] = [$r('app.media.1_nor'),$r('app.media.2_nor'),$r('app.media.3_nor'),$r('app.media.4_nor'),$r('app.media.5_nor'),$r('app.media.6_nor'),$r('app.media.7_nor'),$r('app.media.8_nor'),$r('app.media.9_nor'),$r('app.media.0_nor'),$r('app.media.x_nor'),$r('app.media.clear_nor'),$r('app.media.delete_nor'),$r('app.media.confirm_nor')] + @State inputPlaceholderArr: string[] = ['用户账户', '密码']; + @State inputTextArr: string[] = ['', '']; + @State imgArr1: Resource[] = [$r('app.media.1_nor'), $r('app.media.2_nor'), $r('app.media.3_nor'), $r('app.media.4_nor'), $r('app.media.5_nor'), $r('app.media.6_nor'), $r('app.media.7_nor'), $r('app.media.8_nor'), $r('app.media.9_nor'), $r('app.media.0_nor'), $r('app.media.x_nor'), $r('app.media.clear_nor'), $r('app.media.delete_nor'), $r('app.media.confirm_nor')] @State currentInputIndex: number = 0 @State @Watch('outClick') outFlag: boolean = false; private vocObj = null; + build() { Column() { - TopLogo({outFlag:$outFlag}) + TopLogo({ outFlag: $outFlag }) Column() { - Text('请考官输入用户名密码').fontColor('#FFAD33').fontSize(36*this.ratio) + Text('请考官输入用户名密码').fontColor('#FFAD33').fontSize(36 * this.ratio) Row() { - ForEach(this.inputPlaceholderArr, (item:any, index:number) => { - Row(){ - TextInput({ placeholder: `${item}`,text: this.inputTextArr[index] }) - .fontSize(42*this.ratio) + ForEach(this.inputPlaceholderArr, (item: any, index: number) => { + Row() { + TextInput({ placeholder: `${item}`, text: this.inputTextArr[index] }) + .fontSize(42 * this.ratio) .fontColor('white') - .placeholderFont({ size: 42*this.ratio }) + .placeholderFont({ size: 42 * this.ratio }) .placeholderColor('gray') .caretColor('white') .backgroundColor('transparent') .width('90%') - .margin({left: '4%'}) + .margin({ left: '4%' }) .type(index === 0 ? InputType.Normal : InputType.Password) .focusable(false) .onClick(() => { this.currentInputIndex = index; }) } - .backgroundImage(this.currentInputIndex == index ? $r('app.media.kuang_pre') : $r('app.media.kuang_nor')) - .backgroundImageSize({width:'100%',height:'100%'}) + .backgroundImage(this.currentInputIndex == index ? $r('app.media.kuang_pre') : $r('app.media.kuang_nor')) + .backgroundImageSize({ width: '100%', height: '100%' }) .width('48%') .height('14.9%') }) } .width('90%') - .margin({top: 25*this.ratio}) //20 + .margin({ top: 25 * this.ratio }) //20 .justifyContent(FlexAlign.SpaceBetween) + Column() { - Flex({wrap: FlexWrap.Wrap, - justifyContent:FlexAlign.SpaceAround, - alignContent: FlexAlign.SpaceAround}) { - ForEach(this.imgArr1, (item:Resource, index:number) => { - if(index === this.imgArr1.length -1 ) { + Flex({ wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.SpaceAround, + alignContent: FlexAlign.SpaceAround }) { + ForEach(this.imgArr1, (item: Resource, index: number) => { + if (index === this.imgArr1.length - 1) { Image(item).width('38%').height('24%').onClick(() => { - if(this.inputTextArr[0].trim()==''||this.inputTextArr[1].trim()==''){ + if (this.inputTextArr[0].trim() == '' || this.inputTextArr[1].trim() == '') { promptAction.showToast({ message: '请输入用户名和密码', duration: 3000 @@ -69,7 +71,7 @@ struct Index { username: this.inputTextArr[0], password: Md5.Instance.get_md5(this.inputTextArr[1]) } - console.log('paramparam',JSON.stringify(globalThis.carInfo)) + console.log('paramparam', JSON.stringify(globalThis.carInfo)) examinerLoginService(param).then(res => { // this.vocObj.playAudio({ // type: 1, @@ -78,28 +80,30 @@ struct Index { // this.url='pages/userInfo' router.pushUrl({ url: 'pages/UserInfo', - },router.RouterMode.Single); - console.log('res11',JSON.stringify(res)) - globalThis.username=this.inputTextArr[0] + }, router.RouterMode.Single); + console.log('res11', JSON.stringify(res)) + globalThis.username = this.inputTextArr[0] }) }) - }else { + } else { Image(item).width('18%').height('24%').onClick(() => { // this.vocObj.playAudio({ // type: 1, // name: 'media_button.wav' // }) - this.url='' - if(index < 9) { - this.inputTextArr[this.currentInputIndex] += (index + 1).toString() - }else { - if(index === 9) { - this.inputTextArr[this.currentInputIndex] += (0).toString() - } if(index === 10) { - this.inputTextArr[this.currentInputIndex] += 'X'; - } else if(index === 11) { - this.inputTextArr[this.currentInputIndex] = ''; - } if(index === 12) { + this.url = '' + if (index < 9) { + this.inputTextArr[this.currentInputIndex] += (index + 1).toString() + } else { + if (index === 9) { + this.inputTextArr[this.currentInputIndex] += (0).toString() + } + if (index === 10) { + this.inputTextArr[this.currentInputIndex] += 'X'; + } else if (index === 11) { + this.inputTextArr[this.currentInputIndex] = ''; + } + if (index === 12) { this.inputTextArr[this.currentInputIndex] = this.inputTextArr[this.currentInputIndex].slice(0, -1) } } @@ -110,28 +114,31 @@ struct Index { } .height('100%') } - .margin({top: 20*this.ratio}) + .margin({ top: 20 * this.ratio }) .width('90%') .height('62.7%') .backgroundColor('#E5E3DF') - .borderRadius(20*this.ratio) + .borderRadius(20 * this.ratio) } - .margin({top: -10*this.ratio}) + .margin({ top: -10 * this.ratio }) .justifyContent(FlexAlign.SpaceAround) } .width('100%') .height('100%') .justifyContent(FlexAlign.SpaceBetween) - .backgroundImagePosition({x: 0, y: 0}) + .backgroundImagePosition({ x: 0, y: 0 }) .backgroundImage($r('app.media.index_bg')) .backgroundImageSize({ width: '100%', height: '100%' }) } + aboutToAppear() { - this.url='' + this.url = '' console.info('ExmainerLogin aboutToAppear'); } + onPageShow() { } - outClick(){ + + outClick() { } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 30089ea8..6b17c650 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -1,40 +1,38 @@ -// @ts-nocheck -import { VideoConfig } from './interfaces' +import { VideoConfig } from './interfaces'; import common from '@ohos.app.ability.common'; -import router from '@ohos.router' -import { getDeviceInfo ,getCarInfo} from '../common/service/terminalService' -import { setCurrentTime } from '../common/service/timeService' -import {string2Bytes} from '../common/utils/tools' +import router from '@ohos.router'; +import { getCarInfo, getDeviceInfo } from '../common/service/terminalService'; +import { setCurrentTime } from '../common/service/timeService'; +import { string2Bytes } from '../common/utils/tools'; import { FileHelper } from '../common/service/FileHelper'; +import { getUDP, getUDP2 } from '../common/utils/GlobalUdp'; +import { initJudgeUdp } from '../common/utils/UdpJudge'; +import { getTCP } from '../common/utils/GlobalTcp'; +import testNapi from '@ohos.hiserialsdk'; import { - getEsCarModel, -} from '../common/service/initable' -import FileUtil from '../common/utils/File' -import { getUDP, getUDP2 } from '../common/utils/GlobleUdp' -import {initJudgeUdp} from '../common/utils/UdpJudge' -import { getTCP } from '../common/utils/GlobleTcp' -import TcpClient from '../common/utils/TcpClient'; -import testNapi from '@ohos.hiserialsdk' -import {setliushuiNum,getliushuiNum,getSingleCenterTable,getDoubleCeneterTable,takePhotoFn} from '../common/service/indexService' + getDoubleCeneterTable, + getliushuiNum, + getSingleCenterTable, + takePhotoFn +} from '../common/service/indexService'; import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; +import promptAction from '@ohos.promptAction'; + @Entry @Component struct Index { - private fileUtil: FileUtil @State carNum: string = '' @State version: string = '' @State url: string = '' @State hasAuth: boolean = false; @State isSingle: boolean = false; @State deviceId: string = ''; - private interval = null; @State angle: number = 0 @State ratio: number = 1700 / 960 @State loading: boolean = true @State fd: number = -1; - private context = getContext(this) as common.UIAbilityContext; @State param: VideoConfig = { - videoNum:'1', + videoNum: '1', spls: '1', wz: '0,0', faceFlag: false, @@ -59,13 +57,16 @@ struct Index { dolt: '', fontSize: '', rlls: '1', - spzd4:false, - spzd3:false, - spzd2:false, - spzd1:false, - zdyz:'5', + spzd4: false, + spzd3: false, + spzd2: false, + spzd1: false, + zdyz: '5', } - fileHelper =null; + fileHelper = null; + private interval = null; + private context = getContext(this) as common.UIAbilityContext; + build() { Column() { Column() { @@ -97,7 +98,7 @@ struct Index { Column() { Row() { if (!this.isSingle) { - Image($r('app.media.index_lw')).width('30.5%').height('74%').onClick(async() => { + Image($r('app.media.index_lw')).width('30.5%').height('74%').onClick(async () => { if (this.loading) { return } @@ -108,18 +109,18 @@ struct Index { this.angle = 0 //mode为3双中心下载表 - if(globalThis.timeInfo?.mode=='3'){ - await getDoubleCeneterTable() - }else if(globalThis.timeInfo?.mode=='1'){ - await getSingleCenterTable() - }else{ + if (globalThis.timeInfo?.mode == '3') { + await getDoubleCeneterTable() + } else if (globalThis.timeInfo?.mode == '1') { + await getSingleCenterTable() + } else { promptAction.showToast({ message: `网络连接失败`, duration: 3000 }); - this.loading=false + this.loading = false } - this.loading=false + this.loading = false }) } @@ -182,6 +183,7 @@ struct Index { .justifyContent(FlexAlign.SpaceBetween) .margin({ bottom: 10 }) } + // if (this.loading) { Column() { @@ -224,15 +226,20 @@ struct Index { } async heartMsg() { - const arr = [globalThis.signNum||0, globalThis.statue||1] - let tmpList = [];j + const arr = [globalThis.signNum || 0, globalThis.statue || 1] + let tmpList = []; tmpList.push(string2Bytes(arr[0], 1 * 8)[0]) tmpList.push(string2Bytes(arr[1], 1 * 8)[0]) - const str =globalThis.lsh|| '0000000000000' - for (let i = 0;i < str.length; i++) { + const str = globalThis.lsh || '0000000000000' + for (let i = 0; i < str.length; i++) { tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0]) } - const param= {id: 31,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRomId} + const param = { + id: 31, + list: tmpList, + carNo: globalThis.carInfo.carNo, + placeId: globalThis.carInfo.examinationRomId + } // globalThis.udpClient2.initHeartSendMsg(param,this.context) globalThis.udpClient2.sendMsg(param, this.context) } @@ -244,7 +251,7 @@ struct Index { getUDP() getUDP2() clearInterval(this.interval) - this.interval=setInterval(() => { + this.interval = setInterval(() => { // setliushuiNum() getliushuiNum() this.heartMsg() @@ -270,8 +277,9 @@ struct Index { this.fileHelper.createAlbum('pz'); } + userAuth() { - const permissions: Array = ["ohos.permission.READ_IMAGEVIDEO", "ohos.permission.DISTRIBUTED_DATASYNC" ,'ohos.permission.CONNECTIVITY_INTERNAL','ohos.permission.CAMERA','ohos.permission.READ_MEDIA','ohos.permission.WRITE_MEDIA','ohos.permission.FILE_ACCESS_MANAGER']; + const permissions: Array = ["ohos.permission.READ_IMAGEVIDEO", "ohos.permission.DISTRIBUTED_DATASYNC", 'ohos.permission.CONNECTIVITY_INTERNAL', 'ohos.permission.CAMERA', 'ohos.permission.READ_MEDIA', 'ohos.permission.WRITE_MEDIA', 'ohos.permission.FILE_ACCESS_MANAGER']; let context = this.context; let atManager = abilityAccessCtrl.createAtManager(); // requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗 @@ -293,8 +301,9 @@ struct Index { console.error(`Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`); }) } + async initParams() { - this.loading=false + this.loading = false await getDeviceInfo() getCarInfo() await setCurrentTime(); @@ -303,14 +312,9 @@ struct Index { this.hasAuth = globalThis.hasAuth; initJudgeUdp() //下载模型 - // await this.getModel() + // await this.getEsCarModel(this.context) // const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00] // globalThis.udpClientByTopLine.sendMsg(Array2Byte(arr).buffer) - console.info(testNapi) - } - async getModel() { - const context = this.context; - //下载模型 - await getEsCarModel(context) + console.info(testNapi.toString()) } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index fd74671c..1cc2a067 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -1,30 +1,105 @@ -import router from '@ohos.router' -import prompt from '@ohos.prompt' +import router from '@ohos.router'; +import prompt from '@ohos.prompt'; import common from '@ohos.app.ability.common'; -import EndPoPup from './compontents/judge/end-popup' -import LoadingPopup from './compontents/judge/loading-popup' -import DeductedPopup from './compontents/judge/deduction-popup' -import AmplifyPopup from './compontents/judge/amplify-popup' -import Judge from './judgeSDK/judge' -import {defaultJudgeConfigObj} from './judgeSDK/utils//judge-common' +import EndPoPup from './compontents/judge/end-popup'; +import LoadingPopup from './compontents/judge/loading-popup'; +import DeductedPopup from './compontents/judge/deduction-popup'; +import AmplifyPopup from './compontents/judge/amplify-popup'; +import Judge from './judgeSDK/judge'; +import { defaultJudgeConfigObj } from './judgeSDK/utils//judge-common'; import { - Project, ProjectObj, MarkRule, CDSBInfo, - SYSTEMPARMARR,CARINFO ,MAPPOINT ,MAPITEMPOINTITEM -} from './judgeSDK/api/judgeSDK.d' -import { getCurrentTime, formatTime, getCurrentHourTime,chunkArr } from '../common/utils/tools' -import { examJudgeEndExam } from './judgeSDK/api/index' -import { getSyncData } from '../common/service/initable' -import { judgeConfig } from './judgeSDK/utils/judge-config' + CARINFO, + CDSBInfo, + MAPITEMPOINTITEM, + MAPPOINT, + MarkRule, + Project, + ProjectObj, + SYSTEMPARMARR +} from './judgeSDK/api/judgeSDK.d'; +import { chunkArr, formatTime, getCurrentHourTime, getCurrentTime } from '../common/utils/tools'; +import { examJudgeEndExam } from './judgeSDK/api/index'; +import { getSyncData } from '../common/service/initable'; +import { judgeConfig } from './judgeSDK/utils/judge-config'; import FileUtil from '../common/utils/File'; -import SignDisplayCom from './compontents/signDisplayCom' -import {testMarkRules} from './judgeSDK/dataTest/index' +import SignDisplayCom from './compontents/signDisplayCom'; +import { testMarkRules } from './judgeSDK/dataTest/index'; @Entry @Component -struct Index { +export default struct Index { scroller: Scroller = new Scroller() + //页面通用字体大小 + @State FONTSIZE: number = 28 + @State BIGFONTSIZE: number = 28 + //结束考试弹窗 + @State endPopupVisible: boolean = false + //等待弹窗(考试及格,考试不及格使用) + @State loadingPopupVisible: boolean = false + //实时轨迹弹窗 + @State signDisplayComVisible: boolean = false + @State isDdxk: boolean = false; + @State time: string = '' + //考试用时 + @State examTime: number = 0 + //开始时间 + @State startTime: string = '00:00:00' + @State startFullTime: string = '' + @State startHourTime: string = '' + //科目类型 + @State examSubject: 2 | 3 = 2; + @State ddxkTime: number = 0; + @State ddxkKsxmArr: string[] = [''] + @State ddxkKfArr: string[] = [''] + @State xmmcStr: string = '' + @State carztStr: string = '' + @State kfArr: { + xmmcStr?: string, + score: string, + desc: string + }[] = [] + @State name: string = '' + @State idCard: string = '' + @State totalScore: number = 100 + //模拟考试项目 + @State projects: Project[] = [] + @State projectsObj: ProjectObj = {} + @State projectsCenterObj: ProjectObj = {} + @State markRuleListObj: MarkRule = {} + @State cdsbInfoObj: CDSBInfo = {} + @State timer: number = 0 + @State judgeConfig: { [k: string]: string }[] = [] + @State judgeConfigObj: { [k: string]: any } = defaultJudgeConfigObj + //流水号 + @State lsh: string = '' + @State kszp: string = '' + @State ksdd: string = '' + @State kssycs: string = '' + @State kslx: string = '' + //监管接口序列号 + @State serialNumber: number = 0 + @State carType: string = '' + @State carName: string = '' + @State isDeductedPopShow: boolean = false + @State isAmplifyPopShow: boolean = false + @State amplifiedImgIndex: number = 0 + @State judge: any = {} + //行驶距离 + @State jl: number = 0 + //应考里程 + @State examMileage: string = '0' + @State artSubject3Projects: string[] = ['直线', '会车', '变道', '超车', '掉头', '停车'] + @State artSubject3ProjectsCodesArr: string[] = ['3', '9', '4', '10', '12', '11'] + @State manualMarkRules: MarkRule[] = [] + //科目三评判初始化数据 + @State systemparmArr: SYSTEMPARMARR[] = [] + @State mapPointItemArr: MAPITEMPOINTITEM[] = [] + @State carinfoArrr: CARINFO[] = [] + @State mapPointArr: MAPPOINT[] = [] private context = getContext(this) as common.UIAbilityContext; private img: ImageBitmap = new ImageBitmap("/resources/base/media/1.png") + //已考的考试项目 + private wantInfos = [] async aboutToAppear() { globalThis.windowClass.setWindowSystemBarEnable(['']) @@ -53,16 +128,16 @@ struct Index { } //初始化相关数据库表 - async initDb(){ + async initDb() { const examSubject = globalThis.carInfo.examSubject; const {isTrajectoryOpen,trajectoryPath} = judgeConfig await this.initStudent(); await this.initCar(); //是否开启轨迹回放模式 - if(isTrajectoryOpen){ + if (isTrajectoryOpen) { this.initTrajectoryParam(trajectoryPath) - }else{ + } else { examSubject == 2 ? await this.initSystemKm2Param() : await this.initSystemKm3Param() @@ -73,11 +148,12 @@ struct Index { await this.initCDSBInfo() // 科目三新增读取表数据 - if(examSubject == 3){ + if (examSubject == 3) { await this.initMapPoint() await this.initMapPointItem() } } + // 查询考车信息 async initCar() { const result = await getSyncData('ES_CARINFO') @@ -85,14 +161,14 @@ struct Index { this.carName = decodeURI(carInfo.carclass) this.carType = carInfo.kscx this.carinfoArrr.push({ - CARID:carInfo.carid, - IPADDR:'', - CARCLASS:decodeURI(carInfo.carclass), - KSCX:carInfo.kscx, - CARNAME:decodeURI(carInfo.carclass), - FLAG:carInfo.flag, - BK1:carInfo.bk1, - BK2:carInfo.bk2, + CARID: carInfo.carid, + IPADDR: '', + CARCLASS: decodeURI(carInfo.carclass), + KSCX: carInfo.kscx, + CARNAME: decodeURI(carInfo.carclass), + FLAG: carInfo.flag, + BK1: carInfo.bk1, + BK2: carInfo.bk2, }) } @@ -112,29 +188,29 @@ struct Index { // 获取扣分代码信息 async initMarkRules(markRules ?: MarkRule[]) { - const markRuleParams = markRules ||( await getSyncData('MA_MARKRULE') as MarkRule[]) + const markRuleParams = markRules || (await getSyncData('MA_MARKRULE') as MarkRule[]) - markRuleParams .forEach(mark => { + markRuleParams.forEach(mark => { const tempObj = { - itemno:mark.itemno * 1, - markcatalog:mark.markcatalog, - markshow:decodeURI(mark.markshow), - markreal:mark.markreal * 1, - markserial:mark.markserial, - kfxh:mark.kfxh, + itemno: mark.itemno * 1, + markcatalog: mark.markcatalog, + markshow: decodeURI(mark.markshow), + markreal: mark.markreal * 1, + markserial: mark.markserial, + kfxh: mark.kfxh, //TODO 科目三评判新参数 - OnlyOneKind:mark.onlyoneid * 1, - NoCancelId:mark.nocancelid * 1, - GPS_SID:mark.gps_sid == 0 ? false : true + OnlyOneKind: mark.onlyoneid * 1, + NoCancelId: mark.nocancelid * 1, + GPS_SID: mark.gps_sid == 0 ? false : true } const markserial = mark.markserial * 1; //筛选出人工评判的扣分 - if(markserial > 100 && markserial < 200){ + if (markserial > 100 && markserial < 200) { this.manualMarkRules.push(tempObj) } this.markRuleListObj[`${mark.itemno}_${mark.markserial}`] = { - ...tempObj, + ...tempObj, markserial: mark.markserial, }; }) @@ -154,9 +230,9 @@ struct Index { const {v_no,v_value} = sys; const v_no_num = v_no * 1; const value = decodeURIComponent(v_value) - if(v_no_num >= 10 &&v_no_num <= 900){ + if (v_no_num >= 10 && v_no_num <= 900) { judgeConfig.push({ - key: v_no_num,value: value, + key: v_no_num, value: value, name: decodeURI(sys.v_name) }) } @@ -167,35 +243,35 @@ struct Index { } // 初始化systemParam表 - async initSystemKm2Param(){ - const systemParms:any = await getSyncData('MA_SYSTEMPARM') + async initSystemKm2Param() { + const systemParms: any = await getSyncData('MA_SYSTEMPARM') const carName = this.carName; - let carNo2 = '',allItems = []; - systemParms.forEach((systemParm)=>{ + let carNo2 = '', allItems = []; + systemParms.forEach((systemParm) => { const {no1,no2,no3} = systemParm; //获取当前考车的no2 - if(no1 == 3 && no3 == 1){ + if (no1 == 3 && no3 == 1) { const txt1 = decodeURI(systemParm.txt1) - if(txt1 === carName){ + if (txt1 === carName) { carNo2 = no2; } } //获取当前考车的考试项目 - if(carNo2 !== '' && no2 == carNo2 && no3 == 10){ + if (carNo2 !== '' && no2 == carNo2 && no3 == 10) { allItems = decodeURIComponent(systemParm.txt1).split(',') } // 存储当前考车考试项目 - if(allItems.length && no1 == 6 && allItems.includes(no2)){ + if (allItems.length && no1 == 6 && allItems.includes(no2)) { const txt2 = decodeURIComponent(systemParm.txt2) const currentProject = { - name:decodeURI(systemParm.txt1), - abbreviation:decodeURI(systemParm.txt3), - projectCode:no2, - projectCodeCenter:txt2 + name: decodeURI(systemParm.txt1), + abbreviation: decodeURI(systemParm.txt3), + projectCode: no2, + projectCodeCenter: txt2 // sbxh:project.type } this.projectsObj[no2] = currentProject @@ -205,7 +281,7 @@ struct Index { }) const projects = this.projects; - if(!projects.length){ + if (!projects.length) { prompt.showToast({ message: '读取数据库信息失败,请重新考试!', duration: 8000 @@ -215,14 +291,14 @@ struct Index { } //初始化systemParam表 - async initSystemKm3Param(sysParam?:SYSTEMPARMARR[]) { + async initSystemKm3Param(sysParam?: SYSTEMPARMARR[]) { const systemParms: any = sysParam || await getSyncData('MA_SYSTEMPARM') const {isTrajectoryOpen} = judgeConfig systemParms.forEach((systemParm) => { - if(isTrajectoryOpen){ + if (isTrajectoryOpen) { systemParm.no1 = systemParm.NO1; systemParm.no2 = systemParm.NO2; systemParm.no3 = systemParm.NO3; @@ -234,10 +310,12 @@ struct Index { const {no1,no2,no3,} = systemParm; this.systemparmArr.push({ - 'NO1':no1*1,'NO2':no2*1,'NO3':no3*1, - 'TXT1':decodeURIComponent(systemParm.txt1), - 'TXT2':decodeURIComponent(systemParm.txt2), - 'TXT3':decodeURIComponent(systemParm.txt3), + 'NO1': no1 * 1, + 'NO2': no2 * 1, + 'NO3': no3 * 1, + 'TXT1': decodeURIComponent(systemParm.txt1), + 'TXT2': decodeURIComponent(systemParm.txt2), + 'TXT3': decodeURIComponent(systemParm.txt3), }) const txt2 = decodeURIComponent(systemParm.txt2) @@ -253,7 +331,7 @@ struct Index { this.projectsCenterObj[txt2] = currentProject this.projects.push(currentProject) } - if(no1 == 3 && no2 == 1 && no3 == 15){ + if (no1 == 3 && no2 == 1 && no3 == 15) { this.examMileage = decodeURI(systemParm.txt1) } }) @@ -303,7 +381,7 @@ struct Index { // 断点续考判断 async goDdxkItems() { const judgeConfigObj = this.judgeConfigObj - if(judgeConfigObj['369'] != 1 || judgeConfigObj['432'] != 1){ + if (judgeConfigObj['369'] != 1 || judgeConfigObj['432'] != 1) { return } //断点续考判断 @@ -348,53 +426,64 @@ struct Index { } // 初始化mapPoint表 - async initMapPoint(){ + async initMapPoint() { const pointParams = await getSyncData('MA_MAP_POINT') //@ts-ignore - pointParams.forEach(point=>{ - const {point_no,gps_e,gps_n,point_no_f,point_type,road_code,gps_e_Location,gps_n_Location,f_gps_e,f_gps_n,passed} = point; - this.mapPointArr.push({ - point_no:point_no * 1, - gps_e:gps_e * 1, - gps_n:gps_n * 1, - point_no_f:point_no_f * 1, - point_type:point_type * 1, + pointParams.forEach(point => { + const { + point_no, + gps_e, + gps_n, + point_no_f, + point_type, road_code, - gps_e_Location:(gps_e_Location || 0 ) * 1, - gps_n_Location:(gps_n_Location || 0 ) * 1, - f_gps_e:f_gps_e * 1, - f_gps_n:f_gps_n * 1, - passed:passed * 1 + gps_e_Location, + gps_n_Location, + f_gps_e, + f_gps_n, + passed + } = point; + this.mapPointArr.push({ + point_no: point_no * 1, + gps_e: gps_e * 1, + gps_n: gps_n * 1, + point_no_f: point_no_f * 1, + point_type: point_type * 1, + road_code, + gps_e_Location: (gps_e_Location || 0) * 1, + gps_n_Location: (gps_n_Location || 0) * 1, + f_gps_e: f_gps_e * 1, + f_gps_n: f_gps_n * 1, + passed: passed * 1 }) }) } // 初始化mapPointItem表 - async initMapPointItem(){ + async initMapPointItem() { const pointItemPoints = await getSyncData('MA_MAP_POINT_ITEM'); //@ts-ignore pointItemPoints.forEach(itemPoint => { const {point_no,itemno,itemno1,subname} = itemPoint this.mapPointItemArr.push({ - point_no:point_no * 1, - itemno:itemno * 1, - itemno1:itemno1 * 1, - subname + point_no: point_no * 1, + itemno: itemno * 1, + itemno1: itemno1 * 1, + subname }) }) } - // 初始化本地systemparam表、markrule表 - async initTrajectoryParam(trajectoryPath:string){ + async initTrajectoryParam(trajectoryPath: string) { const examSubject = globalThis.carInfo.examSubject; //轨迹回放读取 systemparam表、markrule表 - const fileUtil = new FileUtil(this.context); + const fileUtil = new FileUtil(this.context); const folderPath = await fileUtil.initFolder(trajectoryPath); const str = await fileUtil.readFile(folderPath); const strArr = str.split('\n'); - const [initData,beginData] = [strArr[0],strArr[1]]; + const [initData, beginData] = [strArr[0], strArr[1]]; const initDataObj = JSON.parse(initData) examSubject == 2 @@ -404,7 +493,6 @@ struct Index { await this.initMarkRules(testMarkRules); } - build() { Column() { Row() { @@ -412,7 +500,7 @@ struct Index { Image($rawfile('judge/signal_logoS.png')).width(120) Text(this.time).fontColor('#CCB48F').fontSize(32).padding({ left: 10, right: 5 }) Image($rawfile('judge/xh_green.png')).width(50) - }.padding({left:20}) + }.padding({ left: 20 }) Row() { Text(`当前项目:${this.xmmcStr || '无'} `).fontColor('#E5CCA1').fontSize(32) @@ -440,7 +528,7 @@ struct Index { Text(this.startTime).fontColor('#FFF').fontSize(this.FONTSIZE) }.margin({ bottom: 10 }) - if(this.examSubject == 3){ + if (this.examSubject == 3) { Row() { Text('考试路线:').fontColor('#E5CCA1').fontSize(this.FONTSIZE) Text('线路6').fontColor('#FFAD33').fontSize(this.FONTSIZE) @@ -460,10 +548,13 @@ struct Index { Text(formatTime(this.examTime)).fontColor('#FFF').fontSize(this.FONTSIZE) }.margin({ bottom: 10 }) - if(this.examSubject == 3){ + if (this.examSubject == 3) { Row() { - if(this.judgeConfigObj['375'] == '0'){ - Text(`应行驶:${this.examMileage}m`).fontColor('#E5CCA1').fontSize(this.FONTSIZE).padding({right:20}) + if (this.judgeConfigObj['375'] == '0') { + Text(`应行驶:${this.examMileage}m`) + .fontColor('#E5CCA1') + .fontSize(this.FONTSIZE) + .padding({ right: 20 }) } Text(`已行驶:${this.jl}m`).fontColor('#FFAD33').fontSize(this.FONTSIZE) } @@ -474,9 +565,10 @@ struct Index { }.width('100%') Column() { - Row(){ + Row() { Text(this.carztStr).fontColor('#FFA500').fontSize(this.FONTSIZE) }.height(40) + Row() { Flex({ direction: FlexDirection.Column }) { List({}) { @@ -498,73 +590,115 @@ struct Index { .margin({ top: 10, bottom: 8, left: 5, right: 5 }) }.margin({ top: 15 }).alignItems(HorizontalAlign.Start) - }.margin({bottom:25}) + }.margin({ bottom: 25 }) }) - }.padding({left:15,right:15,top:30,bottom:5}) + }.padding({ left: 15, right: 15, top: 30, bottom: 5 }) } - .backgroundImage($rawfile('judge/score_bg.png'), ImageRepeat.NoRepeat) - .backgroundImageSize({ width: '100%', height: '100%' }) - .width(514) - .height(618) - .padding({ top: 18, bottom: 15, left: 13, right: 14 }) + .backgroundImage($rawfile('judge/score_bg.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .width(514) + .height(618) + .padding({ top: 18, bottom: 15, left: 13, right: 14 }) //科目二 - if(this.examSubject == 2){ - Flex({wrap:FlexWrap.Wrap,direction:FlexDirection.Row,justifyContent:FlexAlign.SpaceBetween}){ - List({}){ - ForEach(chunkArr(this.projects,2),(item)=>{ - ListItem(){ - Row(){ - Row(){ + if (this.examSubject == 2) { + Flex({ wrap: FlexWrap.Wrap, direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween }) { + List({}) { + ForEach(chunkArr(this.projects, 2), (item) => { + ListItem() { + Row() { + Row() { //#FF7566 #00FFD5 #E6DECF // Text(this.projectsObj[item[0].projectCode]) - Text(item[0].abbreviation).fontSize(item[0].abbreviation.length > 5?28:32).fontColor(this.getProjectColor(this.projectsObj[item[0].projectCode].type)) - }.backgroundImage($rawfile('judge/project_item.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width('48.5%').height(115).margin({bottom:5}).justifyContent(FlexAlign.Center) - if(item[1]){ - Row(){ + Text(item[0].abbreviation) + .fontSize(item[0].abbreviation.length > 5 ? 28 : 32) + .fontColor(this.getProjectColor(this.projectsObj[item[0].projectCode].type)) + } + .backgroundImage($rawfile('judge/project_item.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .width('48.5%') + .height(115) + .margin({ bottom: 5 }) + .justifyContent(FlexAlign.Center) + + if (item[1]) { + Row() { //#FF7566 #00FFD5 #E6DECF - Text(item[1].abbreviation).fontSize(item[1].abbreviation.length > 5?28:32).fontColor(this.getProjectColor(this.projectsObj[item[1].projectCode].type)) - }.backgroundImage($rawfile('judge/project_item.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width('48.5%').height(115).margin({left:5,bottom:5}).justifyContent(FlexAlign.Center) + Text(item[1].abbreviation) + .fontSize(item[1].abbreviation.length > 5 ? 28 : 32) + .fontColor(this.getProjectColor(this.projectsObj[item[1].projectCode].type)) + } + .backgroundImage($rawfile('judge/project_item.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .width('48.5%') + .height(115) + .margin({ left: 5, bottom: 5 }) + .justifyContent(FlexAlign.Center) } } } }); } - }.backgroundImage($rawfile('judge/project_bg.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width('57%').height('100%').padding(30).margin({right:10}) + } + .backgroundImage($rawfile('judge/project_bg.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .width('57%') + .height('100%') + .padding(30) + .margin({ right: 10 }) } //科目三 - if(this.examSubject == 3){ - Column(){ - Flex({wrap:FlexWrap.Wrap,direction:FlexDirection.Row,justifyContent:FlexAlign.SpaceBetween}){ - List({}){ - ForEach(this.projects,(project)=>{ - ListItem(){ - Text(project.name){ + if (this.examSubject == 3) { + Column() { + Flex({ + wrap: FlexWrap.Wrap, + direction: FlexDirection.Row, + justifyContent: FlexAlign.SpaceBetween + }) { + List({}) { + ForEach(this.projects, (project) => { + ListItem() { + Text(project.name) { - }.fontColor(this.getProjectColor(this.projectsObj[project.projectCode].type)).margin({bottom:5}).fontSize(26) - }.margin({bottom:8}) + } + .fontColor(this.getProjectColor(this.projectsObj[project.projectCode].type)) + .margin({ bottom: 5 }) + .fontSize(26) + }.margin({ bottom: 8 }) }) - }.lanes(2).margin({left:25}) - }.width('100%').height('50%').backgroundImage($rawfile('judge/project_km3_bg.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).padding(30).margin({right:5}) + }.lanes(2).margin({ left: 25 }) + } + .width('100%') + .height('50%') + .backgroundImage($rawfile('judge/project_km3_bg.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .padding(30) + .margin({ right: 5 }) - Flex({wrap:FlexWrap.Wrap,direction:FlexDirection.Row,justifyContent:FlexAlign.SpaceAround}){ - List(){ - ForEach(this.artSubject3Projects,(item,index)=>{ - ListItem(){}.backgroundImage( + Flex({ wrap: FlexWrap.Wrap, direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceAround }) { + List() { + ForEach(this.artSubject3Projects, (item, index) => { + ListItem() { + } + .backgroundImage( $rawfile( - `judge/km3/${this.getIsExitManualProject(index) ? item : (item+'_gray')}.png` - ),ImageRepeat.NoRepeat) - .backgroundImageSize({width:'100%',height:'100%'}).width(174).height(118).margin({bottom:15}) - .onClick(()=>{ - if(this.getIsExitManualProject(index)){ + `judge/km3/${this.getIsExitManualProject(index) ? item : (item + '_gray')}.png` + ), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .width(174) + .height(118) + .margin({ bottom: 15 }) + .onClick(() => { + if (this.getIsExitManualProject(index)) { // 靠边停车时候可以触发 - if(this.judgeConfigObj['343'] == 0 ){ + if (this.judgeConfigObj['343'] == 0) { const xmmcStr = this.xmmcStr; - if(xmmcStr == '无' || xmmcStr == ''){ - this.amplifiedImgIndex = index;this.isAmplifyPopShow = true - } else{ - if(index === 5){ + if (xmmcStr == '无' || xmmcStr == '') { + this.amplifiedImgIndex = index; + this.isAmplifyPopShow = true + } else { + if (index === 5) { prompt.showToast({ message: `${xmmcStr}未结束,不允许靠边停车`, duration: 8000 @@ -572,15 +706,22 @@ struct Index { } } - }else{ - this.amplifiedImgIndex = index;this.isAmplifyPopShow = true + } else { + this.amplifiedImgIndex = index; + this.isAmplifyPopShow = true } } }) }) - }.lanes(3).margin({left:5,top:18}) + }.lanes(3).margin({ left: 5, top: 18 }) } - }.backgroundImage($rawfile('judge/project_bg.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width(660).height(640).padding(44).margin({right:10}) + } + .backgroundImage($rawfile('judge/project_bg.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .width(660) + .height(640) + .padding(44) + .margin({ right: 10 }) } }.margin({ top: 15 }).height('80%').justifyContent(FlexAlign.SpaceBetween) }.width('100%').height('100%').alignItems(HorizontalAlign.Start).margin({ top: 10 }) @@ -611,22 +752,32 @@ struct Index { .backgroundImageSize({ width: '100%', height: '100%' }) .justifyContent(FlexAlign.Center) .alignItems(VerticalAlign.Center) - .margin({ top: 30 ,bottom:15}) + .margin({ top: 30, bottom: 15 }) } - Column(){ - if(this.examSubject == 3){ - Row(){ - Row(){}.width(60).height(60).backgroundImage($rawfile('judge/manual_judge.png'), ImageRepeat.NoRepeat).backgroundImageSize({ width: '100%', height: '100%' }) - Text('人工评判').fontColor('#FFF').fontSize(32).padding({right:12}) - }.width(334).height(110).justifyContent(FlexAlign.Center).alignItems(VerticalAlign.Center) - .backgroundImage($rawfile('judge/button_nor.png'), ImageRepeat.NoRepeat) - .backgroundImageSize({ width: '100%', height: '100%' }) - .margin({bottom:10}) - .onClick(()=>{ - if(this.judgeConfigObj['342'] == 0){ + Column() { + if (this.examSubject == 3) { + Row() { + Row() { + } + .width(60) + .height(60) + .backgroundImage($rawfile('judge/manual_judge.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + + Text('人工评判').fontColor('#FFF').fontSize(32).padding({ right: 12 }) + } + .width(334) + .height(110) + .justifyContent(FlexAlign.Center) + .alignItems(VerticalAlign.Center) + .backgroundImage($rawfile('judge/button_nor.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .margin({ bottom: 10 }) + .onClick(() => { + if (this.judgeConfigObj['342'] == 0) { this.isDeductedPopShow = true - }else{ + } else { prompt.showToast({ message: '平台配置不允许人工评判!', duration: 4000 @@ -636,30 +787,41 @@ struct Index { } - Row(){ - Row(){}.width(60).height(60).backgroundImage($rawfile('judge/phone.png'), ImageRepeat.NoRepeat).backgroundImageSize({ width: '100%', height: '100%' }) - Text('呼叫请求').fontColor('#FFF').fontSize(32).padding({right:12}) - }.width(334).height(110).justifyContent(FlexAlign.Center).alignItems(VerticalAlign.Center) + Row() { + Row() { + } + .width(60) + .height(60) + .backgroundImage($rawfile('judge/phone.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + + Text('呼叫请求').fontColor('#FFF').fontSize(32).padding({ right: 12 }) + } + .width(334) + .height(110) + .justifyContent(FlexAlign.Center) + .alignItems(VerticalAlign.Center) .backgroundImage($rawfile('judge/button_nor.png'), ImageRepeat.NoRepeat) .backgroundImageSize({ width: '100%', height: '100%' }) - .margin({bottom:10}) + .margin({ bottom: 10 }) - Row() {} + Row() { + } .width(334) .height(100) .backgroundImage($rawfile('judge/anniu_nor.png'), ImageRepeat.NoRepeat) .backgroundImageSize({ width: '100%', height: '100%' }) .onClick(() => { - if(this.judgeConfigObj['353'] == '0' ){ + if (this.judgeConfigObj['353'] == '0') { this.endPopupVisible = true - }else{ + } else { prompt.showToast({ message: '车上不允许手动结束考试!', duration: 4000 }); } }) - }.margin({bottom:30}) + }.margin({ bottom: 30 }) } .width('25%') @@ -705,7 +867,8 @@ struct Index { msgStr: this.judge.plcStr || '' }).margin({ top: 100 }) - Row() {} + Row() { + } .width(240) .height(240) .position({ x: '81%', y: 80 }) @@ -720,30 +883,32 @@ struct Index { //科目三人工扣分弹窗 if (this.isDeductedPopShow) { DeductedPopup({ - currentItems:Reflect.ownKeys(this.projectsObj).map(projectKey => { + currentItems: Reflect.ownKeys(this.projectsObj).map(projectKey => { const project = this.projectsObj[projectKey] - return project.type == '2'?project.projectCode:'' + return project.type == '2' ? project.projectCode : '' }).filter(project => project !== ''), - markRules:this.manualMarkRules, - closePopup:()=>{this.isDeductedPopShow = false}, - confirmMark:async (itemno,serial) => { + markRules: this.manualMarkRules, + closePopup: () => { + this.isDeductedPopShow = false + }, + confirmMark: async (itemno, serial) => { const judge = this.judge - await judge.setJudgeMark(itemno,serial); + await judge.setJudgeMark(itemno, serial); this.isDeductedPopShow = false } }) } //科目三人工项目确认框 - if(this.isAmplifyPopShow){ + if (this.isAmplifyPopShow) { AmplifyPopup({ - amplifyImgIndex:this.amplifiedImgIndex, - confirmAmplify:async (amplify)=>{ + amplifyImgIndex: this.amplifiedImgIndex, + confirmAmplify: async (amplify) => { const judge = this.judge await judge.setJudgeItem(amplify.projectCode); this.isAmplifyPopShow = false }, - closeAmplifyPop:()=>{ + closeAmplifyPop: () => { this.isAmplifyPopShow = false } }) @@ -773,108 +938,30 @@ struct Index { } // 获取是否能人工进项目 - getIsExitManualProject = (index:number)=>{ + getIsExitManualProject = (index: number) => { const {judgeConfigObj,artSubject3ProjectsCodesArr,projectsObj} = this; const unExitManualProjects = judgeConfigObj['332'].split(',') || []; const param348 = judgeConfigObj['348'] || '0'; const param387 = judgeConfigObj['348'] || '0'; - if(judgeConfigObj['342'] === '3' || judgeConfigObj['342'] === '2'){ + if (judgeConfigObj['342'] === '3' || judgeConfigObj['342'] === '2') { return false } - if(unExitManualProjects.includes(artSubject3ProjectsCodesArr[index])){ + if (unExitManualProjects.includes(artSubject3ProjectsCodesArr[index])) { return false } - if(param348 == '0' && projectsObj['9']?.type == 2){ + if (param348 == '0' && projectsObj['9']?.type == 2) { return index === 0 ? true : false } - if(param387 === '0' && index === 5){ + if (param387 === '0' && index === 5) { const {examMileage,jl} = this return jl >= Number(examMileage) } return true } - - //页面通用字体大小 - @State FONTSIZE: number = 28 - @State BIGFONTSIZE: number = 28 - //结束考试弹窗 - @State endPopupVisible: boolean = false - //等待弹窗(考试及格,考试不及格使用) - @State loadingPopupVisible: boolean = false - //实时轨迹弹窗 - @State signDisplayComVisible: boolean = false - @State isDdxk: boolean = false; - @State time: string = '' - //考试用时 - @State examTime: number = 0 - //开始时间 - @State startTime: string = '00:00:00' - @State startFullTime: string = '' - @State startHourTime: string = '' - //科目类型 - @State examSubject: 2 | 3 = 2; - @State ddxkTime: number = 0; - @State ddxkKsxmArr: string[] = [''] - @State ddxkKfArr: string[] = [''] - @State xmmcStr: string = '' - @State carztStr: string = '' - @State kfArr: { - xmmcStr?: string, - score: string, - desc: string - }[] = [] - - @State name: string = '' - @State idCard: string = '' - @State totalScore: number = 100 - //模拟考试项目 - @State projects: Project[] = [] - @State projectsObj: ProjectObj = {} - @State projectsCenterObj: ProjectObj = {} - @State markRuleListObj: MarkRule = {} - @State cdsbInfoObj: CDSBInfo = {} - @State timer: number = 0 - @State judgeConfig: {[k:string]:string}[] = [] - @State judgeConfigObj: {[k:string]:any} = defaultJudgeConfigObj - - //流水号 - @State lsh: string = '' - @State kszp: string = '' - @State ksdd: string = '' - @State kssycs: string = '' - @State kslx: string = '' - - //监管接口序列号 - @State serialNumber: number = 0 - @State carType: string = '' - @State carName: string = '' - @State isDeductedPopShow: boolean = false - @State isAmplifyPopShow: boolean = false - @State amplifiedImgIndex: number = 0 - @State judge:any = {} - - //行驶距离 - @State jl:number =0 - //应考里程 - @State examMileage:string = '0' - //已考的考试项目 - private wantInfos = [] - - @State artSubject3Projects: string[] = ['直线', '会车', '变道','超车', '掉头', '停车'] - @State artSubject3ProjectsCodesArr: string[] = ['3', '9', '4','10', '12', '11'] - - @State manualMarkRules:MarkRule[] = [] - - //科目三评判初始化数据 - @State systemparmArr:SYSTEMPARMARR[] = [] - @State mapPointItemArr:MAPITEMPOINTITEM[] = [] - @State carinfoArrr:CARINFO[] = [] - @State mapPointArr:MAPPOINT[] = [] - } diff --git a/entry/src/main/ets/pages/RealTime.ets b/entry/src/main/ets/pages/RealTime.ets index 33eb061a..907672df 100644 --- a/entry/src/main/ets/pages/RealTime.ets +++ b/entry/src/main/ets/pages/RealTime.ets @@ -1,26 +1,24 @@ import hilog from '@ohos.hilog'; import apiJudgeSdk from 'libJudgeSdk.so'; -import Judge from './judgeSDK/utils/judge-real' -import {Project,ProjectObj,MarkRule} from './judgeSDK/api/judgeSDK.d' +import Judge from './judgeSDK/utils/judge-real'; +import { MarkRule, Project, ProjectObj } from './judgeSDK/api/judgeSDK.d'; import AccountTable from '../common/database/tables/AccountTable'; import MA_SYSSET from '../common//constants/MA_SYSSET'; import common from '@ohos.app.ability.common'; -import { getSyncData } from '../common/service/initable' +import { getSyncData } from '../common/service/initable'; @Entry @Component -struct Index { +export default struct Index { @State message: string = '开始绘制' - // 控制XComponent组件的创建和销毁 @State draw: boolean = false //监管接口序列号 - @State serialNumber:number = 0 - + @State serialNumber: number = 0 //模拟考试项目 - @State projects:Project[] = [] - @State projectsObj:ProjectObj = {} - @State markRuleListObj:MarkRule ={} + @State projects: Project[] = [] + @State projectsObj: ProjectObj = {} + @State markRuleListObj: MarkRule = {} private context = getContext(this) as common.UIAbilityContext; // xcomponentController: XComponentController = new XComponentController() @@ -46,9 +44,10 @@ struct Index { apiJudgeSdk.examJudgeMapSetDrawing(false); //停止绘制地图轨迹,false:表示结束绘制 }) } else { - Column() {} - .width(640/2) - .height(480/2) + Column() { + } + .width(640 / 2) + .height(480 / 2) } Text(this.message) @@ -81,7 +80,7 @@ struct Index { } //获取项目信息 - async initProjectInfo(){ + async initProjectInfo() { const that = this; const systemParamsArr = await getSyncData('MA_SYSTEMPARM') const itemInfoArr = await getSyncData('MA_ITEMINFO') @@ -91,20 +90,20 @@ struct Index { that.projects = filterProjectsArr.map(project => { //TODO 临时代码 - const testType= { - 0:1, - 2:4, - 3:3, - 5:5, - 6:2 + const testType = { + 0: 1, + 2: 4, + 3: 3, + 5: 5, + 6: 2 } const currentProject = { - name:decodeURI(project.txt1), - abbreviation:decodeURI(project.txt3), - projectCode:decodeURI(project.no2), - projectCodeCenter:decodeURI(project.txt2), + name: decodeURI(project.txt1), + abbreviation: decodeURI(project.txt3), + projectCode: decodeURI(project.no2), + projectCodeCenter: decodeURI(project.txt2), //@ts-ignore - type:testType[decodeURI(project.no2)*1] + type: testType[decodeURI(project.no2)*1] // type:'0' + (project.type || '1') } that.projectsObj[project.no2] = currentProject @@ -113,25 +112,26 @@ struct Index { } //获取扣分代码信息 - async initMarkRules(){ + async initMarkRules() { const that = this; const markRuleParams = await getSyncData('MA_MARKRULE') //@ts-ignore - markRuleParams.forEach(mark=>{ + markRuleParams.forEach(mark => { that.markRuleListObj[`${mark.itemno}_${mark.markserial}`] = { - itemno:mark.itemno*1, - markcatalog:mark.markcatalog, - markshow:decodeURI(mark.markshow), - markreal:mark.markreal*1, - markserial:mark.markserial + itemno: mark.itemno * 1, + markcatalog: mark.markcatalog, + markshow: decodeURI(mark.markshow), + markreal: mark.markreal * 1, + markserial: mark.markserial }; }) } // 获取sysset表信息 - async initSysset(){ + async initSysset() { const that = this; - const db = new AccountTable(()=>{},MA_SYSSET); + const db = new AccountTable(() => { + }, MA_SYSSET); const syssetParams = await getSyncData('MA_SYSSET') //@ts-ignore const serialNumberArr = syssetParams.filter(sys => sys.v_no === '901'); @@ -142,5 +142,4 @@ struct Index { //apiJudgeSdk.stopRender(); } - } diff --git a/entry/src/main/ets/pages/register.ets b/entry/src/main/ets/pages/Register.ets similarity index 69% rename from entry/src/main/ets/pages/register.ets rename to entry/src/main/ets/pages/Register.ets index f39c1c2a..fea54a4c 100644 --- a/entry/src/main/ets/pages/register.ets +++ b/entry/src/main/ets/pages/Register.ets @@ -1,14 +1,13 @@ import TopLogo from './compontents/topLogo' -import { getDeviceInfo} from '../common/service/terminalService' import { registrationDeviceNo } from '../api/checkCar' -import { dateFormat} from '../common/utils/tools' +import { dateFormat } from '../common/utils/tools' import deviceManager from '@ohos.distributedHardware.deviceManager' import { upDateTableByArray } from '../common/service/initable' -import { voiceService } from '../common/service/voiceService' import promptAction from '@ohos.promptAction' + @Entry @Component -struct Index { +export default struct Index { @State ratio: number = 1700 / 960 @State ip: string = '' @State deviceNo: string = '' @@ -18,6 +17,7 @@ struct Index { @State plateNo: string = '' @State @Watch('outClick') outFlag: boolean = false; @State subType: string = '2'; + onPageShow() { // this.plateNo=globalThis.carInfo.plateNo deviceManager.createDeviceManager('com.oh.dts', (error, value) => { @@ -27,45 +27,45 @@ struct Index { } let dvMgrObj = value; this.deviceName = dvMgrObj.getLocalDeviceInfoSync().deviceName - this.deviceNo=dvMgrObj.getLocalDeviceInfoSync().deviceId.substring(0,10).toUpperCase() - this.ip='MAC-'+this.deviceNo - globalThis.deviceNo='MAC-'+this.deviceNo + this.deviceNo = dvMgrObj.getLocalDeviceInfoSync().deviceId.substring(0, 10).toUpperCase() + this.ip = 'MAC-' + this.deviceNo + globalThis.deviceNo = 'MAC-' + this.deviceNo }); } build() { Column() { - TopLogo({outFlag:$outFlag}) + TopLogo({ outFlag: $outFlag }) Column() { Row() { Row() { - Radio({ value: '0', group: 'radioGroup' }).checked(this.subType=='2'?true:false) + Radio({ value: '0', group: 'radioGroup' }).checked(this.subType == '2' ? true : false) .height(50) .width(50).onChange((isChecked: boolean) => { - if(isChecked) + if (isChecked) this.subType = '2' - this.ip='MAC-'+this.deviceNo - globalThis.deviceNo=this.ip + this.ip = 'MAC-' + this.deviceNo + globalThis.deviceNo = this.ip }) Text('网卡').fontSize(34 * this.ratio).fontColor('#FFE0B2').margin({ right: 98.5 * this.ratio }) } Row() { - Radio({ value: '1', group: 'radioGroup' }).checked(this.subType=='3'?true:false) + Radio({ value: '1', group: 'radioGroup' }).checked(this.subType == '3' ? true : false) .height(50) .width(50).onChange((isChecked: boolean) => { - if(isChecked) + if (isChecked) this.subType = '3' - this.ip='DISK-'+this.deviceNo - globalThis.deviceNo=this.ip - // this.ip = ip + this.ip = 'DISK-' + this.deviceNo + globalThis.deviceNo = this.ip + // this.ip = ip }) Text('硬盘').fontSize(34 * this.ratio).fontColor('#FFE0B2').margin({ right: 83 * this.ratio }) } }.margin({ top: 35 * this.ratio }) Row() { - Column(){ + Column() { Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { Text(this.ip).fontColor('#fff') .fontSize(33.6 * this.ratio) @@ -88,28 +88,34 @@ struct Index { .margin({ top: 37 * this.ratio }) .borderRadius(19 * this.ratio) - Image($r('app.media.zhuce_nor')).width(320 * this.ratio).height(92 * this.ratio).margin({ top: 30 * this.ratio }).onClick(()=>{ - this.registrationDeviceNoFn() - }) + Image($r('app.media.zhuce_nor')) + .width(320 * this.ratio) + .height(92 * this.ratio) + .margin({ top: 30 * this.ratio }) + .onClick(() => { + this.registrationDeviceNoFn() + }) } .height('100%') .width('100%') .backgroundImage($r('app.media.bg')) .backgroundImageSize({ width: '100%', height: '100%' }) } - outClick(){ + + outClick() { } - registrationDeviceNoFn(){ - const date=new Date() - const param={ + + registrationDeviceNoFn() { + const date = new Date() + const param = { time: dateFormat(date), - deviceName:this.ip, - type:'1' + deviceName: this.ip, + type: '1' } - globalThis.deviceNo=this.ip - upDateTableByArray('DeviceInfoTable',[{deviceId:this.ip}]) - registrationDeviceNo(param).then(res=>{ - if(res.registrationDeviceNoRsp.head.resultCode=='0'){ + globalThis.deviceNo = this.ip + upDateTableByArray('DeviceInfoTable', [{ deviceId: this.ip }]) + registrationDeviceNo(param).then(res => { + if (res.registrationDeviceNoRsp.head.resultCode == '0') { promptAction.showToast({ message: decodeURIComponent(res.registrationDeviceNoRsp.head.resultMessage), duration: 3000 diff --git a/entry/src/main/ets/pages/Roads.ets b/entry/src/main/ets/pages/Roads.ets index b53f4353..443245d9 100644 --- a/entry/src/main/ets/pages/Roads.ets +++ b/entry/src/main/ets/pages/Roads.ets @@ -1,60 +1,75 @@ -import TopLogo from './compontents/topLogo' +import TopLogo from './compontents/topLogo'; +import MA_SYSTEMPARM from '../common/constants/MA_SYSTEMPARM'; +import AccountTable from '../common/database/tables/AccountTable'; +import { getSyncData } from '../common/service/initable'; const cBg = $rawfile('judge/km3/road/luxian_pre.png'); const lBg = $rawfile('judge/km3/road/luxian_nor.png'); const ctBg = $rawfile('judge/km3/road/luxian_pre.png'); const ltBg = $rawfile('judge/km3/road/luxian_nor.png'); -import MA_SYSTEMPARM from '../common/constants/MA_SYSTEMPARM'; -import AccountTable from '../common/database/tables/AccountTable'; -import { getSyncData } from '../common/service/initable' //单机模式才选线路 @Entry @Component -struct Index { - +export default struct Index { @State @Watch('outClick') outFlag: boolean = false; - @State roadObj:any = {} + @State roadObj: any = {} - async aboutToAppear(){ + async aboutToAppear() { //读取systemparam表的no1等于4的 - const db = new AccountTable(()=>{},MA_SYSTEMPARM); - const systemParms:any = await getSyncData('MA_SYSTEMPARM') - systemParms.forEach((systemParm)=>{ + const db = new AccountTable(() => { + }, MA_SYSTEMPARM); + const systemParms: any = await getSyncData('MA_SYSTEMPARM') + systemParms.forEach((systemParm) => { //TODO 字段名称待修改 const {no1,no2,no3,txt1,txt2} = systemParm; - if(no1 == 4){ - const temp = {no2,no3,txt1:decodeURI(txt1),txt2} - if(this.roadObj[no2]){ + if (no1 == 4) { + const temp = { no2, no3, txt1: decodeURI(txt1), txt2 } + if (this.roadObj[no2]) { this.roadObj[no2].push(temp) - }else{ + } else { this.roadObj[no2] = temp } } }) } - build(){ - Column(){ - TopLogo({outFlag:$outFlag}) - List({}){ - ForEach(Reflect.ownKeys(this.roadObj) , (roadIndex,index) =>{ - ListItem(){ - Column(){ - Row(){}.backgroundImage(lBg,ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width(90).height(80) - Text(`线路${index + 1 + ''}`){}.fontColor('#FFF2D9').fontSize(24).padding({top:10}) - } - }.backgroundImage(cBg,ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width(180).height(220).margin({left:5,bottom:10}) - .onClick(async ()=>{ - console.info(this.roadObj[roadIndex]) - }) - }) - }.lanes(5).margin({top:50,left:15}) - } .width('100%') - .height('100%') - .backgroundColor('#1A1A1A') + build() { + Column() { + TopLogo({ outFlag: $outFlag }) + List({}) { + ForEach(Reflect.ownKeys(this.roadObj), (roadIndex, index) => { + ListItem() { + Column() { + Row() { + } + .backgroundImage(lBg, ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .width(90) + .height(80) + + Text(`线路${index + 1 + ''}`) { + }.fontColor('#FFF2D9').fontSize(24).padding({ top: 10 }) + } + } + .backgroundImage(cBg, ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .width(180) + .height(220) + .margin({ left: 5, bottom: 10 }) + .onClick(async () => { + console.info(this.roadObj[roadIndex]) + }) + }) + }.lanes(5).margin({ top: 50, left: 15 }) + + }.width('100%') + .height('100%') + .backgroundColor('#1A1A1A') } - outClick(){} + + outClick() { + } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/Settings.ets b/entry/src/main/ets/pages/Settings.ets index 01ce4a16..08533b60 100644 --- a/entry/src/main/ets/pages/Settings.ets +++ b/entry/src/main/ets/pages/Settings.ets @@ -1,71 +1,84 @@ import router from '@ohos.router' import TopLogo from './compontents/topLogo' -import { voiceService } from '../common/service/voiceService' @Entry @Component -struct Index { +export default struct Index { @State ratio: number = 1280 / 960 @State carNum: string = '' @State version: string = '' @State hasAuth: boolean = false; - private vocObj = null; @State url: string = '' @State @Watch('outClick') outFlag: boolean = false; + private vocObj = null; + build() { Column() { - TopLogo({outFlag:$outFlag}) + TopLogo({ outFlag: $outFlag }) Column() { Row() { - Image($r('app.media.setting_clzc')).width('30.5%').height('74%').onClick(()=>{ - this.url='pages/Register' + Image($r('app.media.setting_clzc')).width('30.5%').height('74%').onClick(() => { + this.url = 'pages/Register' router.pushUrl({ url: this.url, - },router.RouterMode.Single); + }, router.RouterMode.Single); }) - Image($r('app.media.setting_spjk')).width('30.5%').height('74%').onClick(()=>{ - this.url='pages/VideoConfig' + Image($r('app.media.setting_spjk')).width('30.5%').height('74%').onClick(() => { + this.url = 'pages/VideoConfig' router.pushUrl({ url: this.url, - },router.RouterMode.Single); + }, router.RouterMode.Single); }) - Image($r('app.media.setting_xtts')).width('30.5%').height('74%').onClick(()=>{ - this.url='pages/TerminalInfos' + Image($r('app.media.setting_xtts')).width('30.5%').height('74%').onClick(() => { + this.url = 'pages/TerminalInfos' router.pushUrl({ url: this.url, - },router.RouterMode.Single); + }, router.RouterMode.Single); }) } .width('100%') .justifyContent(FlexAlign.SpaceAround) } + Column() { Row() { Column() { - Text('V ' + this.version).fontColor('#CCAE7A').fontSize(22*this.ratio).width('30%').margin({bottom:10*this.ratio}) - Text('授权信息:' + (this.hasAuth?'已授权':'未授权')).fontColor('#CCAE7A').fontSize(22*this.ratio).width('30%') + Text('V ' + this.version) + .fontColor('#CCAE7A') + .fontSize(22 * this.ratio) + .width('30%') + .margin({ bottom: 10 * this.ratio }) + Text('授权信息:' + (this.hasAuth ? '已授权' : '未授权')) + .fontColor('#CCAE7A') + .fontSize(22 * this.ratio) + .width('30%') } - .margin({left: 24*this.ratio}) - Text('考车号:' + globalThis.deviceNo).fontColor('#CCAE7A').fontSize(22*this.ratio).margin({right: 24*this.ratio}) + .margin({ left: 24 * this.ratio }) + + Text('考车号:' + globalThis.deviceNo) + .fontColor('#CCAE7A') + .fontSize(22 * this.ratio) + .margin({ right: 24 * this.ratio }) } .width('100%') .justifyContent(FlexAlign.SpaceBetween) - .margin({bottom: 10*this.ratio}) + .margin({ bottom: 10 * this.ratio }) } } .width('100%') .height('100%') .justifyContent(FlexAlign.SpaceBetween) - .backgroundImagePosition({x: 0, y: 0}) + .backgroundImagePosition({ x: 0, y: 0 }) .backgroundImage($r('app.media.index_bg')) .backgroundImageSize({ width: '100%', height: '100%' }) } - aboutToAppear() { - this.carNum = globalThis.carInfo.plateNo; - this.version = globalThis.version; - this.hasAuth = globalThis.hasAuth; + + aboutToAppear() { + this.carNum = globalThis.carInfo.plateNo; + this.version = globalThis.version; + this.hasAuth = globalThis.hasAuth; } - outClick(){ + outClick() { } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/SignDisplay.ets b/entry/src/main/ets/pages/SignDisplay.ets index 66026bc1..060a782f 100644 --- a/entry/src/main/ets/pages/SignDisplay.ets +++ b/entry/src/main/ets/pages/SignDisplay.ets @@ -1,57 +1,59 @@ -import router from '@ohos.router' -import UdpClient from '../common/utils/UdpClient'; -import FileLog from './judgeSDK/utils/file-log' -import signDisplayCom from './compontents/signDisplayCom' +import signDisplayCom from './compontents/signDisplayCom'; + @Entry @Component -struct Index { +export default struct Index { @State signArr: Array = [] @State sjxhColum: Array = [ - { key: '左方向灯', value: '0' }, { key: '右方向灯', value: '0' }, { - key: '喇叭', - value: '0' - }, { key: '点火1', value: '0' }, { key: '点火2', value: '0' }, { key: '近光灯', value: '0' }, { - key: '远光灯', - value: '0' - }, { key: '示廓灯', value: '0' }, { key: '雾灯', value: '0' }, { key: '雨刮器', value: '0' }, { - key: '脚刹', - value: '0' - }, { key: '手刹', value: '0' }, { key: '主驾驶门', value: '0' }, { key: '离合', value: '0' }, { - key: '副刹车', - value: '0' - }, { - key: '安全带', - value: '0' - }, { key: '双跳灯', value: '0' }, { key: '车速', value: '0' }, { key: '档位', value: '0' }, { - key: '超声波1', - value: '0' - }, { - key: '超声波2', - value: '0' - }, { - key: 'NC', - value: '0' - }, { key: 'SA15', value: '0' }, { key: '其他门', value: '0' }, { key: '转速过高', value: '0' }, { - key: '累计脉冲', - value: '0' - }, { key: '熄火次数', value: '0' }, { key: '发动机转速', value: '0' }, { key: '方向盘角度', value: '0' }, { - key: '超声波3', - value: '0' - }, { key: '超声波4', value: '0' }, { key: '触摸1', value: '0' }, { key: '触摸2', value: '0' }, { - key: '触摸3', - value: '0' - }, { key: 'SCIO', value: '0' } - , { key: 'SC1A_C', value: '0' }, { key: 'SC1B_C', value: '0' }, { key: 'SC2A_C', value: '0' }, { - key: 'SC2B_C', - value: '0' - }, { key: 'SC3A_C', value: '0' }, { key: 'SC3B_C', value: '0' }, { key: 'SC4A_C', value: '0' }, { - key: 'SC4B_C', - value: '0' - }, { key: 'SC5A_C', value: '0' }, { key: 'SC5B_C', value: '0' }, { key: 'SC6A_C', value: '0' }, { - key: 'SC6B_C', - value: '0' - }] - @State GPSColum:Array=[ + { key: '左方向灯', value: '0' }, + { key: '右方向灯', value: '0' }, + { key: '喇叭', value: '0' }, + { key: '点火1', value: '0' }, + { key: '点火2', value: '0' }, + { key: '近光灯', value: '0' }, + { key: '远光灯', value: '0' }, + { key: '示廓灯', value: '0' }, + { key: '雾灯', value: '0' }, + { key: '雨刮器', value: '0' }, + { key: '脚刹', value: '0' }, + { key: '手刹', value: '0' }, + { key: '主驾驶门', value: '0' }, + { key: '离合', value: '0' }, + { key: '副刹车', value: '0' }, + { key: '安全带', value: '0' }, + { key: '双跳灯', value: '0' }, + { key: '车速', value: '0' }, + { key: '档位', value: '0' }, + { key: '超声波1', value: '0' }, + { key: '超声波2', value: '0' }, + { key: 'NC', value: '0' }, + { key: 'SA15', value: '0' }, + { key: '其他门', value: '0' }, + { key: '转速过高', value: '0' }, + { key: '累计脉冲', value: '0' }, + { key: '熄火次数', value: '0' }, + { key: '发动机转速', value: '0' }, + { key: '方向盘角度', value: '0' }, + { key: '超声波3', value: '0' }, + { key: '超声波4', value: '0' }, + { key: '触摸1', value: '0' }, + { key: '触摸2', value: '0' }, + { key: '触摸3', value: '0' }, + { key: 'SCIO', value: '0' }, + { key: 'SC1A_C', value: '0' }, + { key: 'SC1B_C', value: '0' }, + { key: 'SC2A_C', value: '0' }, + { key: 'SC2B_C', value: '0' }, + { key: 'SC3A_C', value: '0' }, + { key: 'SC3B_C', value: '0' }, + { key: 'SC4A_C', value: '0' }, + { key: 'SC4B_C', value: '0' }, + { key: 'SC5A_C', value: '0' }, + { key: 'SC5B_C', value: '0' }, + { key: 'SC6A_C', value: '0' }, + { key: 'SC6B_C', value: '0' } + ]; + @State GPSColum: Array = [ { key: '状态', value: '0' }, { key: '收星数', value: '0' }, { key: '海拔高', value: '0' }, @@ -73,16 +75,13 @@ struct Index { @State active: number = 0 @State msg: string = '' @State @Watch('outClick') outFlag: boolean = false; - private timer = null - private udpClient: UdpClient = null - private FileLog: FileLog - private vocObj = null; @State url: string = '' + // @State gpsList: Array = [] build() { Column() { signDisplayCom({ - showBack:true + showBack: true }) } .width('100%') @@ -91,7 +90,6 @@ struct Index { .backgroundImageSize({ width: '100%', height: '100%' }) } - outClick() { } diff --git a/entry/src/main/ets/pages/TerminalInfos.ets b/entry/src/main/ets/pages/TerminalInfos.ets index 7ee8b004..1e584cfa 100644 --- a/entry/src/main/ets/pages/TerminalInfos.ets +++ b/entry/src/main/ets/pages/TerminalInfos.ets @@ -1,70 +1,66 @@ - -import router from '@ohos.router' -import TopLogo from './compontents/topLogo' +import TopLogo from './compontents/topLogo'; import ethernet from '@ohos.net.ethernet'; -import prompt from '@ohos.prompt' -import { upDateTableByArray} from '../common/service/initable' -import { getSyncData} from '../common/service/initable' -import { voiceService } from '../common/service/voiceService' -import { GlobalConfig } from '../config/index' -import { getUDP, getUDP2 } from '../common/utils/GlobleUdp'; -import { getTCP } from '../common/utils/GlobleTcp'; +import prompt from '@ohos.prompt'; +import { getSyncData, upDateTableByArray } from '../common/service/initable'; +import { getUDP, getUDP2 } from '../common/utils/GlobalUdp'; +import { getTCP } from '../common/utils/GlobalTcp'; + @Entry @Component struct Index { - @State textList1: string[] = ['差分服务器Ip','响应端口','中心服务器IP','响应端口', '子网掩码','默认网关','dns','后置机IP ', '响应端口','前置机IP','本地端口','平台服务器Ip','响应端口'] + @State textList1: string[] = ['差分服务器Ip', '响应端口', '中心服务器IP', '响应端口', '子网掩码', '默认网关', 'dns', '后置机IP ', '响应端口', '前置机IP', '本地端口', '平台服务器Ip', '响应端口'] // @State textList2: string[] = [] @State ratio: number = 1700 / 960 - @State inputFontSize:number=12 //12 + @State inputFontSize: number = 12 //12 // // @State inputTextList1: string[] = ['192.168.7.170','8084','192.168.7.170','20122','255.255.255.0','192.168.7.1','','','114.114.114.114','112.80.35.83','11055' + // '',] // @State inputTextList2: string[] = ['192.168.7.124','20022'] - @State inputTextList1: string[] = ['112.80.35.83','11055','112.80.35.83','11052','255.255.255.0','192.168.7.1','114.114.114.114','192.168.7.124','20022','192.168.7.170','20122','112.80.35.83','11050'] + @State inputTextList1: string[] = ['112.80.35.83', '11055', '112.80.35.83', '11052', '255.255.255.0', '192.168.7.1', '114.114.114.114', '192.168.7.124', '20022', '192.168.7.170', '20122', '112.80.35.83', '11050'] // @State inputTextList2: string[] = [] // 112.80.35.83 11052 // @State inputTextList1: string[] = ['192.168.36.2','8084','192.168.36.200','20122','255.255.255.0','192.168.36.1','','','114.114.114.114','192.168.36.139','8000'] // @State inputTextList2: string[] = ['192.168.36.139','20022'] - - @State @Watch('outClick') outFlag: boolean = false; - private vocObj = null; scroller: Scroller = new Scroller() + private vocObj = null; + build() { Column() { - TopLogo({outFlag:$outFlag}) + TopLogo({ outFlag: $outFlag }) Column() { Column() { - Scroll(this.scroller){ - Flex({'wrap':FlexWrap.Wrap}) { - ForEach(this.textList1, (item:string, index:number) => { + Scroll(this.scroller) { + Flex({ 'wrap': FlexWrap.Wrap }) { + ForEach(this.textList1, (item: string, index: number) => { Row() { Text(item) .width('40%') .height('100%') .fontColor('#E5CBA1') - .padding({'left': '35px'}) - .fontSize(this.inputFontSize*this.ratio) - TextInput({'text':this.inputTextList1[index]?this.inputTextList1[index]: ''}) + .padding({ 'left': '35px' }) + .fontSize(this.inputFontSize * this.ratio) + TextInput({ 'text': this.inputTextList1[index] ? this.inputTextList1[index] : '' }) .width('50%') .height('60%') .fontColor('#fff') .borderColor('#E6E0D8') .borderRadius('10px') .borderWidth('2px') - .fontSize(this.inputFontSize*this.ratio) - .padding({top:0,bottom:0}) + .fontSize(this.inputFontSize * this.ratio) + .padding({ top: 0, bottom: 0 }) .linearGradient({ angle: 0, colors: [[0x403C36, 0.0], [0x4D473D, 0.34], [0x3D3A34, 1.0]] - }).onChange((value: string) => { - this.inputTextList1[index]=value + }) + .onChange((value: string) => { + this.inputTextList1[index] = value - }) + }) } .width('50%') .height('16.7%') @@ -74,28 +70,43 @@ struct Index { } .width('95%') .height('90%') - .margin({'top': '2%'}) + .margin({ 'top': '2%' }) .backgroundColor('#282828') .borderRadius('15px') } .width('100%') .height('80%') .borderRadius('25px') + Column() { - Image($r('app.media.terminal_save')).width('20.5%').height('74%').onClick(()=>{ - upDateTableByArray('IpConfigTable',[{udplocalIp:this.inputTextList1[9],udplocalIpPort:this.inputTextList1[10],udpOppositeIp:this.inputTextList1[7],udpOppositeIpPort:this.inputTextList1[8],tcplocalIp:this.inputTextList1[9],tcplocalIpPort:'8088',tcpOppositeIp:this.inputTextList1[0],tcpOppositePort:this.inputTextList1[1],netMask:this.inputTextList1[4],gateway:this.inputTextList1[5],dnsServers:this.inputTextList1[6],centerIp:this.inputTextList1[2],centerPort:this.inputTextList1[3]}]) + Image($r('app.media.terminal_save')).width('20.5%').height('74%').onClick(() => { + upDateTableByArray('IpConfigTable', [{ + udplocalIp: this.inputTextList1[9], + udplocalIpPort: this.inputTextList1[10], + udpOppositeIp: this.inputTextList1[7], + udpOppositeIpPort: this.inputTextList1[8], + tcplocalIp: this.inputTextList1[9], + tcplocalIpPort: '8088', + tcpOppositeIp: this.inputTextList1[0], + tcpOppositePort: this.inputTextList1[1], + netMask: this.inputTextList1[4], + gateway: this.inputTextList1[5], + dnsServers: this.inputTextList1[6], + centerIp: this.inputTextList1[2], + centerPort: this.inputTextList1[3] + }]) ethernet.setIfaceConfig("eth0", { mode: 0, - ipAddr:this.inputTextList1[9], + ipAddr: this.inputTextList1[9], route: "0.0.0.0", - gateway: this.inputTextList1[5],//value.gateway网关 - netMask: this.inputTextList1[4],//value.netMask网络掩码 + gateway: this.inputTextList1[5], //value.gateway网关 + netMask: this.inputTextList1[4], //value.netMask网络掩码 dnsServers: this.inputTextList1[6], // domain: "" }, (error) => { if (error) { prompt.showToast({ - message: '设置失败'+JSON.stringify(error), + message: '设置失败' + JSON.stringify(error), duration: 3000 }); } else { @@ -113,42 +124,43 @@ struct Index { .backgroundColor('#CCC4B8') .width('100%') .height('20%') - .borderRadius({'bottomLeft':'25px','bottomRight':'25px'}) + .borderRadius({ 'bottomLeft': '25px', 'bottomRight': '25px' }) .justifyContent(FlexAlign.SpaceAround) } .width('75%') .height('69.4%') .backgroundColor('#E6E3DF') .borderRadius('25px') - .margin({'top':'7%'}) + .margin({ 'top': '7%' }) .justifyContent(FlexAlign.SpaceAround) } .width('100%') .height('100%') - .backgroundImagePosition({x: 0, y: 0}) + .backgroundImagePosition({ x: 0, y: 0 }) .backgroundImage($r('app.media.index_bg')) .backgroundImageSize({ width: '100%', height: '100%' }) } + aboutToAppear() { - getSyncData('IpConfigTable').then((result:Array)=>{ - console.log('result222',JSON.stringify(result)) - if(result.length){ - console.log('tagtag',JSON.stringify(result)) - this.inputTextList1[9]=result[0].udplocalIp - this.inputTextList1[10]=result[0].udplocalIpPort - this.inputTextList1[7]=result[0].udpOppositeIp - this.inputTextList1[8]=result[0].udpOppositeIpPort + getSyncData('IpConfigTable').then((result: Array) => { + console.log('result222', JSON.stringify(result)) + if (result.length) { + console.log('tagtag', JSON.stringify(result)) + this.inputTextList1[9] = result[0].udplocalIp + this.inputTextList1[10] = result[0].udplocalIpPort + this.inputTextList1[7] = result[0].udpOppositeIp + this.inputTextList1[8] = result[0].udpOppositeIpPort // this.inputTextList1[0]=result[0].tcplocalIp // this.inputTextList1[13]=result[0].tcplocalIpPort - this.inputTextList1[0]=result[0].tcpOppositeIp - this.inputTextList1[1]=result[0].tcpOppositePort - this.inputTextList1[5]=result[0].gateway - this.inputTextList1[4]=result[0].netMask - this.inputTextList1[6]=result[0].dnsServers - this.inputTextList1[2]=result[0].centerIp - this.inputTextList1[3]=result[0].centerPort + this.inputTextList1[0] = result[0].tcpOppositeIp + this.inputTextList1[1] = result[0].tcpOppositePort + this.inputTextList1[5] = result[0].gateway + this.inputTextList1[4] = result[0].netMask + this.inputTextList1[6] = result[0].dnsServers + this.inputTextList1[2] = result[0].centerIp + this.inputTextList1[3] = result[0].centerPort } }) ethernet.getIfaceConfig("eth0", (error, value) => { @@ -166,10 +178,12 @@ struct Index { }) } + onPageShow() { console.info('Index onPageShow'); } - outClick(){ + + outClick() { } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 49e267fd..ffb24321 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -1,25 +1,24 @@ -import { getExaminationItem, getExaminationStudentInfo, examinationStuAbsent, getPhotosForOther } from '../api/userInfo' -import router from '@ohos.router' -import TopLogo from './compontents/topLogo' +import { examinationStuAbsent, getExaminationItem, getExaminationStudentInfo } from '../api/userInfo'; +import router from '@ohos.router'; +import TopLogo from './compontents/topLogo'; import Md5 from '../common/utils/md5'; import AccountTable from '../common/database/tables/AccountTable'; import USER from '../common/constants/USER'; -import { dateFormat, getCurrentTime } from '../common/utils/tools'; +import { dateFormat, getCurrentTime, string2Bytes } from '../common/utils/tools'; import MA_SYSSET from '../common//constants/MA_SYSSET'; -import FaceCompare from './compontents/faceCompareByhaikang' -// import { initJudgeUdp } from '../common/utils/UdpJudge' -import { writeObjectOut } from '../api/judge' -import testNapi from "@ohos.idcard"; +import FaceCompare from './compontents/FaceCompareByhaikang'; +import { writeObjectOut } from '../api/judge'; +import testNapi from '@ohos.idcard'; import common from '@ohos.app.ability.common'; -import { VideoConfig, User } from './interfaces' -import WebRTCVoice from './webRTC/' -import promptAction from '@ohos.promptAction' -import { CandidateData, EmptyCandidateObject } from "../mock/CandidateData" -import {string2Bytes} from '../common/utils/tools' -import { getSyncData } from '../common/service/initable' +import { User, VideoConfig } from './interfaces'; +import WebRTCVoice from './webRTC/'; +import promptAction from '@ohos.promptAction'; +import { CandidateData, EmptyCandidateObject } from '../mock/CandidateData'; +import { getSyncData } from '../common/service/initable'; + @Entry @Component -struct UserInfo { +export default struct UserInfo { @State pageIndex: number = 0 @State ratio: number = 1700 / 960 @State index: number = 0 @@ -56,15 +55,12 @@ struct UserInfo { videoRecord3: false, videoRecord4: false, rlls: '1', - spzd4:false, - spzd3:false, - spzd2:false, - spzd1:false, - zdyz:'500' + spzd4: false, + spzd3: false, + spzd2: false, + spzd1: false, + zdyz: '500' } - private AccountTable = new AccountTable(() => { - }, USER); - private context = getContext(this) as common.UIAbilityContext; @State name: string = 'initName'; @State sex: string = ''; @State callBackFlag: boolean = false; @@ -81,15 +77,26 @@ struct UserInfo { @State signNum: number = 0; @State isCanClick: boolean = true; @State faceFlag: string = '0'; - @State FaceOpenStatue: string = '0';//是否开启人脸识别 + @State FaceOpenStatue: string = '0'; //是否开启人脸识别 subscriber; @State faceCatchImg: string = '' + private AccountTable = new AccountTable(() => { + }, USER); + private context = getContext(this) as common.UIAbilityContext; + private labelBlocks = [ + { label: '考生姓名', key: 'xm' }, + { label: '身份证号', key: 'sfzmhm' }, + { label: ' 流 水 号 ', key: 'lsh' }, + { label: '考试路线', key: 'kslx' }, + { label: '待考次数', key: 'kssycs' }, + { label: '考官姓名', key: 'ksy1' }, + ] async onPageShow() { //语音功能 - const systemParms:any = await getSyncData('MA_SYSTEMPARM') - console.log('systemParms',systemParms.length) + const systemParms: any = await getSyncData('MA_SYSTEMPARM') + console.log('systemParms', systemParms.length) new WebRTCVoice(this.context); //初始化数据 this.initData() @@ -102,8 +109,9 @@ struct UserInfo { this.heartMsg() } + //身份证读卡器初始化 - openDeviceByIDCard(){ + openDeviceByIDCard() { globalThis.indexComponent = this; // 应用启动时打开读卡设备 let ret = testNapi.OpenDevice(); @@ -113,11 +121,13 @@ struct UserInfo { console.error("zzctest Failed to Open Device"); } } - stopDeviceById(){ - if(this.faceFlag=='1'){ - testNapi&&testNapi.StopReadCard() + + stopDeviceById() { + if (this.faceFlag == '1') { + testNapi && testNapi.StopReadCard() } } + // 通过身份证获取当前学员 getCurrentStudent(id) { let flag = false @@ -153,6 +163,7 @@ struct UserInfo { }); } } + onReadCard(ret) { console.info(`zzctest xx Read Card ret =${ret.status}`) let thisVar = globalThis.indexComponent; @@ -209,7 +220,8 @@ struct UserInfo { changeQkfn() { this.qkFn() } - initData(){ + + initData() { this.stepFlag = false this.faceCompareSucess = 0 this.showFaceCompare = false @@ -234,19 +246,20 @@ struct UserInfo { } async heartMsg() { - globalThis.udpClient2&globalThis.udpClient2.setMsgCallBack((val)=>{ - if(val.id=='32'){ - globalThis.signNum=val.body[1] - if(val.body[0]=='7'){ + globalThis.udpClient2 & globalThis.udpClient2.setMsgCallBack((val) => { + if (val.id == '32') { + globalThis.signNum = val.body[1] + if (val.body[0] == '7') { this.getqkFn() - this.signNum=val.body[1] + this.signNum = val.body[1] } - }else if(val.id=='42'){ - console.log('qkfnqkfn',val.body[0]) + } else if (val.id == '42') { + console.log('qkfnqkfn', val.body[0]) this.qkFn() } }) } + getqkFn() { let tmpList = []; tmpList.push(string2Bytes(globalThis.signNum, 1 * 8)[0]) @@ -279,13 +292,13 @@ struct UserInfo { const studentRefreshParam = syssetParams.filter(sys => sys.v_no === '452') that.studentRefreshStatue = studentRefreshParam?.[0]?.v_value || '0' const faceParam = syssetParams.filter(sys => sys.v_no === '2313') - that.FaceOpenStatue =faceParam?.[0]?.v_value=='3'? '1':'0' + that.FaceOpenStatue = faceParam?.[0]?.v_value == '3' ? '1' : '0' that.FaceOpenStatue = '0' - console.log('that.FaceOpenStatue',that.FaceOpenStatue) + console.log('that.FaceOpenStatue', that.FaceOpenStatue) // faceParam?.[0]?.v_value || // 1身份证读卡器 2指纹 3人脸 - this.faceFlag=faceParam?.[0]?.v_value ||'0' - if(faceParam?.[0]?.v_value=='1'){ + this.faceFlag = faceParam?.[0]?.v_value || '0' + if (faceParam?.[0]?.v_value == '1') { that.openDeviceByIDCard() } //0不自动更新 1自动更新(不限次数) 2没有考生更新2次 @@ -304,7 +317,7 @@ struct UserInfo { that.getExaminationStudentInfoFn() } }, 5000) - }else{ + } else { this.getExaminationItemFn() } @@ -387,6 +400,7 @@ struct UserInfo { console.log('error12error' + error) }) } + qkFn() { this.faceCompareSucess = 0 if (globalThis.singlePlay) { @@ -423,9 +437,10 @@ struct UserInfo { }) } - async getExaminationItemFn(){ + + async getExaminationItemFn() { console.info('surenjun', this.currentUser.lsh) - if(!this.currentUser.lsh||globalThis.singlePlay){ + if (!this.currentUser.lsh || globalThis.singlePlay) { return } const carInfo = globalThis.carInfo; @@ -436,14 +451,15 @@ struct UserInfo { lsh: this.currentUser.lsh || '', examinationRoomId }); - if(examItems?.getExaminationItemRsp?.body?.kssycs!=0){ + if (examItems?.getExaminationItemRsp?.body?.kssycs != 0) { this.getExaminationStudentInfoFn() - }else{ - this.dataList=[] + } else { + this.dataList = [] this.currentUser = EmptyCandidateObject } } + //身份比对 async sfbdinterfaceFn() { this.stepFlag = true @@ -468,7 +484,7 @@ struct UserInfo { ksxtbh: this.ksxtbh || '222', sfzmhm: this.currentUser.sfzmhm || '', ksysfzmhm: this.currentUser.ksy1sfzmhm || '', - zp: encodeURIComponent((this.faceCatchImg||this.currentUser.kszp.substr(22)) || ''), + zp: encodeURIComponent((this.faceCatchImg || this.currentUser.kszp.substr(22)) || ''), kssj: dateFormat(date) || '', kchp: decodeURI(plateNo), Ksy2sfzmhm: this.currentUser.ksy2sfzmhm || '' @@ -518,14 +534,18 @@ struct UserInfo { this.stepFlag = false } } + aboutToDisappear() { this.outClick() } + outClick() { clearInterval(this.interval) this.stopDeviceById() - globalThis.udpClient2&&globalThis.udpClient2?.setMsgCallBack(()=>{}) + globalThis.udpClient2 && globalThis.udpClient2?.setMsgCallBack(() => { + }) } + // 几个按钮公共样式 @Styles commStyle(){ @@ -536,15 +556,6 @@ struct UserInfo { .margin({ bottom: 12 * this.ratio }) } - private labelBlocks = [ - { label: '考生姓名', key: 'xm' }, - { label: '身份证号', key: 'sfzmhm' }, - { label: ' 流 水 号 ', key: 'lsh' }, - { label: '考试路线', key: 'kslx' }, - { label: '待考次数', key: 'kssycs' }, - { label: '考官姓名', key: 'ksy1' }, - ] - build() { Column() { TopLogo({ outFlag: $outFlag }).margin({ bottom: 10 }) @@ -683,9 +694,9 @@ struct UserInfo { }) return } - if(this.FaceOpenStatue!='0'){ + if (this.FaceOpenStatue != '0') { this.showFaceCompare = true - }else{ + } else { this.sfbdinterfaceFn() } }) diff --git a/entry/src/main/ets/pages/compontents/faceCompare.ets b/entry/src/main/ets/pages/compontents/FaceCompare.ets similarity index 96% rename from entry/src/main/ets/pages/compontents/faceCompare.ets rename to entry/src/main/ets/pages/compontents/FaceCompare.ets index 4057c9f5..f9492f7a 100644 --- a/entry/src/main/ets/pages/compontents/faceCompare.ets +++ b/entry/src/main/ets/pages/compontents/FaceCompare.ets @@ -1,13 +1,8 @@ -//@ts-ignore import camera from '@ohos.multimedia.camera'; -import image from '@ohos.multimedia.image' -import util from '@ohos.util'; -import { writeFile } from '../../common/service/fileService' -import TopLogo from '../compontents/topLogo' -import { cameraService } from '../../common/service/cameraService' -import { voiceService } from '../../common/service/voiceService' -import { faceCompare } from '../../api/userInfo' -import prompt from '@ohos.prompt' +import { cameraService } from '../../common/service/cameraService'; +import { voiceService } from '../../common/service/voiceService'; +import { faceCompare } from '../../api/userInfo'; +import prompt from '@ohos.prompt'; import grantPermission from '../../common/utils/PermissionUtils'; import CameraModel from '../../common/service/CameraModel'; @@ -19,25 +14,25 @@ const PERMISSIONS: Array = [ @Component export default struct FaceCompare { - constructor() { - super() - } - - private mXComponentController: XComponentController = new XComponentController(); @State imageBase64: string = 'data:image/jpeg;base64,' - private cameraModel: CameraModel = new CameraModel(); @Prop sfzh: string; @Prop firstImage: string; @Link showFaceCompare: boolean; @Link faceCompareSucess: boolean; - private cameraObj = null; @State imageThumbnail: string = ''; + private mXComponentController: XComponentController = new XComponentController(); + private cameraModel: CameraModel = new CameraModel(); + private cameraObj = null; private timer = null; //人脸比对执行任务定时器 private stopClose = false; // 阻止用户关闭此组件 private times = 1; //人脸比对失败次数, 超过3次将不会自动比对,需要点击重新打开重新触发 private vocObj = null; private surfaceId: string = ''; + constructor() { + super() + } + build() { Column() { Column() { @@ -281,10 +276,10 @@ export default struct FaceCompare { this.surfaceId = surfaceId; this.cameraObj = new cameraService(surfaceId); - setTimeout(()=>{ + setTimeout(() => { this.showFaceCompare = false this.faceCompareSucess = true; - },3000) + }, 3000) return await this.cameraObj.initCamera((img) => { console.log('jiangsong getPhoto res.' + img.slice(0, 100)) diff --git a/entry/src/main/ets/pages/compontents/faceCompareByhaikang.ets b/entry/src/main/ets/pages/compontents/FaceCompareByhaikang.ets similarity index 89% rename from entry/src/main/ets/pages/compontents/faceCompareByhaikang.ets rename to entry/src/main/ets/pages/compontents/FaceCompareByhaikang.ets index a97acd81..c50618f2 100644 --- a/entry/src/main/ets/pages/compontents/faceCompareByhaikang.ets +++ b/entry/src/main/ets/pages/compontents/FaceCompareByhaikang.ets @@ -1,23 +1,15 @@ -//@ts-ignore - -import util from '@ohos.util'; - -import { voiceService } from '../../common/service/voiceService' -import { faceCompare } from '../../api/userInfo' -import FileUtil from '../../common/utils/File' -import { VideoConfig } from '../interfaces' +import { voiceService } from '../../common/service/voiceService'; +import { faceCompare } from '../../api/userInfo'; +import FileUtil from '../../common/utils/File'; +import { VideoConfig } from '../interfaces'; import common from '@ohos.app.ability.common'; -import { string2Bytes } from '../../common/utils/tools' -import { takePhoto } from '../../common/service/videoService' -import { GlobalConfig } from '../../config/index' +import { string2Bytes } from '../../common/utils/tools'; +import { takePhoto } from '../../common/service/videoService'; +import { GlobalConfig } from '../../config/index'; @Component -struct FaceCompare { - constructor() { - super() - } - +export default struct FaceCompare { @State imageBase64: string = 'data:image/jpeg;base64,' @Prop sfzh: string; @Prop lsh: string; @@ -27,19 +19,14 @@ struct FaceCompare { @Link getqkFlag: boolean; @Link faceCatchImg: string; @State imageThumbnail: string = ''; - private times = 1; //人脸比对失败次数, 超过3次将不会自动比对,需要点击重新打开重新触发 - private vocObj = null; @State callBackFlag: boolean = false; @State @Watch('clearIntervalFn') showFaceCompareFlag: Boolean = false; @State video_url: string = 'rtsp://admin:12345qwe@192.168.5.41:8000/h264/ch2/main/av_stream' @State previewUri: Resource = $r('app.media.2_nor') @State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X @State showControls: boolean = false - private controller: VideoController = new VideoController() @State isAutoPlay: boolean = true @State signNum: number = 0; - private fileUtil: FileUtil - private interval: any @State param: VideoConfig = { spls: '', videoNum: '1', @@ -59,14 +46,23 @@ struct FaceCompare { videoRecord3: false, videoRecord4: false, rlls: '1', - spzd4:false, - spzd3:false, - spzd2:false, - spzd1:false, - zdyz:'500', + spzd4: false, + spzd3: false, + spzd2: false, + spzd1: false, + zdyz: '500', } + private times = 1; //人脸比对失败次数, 超过3次将不会自动比对,需要点击重新打开重新触发 + private vocObj = null; + private controller: VideoController = new VideoController() + private fileUtil: FileUtil + private interval: any private context = getContext(this) as common.UIAbilityContext; + constructor() { + super() + } + build() { Column() { Column() { @@ -162,7 +158,7 @@ struct FaceCompare { this.controller.stop() this.vocObj && this.vocObj.releasePlayer() this.showFaceCompare = !this.showFaceCompare - this.showFaceCompareFlag=!this.showFaceCompareFlag + this.showFaceCompareFlag = !this.showFaceCompareFlag this.faceCompareSucess = -1 globalThis.statue = 2 @@ -203,9 +199,9 @@ struct FaceCompare { } async faceComparFn() { - console.log('mmmmm0',1) + console.log('mmmmm0', 1) - takePhoto(this.param, this.context, 'jt/',0,({base64})=>{ + takePhoto(this.param, this.context, 'jt/', 0, ({base64}) => { faceCompare({ sfzh: this.sfzh, firstImage: this.firstImage.substr(22), @@ -213,12 +209,12 @@ struct FaceCompare { type: 2, verifyType: 1 }).then(res => { - console.log('mmmmm8',res) + console.log('mmmmm8', res) if (res) { this.controller.stop() this.showFaceCompare = !this.showFaceCompare - this.showFaceCompareFlag=!this.showFaceCompareFlag + this.showFaceCompareFlag = !this.showFaceCompareFlag this.faceCompareSucess = 1; // this.faceCatchImg = result this.vocObj.playAudio({ @@ -236,9 +232,7 @@ struct FaceCompare { } }) }) - console.log('mmmmm8',9) - - + console.log('mmmmm8', 9) } @@ -246,7 +240,7 @@ struct FaceCompare { async heartMsg(context) { let tmpList = [] const str = this.lsh - for (let i = 0;i < str.length; i++) { + for (let i = 0; i < str.length; i++) { tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0]) } const param = { @@ -274,7 +268,7 @@ struct FaceCompare { globalThis.udpClient2.setMsgCallBack((val) => { if (val.id == '48') { if (val.body[13] == '1') { - this.showFaceCompareFlag=!this.showFaceCompareFlag + this.showFaceCompareFlag = !this.showFaceCompareFlag this.showFaceCompare = !this.showFaceCompare this.vocObj && this.vocObj.releasePlayer() this.faceCompareSucess = 1 @@ -311,7 +305,7 @@ struct FaceCompare { } } else if (val == 'yzcg.wav') { this.showFaceCompare = !this.showFaceCompare - this.showFaceCompareFlag=!this.showFaceCompareFlag + this.showFaceCompareFlag = !this.showFaceCompareFlag globalThis.statue = 4 this.faceCompareSucess = 1; this.vocObj && this.vocObj.releasePlayer() @@ -320,13 +314,13 @@ struct FaceCompare { this.vocObj && this.vocObj.releasePlayer() this.faceCompareSucess = -1 this.showFaceCompare = !this.showFaceCompare - this.showFaceCompareFlag=!this.showFaceCompareFlag + this.showFaceCompareFlag = !this.showFaceCompareFlag } } }); const data = await this.fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/config3.txt'); - console.log('faceEnterIn,data',data) + console.log('faceEnterIn,data', data) setTimeout(() => { this.vocObj && this.vocObj.playAudio({ @@ -343,11 +337,7 @@ struct FaceCompare { this.controller.start() } - - async aboutToDisappear() { } -} - -export default FaceCompare \ No newline at end of file +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/compontents/faceCompare_bak.ets b/entry/src/main/ets/pages/compontents/FaceCompare_bak.ets similarity index 90% rename from entry/src/main/ets/pages/compontents/faceCompare_bak.ets rename to entry/src/main/ets/pages/compontents/FaceCompare_bak.ets index 1e12b0c1..9596900a 100644 --- a/entry/src/main/ets/pages/compontents/faceCompare_bak.ets +++ b/entry/src/main/ets/pages/compontents/FaceCompare_bak.ets @@ -1,20 +1,15 @@ import camera from '@ohos.multimedia.camera'; -import image from '@ohos.multimedia.image' -import util from '@ohos.util'; -import { writeFile } from '../../common/service/fileService' -import TopLogo from '../compontents/topLogo' +import image from '@ohos.multimedia.image'; +import TopLogo from '../compontents/topLogo'; import buffer from '@ohos.buffer'; @Component -struct FaceCompare { - constructor() { - super() - } - +export default struct FaceCompare { + @State imageBase64: string = 'data:image/jpeg;base64,' private cameraObj: any = null; private cameraManager: any = null; - private surfaceId : string =''; + private surfaceId: string = ''; private xcomponentController: XComponentController = new XComponentController(); // 相机会话 private captureSession: any = null; @@ -26,16 +21,18 @@ struct FaceCompare { private photoOutput: any = null; // 照片接收对象 private imageRecever: any = null; - - @State imageBase64: string = 'data:image/jpeg;base64,' - - private timeSetTimeout: number = 0; //定时器执行次数 private timer: any = 0; //定时器 - build(){ + constructor() { + super() + } + + build() { Column() { - TopLogo() + TopLogo({ + outFlag: false + }) Row() { XComponent({ id: 'xcomponent', @@ -43,7 +40,7 @@ struct FaceCompare { controller: this.xcomponentController }) .onLoad(async () => { - this.xcomponentController.setXComponentSurfaceSize({surfaceWidth:640,surfaceHeight:480}); + this.xcomponentController.setXComponentSurfaceSize({ surfaceWidth: 640, surfaceHeight: 480 }); this.surfaceId = this.xcomponentController.getXComponentSurfaceId() console.log('jiangsong: xcomponentController this.surfaceId = ' + this.surfaceId) await this.initCamera(); @@ -52,7 +49,7 @@ struct FaceCompare { .height('240px') } .backgroundColor(Color.Yellow) - .position({x: 0, y: 0}) + .position({ x: 0, y: 0 }) Row() { Text('拍照') @@ -63,6 +60,7 @@ struct FaceCompare { this.takePhoto() }) } + Row() { Image(this.imageBase64) .width(420).height(240).border({ width: 1 }) @@ -73,6 +71,7 @@ struct FaceCompare { async aboutToAppear() { } + async aboutToDisappear() { // 停止当前会话 this.captureSession.stop() @@ -88,7 +87,7 @@ struct FaceCompare { this.captureSession = null } - async initCamera(){ + async initCamera() { let cameraManager = await camera.getCameraManager(globalThis.context) if (!cameraManager) { console.error("jiangsong camera.getCameraManager error") @@ -108,10 +107,10 @@ struct FaceCompare { } for (let index = 0; index < cameraArray.length; index++) { - console.info('cameraId : ' + cameraArray[index].cameraId); // 获取相机ID - console.info('cameraPosition : ' + cameraArray[index].cameraPosition); // 获取相机位置 - console.info('cameraType : ' + cameraArray[index].cameraType); // 获取相机类型 - console.info('connectionType : ' + cameraArray[index].connectionType); // 获取相机连接类型 + console.info('cameraId : ' + cameraArray[index].cameraId); // 获取相机ID + console.info('cameraPosition : ' + cameraArray[index].cameraPosition); // 获取相机位置 + console.info('cameraType : ' + cameraArray[index].cameraType); // 获取相机类型 + console.info('connectionType : ' + cameraArray[index].connectionType); // 获取相机连接类型 } // 创建相机输入流 @@ -241,7 +240,7 @@ struct FaceCompare { } catch (error) { console.error('jiangsong Failed to check whether the flash mode is supported. errorCode = ' + error.code); } - if(flashModeStatus) { + if (flashModeStatus) { // 设置自动闪光灯模式 try { this.captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO) @@ -254,7 +253,7 @@ struct FaceCompare { takePhoto() { let settings = { - quality: camera.QualityLevel.QUALITY_LEVEL_HIGH, // 设置图片质量高 + quality: camera.QualityLevel.QUALITY_LEVEL_HIGH, // 设置图片质量高 rotation: camera.ImageRotation.ROTATION_0 // 设置图片旋转角度0 } // 使用当前拍照设置进行拍照 @@ -265,7 +264,7 @@ struct FaceCompare { } console.info('jiangsong Callback invoked to indicate the photo capture request success.'); - this.imageRecever.getReceivingSurfaceId().then( id => { + this.imageRecever.getReceivingSurfaceId().then(id => { console.log('jiangsong getReceivingSurfaceId succeeded.'); }).catch(error => { console.log('jiangsong getReceivingSurfaceId failed.'); @@ -273,16 +272,16 @@ struct FaceCompare { this.getPhoto(); this.timeSetTimeout = 0; - clearTimeout(this.timer ); + clearTimeout(this.timer); }); } getPhoto() { this.imageRecever.readLatestImage((err, img) => { - if(err) { - console.log('jiangsong readLatestImage failed.' + JSON.stringify((err))); - this.timeSetTimeout ++; - if(this.timeSetTimeout > 20) { + if (err) { + console.log('jiangsong readLatestImage failed.' + JSON.stringify((err))); + this.timeSetTimeout++; + if (this.timeSetTimeout > 20) { return; } this.timer = setTimeout(() => { @@ -292,12 +291,12 @@ struct FaceCompare { console.log('jiangsong img.clipRect.' + JSON.stringify(img.clipRect)); img.getComponent(4, (err, component) => { - if(err) { + if (err) { console.log('jiangsong getComponent failed.' + JSON.stringify(err)); } else { const imagePackerApi = image.createImagePacker(); - let packOpts = { format:"image/jpeg", quality:98 }; + let packOpts = { format: "image/jpeg", quality: 98 }; let buf = buffer.from(component.byteBuffer); let str = buf.toString('base64') @@ -325,5 +324,3 @@ struct FaceCompare { }); } } - -export default FaceCompare \ No newline at end of file diff --git a/entry/src/main/ets/pages/compontents/signDisplayCom.ets b/entry/src/main/ets/pages/compontents/SignDisplayCom.ets similarity index 100% rename from entry/src/main/ets/pages/compontents/signDisplayCom.ets rename to entry/src/main/ets/pages/compontents/SignDisplayCom.ets diff --git a/entry/src/main/ets/pages/compontents/topLogo.ets b/entry/src/main/ets/pages/compontents/topLogo.ets index d34e5af9..96f9291b 100644 --- a/entry/src/main/ets/pages/compontents/topLogo.ets +++ b/entry/src/main/ets/pages/compontents/topLogo.ets @@ -1,35 +1,44 @@ -import router from '@ohos.router' -import { getCurrentTime } from '../../common/service/timeService' -import { voiceService } from '../../common/service/voiceService' +import router from '@ohos.router'; +import { getCurrentTime } from '../../common/service/timeService'; + @Component -struct TopLogo { - constructor() { - super() - } +export default struct TopLogo { @State ratio: number = 850 / 960 @State timeText: string = ''; @Link outFlag: boolean; //返回按钮触发 - private timer:any = null; - // private vocObj = null; - build(){ + private timer: any = null; + + constructor() { + super() + } + + build() { Column() { - Column() {} + Column() { + } .backgroundColor('#333230') .width('100%') .height('10%') + Row() { Row() { - Image($r('app.media.shortLogo')).width('10.2%').height('5.7%').margin({left: 30*this.ratio,top: -15*this.ratio}) - Text(this.timeText).fontSize(30*this.ratio).fontColor('#CCB48F').margin({top: -15*this.ratio,left:14*this.ratio}) //fontsize40 + Image($r('app.media.shortLogo')) + .width('10.2%') + .height('5.7%') + .margin({ left: 30 * this.ratio, top: -15 * this.ratio }) + Text(this.timeText) + .fontSize(30 * this.ratio) + .fontColor('#CCB48F') + .margin({ top: -15 * this.ratio, left: 14 * this.ratio }) //fontsize40 } Image($r('app.media.topB_back')).width('16.7%').height('12.2%') - .onClick(()=>{ + .onClick(() => { router.back() - this.outFlag=true + this.outFlag = true }) } - .position({x: 0,y:0}) + .position({ x: 0, y: 0 }) .width('100%') .justifyContent(FlexAlign.SpaceBetween) } @@ -48,10 +57,9 @@ struct TopLogo { // } // }); } + aboutToDisappear() { clearInterval(this.timer) console.log('jiangsong: topLogo aboutToDisappear222222222') } } - -export default TopLogo \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json index c596b8d5..fb7b1d1d 100644 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -4,7 +4,7 @@ "pages/Index", "pages/ExaminerLogin", "pages/UserInfo", - "pages/register", + "pages/Register", "pages/Settings", "pages/TerminalInfos", "pages/VideoConfig", @@ -12,7 +12,6 @@ "pages/RealTime", "pages/Roads", "pages/Judge" - ], "window": { }