Compare commits
2 Commits
3e509779f1
...
abc48bd774
| Author | SHA1 | Date | |
|---|---|---|---|
| abc48bd774 | |||
| 43a673fa4f |
@ -1,44 +1,47 @@
|
||||
// @ts-nocheck
|
||||
import { obtainCarExamInfo} from '../../api/index'
|
||||
import { dateFormat} from '../utils/tools'
|
||||
import { obtainCarExamInfo } from '../../api/index'
|
||||
import { dateFormat } from '../utils/tools'
|
||||
import router from '@ohos.router'
|
||||
import { getSyncData } from '../../common/service/initable'
|
||||
import { GlobalConfig } from '../../config/index'
|
||||
import FileUtil from '../../common/utils/File'
|
||||
|
||||
//获取设备信息
|
||||
export async function getDeviceInfo() {
|
||||
// globalThis.deviceNo = '153216400880'; //科目三设备
|
||||
globalThis.deviceNo = '150667400235'; //科目三设备
|
||||
|
||||
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('')
|
||||
}
|
||||
})
|
||||
})
|
||||
export async function getDeviceInfo(context) {
|
||||
// globalThis.deviceNo = '153216400880'; //科目三设备
|
||||
globalThis.deviceNo = '150667400235'; //科目三设备
|
||||
return
|
||||
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) {
|
||||
router.pushUrl({
|
||||
url: 'pages/Register',
|
||||
}, router.RouterMode.Single);
|
||||
resolve('')
|
||||
} else {
|
||||
const fileData=JSON.parse(data)
|
||||
globalThis.deviceNo = fileData.deviceName
|
||||
getCarInfo()
|
||||
resolve(fileData.deviceName)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//获取考车信息
|
||||
export async function getCarInfo() {
|
||||
let date = new Date();
|
||||
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.carInfo',JSON.stringify(globalThis.carInfo));
|
||||
// globalThis.carInfo.carId=res.obtainCarExamInfoRsp.body.carId
|
||||
globalThis.carInfo.plateNo = decodeURIComponent(globalThis.carInfo.plateNo)
|
||||
}
|
||||
return res
|
||||
let date = new Date();
|
||||
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.carInfo', JSON.stringify(globalThis.carInfo));
|
||||
// globalThis.carInfo.carId=res.obtainCarExamInfoRsp.body.carId
|
||||
globalThis.carInfo.plateNo = decodeURIComponent(globalThis.carInfo.plateNo)
|
||||
}
|
||||
return res
|
||||
}
|
||||
@ -10,5 +10,5 @@ export const GlobalConfig={
|
||||
comoonfileWriteAddress:'/mnt/hmdfs/100/account/device_view/local/files',
|
||||
picSavePath:'/storage/cloud/100/files/Photo/',
|
||||
videoSavePath:'/storage/cloud/100/files/Videos/',
|
||||
host:'http://172.37.55.191:8082'
|
||||
host:'http://172.37.55.1912:8082'
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ struct Index {
|
||||
)
|
||||
)
|
||||
|
||||
Text('考车号:' + globalThis.deviceNo)
|
||||
Text('考车号:' + this.deviceId)
|
||||
.fontColor('#CCAE7A')
|
||||
.fontSize(22 * globalThis.ratio)
|
||||
.margin({ right: 24 })
|
||||
@ -212,7 +212,6 @@ struct Index {
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
globalThis.ratio = 1700 / 960
|
||||
this.angle = 0
|
||||
this.loading = false
|
||||
this.vocObj = new voiceService(async (status, val, next) => {
|
||||
@ -338,13 +337,14 @@ struct Index {
|
||||
|
||||
async initParams() {
|
||||
this.loading = false
|
||||
await getDeviceInfo()
|
||||
getCarInfo()
|
||||
this.deviceId=await getDeviceInfo(this.context) || ''
|
||||
await getCarInfo()
|
||||
await setCurrentTime();
|
||||
this.carNum = globalThis.carInfo.plateNo;
|
||||
this.version = globalThis.version;
|
||||
this.hasAuth = globalThis.hasAuth;
|
||||
initJudgeUdp()
|
||||
console.log('deviceIddeviceId',globalThis.deviceNo,this.deviceNo)
|
||||
//下载模型
|
||||
// await this.getModel()
|
||||
// const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]
|
||||
|
||||
@ -4,6 +4,8 @@ import { dateFormat } from '../common/utils/tools'
|
||||
import deviceManager from '@ohos.distributedHardware.deviceManager'
|
||||
import { upDateTableByArray } from '../common/service/initable'
|
||||
import promptAction from '@ohos.promptAction'
|
||||
import FileUtil from '../common/utils/File'
|
||||
import common from '@ohos.app.ability.common';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
@ -17,6 +19,7 @@ export default struct Index {
|
||||
@State plateNo: string = ''
|
||||
@State @Watch('outClick') outFlag: boolean = false;
|
||||
@State subType: string = '2';
|
||||
private context = getContext(this) as common.UIAbilityContext;
|
||||
|
||||
onPageShow() {
|
||||
// this.plateNo=globalThis.carInfo.plateNo
|
||||
@ -111,15 +114,19 @@ export default struct Index {
|
||||
outClick() {
|
||||
}
|
||||
|
||||
registrationDeviceNoFn() {
|
||||
async registrationDeviceNoFn() {
|
||||
const date = new Date()
|
||||
const param = {
|
||||
time: dateFormat(date),
|
||||
deviceName: this.ip,
|
||||
type: '1'
|
||||
}
|
||||
const fileUtil = new FileUtil(this.context)
|
||||
const folderPath = await fileUtil.initFolder(`/config`);
|
||||
fileUtil.addFile(`${folderPath}/deviceNo.txt`, JSON.stringify(param))
|
||||
globalThis.deviceNo = this.ip
|
||||
upDateTableByArray('DeviceInfoTable', [{ deviceId: this.ip }])
|
||||
console.log('globalThis.deviceNo',globalThis.deviceNo)
|
||||
// upDateTableByArray('DeviceInfoTable', [{ deviceId: this.ip }])
|
||||
registrationDeviceNo(param).then(res => {
|
||||
if (res.registrationDeviceNoRsp.head.resultCode == '0') {
|
||||
promptAction.showToast({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user