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