import TopLogo from './compontents/topLogo' import { getDeviceInfo} from '../common/service/terminalService' import { registrationDeviceNo } from '../api/checkCar' import { dateFormat} from '../common/utils/tools' import deviceManager from '@ohos.distributedHardware.deviceManager' import { upDateTableByArray } from '../common/service/initable' import { voiceService } from '../common/service/voiceService' import promptAction from '@ohos.promptAction' @Entry @Component struct Index { @State ratio: number = 1700 / 960 @State ip: string = '' @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'; onPageShow() { // this.plateNo=globalThis.carInfo.plateNo deviceManager.createDeviceManager('com.oh.dts', (error, value) => { 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.ip='MAC-'+this.deviceNo globalThis.deviceNo='MAC-'+this.deviceNo }); } build() { Column() { TopLogo({outFlag:$outFlag}) Column() { Row() { Row() { Radio({ value: '0', group: 'radioGroup' }).checked(this.subType=='2'?true:false) .height(50) .width(50).onChange((isChecked: boolean) => { if(isChecked) this.subType = '2' this.ip='MAC-'+this.deviceNo globalThis.deviceNo=this.ip }) Text('网卡').fontSize(34 * globalThis.ratio).fontColor('#FFE0B2').margin({ right: 98.5 * globalThis.ratio }) } Row() { Radio({ value: '1', group: 'radioGroup' }).checked(this.subType=='3'?true:false) .height(50) .width(50).onChange((isChecked: boolean) => { if(isChecked) this.subType = '3' this.ip='DISK-'+this.deviceNo globalThis.deviceNo=this.ip // this.ip = ip }) Text('硬盘').fontSize(34 * globalThis.ratio).fontColor('#FFE0B2').margin({ right: 83 * globalThis.ratio }) } }.margin({ top: 35 * globalThis.ratio }) Row() { Column(){ Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { Text(this.ip).fontColor('#fff') .fontSize(33.6 * globalThis.ratio) } .width('100%') .height('100%') .padding({ left: 30 * globalThis.ratio, right: 30 * globalThis.ratio }) } .backgroundImage($r('app.media.xk')) .backgroundImageSize({ width: '100%', height: '100%' }) .width(610 * globalThis.ratio) .height(108 * globalThis.ratio) .margin({ left: 22 * globalThis.ratio }) }.margin({ top: 30 * globalThis.ratio }) } .width(720 * globalThis.ratio) .height(310 * globalThis.ratio) .backgroundColor('#333230') .margin({ top: 37 * globalThis.ratio }) .borderRadius(19 * globalThis.ratio) Image($r('app.media.zhuce_nor')).width(320 * globalThis.ratio).height(92 * globalThis.ratio).margin({ top: 30 * globalThis.ratio }).onClick(()=>{ this.registrationDeviceNoFn() }) } .height('100%') .width('100%') .backgroundImage($r('app.media.bg')) .backgroundImageSize({ width: '100%', height: '100%' }) } outClick(){ } registrationDeviceNoFn(){ const date=new Date() const param={ time: dateFormat(date), deviceName:this.ip, type:'1' } globalThis.deviceNo=this.ip upDateTableByArray('DeviceInfoTable',[{deviceId:this.ip}]) registrationDeviceNo(param).then(res=>{ if(res.registrationDeviceNoRsp.head.resultCode=='0'){ promptAction.showToast({ message: decodeURIComponent(res.registrationDeviceNoRsp.head.resultMessage), duration: 3000 }); } }) } }