52 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| // @ts-nocheck
 | |
| import { obtainCarExamInfo } from '../../api/index'
 | |
| import { dateFormat } from '../utils/tools'
 | |
| import router from '@ohos.router'
 | |
| import promptAction from '@ohos.promptAction'
 | |
| import { getSyncData } from '../../common/service/initable'
 | |
| import { GlobalConfig } from '../../config/index'
 | |
| import FileUtil from '../../common/utils/File'
 | |
| 
 | |
| //获取设备信息
 | |
| export async function getDeviceInfo(context) {
 | |
|   return new Promise(async (resolve, reject) => {
 | |
|     const fileUtil = new FileUtil(context)
 | |
|     const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/deviceNo.txt');
 | |
|     if (data === '' || data === undefined) {
 | |
|       promptAction.showToast({
 | |
|         message: `请先进行设备注册`,
 | |
|         duration: 3000
 | |
|       });
 | |
|       globalThis.type='1'
 | |
|       globalThis.title=decodeURIComponent('请先进行设备注册')
 | |
|       globalThis.errorDialog.open()
 | |
|       resolve('')
 | |
|     } else {
 | |
|       const fileData=JSON.parse(data)
 | |
|       globalThis.deviceNo = fileData.deviceName
 | |
|       console.log('globalThis.deviceNo', globalThis.deviceNo)
 | |
|       // getCarInfo()
 | |
|       resolve(fileData.deviceName)
 | |
|     }
 | |
|   })
 | |
| }
 | |
| 
 | |
| //获取考车信息
 | |
| export async function getCarInfo() {
 | |
|   let date = new Date();
 | |
|   console.log('globalThis.carInfo2222', globalThis.deviceNo)
 | |
| 
 | |
|   let params = { time: dateFormat(date), deviceNo: globalThis.deviceNo };
 | |
|   let res: any = await obtainCarExamInfo(params)
 | |
|   if (!res?.obtainCarExamInfoRsp?.body) {
 | |
|     // router.pushUrl({
 | |
|     //     url: 'pages/Register',
 | |
|     // }, router.RouterMode.Single);
 | |
|   } else {
 | |
|     globalThis.carInfo = res.obtainCarExamInfoRsp.body
 | |
|     console.log('globalThis.carInfo2222', JSON.stringify(res));
 | |
|     // globalThis.carInfo.carId=res.obtainCarExamInfoRsp.body.carId
 | |
|     globalThis.carInfo.plateNo = decodeURIComponent(globalThis.carInfo.plateNo)
 | |
|   }
 | |
|   return res
 | |
| } |