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