优化
This commit is contained in:
parent
50b63e471d
commit
291e75c150
@ -9,7 +9,6 @@ import appRecovery from '@ohos.app.ability.appRecovery';
|
|||||||
import power from '@ohos.power';
|
import power from '@ohos.power';
|
||||||
import preferences from '@ohos.data.preferences';
|
import preferences from '@ohos.data.preferences';
|
||||||
|
|
||||||
|
|
||||||
export const gpsConfig = [
|
export const gpsConfig = [
|
||||||
{ label: "差分状态", prop: "cfzt" },
|
{ label: "差分状态", prop: "cfzt" },
|
||||||
{ label: "经纬度收星数", prop: "sxs" },
|
{ label: "经纬度收星数", prop: "sxs" },
|
||||||
@ -71,6 +70,18 @@ enum EventCode {
|
|||||||
Reply
|
Reply
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ButtonEventType {
|
||||||
|
Single,
|
||||||
|
Double,
|
||||||
|
LongPress
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ToolEvent<T = any> {
|
||||||
|
code: EventCode,
|
||||||
|
data: T
|
||||||
|
id?: string
|
||||||
|
}
|
||||||
|
|
||||||
interface FileInfo {
|
interface FileInfo {
|
||||||
fileName: string
|
fileName: string
|
||||||
lastUpdateTime: string
|
lastUpdateTime: string
|
||||||
@ -85,6 +96,13 @@ interface PlatformEvent<T = any> {
|
|||||||
data: T
|
data: T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ButtonParams {
|
||||||
|
type: ButtonEventType
|
||||||
|
button: number
|
||||||
|
page: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type CommandCallback = (button: number, reply: (result: number) => void) => void
|
||||||
|
|
||||||
const Tag = "[websocket]"
|
const Tag = "[websocket]"
|
||||||
const SystemLogDir = "/data/log/hilog"
|
const SystemLogDir = "/data/log/hilog"
|
||||||
@ -208,6 +226,10 @@ export class RemoteToolWebsocket {
|
|||||||
page: number,
|
page: number,
|
||||||
cb: () => void
|
cb: () => void
|
||||||
}> = []
|
}> = []
|
||||||
|
private onButtonCallback: Array<{
|
||||||
|
page: number,
|
||||||
|
cb: CommandCallback
|
||||||
|
}> = []
|
||||||
public isStart: boolean = false
|
public isStart: boolean = false
|
||||||
private isRegister: boolean = false
|
private isRegister: boolean = false
|
||||||
private context: common.UIAbilityContext
|
private context: common.UIAbilityContext
|
||||||
@ -374,6 +396,34 @@ export class RemoteToolWebsocket {
|
|||||||
this.sendReply(this.serialNumber, data.eventType)
|
this.sendReply(this.serialNumber, data.eventType)
|
||||||
break
|
break
|
||||||
case PlatFormEventType.ToolCommand:
|
case PlatFormEventType.ToolCommand:
|
||||||
|
let command = JSON.parse(data.data) as ToolEvent
|
||||||
|
switch (command.code) {
|
||||||
|
case EventCode.Data:
|
||||||
|
break
|
||||||
|
case EventCode.Button:
|
||||||
|
let button = JSON.parse(command.data) as ButtonParams
|
||||||
|
this.onButtonCallback.forEach(item => {
|
||||||
|
const reply = (result: number) => {
|
||||||
|
this.sendReply(this.serialNumber, PlatFormEventType.SyncData, JSON.stringify({
|
||||||
|
code: EventCode.Reply,
|
||||||
|
data: JSON.stringify(result),
|
||||||
|
id: command.id
|
||||||
|
} as ToolEvent))
|
||||||
|
}
|
||||||
|
if (item.page === button.page) {
|
||||||
|
item.cb(button.button, reply)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
break
|
||||||
|
case EventCode.Router:
|
||||||
|
break
|
||||||
|
case EventCode.Function:
|
||||||
|
break
|
||||||
|
case EventCode.Reply:
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
return
|
||||||
|
}
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
console.warn("Unknown event type:", data.eventType);
|
console.warn("Unknown event type:", data.eventType);
|
||||||
@ -640,6 +690,17 @@ export class RemoteToolWebsocket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
offStart(page: number) {
|
offStart(page: number) {
|
||||||
this.onStartCallback = this.onStartCallback.filter(item => item.page != page)
|
this.onStartCallback = this.onStartCallback.filter(item => item.page !== page)
|
||||||
|
}
|
||||||
|
|
||||||
|
onButton(cb: CommandCallback, page: number) {
|
||||||
|
this.onButtonCallback.push({
|
||||||
|
page,
|
||||||
|
cb
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
offButton(page: number) {
|
||||||
|
this.onButtonCallback = this.onButtonCallback.filter(item => item.page !== page)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,7 +38,6 @@ export default class EntryAbility extends UIAbility {
|
|||||||
|
|
||||||
async onWindowStageCreate(windowStage: window.WindowStage) {
|
async onWindowStageCreate(windowStage: window.WindowStage) {
|
||||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
||||||
await tcpUtil.init()
|
|
||||||
globalThis.tcpStep=0
|
globalThis.tcpStep=0
|
||||||
|
|
||||||
globalThis.carInfo = {}
|
globalThis.carInfo = {}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import { delPic } from '../common/service/videoService';
|
|||||||
import imageBtn from './compontents/imageBtn';
|
import imageBtn from './compontents/imageBtn';
|
||||||
import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
|
import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
|
||||||
import { updateModelAndCar } from '../common/autoUpdate/index'
|
import { updateModelAndCar } from '../common/autoUpdate/index'
|
||||||
import { RemoteToolWebsocket } from '../common/utils/RemotetoolWebsocket';
|
import { CommandCallback, RemoteToolWebsocket } from '../common/utils/RemotetoolWebsocket';
|
||||||
import { UsbUtils } from '../common/utils/UsbUtils';
|
import { UsbUtils } from '../common/utils/UsbUtils';
|
||||||
|
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ struct Index {
|
|||||||
@State version: string = ''
|
@State version: string = ''
|
||||||
@State url: string = ''
|
@State url: string = ''
|
||||||
@State hasAuth: boolean = false;
|
@State hasAuth: boolean = false;
|
||||||
@State dialogVisiable: boolean = false;
|
@State dialogVisible: boolean = false;
|
||||||
@State isSingle: boolean = false;
|
@State isSingle: boolean = false;
|
||||||
@State deviceId: string = '';
|
@State deviceId: string = '';
|
||||||
@State angle: number = 0
|
@State angle: number = 0
|
||||||
@ -63,6 +63,15 @@ struct Index {
|
|||||||
private context = getContext(this) as common.UIAbilityContext;
|
private context = getContext(this) as common.UIAbilityContext;
|
||||||
private remoteToolWebsocket: RemoteToolWebsocket = new RemoteToolWebsocket()
|
private remoteToolWebsocket: RemoteToolWebsocket = new RemoteToolWebsocket()
|
||||||
private usbUtils: UsbUtils = new UsbUtils(this.context)
|
private usbUtils: UsbUtils = new UsbUtils(this.context)
|
||||||
|
private onButtonCallback: CommandCallback = (button, reply) => {
|
||||||
|
switch (button) {
|
||||||
|
case 1:
|
||||||
|
this.onNetWork(reply)
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Styles
|
@Styles
|
||||||
commStyle(){
|
commStyle(){
|
||||||
@ -91,7 +100,7 @@ struct Index {
|
|||||||
Image($r('app.media.btn_back')).width('14.4%').height('12.2%')
|
Image($r('app.media.btn_back')).width('14.4%').height('12.2%')
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
|
|
||||||
this.dialogVisiable = true
|
this.dialogVisible = true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,40 +113,8 @@ struct Index {
|
|||||||
if (!this.isSingle) {
|
if (!this.isSingle) {
|
||||||
imageBtn({ btnWidth: '28%', btnHeight: '71%', imgSrc: $r('app.media.index_lw') })
|
imageBtn({ btnWidth: '28%', btnHeight: '71%', imgSrc: $r('app.media.index_lw') })
|
||||||
.margin({ left: 80 * globalThis.ratio })
|
.margin({ left: 80 * globalThis.ratio })
|
||||||
.onClick(async () => {
|
.onClick(() => {
|
||||||
|
this.onNetWork()
|
||||||
if (this.loading) {
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
setTimeout(() => {
|
|
||||||
this.angle = 360
|
|
||||||
}, 1000)
|
|
||||||
this.angle = 0
|
|
||||||
if (!globalThis.timeInfo) {
|
|
||||||
globalThis.type = '1'
|
|
||||||
globalThis.title = '时间同步接口连接失败'
|
|
||||||
this.errorDialog.open()
|
|
||||||
promptAction.showToast({
|
|
||||||
message: `时间同步接口连接失败`,
|
|
||||||
duration: 3000
|
|
||||||
});
|
|
||||||
this.loading = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!globalThis.carInfo) {
|
|
||||||
promptAction.showToast({
|
|
||||||
message: `车辆信息接口获取失败`,
|
|
||||||
duration: 3000
|
|
||||||
});
|
|
||||||
globalThis.type = '1'
|
|
||||||
globalThis.title = '车辆信息接口获取失败'
|
|
||||||
this.errorDialog.open()
|
|
||||||
this.loading = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.testXMLToJSONInWorker()
|
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (this.isSingle) {
|
if (this.isSingle) {
|
||||||
@ -247,8 +224,7 @@ struct Index {
|
|||||||
.margin({ bottom: 10 })
|
.margin({ bottom: 10 })
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
if (this.dialogVisible) {
|
||||||
if (this.dialogVisiable) {
|
|
||||||
Flex({ justifyContent: FlexAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center }) {
|
||||||
Text('确认是否退出应用')
|
Text('确认是否退出应用')
|
||||||
.fontSize(28 * this.ratio * this.dialogRatio)
|
.fontSize(28 * this.ratio * this.dialogRatio)
|
||||||
@ -262,7 +238,7 @@ struct Index {
|
|||||||
}
|
}
|
||||||
.commStyle()
|
.commStyle()
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
this.dialogVisiable = false
|
this.dialogVisible = false
|
||||||
|
|
||||||
}).margin({ right: 10 * this.ratio })
|
}).margin({ right: 10 * this.ratio })
|
||||||
|
|
||||||
@ -312,7 +288,6 @@ struct Index {
|
|||||||
.backgroundColor('#E6E3DF')
|
.backgroundColor('#E6E3DF')
|
||||||
.borderRadius(19 * globalThis.ratio)
|
.borderRadius(19 * globalThis.ratio)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.loading) {
|
if (this.loading) {
|
||||||
Column() {
|
Column() {
|
||||||
Image($r('app.media.open_loading'))
|
Image($r('app.media.open_loading'))
|
||||||
@ -353,13 +328,11 @@ struct Index {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async aboutToAppear() {
|
async aboutToAppear() {
|
||||||
|
this.remoteToolWebsocket.onButton(this.onButtonCallback, 1)
|
||||||
console.log('diyidiy')
|
|
||||||
|
|
||||||
this.avPlayer = new VoiceAnnounce();
|
this.avPlayer = new VoiceAnnounce();
|
||||||
this.initParamFlag = false
|
this.initParamFlag = false
|
||||||
this.delLoading = false
|
this.delLoading = false
|
||||||
this.dialogVisiable = false
|
this.dialogVisible = false
|
||||||
this.angle = 0
|
this.angle = 0
|
||||||
this.loading = false
|
this.loading = false
|
||||||
globalThis.lsh = '1111111111111'
|
globalThis.lsh = '1111111111111'
|
||||||
@ -386,15 +359,46 @@ struct Index {
|
|||||||
}
|
}
|
||||||
|
|
||||||
aboutToDisappear() {
|
aboutToDisappear() {
|
||||||
// this.vocObj && this.vocObj.releasePlayer()
|
this.remoteToolWebsocket.offButton(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
async testXMLToJSONInWorker() {
|
onNetWork(cb?: Function) {
|
||||||
if (this.loading) {
|
if (this.loading) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
this.angle = 360
|
||||||
|
}, 1000)
|
||||||
|
this.angle = 0
|
||||||
|
if (!globalThis.timeInfo) {
|
||||||
|
globalThis.type = '1'
|
||||||
|
globalThis.title = '时间同步接口连接失败'
|
||||||
|
this.errorDialog.open()
|
||||||
|
promptAction.showToast({
|
||||||
|
message: `时间同步接口连接失败`,
|
||||||
|
duration: 3000
|
||||||
|
});
|
||||||
|
this.loading = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!globalThis.carInfo) {
|
||||||
|
promptAction.showToast({
|
||||||
|
message: `车辆信息接口获取失败`,
|
||||||
|
duration: 3000
|
||||||
|
});
|
||||||
|
globalThis.type = '1'
|
||||||
|
globalThis.title = '车辆信息接口获取失败'
|
||||||
|
this.errorDialog.open()
|
||||||
|
this.loading = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.testXMLToJSONInWorker(cb)
|
||||||
|
}
|
||||||
|
|
||||||
|
async testXMLToJSONInWorker(cb?: Function) {
|
||||||
|
if (this.loading) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const param = {
|
const param = {
|
||||||
carId: globalThis.carInfo?.carId,
|
carId: globalThis.carInfo?.carId,
|
||||||
examinationRoomId: globalThis.carInfo?.examinationRoomId,
|
examinationRoomId: globalThis.carInfo?.examinationRoomId,
|
||||||
@ -448,12 +452,14 @@ struct Index {
|
|||||||
}
|
}
|
||||||
if (sys.v_no === '824' && decodeURIComponent(sys.v_value) == '0') {
|
if (sys.v_no === '824' && decodeURIComponent(sys.v_value) == '0') {
|
||||||
// this.Param612Str= decodeURIComponent(sys.v_value)
|
// this.Param612Str= decodeURIComponent(sys.v_value)
|
||||||
|
cb(1)
|
||||||
router.pushUrl({
|
router.pushUrl({
|
||||||
url: 'pages/CarCheck',
|
url: 'pages/CarCheck',
|
||||||
params: {
|
params: {
|
||||||
'fromIndex': true
|
'fromIndex': true
|
||||||
}
|
}
|
||||||
}, router.RouterMode.Single)
|
}, router.RouterMode.Single)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
router.pushUrl({
|
router.pushUrl({
|
||||||
url: 'pages/ExaminerLogin',
|
url: 'pages/ExaminerLogin',
|
||||||
@ -463,6 +469,8 @@ struct Index {
|
|||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
cb(0)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,7 +490,7 @@ struct Index {
|
|||||||
carNo: globalThis.carInfo.carNo,
|
carNo: globalThis.carInfo.carNo,
|
||||||
placeId: globalThis.carInfo.examinationRoomId
|
placeId: globalThis.carInfo.examinationRoomId
|
||||||
}
|
}
|
||||||
// globalThis.udpClient2.initHeartSendMsg(param,this.context)
|
|
||||||
if (globalThis.udpClient2.getStatus()) {
|
if (globalThis.udpClient2.getStatus()) {
|
||||||
globalThis.udpClient2.sendMsgExt(param, this.context)
|
globalThis.udpClient2.sendMsgExt(param, this.context)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user