233 lines
7.3 KiB
Plaintext
Raw Normal View History

2024-01-05 11:11:15 +08:00
// @ts-nocheck
import common from '@ohos.app.ability.common';
import router from '@ohos.router'
import { getCarInfo, getDeviceInfo } from '../common/service/terminalService'
import { setCurrentTime } from '../common/service/timeService'
2024-02-23 15:23:48 +08:00
import {string2Bytes} from '../common/utils/tools'
2024-01-05 11:11:15 +08:00
import {
getEsCarModel,
} from '../common/service/initable'
2024-02-22 10:40:35 +08:00
2024-01-05 11:11:15 +08:00
import { getUDP, getUDP2 } from '../common/utils/GlobleUdp'
import {initJudgeUdp} from '../common/utils/UdpJudge'
2024-01-31 14:42:14 +08:00
import { getTCP } from '../common/utils/GlobleTcp'
import TcpClient from '../common/utils/TcpClient';
2024-02-23 16:08:37 +08:00
import testNapi from '@ohos.hiserialsdk'
2024-02-22 10:40:35 +08:00
import {setliushuiNum,getSingleCenterTable,getDoubleCeneterTable} from '../common/service/indexService'
2024-01-05 11:11:15 +08:00
@Entry
@Component
struct Index {
@State carNum: string = ''
@State version: string = ''
@State url: string = ''
@State hasAuth: boolean = false;
@State isSingle: boolean = false;
@State deviceId: string = '';
private vocObj = null;
@State angle: number = 0
@State ratio: number = 850 / 960
@State loading: boolean = true
@State fd: number = -1;
private context = getContext(this) as common.UIAbilityContext;
2024-01-31 14:42:14 +08:00
2024-01-05 11:11:15 +08:00
build() {
Column() {
Column() {
Row() {
Image($r('app.media.logo')).width('30%').height('5.5%').margin({ left: 24 })
Row() {
Image($r('app.media.btn_setting')).width('16.7%').height('12.2%')
.onClick(async () => {
if (this.loading) {
return
}
router.pushUrl({
url: 'pages/Settings',
}, router.RouterMode.Single);
})
Image($r('app.media.btn_back')).width('14.4%').height('12.2%')
.onClick(() => {
if (this.loading) {
return
}
router.back()
})
}
}
.width('100%')
.justifyContent(FlexAlign.SpaceBetween)
}
Column() {
Row() {
if (!this.isSingle) {
2024-02-23 15:23:48 +08:00
Image($r('app.media.index_lw')).width('30.5%').height('74%').onClick(async() => {
2024-01-05 11:11:15 +08:00
if (this.loading) {
return
}
this.loading = true
setTimeout(() => {
2024-02-22 10:40:35 +08:00
this.angle = 360
2024-01-05 11:11:15 +08:00
}, 1000)
2024-02-22 10:40:35 +08:00
this.angle = 0
//mode为3双中心下载表
2024-01-31 14:35:16 +08:00
if(globalThis.timeInfo.mode=='3'){
2024-02-23 15:23:48 +08:00
await getDoubleCeneterTable()
2024-01-31 14:35:16 +08:00
}else{
2024-02-23 15:23:48 +08:00
await getSingleCenterTable()
2024-01-31 14:35:16 +08:00
}
2024-02-23 15:23:48 +08:00
this.loading=false
2024-02-22 10:40:35 +08:00
2024-01-05 11:11:15 +08:00
})
}
if (this.isSingle) {
Image($r('app.media.index_dj')).width('30.5%').height('74%').onClick(() => {
if (this.loading) {
return
}
router.pushUrl({
2024-02-22 17:33:10 +08:00
url: 'pages/UserInfo',
2024-01-05 11:11:15 +08:00
}, router.RouterMode.Single);
})
}
Image($r('app.media.index_zj')).width('30.5%').height('74%').onClick(() => {
if (this.loading) {
return
}
router.pushUrl({
2024-02-22 17:33:10 +08:00
url: 'pages/CarCheck'
2024-01-05 11:11:15 +08:00
}, router.RouterMode.Single);
})
}
.width('100%')
.justifyContent(FlexAlign.SpaceAround)
}
Column() {
Row() {
Column() {
Text('V ' + globalThis.version)
.fontColor('#CCAE7A')
.fontSize(22 * this.ratio)
.width('30%')
.margin({ bottom: 10 })
Text('授权信息:' + (this.hasAuth ? '已授权' : '未授权'))
.fontColor('#CCAE7A')
.fontSize(22 * this.ratio)
.width('30%')
}
.margin({ left: 24 })
.gesture(
GestureGroup(GestureMode.Exclusive,
2024-01-31 14:35:16 +08:00
TapGesture({ count: 2 })
2024-01-05 11:11:15 +08:00
.onAction(() => {
globalThis.singlePlay = !globalThis.singlePlay
this.isSingle = globalThis.singlePlay
})
)
)
Text('考车号:' + this.deviceId).fontColor('#CCAE7A').fontSize(22 * this.ratio).margin({ right: 24 })
}
.width('100%')
.justifyContent(FlexAlign.SpaceBetween)
.margin({ bottom: 10 })
}
if (this.loading) {
Column() {
Image($r('app.media.open_loading'))
.width(200 * this.ratio)
.rotate({ angle: this.angle })
.height(200 * this.ratio)
.animation({
duration: 5000, // 动画时长
curve: Curve.EaseOut, // 动画曲线
delay: 500, // 动画延迟
iterations: -1, // 播放次数
playMode: PlayMode.Normal, // 动画模式
})
.margin({ top: 30 * this.ratio })
Image($r('app.media.car'))
.width(80 * this.ratio)
.height(80 * this.ratio)
.position({ x: 288 * this.ratio, y: 89 * this.ratio })
Text('获取考车信息,请稍候……').fontSize(24 * this.ratio).margin({ top: 20 * this.ratio }).fontWeight(400)
}
.width(660 * this.ratio)
.height(360 * this.ratio)
.position({ x: 150 * this.ratio, y: 98 * this.ratio })
.backgroundColor('#E6E3DF')
.borderRadius(19 * this.ratio)
}
}
.width('100%')
.height('100%')
.justifyContent(FlexAlign.SpaceBetween)
.backgroundImagePosition({ x: 0, y: 0 })
.backgroundImage($r('app.media.index_bg'))
.backgroundImageSize({ width: '100%', height: '100%' })
}
aboutToAppear() {
this.angle = 0
this.loading = false
}
2024-02-26 15:01:27 +08:00
async heartMsg() {
2024-01-05 11:11:15 +08:00
const arr = [globalThis.signNum||0, globalThis.statue||1]
let tmpList = [];
2024-02-22 10:40:35 +08:00
tmpList.push(string2Bytes(arr[0], 1 * 8)[0])
tmpList.push(string2Bytes(arr[1], 1 * 8)[0])
2024-01-05 11:11:15 +08:00
const str =globalThis.lsh|| '0000000000000'
for (let i = 0;i < str.length; i++) {
2024-02-22 10:40:35 +08:00
tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
2024-01-05 11:11:15 +08:00
}
2024-03-05 15:44:53 +08:00
const param= {id: 31,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRomId}
// globalThis.udpClient2.initHeartSendMsg(param,this.context)
2024-01-05 11:11:15 +08:00
globalThis.udpClient2.sendMsg(param, this.context)
}
onPageShow() {
this.loading = false
this.initParams()
getUDP()
getUDP2()
setInterval(() => {
2024-03-05 15:44:53 +08:00
setliushuiNum()
this.heartMsg()
2024-01-05 11:11:15 +08:00
}, 1000)
2024-01-31 14:42:14 +08:00
// getTCP()
// const TcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort)
2024-01-05 11:11:15 +08:00
if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) {
globalThis.singlePlay = false
}
this.isSingle = globalThis.singlePlay
console.info('Index onPageShow');
}
async initParams() {
this.loading=false
await getDeviceInfo()
await setCurrentTime();
await getCarInfo();
this.carNum = globalThis.carInfo.plateNo;
this.version = globalThis.version;
this.hasAuth = globalThis.hasAuth;
2024-01-31 14:35:16 +08:00
initJudgeUdp()
2024-01-31 14:42:14 +08:00
//下载模型
// await this.getModel()
// const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]
2024-02-22 10:40:35 +08:00
// globalThis.udpClientByTopLine.sendMsg(Array2Byte(arr).buffer)
2024-02-23 16:08:37 +08:00
console.info(testNapi)
2024-01-05 11:11:15 +08:00
}
async getModel() {
const context = this.context;
//下载模型
await getEsCarModel(context)
}
}