diff --git a/entry/src/main/ets/model/Register.ets b/entry/src/main/ets/model/Register.ets index e69de29b..44b0fb29 100644 --- a/entry/src/main/ets/model/Register.ets +++ b/entry/src/main/ets/model/Register.ets @@ -0,0 +1,5 @@ +export interface DeviceParamType { + time: string; + deviceName: string; + type: string; +} \ No newline at end of file diff --git a/entry/src/main/ets/model/index.ets b/entry/src/main/ets/model/index.ets index 47b97a5b..5a0770be 100644 --- a/entry/src/main/ets/model/index.ets +++ b/entry/src/main/ets/model/index.ets @@ -4,4 +4,6 @@ export * from "./Table" export * from "./Common" -export * from "./Judge" \ No newline at end of file +export * from "./Judge" + +export * from "./Register" \ No newline at end of file diff --git a/entry/src/main/ets/pages/Register.ets b/entry/src/main/ets/pages/Register.ets index 65b0afe9..fbfb4a36 100644 --- a/entry/src/main/ets/pages/Register.ets +++ b/entry/src/main/ets/pages/Register.ets @@ -5,6 +5,7 @@ import deviceManager from '@ohos.distributedHardware.deviceManager' import promptAction from '@ohos.promptAction' import FileUtil from '../common/utils/File' import common from '@ohos.app.ability.common' +import { DeviceParamType } from '../model' @Entry @Component @@ -14,7 +15,6 @@ struct Index { @State deviceNo: string = '' @State deviceName: string = '' @State checked: string = '0' - @State net: any = '' @State plateNo: string = '' @State @Watch('outClick') outFlag: boolean = false; @State subType: string = '2'; @@ -24,14 +24,13 @@ struct Index { // this.plateNo=globalThis.carInfo.plateNo console.log('createDeviceManagerstart') try { - deviceManager.createDeviceManager('com.oh.dts', (error, value) => { + deviceManager.createDeviceManager('com.oh.dts', (error: string, value: deviceManager.DeviceManager) => { if (error) { console.error('createDeviceManager failed.'); return; } - let dvMgrObj = value; - this.deviceName = dvMgrObj.getLocalDeviceInfoSync().deviceName - this.deviceNo = dvMgrObj.getLocalDeviceInfoSync().deviceId.substring(0, 10).toUpperCase() + this.deviceName = value.getLocalDeviceInfoSync().deviceName + this.deviceNo = value.getLocalDeviceInfoSync().deviceId.substring(0, 10).toUpperCase() this.ip = 'MAC-' + this.deviceNo globalThis.deviceNo = 'MAC-' + this.deviceNo }); @@ -117,7 +116,7 @@ struct Index { async registrationDeviceNoFn() { const date = new Date() - const param = { + const param: DeviceParamType = { time: dateFormat(date), deviceName: this.ip, type: '1' @@ -128,11 +127,9 @@ struct Index { globalThis.deviceNo = this.ip console.log('globalThis.deviceNo', globalThis.deviceNo) // upDateTableByArray('DeviceInfoTable', [{ deviceId: this.ip }]) - registrationDeviceNo(param).then(res => { - // @ts-ignore + registrationDeviceNo(param).then((res: ESObject) => { if (res.registrationDeviceNoRsp.head.resultCode == '0') { promptAction.showToast({ - // @ts-ignore message: decodeURIComponent(res.registrationDeviceNoRsp.head.resultMessage), duration: 3000 });