From ffe0dfd6950cf956139e648d026488603c226889 Mon Sep 17 00:00:00 2001 From: wangzhongjie Date: Thu, 26 Jun 2025 14:27:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E7=99=BB=E9=99=86,?= =?UTF-8?q?=E5=A4=AA=E5=BF=AB=E5=BB=B6=E8=BF=9F=E4=B8=80=E4=B8=8B,?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E5=8A=A8=E7=94=BB=E5=A4=AA=E9=9A=BE=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/config/LogEnum.ets | 5 +- entry/src/main/ets/config/global.ets | 2 +- entry/src/main/ets/pages/ExaminerLogin.ets | 50 ++++-- entry/src/main/ets/pages/UserInfo.ets | 160 ++++++------------ .../ets/pages/UserInfo/MissAnExamDialog.ets | 39 +++++ .../src/main/ets/pages/compontents/Button.ets | 23 +++ .../main/ets/pages/compontents/CarLoading.ets | 14 ++ .../src/main/ets/pages/compontents/Header.ets | 23 +-- 8 files changed, 169 insertions(+), 147 deletions(-) create mode 100644 entry/src/main/ets/pages/compontents/Button.ets create mode 100644 entry/src/main/ets/pages/compontents/CarLoading.ets diff --git a/entry/src/main/ets/config/LogEnum.ets b/entry/src/main/ets/config/LogEnum.ets index 6614b4a..dc7a406 100644 --- a/entry/src/main/ets/config/LogEnum.ets +++ b/entry/src/main/ets/config/LogEnum.ets @@ -58,4 +58,7 @@ export const DbOperationTag = '[DbOperation]'; export const RoadsTag = '[Roads]'; //ExaminerLogin -export const ExaminerLoginTag = '[ExaminerLogin]'; \ No newline at end of file +export const ExaminerLoginTag = '[ExaminerLogin]'; + +//UserInfo +export const UserInfoTag = '[UserInfo]'; \ No newline at end of file diff --git a/entry/src/main/ets/config/global.ets b/entry/src/main/ets/config/global.ets index 23ad160..aa15b05 100644 --- a/entry/src/main/ets/config/global.ets +++ b/entry/src/main/ets/config/global.ets @@ -37,7 +37,7 @@ export const GlobalConfig: GlobalConfigType = { }, sz: { km2: ['2024.08.21.01', '2024.08.24.1'], - km3: [], + km3: ['2024.08.21.01', '2024.08.24.1'], }, } } diff --git a/entry/src/main/ets/pages/ExaminerLogin.ets b/entry/src/main/ets/pages/ExaminerLogin.ets index 44e1f4c..c67111e 100644 --- a/entry/src/main/ets/pages/ExaminerLogin.ets +++ b/entry/src/main/ets/pages/ExaminerLogin.ets @@ -5,9 +5,9 @@ import { ApiResponseType, CarInfoType, ExaminerLoginInfo } from '../model'; import CryptoJS from '@ohos/crypto-js'; import { UserLoginType } from '../model/ExaminerLogin'; import { examinerLogin } from '../api/login'; -import router from '@ohos.router'; import { dConsole } from '../utils/LogWorker'; import { ExaminerLoginTag } from '../config'; +import router from '@ohos.router'; @Entry @@ -99,6 +99,7 @@ struct ExaminerLoginPage { btnComponent({ text: "确定" }).onClick(async () => { + console.log("确定按钮", '11111') if (this.userName === "" || this.password === "") { Prompt.showToast({ message: "用户名或密码不能为空", @@ -106,6 +107,11 @@ struct ExaminerLoginPage { }); return; } + + this.loadingDialog.open(); + const startTime = new Date().getTime(); // 记录开始时间 + const minDisplayTime = 1000; // 最小显示时间1秒 + const carInfo: CarInfoType = AppStorage.get('carInfo')! let password: string = CryptoJS.MD5(this.password).toString(); const param: UserLoginType = { @@ -114,26 +120,38 @@ struct ExaminerLoginPage { username: this.userName, password } - this.loadingDialog.open(); + try { const res: ApiResponseType = await examinerLogin(param) if (res?.examinerLoginRsp?.head?.resultCode == '1') { - return - } - this.loadingDialog.close() - router.pushUrl({ - url: 'pages/UserInfo', - params: { - type: 1 - } - }, router.RouterMode.Single); - const examinerLoginInfo: ExaminerLoginInfo | undefined = res.examinerLoginRsp?.body; - if (!examinerLoginInfo) { - dConsole.error(ExaminerLoginTag, 'examinerLoginRsp.body is undefined'); + this.loadingDialog.close(); return; } - examinerLoginInfo.username = this.userName - AppStorage.setOrCreate('examinerInfo', examinerLoginInfo) + + // 计算剩余需要等待的时间 + const endTime = new Date().getTime(); + const elapsedTime = endTime - startTime; + const remainingTime = Math.max(0, minDisplayTime - elapsedTime); + + // 延迟关闭弹窗和跳转 + setTimeout(() => { + this.loadingDialog.close(); + router.pushUrl({ + url: 'pages/UserInfo', + params: { + type: 1 + } + }, router.RouterMode.Single); + + const examinerLoginInfo: ExaminerLoginInfo | undefined = res.examinerLoginRsp?.body; + if (!examinerLoginInfo) { + dConsole.error(ExaminerLoginTag, 'examinerLoginRsp.body is undefined'); + return; + } + examinerLoginInfo.username = this.userName; + AppStorage.setOrCreate('examinerInfo', examinerLoginInfo); + }, remainingTime); + } catch (e) { this.loadingDialog.close(); dConsole.error(ExaminerLoginTag, 'examinerLogin error: ' + e); diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 353c490..85b6121 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -10,7 +10,6 @@ import FilePhoto from './judgeSDK/utils/filePhoto'; import { CandidateData, EmptyCandidateObject } from '../mock/CandidateData'; import BoardPrePareSetPopup from './compontents/judge/BoardPrePareSetPopup'; -import LoadingPopup from './compontents/judge/LoadingPopup'; import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; import imageBtn from './compontents/imageBtn'; @@ -42,19 +41,19 @@ import { GetCurrentTime, NumberToByteArray } from '../utils/Common'; import DB from '../utils/DbSql'; import { CenterUDPBusinessInstance } from '../utils/business/CenterUdpBusiness'; import { JudgeEmitterInstance } from '../utils/business/UdpEvent'; -import errorMsgDialog from './compontents/errorMsgDialog'; import { JudgeConfig } from '../config'; import { dConsole } from '../utils/LogWorker'; import HeaderComponent from './compontents/Header'; import AvatarComponent from './UserInfo/Avatar'; import CommTextComponent from './UserInfo/CommText'; import LabelBlockComponent from './UserInfo/LabelBlock'; +import MissAnExamDialog from './UserInfo/MissAnExamDialog'; +import CarLoadingDialog from './compontents/CarLoading'; @Entry @Component struct UserInfoPage { @State pageIndex: number = 0 - @State ratio: number = 1700 / 960 @State index: number = 0 @State stepFlag: boolean = false; @State errorMsg: string = '' @@ -72,10 +71,23 @@ struct UserInfoPage { @State isSecondBoardPrePareSetPopupOpen: boolean = false @State isFirstBoardPrePareSetPopupBtnShow: boolean = false @State isBoardPrePareSetPopupShow: boolean = false - @State isLoadingPopupVisible: boolean = false; @State loadingText: string = '正在认证监管信息,请稍后...' @State sczbkf: SckType[] = [] @State currentUser: User = EmptyCandidateObject + // 缺考弹窗 + missAnExamDialogController: CustomDialogController = new CustomDialogController({ + builder: MissAnExamDialog({ + name: this.currentUser.xm, + onConfirm: () => { + this.qkFn() + } + }) + }) + // 开始考试弹窗 + startExamDialog: CustomDialogController = new CustomDialogController({ + builder: CarLoadingDialog(), + autoCancel: false + }) @State dataList: Array = [] @State list: Array = [] @State name: string = 'initName'; @@ -129,21 +141,6 @@ struct UserInfoPage { @State startExam: boolean = false @State singlePlay: boolean = false private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - private title = '' - private type = '2' - errorDialog: CustomDialogController = new CustomDialogController({ - builder: errorMsgDialog({ - title: this.title, - type: this.type, - cancel: () => { - }, - confirm: () => { - } - }), - customStyle: true, - alignment: DialogAlignment.Center, - }, - ) private filePhoto!: FilePhoto // 过程照片拍照 getPhoto = async () => { @@ -653,8 +650,6 @@ struct UserInfoPage { // await upDateTableByArray('USERLIST', []) await DB.clearTable('USER') await DB.clearTable('USERLIST') - this.type = '2' - this.errorDialog.open() this.updateTimeLimit = true let md5Message: string = CryptoJS.MD5(this.carInfo.carId! + this.carInfo.examinationRoomId! + @@ -664,7 +659,6 @@ struct UserInfoPage { try { getExaminationStudentInfo(param).then(async (res) => { dConsole.log("temp log ", JSON.stringify(res)) - this.errorDialog.close() setTimeout(() => { this.updateTimeLimit = false }, 3000) @@ -767,12 +761,10 @@ struct UserInfoPage { }) }).catch((error: BusinessError) => { this.updateTimeLimit = false - this.errorDialog.close() dConsole.log('error12error' + error) }) } catch (error) { this.updateTimeLimit = false - this.errorDialog.close() dConsole.log('error14error' + error) } } @@ -796,7 +788,6 @@ struct UserInfoPage { lsh: this.lsh } dConsole.log('carNo1111', param) - examinationStuAbsent(param).then(res => { const arr = [this.signNum || 0, 1] let tmpList: number[] = []; @@ -866,7 +857,7 @@ struct UserInfoPage { } this.currentUser.id = '1' const avPlayer = this.avPlayer; - this.isLoadingPopupVisible = true + this.startExamDialog.open() avPlayer.playAudio([`voice/监管通信中.mp3`], false, async () => { dConsole.info('surenjun', '播放结束开始考试接口调用') @@ -877,7 +868,7 @@ struct UserInfoPage { if (res.code != 1) { avPlayer.playAudio([res.code == -200 ? 'voice/photo_error.mp3' : 'voice/监管审核未通过.mp3']); - this.isLoadingPopupVisible = false + this.startExamDialog.close() this.isExamStart = false promptAction.showToast({ message: res.message, @@ -889,7 +880,7 @@ struct UserInfoPage { // await upDateTableByArray('USER', [this.currentUser]) await SqlInsertTable('USER', [this.currentUser]) this.stepFlag = false - this.isLoadingPopupVisible = false + this.startExamDialog.close() router.pushUrl({ url: 'pages/Judge', params: { @@ -1013,15 +1004,12 @@ struct UserInfoPage { // 开始考试 async beginExam(): Promise { - // const { examSubject, plateNo } = this.carInfo; - const date = new Date() - // const startHourTime = await getCurrentHourTime() const startHourTime = dayTs().format("HHmmssSSS") AppStorage.setOrCreate('startHourTime', startHourTime) const photoBase64 = await this.getPhoto(); if (photoBase64 == '') { this.ksksLimit = false - this.isLoadingPopupVisible = false + this.startExamDialog.close() return { code: -200 } } const drvexam: DrvexamType = { @@ -1032,7 +1020,7 @@ struct UserInfoPage { ksysfzmhm: this.currentUser.ksy1sfzmhm || '', ksxl: this.currentUser.xldm, zp: photoBase64, - kssj: dayTs(date).format("YYYY-MM-DD HH:mm:ss") || '', + kssj: dayTs().format("YYYY-MM-DD HH:mm:ss") || '', kchp: decodeURI(this.carInfo.plateNo || ""), Ksy2sfzmhm: this.currentUser.ksy2sfzmhm || '' } @@ -1088,11 +1076,11 @@ struct UserInfoPage { // 几个按钮公共样式 @Styles commStyle(){ - .width(220 * this.ratio) - .height(69 * this.ratio) + .width(389) + .height(122) .backgroundImage($r('app.media.button_nor')) .backgroundImageSize({ width: '100%', height: '100%' }) - .margin({ bottom: 12 * this.ratio }) + .margin({ bottom: 21 }) } build() { @@ -1117,8 +1105,8 @@ struct UserInfoPage { }) } } - .width(165 * this.ratio) - .height(85 * this.ratio) + .width(292) // 165 * 1.770833 ≈ 292.187 → 292 + .height(151) // 85 * 1.770833 ≈ 150.52 → 151 .backgroundImage(item.sfzmhm != this.currentUser.sfzmhm ? $r('app.media.userbox2') : $r('app.media.userboxbg')) .backgroundImageSize({ width: '100%', height: '100%' }) @@ -1133,26 +1121,26 @@ struct UserInfoPage { setTimeout(() => { this.currentUser = item this.currentUser.ksy2 = this.examinerLoginInfo.kgxm || "" - }, 200) - }) }) - }.width(640 * this.ratio).margin({ left: 30 * this.ratio }) + }.width(1133) // 640 * 1.770833 ≈ 1133.33 → 1133 + .margin({ left: 53 }) // 30 * 1.770833 ≈ 53.12 → 53 Image($r('app.media.dk_prev')) - .width(90 * this.ratio) - .height(70 * this.ratio) - .margin({ left: 65 * this.ratio, right: 10 * this.ratio }) + .width(159)// 90 * 1.770833 ≈ 159.37 → 159 + .height(124)// 70 * 1.770833 ≈ 123.96 → 124 + .margin({ left: 115, right: 18 })// 65→115, 10→18 .onClick(() => { - // this.avPlayer.playAudio(['button_media.wav']) this.prevClick() }) - Image($r('app.media.dk_next')).width(90 * this.ratio).height(70 * this.ratio).onClick(() => { - // this.avPlayer.playAudio(['button_media.wav']) - this.nextClick() - }) - }.margin({ top: 40 * this.ratio, bottom: 10 * this.ratio }) + Image($r('app.media.dk_next')) + .width(159)// 90→159 + .height(124)// 70→124 + .onClick(() => { + this.nextClick() + }) + }.margin({ top: 71, bottom: 18 }) // 40→71, 10→18 Flex({ justifyContent: FlexAlign.SpaceBetween }) { Row() { @@ -1186,17 +1174,17 @@ struct UserInfoPage { }) } } - .width(664 * this.ratio) - .height(339 * this.ratio) + .width(1176) // 664→1176 + .height(600) // 339→600 .backgroundImage($r('app.media.dkbg')) .backgroundImageSize({ width: '100%', height: '100%' }) - .margin({ left: 53 * this.ratio }) + .margin({ left: 94 }) // 53→94 Column() { - imageBtn({ btnWidth: 220 * this.ratio, btnHeight: 69 * this.ratio, imgSrc: $r('app.media.yydj_btn') }) - .margin({ bottom: 12 * this.ratio }) - imageBtn({ btnWidth: 220 * this.ratio, btnHeight: 69 * this.ratio, imgSrc: $r('app.media.gx_btn') }) - .margin({ bottom: 12 * this.ratio }) + imageBtn({ btnWidth: 390, btnHeight: 122, imgSrc: $r('app.media.yydj_btn') })// 220→390, 69→122 + .margin({ bottom: 21 }) // 12→21 + imageBtn({ btnWidth: 390, btnHeight: 122, imgSrc: $r('app.media.gx_btn') }) + .margin({ bottom: 21 }) .onClick(() => { if (this.isExamStart && !this.singlePlay) { return @@ -1205,23 +1193,23 @@ struct UserInfoPage { this.numCount = 0 this.getExaminationStudentInfoFn() }) - imageBtn({ btnWidth: 220 * this.ratio, btnHeight: 69 * this.ratio, imgSrc: $r('app.media.qk_btn') }) - .margin({ bottom: 12 * this.ratio }) + imageBtn({ btnWidth: 390, btnHeight: 122, imgSrc: $r('app.media.qk_btn') }) + .margin({ bottom: 21 }) .onClick(() => { - // 已开始考试不能缺考 已考过一次学员不能缺考 车上不能缺考 if (this.ksksLimit || (this.systemParam.Param352Str == '1' && this.currentUser.kssycs == '1') || this.systemParam.Param770Str == '1') { return } this.ksksLimit = true - this.qkFlag = true + // this.qkFlag = true + this.missAnExamDialogController.open() }) if (this.isBoardPrePareSetPopupOpen && (this.isSecondBoardPrePareSetPopupOpen && this.currentUser.kssycs == '2') && !this.isFirstBoardPrePareSetPopupBtnShow) { - imageBtn({ btnWidth: 220 * this.ratio, btnHeight: 69 * this.ratio, imgSrc: $r('app.media.sczb_btn') }) - .margin({ bottom: 12 * this.ratio }) + imageBtn({ btnWidth: 390, btnHeight: 122, imgSrc: $r('app.media.sczb_btn') }) + .margin({ bottom: 21 }) .onClick(async () => { if (this.systemParam.Param612Str == '1') { return @@ -1229,8 +1217,8 @@ struct UserInfoPage { await this.prePareSCZB() }) } else { - imageBtn({ btnWidth: 220 * this.ratio, btnHeight: 69 * this.ratio, imgSrc: $r('app.media.ksks_btn') }) - .margin({ bottom: 12 * this.ratio }) + imageBtn({ btnWidth: 390, btnHeight: 122, imgSrc: $r('app.media.ksks_btn') }) + .margin({ bottom: 21 }) .onClick(async () => { if (this.systemParam.Param612Str == '1') { return @@ -1242,7 +1230,6 @@ struct UserInfoPage { } }.backgroundColor("#1E1E1E").width("100%").height("100%") - if (this.showFaceCompare) { FaceCompare({ sfzh: this.currentUser.sfzmhm, @@ -1254,40 +1241,6 @@ struct UserInfoPage { lsh: AppStorage.get('lsh'), }) } - if (this.qkFlag) { - Column() { - Text('确认考生:' + this.currentUser.xm + '是否缺考') - .fontSize(28 * this.ratio) - .position({ x: 160 * this.ratio, y: 122 * this.ratio }) - Row() { - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Text(' 取 消 ').fontSize(24 * this.ratio).fontColor('#fff').width(100 * this.ratio) - } - .commStyle() - .onClick(() => { - this.ksksLimit = false - this.qkFlag = false - }) - - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Text(' 确 定 ').fontSize(24 * this.ratio).fontColor('#fff').width(100 * this.ratio) - } - .commStyle() - .onClick(() => { - // this.avPlayer.playAudio(['button_media.wav']) - this.qkFn() - }) - }.position({ y: 265 * this.ratio, x: 115 * this.ratio }) - - } - .width(660 * this.ratio) - .height(360 * this.ratio) - .position({ x: 150 * this.ratio, y: 98 * this.ratio }) - .backgroundColor('#E6E3DF') - .borderRadius(19 * this.ratio) - } - - // 上车准备弹窗 if (this.isBoardPrePareSetPopupShow) { BoardPrePareSetPopup({ closePopup: () => { @@ -1298,13 +1251,6 @@ struct UserInfoPage { } }) } - - // loading - if (this.isLoadingPopupVisible) { - LoadingPopup({ - title: this.loadingText, - }) - } } .height('100%') .width('100%') diff --git a/entry/src/main/ets/pages/UserInfo/MissAnExamDialog.ets b/entry/src/main/ets/pages/UserInfo/MissAnExamDialog.ets index 82d774b..ad67806 100644 --- a/entry/src/main/ets/pages/UserInfo/MissAnExamDialog.ets +++ b/entry/src/main/ets/pages/UserInfo/MissAnExamDialog.ets @@ -1,9 +1,48 @@ // 缺考考生弹窗 +import BtnComponent from '../compontents/Button'; @CustomDialog export default struct MissAnExamDialog { + @Prop name: string = "xxx"; private controller?: CustomDialogController; + onConfirm: () => void = () => { + }; build() { + Column() { + Text("提示信息").fontSize(26).margin({ + top: 40 + }).fontWeight(FontWeight.Bold) + Row() { + Text(`确认考生:${this.name}是否缺考?`).fontSize(28) + }.height(300).justifyContent(FlexAlign.Center).alignItems(VerticalAlign.Center) + + Row() { + BtnComponent({ + text: "取消", + }).onClick(() => { + this.controller?.close(); + }) + + BtnComponent().onClick(() => { + this.onConfirm() + }) + }.width("100%").height(100).justifyContent(FlexAlign.Center).alignItems(VerticalAlign.Center) + } + .width(1000) + .height(500) + .borderRadius(20) + .backgroundColor("#E5E3DF") + .shadow({ + radius: 30, + color: "#E7B544" + }) + } +} + +@Component +struct btnComponent { + build() { + } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/compontents/Button.ets b/entry/src/main/ets/pages/compontents/Button.ets new file mode 100644 index 0000000..5128db7 --- /dev/null +++ b/entry/src/main/ets/pages/compontents/Button.ets @@ -0,0 +1,23 @@ +@Component +export default struct BtnComponent { + @State text: string = "确认" + + build() { + Row() { + Text(this.text).fontColor("#F4EEE7").fontSize(28) + } + .backgroundImage($r("app.media.nor_btn")) + .backgroundImageSize({ + width: "100%", + height: "100%" + }) + .width(200) + .height(80) + .justifyContent(FlexAlign.Center) + .alignItems(VerticalAlign.Center) + .margin({ + left: 40, + right: 40 + }) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/compontents/CarLoading.ets b/entry/src/main/ets/pages/compontents/CarLoading.ets new file mode 100644 index 0000000..ddee98b --- /dev/null +++ b/entry/src/main/ets/pages/compontents/CarLoading.ets @@ -0,0 +1,14 @@ +@CustomDialog +export default struct CarLoadingDialog { + @State text: string = "正在认证监管信息,请稍后..." + private controller?: CustomDialogController; + + build() { + Column() { + Image($rawfile('judge/loading-car.gif')).width(250).margin({ top: 20, bottom: 20 }) + Row() { + Text(this.text).fontSize(20) + } + }.width(500).height(500).justifyContent(FlexAlign.Center).alignItems(HorizontalAlign.Center) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/compontents/Header.ets b/entry/src/main/ets/pages/compontents/Header.ets index 49c985f..1d55f46 100644 --- a/entry/src/main/ets/pages/compontents/Header.ets +++ b/entry/src/main/ets/pages/compontents/Header.ets @@ -9,6 +9,7 @@ import dayTs from '../../utils/Date' import router from '@ohos.router' import common from '@ohos.app.ability.common' +import BtnComponent from './Button' @Component export default struct HeaderComponent { @@ -133,25 +134,3 @@ struct exitDialogComponent { } } -@Component -struct BtnComponent { - @State text: string = "确认" - - build() { - Row() { - Text(this.text).fontColor("#F4EEE7").fontSize(28) - } - .backgroundImage($r("app.media.nor_btn")) - .backgroundImageSize({ - width: "100%", - height: "100%" - }) - .width(200) - .height(80) - .justifyContent(FlexAlign.Center) - .alignItems(VerticalAlign.Center) - .margin({ - left: 80 - }) - } -} \ No newline at end of file