From 636ba1fb1524fa2ba3e363998b2bea98cd799daf Mon Sep 17 00:00:00 2001 From: wangzhongjie Date: Tue, 15 Apr 2025 10:16:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A6=96=E9=A1=B5=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/entryability/EntryAbility.ets | 6 +++--- entry/src/main/ets/model/api.ets | 4 ++-- entry/src/main/ets/pages/Index.ets | 7 ++++--- entry/src/main/ets/pages/Index/BottomMessage.ets | 12 ++++++------ entry/src/main/ets/pages/Index/utils.ets | 10 ++++++---- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index ea4373b..b4d64a4 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -53,8 +53,8 @@ export default class EntryAbility extends UIAbility { AppStorage.setOrCreate('deviceNo', "") //设备号 AppStorage.setOrCreate('baseInfo', { hasAuth: false, - version: GlobalConfig.version.jn.km3[0] || "", - judgeVersion: GlobalConfig.version.jn.km3[1] || "", + version: GlobalConfig.version.sz.km2[0] || "", + judgeVersion: GlobalConfig.version.sz.km2[1] || "", tcpSendNum: 0, videoVersion: '1.0', ratio: width / height, //适配比例 @@ -65,7 +65,7 @@ export default class EntryAbility extends UIAbility { AppStorage.setOrCreate('windowClass', windowClass) await windowClass.setWindowLayoutFullScreen(true) - await windowClass.setWindowSystemBarEnable([]) //全屏 + // await windowClass.setWindowSystemBarEnable([]) //全屏 windowStage.loadContent('pages/Index', (err, data) => { if (err.code) { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); diff --git a/entry/src/main/ets/model/api.ets b/entry/src/main/ets/model/api.ets index d3a1d4e..0ccb3c9 100644 --- a/entry/src/main/ets/model/api.ets +++ b/entry/src/main/ets/model/api.ets @@ -1,4 +1,4 @@ -import { DrvexamType } from '.'; +import { CarInfoType, DrvexamType } from '.'; // -----new----- export interface ApiResponseType { @@ -85,7 +85,7 @@ interface ObtainCarExamInfoRsp { body?: ObtainCarExamInfoRspBody } -export interface ObtainCarExamInfoRspBody { +export interface ObtainCarExamInfoRspBody extends CarInfoType { carId: string; carIp: string; carNo: string; diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 3b50ea1..3d0b05c 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -186,14 +186,14 @@ struct Index { async initParams() { console.log("test1111") ObtainUdpBusinessInstance.init(); - await GetCarInfo() + await GetDeviceInfo(this.context) + this.carInfo = await GetCarInfo() CenterUDPBusinessInstance.init(); CenterUDPBusinessInstance.onMsg((data: centerCallBackMsgType) => { if (data.id == 32) { AppStorage.setOrCreate('signNum', data.body[1]) } },) - await GetDeviceInfo(this.context) this.carInfo = AppStorage.get('carInfo')! this.deviceId = this.carInfo.carNo || "" await SetCurrentTime() @@ -225,11 +225,12 @@ struct Index { this.onlineExam() } }) + BottomMessageComponent({ version: this.baseInfo.version, judgeVersion: this.baseInfo.judgeVersion, hasAuth: this.baseInfo.hasAuth, - examCarNumber: this.baseInfo.deviceNo, + examCarNumber: this.deviceId, versionClick: () => { this.singlePlay = !this.singlePlay AppStorage.setOrCreate('singlePlay', this.singlePlay) diff --git a/entry/src/main/ets/pages/Index/BottomMessage.ets b/entry/src/main/ets/pages/Index/BottomMessage.ets index 433fe70..a2ebe73 100644 --- a/entry/src/main/ets/pages/Index/BottomMessage.ets +++ b/entry/src/main/ets/pages/Index/BottomMessage.ets @@ -1,9 +1,9 @@ @Component export default struct BottomMessageComponent { - @State version: string = "" - @State judgeVersion: string = "" - @State hasAuth: boolean = false - @State examCarNumber: string = "" + @Prop version: string = "" + @Prop judgeVersion: string = "" + @Prop hasAuth: boolean + @Prop examCarNumber: string versionClick?: () => void build() { @@ -16,7 +16,7 @@ export default struct BottomMessageComponent { Column() { Text('V外壳:' + this.version).textCommonStyle() Text('V评判:' + this.judgeVersion).textCommonStyle() - Text("授权信息:" + this.hasAuth ? "已授权" : "未授权").textCommonStyle() + Text('授权信息:' + (this.hasAuth ? "已授权" : "未授权")).textCommonStyle() }.gesture( GestureGroup(GestureMode.Exclusive, TapGesture({ count: 2 }) @@ -27,7 +27,7 @@ export default struct BottomMessageComponent { ) Text("考车号: " + this.examCarNumber).textCommonStyle() - } + }.width("100%") } } diff --git a/entry/src/main/ets/pages/Index/utils.ets b/entry/src/main/ets/pages/Index/utils.ets index 36eeea0..dc6a9aa 100644 --- a/entry/src/main/ets/pages/Index/utils.ets +++ b/entry/src/main/ets/pages/Index/utils.ets @@ -5,6 +5,7 @@ import { ApiResponseType, BaseInfoType, CarConfigurationParamsType, + CarInfoType, ObtainCarExamInfoParams, ObtainCarExamInfoRspBody, TimeSynchronizationParams, @@ -24,23 +25,22 @@ export async function GetDeviceInfo(context: common.UIAbilityContext): Promise { const fileUtil = new FileUtils(context) const data = await fileUtil.readFile(GlobalConfig.commonFileWriteAddress + '/config/deviceNo.txt'); - if (data === '' || data === undefined) { + if (!data) { Prompt.showToast({ message: "请先进行设备注册!", duration: 3000 }) - AppStorage.setOrCreate('type', 1) - AppStorage.setOrCreate('title', '请先进行设备注册') resolve("") } else { const fileData: CarConfigurationParamsType = JSON.parse(data) + console.log("获取设备号", fileData.deviceName) AppStorage.setOrCreate('deviceNo', fileData.deviceName) resolve(fileData.deviceName) } }) } -export async function GetCarInfo() { +export async function GetCarInfo(): Promise { let date = new Date(); let params: ObtainCarExamInfoParams = { time: dayTs(date).format("YYYY-MM-DD HH:mm:ss"), @@ -52,7 +52,9 @@ export async function GetCarInfo() { const carInfo: ObtainCarExamInfoRspBody = res?.obtainCarExamInfoRsp?.body! carInfo.plateNo = decodeURIComponent(carInfo.plateNo) AppStorage.setOrCreate('carInfo', carInfo) + return carInfo } + return {} } // 获取授权