fix: 首页问题修复
This commit is contained in:
		
							parent
							
								
									b1dfddda46
								
							
						
					
					
						commit
						636ba1fb15
					
				| @ -53,8 +53,8 @@ export default class EntryAbility extends UIAbility { | |||||||
|     AppStorage.setOrCreate<string>('deviceNo', "") //设备号 |     AppStorage.setOrCreate<string>('deviceNo', "") //设备号 | ||||||
|     AppStorage.setOrCreate<BaseInfoType>('baseInfo', { |     AppStorage.setOrCreate<BaseInfoType>('baseInfo', { | ||||||
|       hasAuth: false, |       hasAuth: false, | ||||||
|       version: GlobalConfig.version.jn.km3[0] || "", |       version: GlobalConfig.version.sz.km2[0] || "", | ||||||
|       judgeVersion: GlobalConfig.version.jn.km3[1] || "", |       judgeVersion: GlobalConfig.version.sz.km2[1] || "", | ||||||
|       tcpSendNum: 0, |       tcpSendNum: 0, | ||||||
|       videoVersion: '1.0', |       videoVersion: '1.0', | ||||||
|       ratio: width / height, //适配比例 |       ratio: width / height, //适配比例 | ||||||
| @ -65,7 +65,7 @@ export default class EntryAbility extends UIAbility { | |||||||
| 
 | 
 | ||||||
|     AppStorage.setOrCreate('windowClass', windowClass) |     AppStorage.setOrCreate('windowClass', windowClass) | ||||||
|     await windowClass.setWindowLayoutFullScreen(true) |     await windowClass.setWindowLayoutFullScreen(true) | ||||||
|     await windowClass.setWindowSystemBarEnable([]) //全屏 |     // await windowClass.setWindowSystemBarEnable([]) //全屏 | ||||||
|     windowStage.loadContent('pages/Index', (err, data) => { |     windowStage.loadContent('pages/Index', (err, data) => { | ||||||
|       if (err.code) { |       if (err.code) { | ||||||
|         hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); |         hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import { DrvexamType } from '.'; | import { CarInfoType, DrvexamType } from '.'; | ||||||
| 
 | 
 | ||||||
| // -----new----- | // -----new----- | ||||||
| export interface ApiResponseType { | export interface ApiResponseType { | ||||||
| @ -85,7 +85,7 @@ interface ObtainCarExamInfoRsp { | |||||||
|   body?: ObtainCarExamInfoRspBody |   body?: ObtainCarExamInfoRspBody | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface ObtainCarExamInfoRspBody { | export interface ObtainCarExamInfoRspBody extends CarInfoType { | ||||||
|   carId: string; |   carId: string; | ||||||
|   carIp: string; |   carIp: string; | ||||||
|   carNo: string; |   carNo: string; | ||||||
|  | |||||||
| @ -186,14 +186,14 @@ struct Index { | |||||||
|   async initParams() { |   async initParams() { | ||||||
|     console.log("test1111") |     console.log("test1111") | ||||||
|     ObtainUdpBusinessInstance.init(); |     ObtainUdpBusinessInstance.init(); | ||||||
|     await GetCarInfo() |     await GetDeviceInfo(this.context) | ||||||
|  |     this.carInfo = await GetCarInfo() | ||||||
|     CenterUDPBusinessInstance.init(); |     CenterUDPBusinessInstance.init(); | ||||||
|     CenterUDPBusinessInstance.onMsg((data: centerCallBackMsgType) => { |     CenterUDPBusinessInstance.onMsg((data: centerCallBackMsgType) => { | ||||||
|       if (data.id == 32) { |       if (data.id == 32) { | ||||||
|         AppStorage.setOrCreate('signNum', data.body[1]) |         AppStorage.setOrCreate('signNum', data.body[1]) | ||||||
|       } |       } | ||||||
|     },) |     },) | ||||||
|     await GetDeviceInfo(this.context) |  | ||||||
|     this.carInfo = AppStorage.get<CarInfoType>('carInfo')! |     this.carInfo = AppStorage.get<CarInfoType>('carInfo')! | ||||||
|     this.deviceId = this.carInfo.carNo || "" |     this.deviceId = this.carInfo.carNo || "" | ||||||
|     await SetCurrentTime() |     await SetCurrentTime() | ||||||
| @ -225,11 +225,12 @@ struct Index { | |||||||
|           this.onlineExam() |           this.onlineExam() | ||||||
|         } |         } | ||||||
|       }) |       }) | ||||||
|  |    | ||||||
|       BottomMessageComponent({ |       BottomMessageComponent({ | ||||||
|         version: this.baseInfo.version, |         version: this.baseInfo.version, | ||||||
|         judgeVersion: this.baseInfo.judgeVersion, |         judgeVersion: this.baseInfo.judgeVersion, | ||||||
|         hasAuth: this.baseInfo.hasAuth, |         hasAuth: this.baseInfo.hasAuth, | ||||||
|         examCarNumber: this.baseInfo.deviceNo, |         examCarNumber: this.deviceId, | ||||||
|         versionClick: () => { |         versionClick: () => { | ||||||
|           this.singlePlay = !this.singlePlay |           this.singlePlay = !this.singlePlay | ||||||
|           AppStorage.setOrCreate('singlePlay', this.singlePlay) |           AppStorage.setOrCreate('singlePlay', this.singlePlay) | ||||||
|  | |||||||
| @ -1,9 +1,9 @@ | |||||||
| @Component | @Component | ||||||
| export default struct BottomMessageComponent { | export default struct BottomMessageComponent { | ||||||
|   @State version: string = "" |   @Prop version: string = "" | ||||||
|   @State judgeVersion: string = "" |   @Prop judgeVersion: string = "" | ||||||
|   @State hasAuth: boolean = false |   @Prop hasAuth: boolean | ||||||
|   @State examCarNumber: string = "" |   @Prop examCarNumber: string | ||||||
|   versionClick?: () => void |   versionClick?: () => void | ||||||
| 
 | 
 | ||||||
|   build() { |   build() { | ||||||
| @ -16,7 +16,7 @@ export default struct BottomMessageComponent { | |||||||
|       Column() { |       Column() { | ||||||
|         Text('V外壳:' + this.version).textCommonStyle() |         Text('V外壳:' + this.version).textCommonStyle() | ||||||
|         Text('V评判:' + this.judgeVersion).textCommonStyle() |         Text('V评判:' + this.judgeVersion).textCommonStyle() | ||||||
|         Text("授权信息:" + this.hasAuth ? "已授权" : "未授权").textCommonStyle() |         Text('授权信息:' + (this.hasAuth ? "已授权" : "未授权")).textCommonStyle() | ||||||
|       }.gesture( |       }.gesture( | ||||||
|         GestureGroup(GestureMode.Exclusive, |         GestureGroup(GestureMode.Exclusive, | ||||||
|           TapGesture({ count: 2 }) |           TapGesture({ count: 2 }) | ||||||
| @ -27,7 +27,7 @@ export default struct BottomMessageComponent { | |||||||
|       ) |       ) | ||||||
| 
 | 
 | ||||||
|       Text("考车号: " + this.examCarNumber).textCommonStyle() |       Text("考车号: " + this.examCarNumber).textCommonStyle() | ||||||
|     } |     }.width("100%") | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -5,6 +5,7 @@ import { | |||||||
|   ApiResponseType, |   ApiResponseType, | ||||||
|   BaseInfoType, |   BaseInfoType, | ||||||
|   CarConfigurationParamsType, |   CarConfigurationParamsType, | ||||||
|  |   CarInfoType, | ||||||
|   ObtainCarExamInfoParams, |   ObtainCarExamInfoParams, | ||||||
|   ObtainCarExamInfoRspBody, |   ObtainCarExamInfoRspBody, | ||||||
|   TimeSynchronizationParams, |   TimeSynchronizationParams, | ||||||
| @ -24,23 +25,22 @@ export async function GetDeviceInfo(context: common.UIAbilityContext): Promise<s | |||||||
|   return new Promise(async (resolve, reject) => { |   return new Promise(async (resolve, reject) => { | ||||||
|     const fileUtil = new FileUtils(context) |     const fileUtil = new FileUtils(context) | ||||||
|     const data = await fileUtil.readFile(GlobalConfig.commonFileWriteAddress + '/config/deviceNo.txt'); |     const data = await fileUtil.readFile(GlobalConfig.commonFileWriteAddress + '/config/deviceNo.txt'); | ||||||
|     if (data === '' || data === undefined) { |     if (!data) { | ||||||
|       Prompt.showToast({ |       Prompt.showToast({ | ||||||
|         message: "请先进行设备注册!", |         message: "请先进行设备注册!", | ||||||
|         duration: 3000 |         duration: 3000 | ||||||
|       }) |       }) | ||||||
|       AppStorage.setOrCreate('type', 1) |  | ||||||
|       AppStorage.setOrCreate('title', '请先进行设备注册') |  | ||||||
|       resolve("") |       resolve("") | ||||||
|     } else { |     } else { | ||||||
|       const fileData: CarConfigurationParamsType = JSON.parse(data) |       const fileData: CarConfigurationParamsType = JSON.parse(data) | ||||||
|  |       console.log("获取设备号", fileData.deviceName) | ||||||
|       AppStorage.setOrCreate('deviceNo', fileData.deviceName) |       AppStorage.setOrCreate('deviceNo', fileData.deviceName) | ||||||
|       resolve(fileData.deviceName) |       resolve(fileData.deviceName) | ||||||
|     } |     } | ||||||
|   }) |   }) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function GetCarInfo() { | export async function GetCarInfo(): Promise<CarInfoType> { | ||||||
|   let date = new Date(); |   let date = new Date(); | ||||||
|   let params: ObtainCarExamInfoParams = { |   let params: ObtainCarExamInfoParams = { | ||||||
|     time: dayTs(date).format("YYYY-MM-DD HH:mm:ss"), |     time: dayTs(date).format("YYYY-MM-DD HH:mm:ss"), | ||||||
| @ -52,7 +52,9 @@ export async function GetCarInfo() { | |||||||
|     const carInfo: ObtainCarExamInfoRspBody = res?.obtainCarExamInfoRsp?.body! |     const carInfo: ObtainCarExamInfoRspBody = res?.obtainCarExamInfoRsp?.body! | ||||||
|     carInfo.plateNo = decodeURIComponent(carInfo.plateNo) |     carInfo.plateNo = decodeURIComponent(carInfo.plateNo) | ||||||
|     AppStorage.setOrCreate('carInfo', carInfo) |     AppStorage.setOrCreate('carInfo', carInfo) | ||||||
|  |     return carInfo | ||||||
|   } |   } | ||||||
|  |   return {} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // 获取授权 | // 获取授权 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user