From 5cb335da5d01abaf08ad1d4ccf07d507caf9e525 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Wed, 12 Feb 2025 10:48:27 +0800 Subject: [PATCH] =?UTF-8?q?globalThis=20index=20userinfo=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/Index.ets | 185 ++++++++++++-------------- entry/src/main/ets/pages/UserInfo.ets | 170 ++++++++++------------- 2 files changed, 157 insertions(+), 198 deletions(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 5940eec9..b0a62360 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -29,7 +29,8 @@ struct Index { @State url: string = '' @State hasAuth: boolean = false; @State dialogVisiable: boolean = false; - @State isSingle: boolean = false; + @State singlePlay: boolean = false; + @State baseInfo: object = { }; @State deviceId: string = ''; @State angle: number = 0 @State dialogRatio: number = 0.8 @@ -38,12 +39,13 @@ struct Index { @State loading: boolean = false @State initParamFlag: boolean = false @State fd: number = -1; + @State carInfo: object = {}; @State num: number = 0; fileHelper = null; errorDialog: CustomDialogController = new CustomDialogController({ builder: errorMsgDialog({ - title: globalThis.title, - type: globalThis.type, + title:AppStorage.get('title'), + type: AppStorage.get('type'), cancel: () => { }, confirm: () => { @@ -54,9 +56,10 @@ struct Index { }, ) private fileUtil: FileUtil - private interval = null; + private interval = -1; // private vocObj = null; private avPlayer + private timeInfo private workerInstance = null; private context = getContext(this) as common.UIAbilityContext; @@ -105,9 +108,9 @@ struct Index { Column() { Row() { - if (!this.isSingle) { + if (!this.singlePlay) { imageBtn({ btnWidth: '28%', btnHeight: '71%', imgSrc: $r('app.media.index_lw') }) - .margin({ left: 80 * globalThis.ratio }) + .margin({ left: 80 * this.ratio }) .onClick(async () => { // this.vocObj.playAudio({ // type: 1, @@ -115,7 +118,6 @@ struct Index { // }) // ||!this.initParamFlag if (this.loading) { - // globalThis.title = '正在初始化,请等待5s后重试' // this.errorDialog.open() return } @@ -123,9 +125,9 @@ struct Index { this.angle = 360 }, 1000) this.angle = 0 - if (!globalThis.timeInfo) { - globalThis.type = '1' - globalThis.title = '时间同步接口连接失败' + if (!this.timeInfo) { + AppStorage.setOrCreate('type',1) + AppStorage.setOrCreate('title','时间同步接口连接失败') this.errorDialog.open() promptAction.showToast({ message: `时间同步接口连接失败`, @@ -134,13 +136,13 @@ struct Index { this.loading = false return } - if (!globalThis.carInfo) { + if (!this.carInfo) { promptAction.showToast({ message: `车辆信息接口获取失败`, duration: 3000 }); - globalThis.type = '1' - globalThis.title = '车辆信息接口获取失败' + AppStorage.setOrCreate('type',1) + AppStorage.setOrCreate('title','车辆信息接口获取失败') this.errorDialog.open() this.loading = false return @@ -150,9 +152,9 @@ struct Index { }) } - if (this.isSingle) { + if (this.singlePlay) { imageBtn({ btnWidth: '28%', btnHeight: '71%', imgSrc: $r('app.media.index_dj') }) - .margin({ left: 80 * globalThis.ratio }) + .margin({ left: 80 * this.ratio }) .onClick(() => { if (this.loading) { return @@ -181,7 +183,7 @@ struct Index { }) } imageBtn({ btnWidth: '28%', btnHeight: '71%', imgSrc: $r('app.media.index_zj') }) - .margin({ right: 80 * globalThis.ratio }) + .margin({ right: 80 * this.ratio }) .onClick(() => { if (this.loading) { return @@ -202,24 +204,20 @@ struct Index { Column() { Row() { Column() { - Text('V外壳:' + globalThis.version) + Text('V外壳:' + this.baseInfo.version) .fontColor('#CCAE7A') - .fontSize(18 * globalThis.ratio) + .fontSize(18 * this.ratio) .width('30%') .margin({ bottom: 10 }) - Text('V评判:' + globalThis.judgeVersion) + Text('V评判:' + this.baseInfo.judgeVersion) .fontColor('#CCAE7A') - .fontSize(18 * globalThis.ratio) + .fontSize(18 * this.ratio) .width('30%') .margin({ bottom: 10 }) - // Text('V 1.0') - // .fontColor('#CCAE7A') - // .fontSize(22 * globalThis.ratio) - // .width('30%') - // .margin({ bottom: 10 }) + Text('授权信息:' + (this.hasAuth ? '已授权' : '未授权')) .fontColor('#CCAE7A') - .fontSize(18 * globalThis.ratio) + .fontSize(18 * this.ratio) .width('30%') } .margin({ left: 24 }) @@ -228,16 +226,16 @@ struct Index { TapGesture({ count: 2 }) .onAction(() => { // takePhotoFn(this.context) + this.singlePlay = !this.singlePlay + AppStorage.setOrCreate('singlePlay',this.singlePlay) - globalThis.singlePlay = !globalThis.singlePlay - this.isSingle = globalThis.singlePlay }) ) ) Text('考车号:' + this.deviceId) .fontColor('#CCAE7A') - .fontSize(22 * globalThis.ratio) + .fontSize(22 * this.ratio) .margin({ right: 24 }) } .width('100%') @@ -293,9 +291,9 @@ struct Index { if (this.delLoading) { Column() { Image($r('app.media.open_loading')) - .width(200 * globalThis.ratio) + .width(200 * this.ratio) .rotate({ angle: this.angle }) - .height(200 * globalThis.ratio) + .height(200 * this.ratio) .animation({ duration: 5000, // 动画时长 curve: Curve.EaseOut, // 动画曲线 @@ -303,27 +301,27 @@ struct Index { iterations: -1, // 播放次数 playMode: PlayMode.Normal, // 动画模式 }) - .margin({ top: 30 * globalThis.ratio }) + .margin({ top: 30 * this.ratio }) Text('正在清理本地数据,请稍候……') - .fontSize(24 * globalThis.ratio) - .margin({ top: 20 * globalThis.ratio }) + .fontSize(24 * this.ratio) + .margin({ top: 20 * this.ratio }) .fontWeight(400) } .visibility(this.delLoading ? Visibility.Visible : Visibility.Hidden) - .width(660 * globalThis.ratio) - .height(360 * globalThis.ratio) - .position({ x: 150 * globalThis.ratio, y: 98 * globalThis.ratio }) + .width(660 * this.ratio) + .height(360 * this.ratio) + .position({ x: 150 * this.ratio, y: 98 * this.ratio }) .backgroundColor('#E6E3DF') - .borderRadius(19 * globalThis.ratio) + .borderRadius(19 * this.ratio) } if (this.loading) { Column() { Image($r('app.media.open_loading')) - .width(200 * globalThis.ratio) + .width(200 * this.ratio) .rotate({ angle: this.angle }) - .height(200 * globalThis.ratio) + .height(200 * this.ratio) .animation({ duration: 5000, // 动画时长 curve: Curve.EaseOut, // 动画曲线 @@ -331,22 +329,22 @@ struct Index { iterations: -1, // 播放次数 playMode: PlayMode.Normal, // 动画模式 }) - .margin({ top: 30 * globalThis.ratio }) + .margin({ top: 30 * this.ratio }) Image($r('app.media.car')) - .width(80 * globalThis.ratio) - .height(80 * globalThis.ratio) - .position({ x: 288 * globalThis.ratio, y: 89 * globalThis.ratio }) + .width(80 * this.ratio) + .height(80 * this.ratio) + .position({ x: 288 * this.ratio, y: 89 * this.ratio }) Text('获取考车信息,请稍候……') - .fontSize(24 * globalThis.ratio) - .margin({ top: 20 * globalThis.ratio }) + .fontSize(24 * this.ratio) + .margin({ top: 20 * this.ratio }) .fontWeight(400) } .visibility(this.loading ? Visibility.Visible : Visibility.Hidden) - .width(660 * globalThis.ratio) - .height(360 * globalThis.ratio) - .position({ x: 150 * globalThis.ratio, y: 98 * globalThis.ratio }) + .width(660 * this.ratio) + .height(360 * this.ratio) + .position({ x: 150 * this.ratio, y: 98 * this.ratio }) .backgroundColor('#E6E3DF') - .borderRadius(19 * globalThis.ratio) + .borderRadius(19 * this.ratio) } } .width('100%') @@ -358,28 +356,16 @@ struct Index { } async aboutToAppear() { - // setInterval(() => { - // let date = new Date(); - // console.info('jiangsong1:timeSynchronization begin '); - // uploadProgressData() - // let params = { - // time: dateFormat(date), - // deviceNo: globalThis.deviceNo, - // version: globalThis.version, - // judgeVersion: globalThis.judgeVersion - // } - // timeSynchronizationHTTP(params) - // }, 1000) - - console.log('diyidiy') - this.avPlayer = new VoiceAnnounce(); + this.ratio = AppStorage.get('ratio') this.initParamFlag = false this.delLoading = false this.dialogVisiable = false this.angle = 0 this.loading = false - globalThis.lsh = '1111111111111' + const baseInfo=AppStorage.get('baseInfo') + baseInfo.lsh = '1111111111111' + AppStorage.setOrCreate('baseInfo',baseInfo) globalThis.errorDialog = this.errorDialog globalThis.udpEvent = new UdpEvent(); getSyncData('MA_SYSSET').then(async data => { @@ -417,17 +403,17 @@ struct Index { // console.log('mode',mode) const param = { - carId: globalThis.carInfo?.carId, - examinationRoomId: globalThis.carInfo?.examinationRoomId, - judgeVersion: globalThis.judgeVersion, - shellVersion: globalThis.version, - paraKdid: globalThis.timeInfo?.paraKdid || globalThis.timeInfo?.kdid, - kdid: globalThis.timeInfo?.kdid || globalThis.timeInfo?.paraKdid, - mode: globalThis.timeInfo?.mode, + carId: this.carInfo?.carId, + examinationRoomId: this.carInfo?.examinationRoomId, + judgeVersion: this.baseInfo.judgeVersion, + shellVersion: this.baseInfo.version, + paraKdid: this.timeInfo?.paraKdid || this.timeInfo?.kdid, + kdid: this..timeInfo?.kdid || this.timeInfo?.paraKdid, + mode: this.timeInfo?.mode, context: this.context, - host: globalThis.host, - centerHost: globalThis.timeInfo?.url, - singlePlay: globalThis.singlePlay + host: AppStorage.get('host'), + centerHost: this.timeInfo?.url, + singlePlay: this.singlePlay } this.loading = true console.log("sql 1111") @@ -450,7 +436,7 @@ struct Index { data.forEach(sys => { //判断是否能点开始考试 if (sys.v_no === '854') { - globalThis.param854Str = sys.v_value + AppStorage.setOrCreate('param854Str',sys.v_value) } if (sys.v_no === '824' && decodeURIComponent(sys.v_value) == '0') { // this.Param612Str= decodeURIComponent(sys.v_value) @@ -514,11 +500,14 @@ struct Index { } async heartMsg() { - const arr = [globalThis.signNum || 0, globalThis.statue || 1] + const signNum=AppStorage.get('signNum') as Number + const statue=AppStorage.get('statue') as Number + const lsh=AppStorage.get('lsh') as String + const arr = [signNum || 0, 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' + const str = lsh || '0000000000000' for (let i = 0; i < str.length; i++) { tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0]) } @@ -526,8 +515,8 @@ struct Index { const param = { id: 31, list: tmpList, - carNo: globalThis.carInfo.carNo, - placeId: globalThis.carInfo.examinationRoomId + carNo: this.carInfo.carNo, + placeId: this.carInfo.examinationRoomId } // globalThis.udpClient2.initHeartSendMsg(param,this.context) if (globalThis.udpClient2.getStatus()) { @@ -537,9 +526,10 @@ struct Index { async onPageShow() { console.log('ttttt', 1111) + this.singlePlay=AppStorage.get('singlePlay') + this.baseInfo=AppStorage.get('baseInfo') await this.userAuth(); - console.log('globalThis.singlePlay', globalThis.singlePlay) - if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) { + if (this.singlePlay == undefined || this.singlePlay == null) { // setVideoParam() console.log('diyidiy') this.context.resourceManager.getRawFileContent("welcome.wav") @@ -556,13 +546,13 @@ struct Index { console.log("getRawFileContent promise error is " + error); }); - globalThis.singlePlay = false + this.singlePlay = false + AppStorage.setOrCreate('singlePlay',false) } - this.isSingle = globalThis.singlePlay // this.loading = false this.num = 0 // const TcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort) - globalThis.lsh = '1111111111111' + AppStorage.setOrCreate('lsh','1111111111111') } async createAlbum() { @@ -609,7 +599,6 @@ struct Index { } async initParams() { - // deleteAllFIleLog(GlobalConfig.comoonfileWriteAddress + '/PLC/') //设置plc udp 同步requesthost await getUDP(this.context, false) this.loading = false @@ -618,17 +607,20 @@ struct Index { await getCarInfo() await getUDP2(this.context, false) getTCP() - this.deviceId = globalThis.carInfo.carNo + this.carInfo=AppStorage.get('carInfo') + this.deviceId = this.carInfo.carNo await setCurrentTime(); - if (!globalThis.distanceClass) { - const distanceClass = new GetDistance(globalThis.context) + this.timeInfo=AppStorage.get('timeInfo') + const distanceClass=AppStorage.get('distanceClass') as boolean + if (!distanceClass) { + const distanceClass = new GetDistance(this.context) await distanceClass.initFolder() - globalThis.distanceClass = distanceClass + AppStorage.setOrCreate('distanceClass',distanceClass) console.info('surenjun', 'distanceClass=>初始化完成') } - this.carNum = globalThis.carInfo.plateNo; - this.version = globalThis.version; - this.hasAuth = globalThis.hasAuth; + this.carNum = this.carInfo.plateNo; + this.version = this.baseInfo.version; + this.hasAuth = this.baseInfo.hasAuth; setTimeout(() => { this.initParamFlag = true }, 3000) @@ -644,11 +636,6 @@ struct Index { } }, 1000) this.createAlbum() - // clearInterval(globalThis.demo) - // globalThis.demo= setInterval(()=>{ - // const str= {"carId":"1062","examinationRoomId":"2","videoVersion":"1.0","judgeVersion":"2023.09.30.1","shellVersion":"2023.12.13.01","host":"http://172.37.55.191:8082"} - // initialization(str) - // },10000) //下载模型 // await this.getModel() // const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00] diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index ebae87fe..8acf439d 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -86,6 +86,7 @@ struct UserInfo { Param398: '0' } @State startExam: boolean = false + @State singlePlay: boolean = false //开始考试准备 prePareExam = async () => { if (this.ksksLimit) { @@ -95,14 +96,14 @@ struct UserInfo { try { await this.checkSignal() this.faceCompareSucess = 0 - globalThis.statue = 2 + AppStorage.setOrCreate('statue',2) if (!this.currentUser.xm) { return } this.ksksLimit = true - if (globalThis.singlePlay) { - const { examSubject } = globalThis.carInfo; + if (this.singlePlay) { + const { examSubject } = this.carInfo; this.currentUser.id = '0' await upDateTableByArray('USER', [this.currentUser]) router.pushUrl({ @@ -151,9 +152,8 @@ struct UserInfo { private filePhoto: FilePhoto // 过程照片拍照 getPhoto = async (empty?: boolean) => { - const singlePlay = globalThis.singlePlay //单机模式返回空照片 - if (singlePlay) { + if (this.singlePlay) { return '' } else { const photoBase64 = await this.filePhoto.getPhoto(); @@ -183,6 +183,9 @@ struct UserInfo { this.ksksLimit = false this.currentUser = EmptyCandidateObject this.filePhoto = new FilePhoto(this.context); + this.singlePlay = AppStorage.get('singlePlay') + this.examinerLoginInfo=AppStorage.get('examinerLoginInfo') + this.carInfo=AppStorage.get('carInfo') //语音功能on // new WebRTCVoice(this.context); //初始化数据 @@ -192,7 +195,7 @@ struct UserInfo { const routerParam = router.getParams() || { type: 0 }; console.log('routerParam', JSON.stringify(routerParam)) - if (!globalThis.singlePlay) { + if (!this.singlePlay) { // @ts-ignore if (routerParam.type != 1) { // @ts-ignore @@ -225,8 +228,8 @@ struct UserInfo { if (this.dataList.length) { setTimeout(() => { this.currentUser = this.dataList[0] - this.currentUser.ksy2 = globalThis.kgxm - globalThis.lsh = this.currentUser.lsh + this.currentUser.ksy2 = this.examinerLoginInfo.kgxm + AppStorage.setOrCreate('lsh',this.currentUser.lsh) }, 200) } else { this.currentUser = EmptyCandidateObject @@ -270,7 +273,7 @@ struct UserInfo { //身份证读卡器初始化 openDeviceByIDCard() { - globalThis.indexComponent = this; + AppStorage.setOrCreate('indexComponent',this) // 应用启动时打开读卡设备 let ret = testNapi.OpenDevice(); if (ret == 0) { @@ -298,17 +301,17 @@ struct UserInfo { this.currentUser = EmptyCandidateObject setTimeout(() => { this.currentUser = res - this.currentUser.ksy2 = globalThis.kgxm + this.currentUser.ksy2 = this.examinerLoginInfo.kgxm }, 200) - globalThis.lsh = res.lsh - globalThis.ksyh = res.ksy1sfzmhm - const { examSubject } = globalThis.carInfo; + this.examinerLoginInfo.ksyh = res.ksy1sfzmhm + AppStorage.setOrCreate('examinerLoginInfo',this.examinerLoginInfo) + AppStorage.setOrCreate('lsh',res.lsh) + const { examSubject } = this.carInfo; // this.currentUser.kszp=this.photo+res.kszp // this.currentUser.ksmjzp=this.photo+this.currentUser.ksmjzp - if (globalThis.singlePlay) { + if (this.singlePlay) { this.stopDeviceById() - // globalThis.statue=4 router.pushUrl({ url: examSubject == 3 ? 'pages/Roads' : 'pages/Judge', params: { @@ -325,13 +328,13 @@ struct UserInfo { }) this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) if (!flag) { - globalThis.lsh = '0000000000000' + + AppStorage.setOrCreate('lsh','0000000000000') await upDateTableByArray('USER', []) setTimeout(() => { this.currentUser = this.list[0] - this.currentUser.ksy2 = globalThis.kgxm - - globalThis.lsh = this.currentUser.lsh + this.currentUser.ksy2 = this.examinerLoginInfo.kgxm + AppStorage.setOrCreate('lsh',this.currentUser.lsh) }, 200) // promptAction.showToast({ @@ -343,7 +346,7 @@ struct UserInfo { onReadCard(ret: IDCardSDK.IDCardInfo) { console.info(`zzctest xx Read Card ret =${ret.status}`) - let thisVar = globalThis.indexComponent; + let thisVar = AppStorage.get('indexComponent'); if (ret.status == 0) { // status = 1 为读到身份证信息; status = 1 为身份证离开读卡器 // 收到身份证离开读卡器的事件通知,根据实际业务需要决定是否需要清空之前已读取的身份证信息。 @@ -405,11 +408,11 @@ struct UserInfo { this.showFaceCompare = false this.lsh = '1111111111111' this.callBackFlag = false - globalThis.lsh = this.lsh + AppStorage.setOrCreate('lsh',this.lsh) + AppStorage.setOrCreate('statue',2) // this.currentUser = EmptyCandidateObject - globalThis.statue = 2 this.numCount = 0 - if (globalThis.singlePlay) { + if (thiis.singlePlay) { // TODO 模拟假数据 this.list = CandidateData this.pageIndex = 0 @@ -418,8 +421,9 @@ struct UserInfo { this.currentUser.ksy2 = '' this.lsh = this.currentUser.lsh - globalThis.ksyh = this.currentUser.ksy1sfzmhm - globalThis.lsh = this.lsh + this.examinerLoginInfo.ksyh=this.currentUser.ksy1sfzmhm + AppStorage.setOrCreate('examinerLoginInfo',this.examinerLoginInfo) + AppStorage.setOrCreate('lsh',this.lsh) } // const syssetParams = await getSyncData('MA_SYSSET'); @@ -430,7 +434,7 @@ struct UserInfo { async heartMsg() { globalThis.udpClient2 & globalThis.udpClient2.setMsgCallBack(async (val) => { if (val.id == '32') { - globalThis.signNum = val.body[1] + AppStorage.setOrCreate('signNum', val.body[1]) if (val.body[0] == '7') { //缺考处理 this.getqkFn() @@ -447,12 +451,12 @@ struct UserInfo { //考点端查询缺考指令内容消息请求 getqkFn() { let tmpList: Array = []; - tmpList.push(string2Bytes(globalThis.signNum, 1 * 8)[0]) + tmpList.push(string2Bytes(AppStorage.get('signNum'), 1 * 8)[0]) const param: QKParamType = { id: 41, list: tmpList, - carNo: globalThis.carInfo.carNo as string, - placeId: globalThis.carInfo.examinationRoomId as string + carNo: this.carInfo.carNo as string, + placeId: this.carInfo.examinationRoomId as string } globalThis.udpClient2.sendMsgExt(param, this.context) } @@ -595,7 +599,7 @@ struct UserInfo { console.log('this.faceCompareSuces', this.faceCompareSucess, JSON.stringify(this.currentUser)) if (this.faceCompareSucess > 0) { //人脸比对通过 - globalThis.statue = 4 + AppStorage.setOrCreate('statue',4) this.showFaceCompare = false this.sfbdinterfaceFn() } @@ -619,7 +623,7 @@ struct UserInfo { //获取下载考生 async getExaminationStudentInfoFn() { - if (globalThis.singlePlay || this.updateTimeLimit) { + if (this.singlePlay || this.updateTimeLimit) { return } this.isExamStart = false @@ -638,9 +642,9 @@ struct UserInfo { this.type = '2' this.errorDialog.open() this.updateTimeLimit = true - const param = `${Md5.Instance.get_md5(globalThis.carInfo.carId + - globalThis.carInfo.examinationRoomId + - globalThis.username)}${globalThis.carInfo.carId}${globalThis.carInfo.examinationRoomId}${globalThis.username}` + const param = `${Md5.Instance.get_md5(this.carInfo.carId + + this.carInfo.examinationRoomId + + this.examinerLoginInfo.username)}${this.carInfo.carId}${this.carInfo.examinationRoomId}${this.examinerLoginInfo.username}` try { getExaminationStudentInfo(param).then(async (res) => { console.log("temp log ", JSON.stringify(res)) @@ -686,10 +690,10 @@ struct UserInfo { } if (this.systemParam.Param828Str == '1' || this.systemParam.Param828Str == '2') { // listData.ksy2=listData.ksy1; - listData.ksy2 = globalThis.kgxm + listData.ksy2 = this.examinerLoginInfo.kgxm } else { // listData.ksy2=listData.ksy2; - listData.ksy2 = globalThis.kgxm + listData.ksy2 = this.examinerLoginInfo.kgxm } listData.kszp = this.photo + listData.kszp listData.ksmjzp = this.photo + listData.ksmjzp @@ -708,47 +712,16 @@ struct UserInfo { return res.kssycs == '1' }) if (this.dataList.length) { - if (user.length) { - setTimeout(() => { - this.currentUser = user[0] - this.currentUser.ksy2 = globalThis.kgxm - globalThis.lsh = this.currentUser.lsh - globalThis.ksyh = this.currentUser.ksy1sfzmhm - }, 200) - } else { - setTimeout(() => { - this.currentUser = this.dataList[0] - this.currentUser.ksy2 = globalThis.kgxm - globalThis.ksyh = this.currentUser.ksy1sfzmhm - globalThis.lsh = this.currentUser.lsh - }, 200) - } + setTimeout(() => { + this.currentUser=user.length?user[0]:this.dataList[0] + this.currentUser.ksy2 = this.examinerLoginInfo.kgxm + AppStorage.setOrCreate('lsh',this.currentUser.lsh) + this.examinerLoginInfo.ksyh=this.currentUser.ksy1sfzmhm + AppStorage.setOrCreate('examinerLoginInfo',this.examinerLoginInfo) + }, 200) } else { this.currentUser = EmptyCandidateObject } - - - // const flag=dataList.filter((res)=>{ - // return res.sfzmhm==this.currentUser.sfzmhm - // }).length?true:false - // if(!this.currentUser.sfzmhm||this.currentUser.kssycs=='0'||!flag){ - // if (this.dataList.length) { - // setTimeout(()=>{ - // this.currentUser = this.dataList[0] - // this.currentUser.ksy2= globalThis.kgxm - // globalThis.lsh=this.currentUser.lsh - // },200) - // console.log('this.currentUser1',JSON.stringify(this.currentUser)) - // } else { - // this.currentUser = EmptyCandidateObject - // } - // } - - - // this.lsh = this.currentUser.lsh - // globalThis.lsh = this.lsh - // globalThis.ksyh = this.currentUser.ksy1sfzmhm - //364 绕车一周评判时机(1-开始考试后判 2-开始考试前判) if (this.systemParam.Param364 == '2') { this.isBoardPrePareSetPopupOpen = true; @@ -784,13 +757,13 @@ struct UserInfo { } this.faceCompareSucess = 0 this.ksksLimit = false - if (globalThis.singlePlay) { + if (this.singlePlay) { this.qkFlag = false return } console.log('JsonJson', JSON.stringify(this.currentUser)) const param = - `${globalThis.carInfo.carId}${this.currentUser.sfzmhm}${globalThis.carInfo.examinationRoomId}${globalThis.username}${this.lsh}` + `${this.carInfo.carId}${this.currentUser.sfzmhm}${this.carInfo.examinationRoomId}${this.examinerLoginInfo.username}${this.lsh}` console.log('carNo1111', param) examinationStuAbsent(param).then(res => { @@ -798,12 +771,12 @@ struct UserInfo { let tmpList = []; tmpList.push(string2Bytes(arr[0], 1 * 8)[0]) tmpList.push(string2Bytes(arr[1], 1 * 8)[0]) - console.log('globalThis.signNum', globalThis.signNum) + const param = { id: 43, list: tmpList, - carNo: globalThis.carInfo.carNo, - placeId: globalThis.carInfo.examinationRoomId + carNo: this.carInfo.carNo, + placeId: this.carInfo.examinationRoomId } globalThis.udpClient2.sendMsgExt(param, this.context) @@ -822,11 +795,10 @@ struct UserInfo { } async getExaminationItemFn() { - if (!this.currentUser.lsh || globalThis.singlePlay) { + if (!this.currentUser.lsh || this.singlePlay) { return } - const carInfo = globalThis.carInfo; - const { carId, examinationRoomId } = carInfo; + const { carId, examinationRoomId } = this.carInfo; const examItems = await getExaminationItem({ time: getCurrentTime(), carId, @@ -845,12 +817,11 @@ struct UserInfo { //身份比对 async sfbdinterfaceFn() { - globalThis.statue = 4 + AppStorage.setOrCreate('statue',4) this.stepFlag = true - const carInfo = globalThis.carInfo; - const { carId, examinationRoomId } = carInfo; + const { carId, examinationRoomId } = this.carInfo; let examItems = { getExaminationItemRsp: { body: { ykxx: '' } } }; - if (!globalThis.singlePlay) { + if (!this.singlePlay) { //获取已考项目 // @ts-ignore examItems = await getExaminationItem({ @@ -1008,11 +979,11 @@ struct UserInfo { // 开始考试 async beginExam() { - const carInfo = globalThis.carInfo; - const { carId, examinationRoomId } = carInfo; - const { examSubject, plateNo } = carInfo; + const { carId, examinationRoomId } = this.carInfo; + const { examSubject, plateNo } = this.carInfo; const date = new Date() - globalThis.startHourTime = await getCurrentHourTime() + const startHourTime = await getCurrentHourTime() + AppStorage.setOrCreate('startHourTime',startHourTime) const photoBase64 = await this.getPhoto(); if (photoBase64 == '') { this.ksksLimit = false @@ -1041,8 +1012,9 @@ struct UserInfo { } console.info('surenjunjianguan', JSON.stringify(param)) const temp = await writeObjectOut(param); - globalThis.lsh = this.currentUser.lsh - globalThis.ksyh = this.currentUser.ksy1sfzmhm + AppStorage.setOrCreate('lsh',this.currentUser.lsh) + this.examinerLoginInfo.ksyh= this.currentUser.ksy1sfzmhm + AppStorage.setOrCreate('examinerLoginInfo',this.examinerLoginInfo) return temp } @@ -1060,7 +1032,7 @@ struct UserInfo { // await upDateTableByArray('USER', [this.currentUser]) console.log("User", JSON.stringify(this.currentUser)) // await sqlInsertCommonFn("USER", [this.currentUser]) - globalThis.statue = 4 + AppStorage.setOrCreate('statue',4) this.isBoardPrePareSetPopupShow = true; this.isFirstBoardPrePareSetPopupBtnShow = true; this.stepFlag = false @@ -1119,15 +1091,15 @@ struct UserInfo { .backgroundImageSize({ width: '100%', height: '100%' }) .onClick(() => { console.log('this.startExam', this.startExam, this.systemParam.Param364, this.isExamStart) - if ((this.isExamStart && !globalThis.singlePlay && this.systemParam.Param341) || + if ((this.isExamStart && !this.singlePlay && this.systemParam.Param341) || (this.startExam && this.systemParam.Param364 == '2')) { return } this.currentUser = EmptyCandidateObject - globalThis.lsh = item.lsh; + AppStorage.setOrCreate('lsh',item.lsh) setTimeout(() => { this.currentUser = item - this.currentUser.ksy2 = globalThis.kgxm + this.currentUser.ksy2 = this.examinerLoginInfo.kgxm }, 200) @@ -1201,7 +1173,7 @@ struct UserInfo { .margin({ bottom: 12 * this.ratio }) .onClick(() => { // this.avPlayer.playAudio(['button_media.wav']) - if (this.isExamStart && !globalThis.singlePlay) { + if (this.isExamStart && !this.singlePlay) { return } this.faceCompareSucess = 0 @@ -1259,7 +1231,7 @@ struct UserInfo { getqkFlag: $getqkFlag, faceCatchImg: $faceCatchImg, showFaceCompare: $showFaceCompare, - lsh: globalThis.lsh, + lsh: AppStorage.get('lsh'), }) } if (this.qkFlag) { @@ -1389,7 +1361,7 @@ struct LabelBlock { } } -type systemParam = { +interface systemParam { 'Param341': boolean, //是否按顺序考试 'Param803Str': string, //开始考试前必须解开安全带或关车门 'Param612Str': string, //开始考试触发方式