subject-two/entry/src/main/ets/common/service/terminalService.ts

44 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-01-05 11:11:15 +08:00
// @ts-nocheck
import { obtainCarExamInfo} from '../../api/index'
import { dateFormat} from '../utils/tools'
2024-03-12 15:32:48 +08:00
import router from '@ohos.router'
import { getSyncData } from '../../common/service/initable'
2024-01-05 11:11:15 +08:00
//获取设备信息
export async function getDeviceInfo() {
2024-07-01 12:36:46 +08:00
// globalThis.deviceNo = '153216400880'; //科目三设备
globalThis.deviceNo = '150667400235'; //科目三设备
2024-06-04 11:30:44 +08:00
2024-03-12 15:32:48 +08:00
return new Promise((resolve, reject) => {
getSyncData('DeviceInfoTable').then((result: Array<any>) => {
if (result.length) {
globalThis.deviceNo = result[0].deviceId
getCarInfo()
resolve(result[0].deviceId)
} else {
// router.pushUrl({
// url: 'pages/Register',
// }, router.RouterMode.Single);
resolve('')
}
})
})
2024-01-05 11:11:15 +08:00
}
//获取考车信息
export async function getCarInfo() {
let date = new Date();
let params = { time: dateFormat(date), deviceNo: globalThis.deviceNo };
let res:any = await obtainCarExamInfo(params)
2024-03-12 15:32:48 +08:00
if(!res?.obtainCarExamInfoRsp?.body){
2024-05-09 13:42:56 +08:00
// router.pushUrl({
// url: 'pages/Register',
// }, router.RouterMode.Single);
2024-01-05 11:11:15 +08:00
}else {
globalThis.carInfo=res.obtainCarExamInfoRsp.body
2024-05-27 17:25:20 +08:00
console.log('globalThis.carInfo',JSON.stringify(globalThis.carInfo));
2024-01-05 11:11:15 +08:00
// globalThis.carInfo.carId=res.obtainCarExamInfoRsp.body.carId
globalThis.carInfo.plateNo = decodeURIComponent(globalThis.carInfo.plateNo)
}
return res
}