fix: 优化类型定义和函数调用,添加缺失的类型注解

This commit is contained in:
wangzhongjie 2025-03-18 17:41:54 +08:00
parent b37b5e9581
commit 3475fc9961
12 changed files with 255 additions and 171 deletions

View File

@ -84,7 +84,7 @@ export async function initCarInfoCache(params: initCarInfoCacheParams) {
//参数下发读表接口
export async function initCenterCache(params: object, url: string) {
const timeInfo = AppStorage.get('timeInfo')
const timeInfo: string = AppStorage.get('timeInfo')
return await request<object>({
url: '/para/initCenterCache.ws',
data: params,

View File

@ -4,6 +4,8 @@ import { getSyncData } from '../common/service/initable';
import writeObjectOutNew from './judgeNew';
import FileUtil from '../common/utils/File';
import http from '@ohos.net.http';
import { MASYSSETTableType, RegulatoryInterfaceParams } from '../model';
import { GetSyncData } from '../utils/table/Operation';
let baseHost: string = AppStorage.get('host');
@ -25,7 +27,7 @@ interface WR {
}
// 通用监管接口
export async function writeObjectOut(params: ESObject, filePath?: string): Promise<WR> {
export async function writeObjectOut(params: RegulatoryInterfaceParams, filePath?: string): Promise<WR> {
const singlePlay: boolean = AppStorage.get('singlePlay')
if (singlePlay) {
return { code: 1 }
@ -33,7 +35,7 @@ export async function writeObjectOut(params: ESObject, filePath?: string): Promi
let JGHOST: string = AppStorage.get("JGHOST")
//获取监管接口地址路径
if (!JGHOST) {
const syssetParams = await getSyncData('MA_SYSSET') || [];
const syssetParams: MASYSSETTableType[] = await GetSyncData<MASYSSETTableType>("MA_SYSSET");
syssetParams.forEach(sys => {
if (sys.v_no == '839') {

View File

@ -1,6 +1,6 @@
import request from '../utils/Request'
import http from '@ohos.net.http'
import { FaceCompareResp } from '../model'
import { FaceCompareResp, GetExaminationItemRsp, GetExaminationStudentInfoResponse } from '../model'
/**
* 照片比对
@ -39,8 +39,8 @@ export async function faceCompare(params: FaceCompareParams) {
}
export async function getExaminationStudentInfo(params: object) {
return request({
export async function getExaminationStudentInfo(params: ESObject) {
return request<GetExaminationStudentInfoResponse>({
url: '/der2/services/exam/getExaminationStudentInfo.ws',
data: params,
method: http.RequestMethod.POST,
@ -67,7 +67,7 @@ interface GetExaminationItemParams {
//获取断点续考
export async function getExaminationItem(params: GetExaminationItemParams) {
return request({
return request<GetExaminationItemRsp>({
url: '/der2/services/exam/getExaminationItem.ws',
data: `<getExaminationItemReq>
<head>

View File

@ -93,4 +93,5 @@ export interface BaseInfoType {
export interface RouteParamsType {
sczb?: string;
kfdm?: string;
type?: string;
}

View File

@ -88,6 +88,7 @@ interface JudgeFile {
/** 考试过程数据 */
export interface DrvexamType extends BaseExamFields {
lsh?: string;
zp?: string;
sbxh?: string;
kffs?: string;
@ -95,4 +96,7 @@ export interface DrvexamType extends BaseExamFields {
kfxm?: string;
kfxmmx?: string;
ghks?: string;
ksxtbh?: string;
ksysfzmhm?: string;
Ksy2sfzmhm?: string;
}

View File

@ -1,3 +1,5 @@
import { DrvexamType } from ".";
export interface RegistrationDeviceNoRsp {
registrationDeviceNoRsp: RegistrationDeviceNoRspDetails;
}
@ -17,9 +19,12 @@ interface ImageCompareRsp {
body: ESObject
}
export interface GetExaminationStudentInfoResponse {
getExaminationStudentInfoRsp: ImageCompareRsp
}
export interface FaceCompareResp {
imageCompareRsp?: ImageCompareRsp
}
export interface ResponseDataType {
@ -34,6 +39,9 @@ export interface ExaminerLoginInfo {
username?: string;
kgxm?: string;
ksyh?: string;
plateNo?: string
isNeedCheck?: string
examSubject?: string
}
export interface SpzdType {
@ -78,7 +86,35 @@ interface ES_CHECK_CAR_ITEMItem {
ITEMS: string;
}
export interface ObtainCarExamInfoParams {
export interface ObtainCarExamInfoParams {
time: string
deviceNo: string
}
//监管接口参数
export interface RegulatoryInterfaceParams {
xtlb?: string;
jkxlh?: string;
jkid?: string;
drvexam?: DrvexamType
}
export interface BeginExamRequest {
keystr?: string;
message?: string | Resource;
code?: number
}
// { getExaminationItemRsp: { body: { ykxx: '' } } }
export interface GetExaminationItemRsp {
getExaminationItemRsp: GetExaminationItemRspDetails
}
interface GetExaminationItemRspDetails {
head?: Head;
body: GetExaminationItemRspBody;
}
interface GetExaminationItemRspBody {
ykxx: string;
}

View File

@ -20,7 +20,7 @@ import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
import { BaseInfoType } from '../model/Common';
import { CarInfoType } from '../model/CarCheck';
import { InitializeTheCentralTableType, MASYSSETTableType, TimeInfo } from '../model';
import { GetCarInfo, GetDeviceInfo, UseAuth } from './index/utils';
import { GetCarInfo, GetDeviceInfo, UseAuth } from './Index/utils';
import { GetSyncData, InitializeTheCentralTable } from '../utils/table/Operation';
import { BusinessError } from '@ohos.base';
@ -57,9 +57,7 @@ struct Index {
alignment: DialogAlignment.Center,
},
)
private fileUtil: FileUtil
private interval = -1;
// private vocObj = null;
private avPlayer: VoiceAnnounce
private timeInfo: TimeInfo
private context = getContext(this) as common.UIAbilityContext;
@ -503,37 +501,6 @@ struct Index {
}
// userAuth() {
// return new Promise((reslove, reject) => {
// const permissions: Array<Permissions> =
// ["ohos.permission.SET_TIME", "ohos.permission.READ_IMAGEVIDEO", "ohos.permission.DISTRIBUTED_DATASYNC",
// 'ohos.permission.CONNECTIVITY_INTERNAL', 'ohos.permission.CAMERA', 'ohos.permission.READ_MEDIA',
// 'ohos.permission.WRITE_MEDIA', 'ohos.permission.FILE_ACCESS_MANAGER'];
// let context = this.context;
// let atManager = abilityAccessCtrl.createAtManager();
//
// atManager.requestPermissionsFromUser(context, permissions).then((data) => {
// this.initParams()
// let grantStatus: Array<number> = data.authResults;
// let length: number = grantStatus.length;
// for (let i = 0; i < length; i++) {
// if (grantStatus[i] === 0) {
// // 用户授权,可以继续访问目标操作
// reslove(true)
// } else {
// reject()
// // 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限
// return;
// }
// }
// // 授权成功
// }).catch((err: BusinessError) => {
// console.error(`Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`);
// })
// })
//
// }
async initParams() {
//设置plc udp 同步requesthost
await getUDP(this.context, false)

View File

@ -30,7 +30,8 @@ import { judgeConfig } from './judgeSDK/utils/judgeConfig';
import FileUtil from '../common/utils/File';
import SignDisplayCom from './compontents/signDisplayCom';
import { CarInfoType, CommonType, KfdmType } from '../model';
import { CarInfoType, CommonType, KfdmType, User } from '../model';
import { GetSyncData } from '../utils/table/Operation';
@Entry
@Component
@ -215,7 +216,7 @@ struct Index {
// 获取考生信息
async initStudent() {
const students = await getSyncData('USER')
const students = await GetSyncData<User>('USER')
const stuInfo = students[0] || {};
const { xm, sfzmhm, lsh, kszp, ksdd, kssycs, kslx, ksxl, xldm } = stuInfo;
this.name = xm || '测试考生';

View File

@ -10,7 +10,7 @@ import IDCardSDK from '@ohos.idcard';
import common from '@ohos.app.ability.common';
import promptAction from '@ohos.promptAction';
import FilePhoto from './judgeSDK/utils/filePhoto';
import { getSyncData, sqlInsertCommonFn, upDateTableByArray } from '../common/service/initable';
import { sqlInsertCommonFn, upDateTableByArray } from '../common/service/initable';
import { CandidateData, EmptyCandidateObject } from '../mock/CandidateData';
import BoardPrePareSetPopup from './compontents/judge/BoardPrePareSetPopup';
import LoadingPopup from './compontents/judge/LoadingPopup';
@ -21,8 +21,25 @@ import errorMsgDialog from './compontents/errorMsgDialog';
import imageBtn from './compontents/imageBtn';
import FileUtil from '../common/utils/File';
import DB, { ColumnType } from '../common/database/DbSql';
import { CarInfoType, IdCard, LabelBlockType, QKParamType, SckType, SystemParamType, User } from '../model';
import {
BeginExamRequest,
CarInfoType,
DrvexamType,
ExaminerLoginInfo,
GetExaminationItemRsp,
IdCard,
LabelBlockType,
MASYSSETTableType,
QKParamType,
RegulatoryInterfaceParams,
RouteParamsType,
SckType,
SystemParamType,
User
} from '../model';
import { BusinessError } from '@ohos.base';
import { GetSyncData } from '../utils/table/Operation';
import { GetCurrentUserKeyValue } from './UserInfo/utils';
@Entry
@Component
@ -208,13 +225,15 @@ struct UserInfo {
this.initData()
//身份证读卡器初始化
// this.openDeviceByIDCard()
const routerParam = router.getParams() || { type: 0 };
const routerParam: RouteParamsType = router.getParams() as RouteParamsType
console.log('routerParam', JSON.stringify(routerParam))
if (!this.singlePlay) {
if (routerParam.type != 1) {
this.list = await getSyncData('USERLIST')
const data = await getSyncData('USER')
if (routerParam.type != "1") {
// this.list = await getSyncData('USERLIST')
this.list = await GetSyncData<User>("USERLIST")
// const data = await getSyncData('USER')
const data = await GetSyncData<User>("USER")
console.log('useruser,', JSON.stringify(this.list))
console.log('useruser1,', JSON.stringify(data))
@ -271,16 +290,16 @@ struct UserInfo {
// }
this.sczbkf = [];
initJudgeUdp()
// TODO UDP更改
//监听远程开始考试
globalThis.udpEvent.onBeginExam(async () => {
console.info('surenjun', 'userInfo收到UdpEvent事件')
if (this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow) {
await this.prePareSCZB()
} else {
await this.prePareExam()
}
})
// globalThis.udpEvent.onBeginExam(async () => {
// console.info('surenjun', 'userInfo收到UdpEvent事件')
// if (this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow) {
// await this.prePareSCZB()
// } else {
// await this.prePareExam()
// }
// })
}
@ -298,12 +317,12 @@ struct UserInfo {
stopDeviceById() {
if (this.faceFlag == '1') {
testNapi && testNapi.StopReadCard()
testNapi.StopReadCard()
}
}
// 通过身份证获取当前学员
async getCurrentStudent(id) {
async getCurrentStudent(id: string) {
let flag = false
// this.pageIndex
console.log('currentidid', id)
@ -320,13 +339,11 @@ struct UserInfo {
this.examinerLoginInfo.ksyh = res.ksy1sfzmhm
AppStorage.setOrCreate('examinerLoginInfo', this.examinerLoginInfo)
AppStorage.setOrCreate('lsh', res.lsh)
const { examSubject } = this.carInfo;
// this.currentUser.kszp=this.photo+res.kszp
// this.currentUser.ksmjzp=this.photo+this.currentUser.ksmjzp
// const { examSubject } = this.carInfo;
if (this.singlePlay) {
this.stopDeviceById()
router.pushUrl({
url: examSubject == 3 ? 'pages/Roads' : 'pages/Judge',
url: this.carInfo.examSubject == "3" ? 'pages/Roads' : 'pages/Judge',
params: {
sczb: Number(this.isBoardPrePareSetPopupOpen),
kfdm: this.sczbkf,
@ -389,7 +406,7 @@ struct UserInfo {
thisVar.address = baseInfos[4];
thisVar.idCard = baseInfos[5];
setTimeout(() => {
thisVar.getCurrentStudent(baseInfos[5])
this.getCurrentStudent(baseInfos[5])
}, 1000)
}
@ -445,20 +462,21 @@ struct UserInfo {
}
async heartMsg() {
globalThis.udpClient2 & globalThis.udpClient2.setMsgCallBack(async (val) => {
if (val.id == '32') {
AppStorage.setOrCreate('signNum', val.body[1])
if (val.body[0] == '7') {
//缺考处理
this.getqkFn()
this.signNum = val.body[1]
}
} else if (val.id == '42') {
//收到中心缺考确认消息
console.log('qkfnqkfn', val.body[0])
this.qkFn()
}
})
// TODO UDP缺失
// globalThis.udpClient2 & globalThis.udpClient2.setMsgCallBack(async (val) => {
// if (val.id == '32') {
// AppStorage.setOrCreate('signNum', val.body[1])
// if (val.body[0] == '7') {
// //缺考处理
// this.getqkFn()
// this.signNum = val.body[1]
// }
// } else if (val.id == '42') {
// //收到中心缺考确认消息
// console.log('qkfnqkfn', val.body[0])
// this.qkFn()
// }
// })
}
//考点端查询缺考指令内容消息请求
@ -471,16 +489,18 @@ struct UserInfo {
carNo: this.carInfo.carNo as string,
placeId: this.carInfo.examinationRoomId as string
}
globalThis.udpClient2.sendMsgExt(param, this.context)
// TODO UDP缺失
// globalThis.udpClient2.sendMsgExt(param, this.context)
}
async initSysset() {
const that = this;
DB.queryListBySql("select * from MA_SYSSET", ['id', 'v_no', 'v_name', 'v_value'].map(item => ({
type: ColumnType.STRING,
name: item,
columnName: item
}))).then((syssetParams: any) => {
// DB.queryListBySql("select * from MA_SYSSET", ['id', 'v_no', 'v_name', 'v_value'].map(item => ({
// type: ColumnType.STRING,
// name: item,
// columnName: item
// }))).then((syssetParams: any) => {
GetSyncData<MASYSSETTableType>("MA_SYSSET").then((syssetParams: MASYSSETTableType[]) => {
const serialNumberArr = syssetParams.filter(sys => sys.v_no === '901')
that.jkxlh = serialNumberArr?.[0]?.v_value || ''
const ksxtbhArr = syssetParams.filter(sys => sys.v_no === '902')
@ -556,15 +576,9 @@ struct UserInfo {
if (!Number(this.systemParam.Param305Str)) {
that.systemParam.Param305Str = '2'
}
// console.log('Param305Str',that.systemParam.Param305Str)
// delHilog(this.Param305Str)
// delPic(that.systemParam.Param305Str,1)
// delPic(that.systemParam.Param305Str,2)
}
})
// faceParam?.[0]?.v_value ||
//0不自动更新 1自动更新不限次数 2没有考生更新2次
if (that.studentRefreshStatue == '2') {
@ -596,14 +610,6 @@ struct UserInfo {
// this.getExaminationItemFn()
}
})
// const db = new AccountTable(() => {
// }, MA_SYSSET);
// db.getRdbStore(() => {
// db.query('0', (syssetParams) => {
//
//
// })
// })
}
//人脸比对窗口关闭
@ -665,23 +671,28 @@ struct UserInfo {
setTimeout(() => {
this.updateTimeLimit = false
}, 3000)
// @ts-ignore
if (!res || res?.getExaminationStudentInfoRsp?.head?.resultCode == '1') {
this.dataList = []
this.list = []
return
}
let dataList = []
let dataList: User[] = []
this.list = []
// @ts-ignore
for (let key in res.getExaminationStudentInfoRsp.body) {
// @ts-ignore
const a = res.getExaminationStudentInfoRsp.body[key]
if (a instanceof Array) {
dataList = a
// for (let key in res.getExaminationStudentInfoRsp.body) {
// const a = res.getExaminationStudentInfoRsp.body[key]
// if (a instanceof Array) {
// dataList = a
// } else {
// dataList = [a]
// }
// }
for (const key of Object.keys(res.getExaminationStudentInfoRsp.body)) {
const a: User[] | User = res.getExaminationStudentInfoRsp.body[key];
if (Array.isArray(a)) {
dataList = a;
} else {
dataList = [a]
dataList = [a];
}
}
if (dataList.length) {
@ -698,9 +709,10 @@ struct UserInfo {
this.startExam = true
}
listData.id = index.toString()
for (let i in listData) {
listData[i] = decodeURI(listData[i])
}
// TODO 需要修改
// for (let i in listData) {
// listData[i] = decodeURI(listData[i])
// }
if (this.systemParam.Param828Str == '1' || this.systemParam.Param828Str == '2') {
// listData.ksy2=listData.ksy1;
listData.ksy2 = this.examinerLoginInfo.kgxm
@ -747,12 +759,13 @@ struct UserInfo {
}
this.pageIndex = 0
getSyncData('USER').then(data => {
// getSyncData('USER').then(data => {
GetSyncData<User>("USER").then(data => {
if (data?.[0]) {
this.getCurrentStudent(data[0].sfzmhm)
}
})
}).catch((error) => {
}).catch((error: BusinessError) => {
this.updateTimeLimit = false
this.errorDialog.close()
console.log('error12error' + error)
@ -793,7 +806,6 @@ struct UserInfo {
}
globalThis.udpClient2.sendMsgExt(param, this.context)
// @ts-ignore
if (res.examinationStuAbsentRsp.head.resultCode == '0') {
this.pageIndex = 0
this.qkFlag = false
@ -811,15 +823,14 @@ struct UserInfo {
if (!this.currentUser.lsh || this.singlePlay) {
return
}
const { carId, examinationRoomId } = this.carInfo;
// const { carId, examinationRoomId } = this.carInfo;
const examItems = await getExaminationItem({
time: getCurrentTime(),
carId,
time: await getCurrentTime() || "",
carId: this.carInfo.carId,
lsh: this.currentUser.lsh || '',
examinationRoomId
examinationRoomId: this.carInfo.examinationRoomId
});
// @ts-ignore
if (examItems?.getExaminationItemRsp?.body?.kssycs != 0) {
this.getExaminationStudentInfoFn()
} else {
@ -832,16 +843,14 @@ struct UserInfo {
async sfbdinterfaceFn() {
AppStorage.setOrCreate('statue', 4)
this.stepFlag = true
const { carId, examinationRoomId } = this.carInfo;
let examItems = { getExaminationItemRsp: { body: { ykxx: '' } } };
let examItems: GetExaminationItemRsp = { getExaminationItemRsp: { body: { ykxx: '' } } };
if (!this.singlePlay) {
//获取已考项目
// @ts-ignore
examItems = await getExaminationItem({
time: getCurrentTime(),
carId,
time: await getCurrentTime(),
carId: this.carInfo.carId,
lsh: this.currentUser.lsh || '',
examinationRoomId
examinationRoomId: this.carInfo.examinationRoomId
});
}
this.currentUser.id = '1'
@ -850,17 +859,17 @@ struct UserInfo {
avPlayer.playAudio([`voice/监管通信中.mp3`], false, async () => {
console.info('surenjun', '播放结束开始考试接口调用')
const { code, keystr, message } = await this.beginExam() || {};
// const { code, keystr, message } = await this.beginExam() || {};
const res = await this.beginExam()
console.info('surenjun', '开始考试接口调用结束')
// console.info('surenjun',code +'')
//@ts-ignore TODO code转换
//TODO code转换
if (code != 1) {
avPlayer.playAudio([code == -200 ? 'voice/photo_error.mp3' : 'voice/监管审核未通过.mp3']);
if (res.code != 1) {
avPlayer.playAudio([res.code == -200 ? 'voice/photo_error.mp3' : 'voice/监管审核未通过.mp3']);
this.isLoadingPopupVisible = false
this.isExamStart = false
promptAction.showToast({
message,
message: res.message,
duration: 4000
})
return
@ -876,7 +885,7 @@ struct UserInfo {
sczb: Number(this.isBoardPrePareSetPopupOpen),
kfdm: this.sczbkf,
//真实监管项目
kString: decodeURIComponent(keystr || '')
kString: decodeURIComponent(res.keystr || '')
}
}, router.RouterMode.Single);
this.updateTimeLimit = false
@ -887,19 +896,21 @@ struct UserInfo {
// 检测车门、熄火信号
async checkSignal(): Promise<boolean> {
const { isCheckFireOpen } = judgeConfig
const { systemParam, isBoardPrePareSetPopupOpen } = this;
const Param803Str = systemParam.Param803Str
// const { isCheckFireOpen } = judgeConfig
// const { systemParam } = this;
const Param803Str = this.systemParam.Param803Str
if (Param803Str === '') {
return true
}
return new Promise((resolve, reject) => {
if (isCheckFireOpen) {
if (judgeConfig.isCheckFireOpen) {
resolve(true)
return
}
let plcValue = globalThis.udpClient.getCurrentMessage();
const msgArr = plcValue.split(',') || ''
// TODO UDP缺失
// let plcValue = globalThis.udpClient.getCurrentMessage();
let plcValue = "";
const msgArr = plcValue.split(',').map(Number) || ''
const mkg = msgArr[14];
const fdjzs = msgArr[25];
const aqd = msgArr[19];
@ -947,7 +958,7 @@ struct UserInfo {
}
//请点火
if (fdjzs * 1 <= 0 && Param803Str.includes('5')) {
if (fdjzs <= 0 && Param803Str.includes('5')) {
this.avPlayer.playAudio(['voice/点火.mp3'])
promptAction.showToast({
message: '请点火',
@ -969,7 +980,7 @@ struct UserInfo {
// if (isBoardPrePareSetPopupOpen) {
if (false) {
//请熄火
if (fdjzs * 1 > 0) {
if (fdjzs > 0) {
this.avPlayer.playAudio(['voice/熄火.mp3'])
promptAction.showToast({
message: '请熄火',
@ -991,9 +1002,8 @@ struct UserInfo {
}
// 开始考试
async beginExam() {
const { carId, examinationRoomId } = this.carInfo;
const { examSubject, plateNo } = this.carInfo;
async beginExam(): Promise<BeginExamRequest> {
// const { examSubject, plateNo } = this.carInfo;
const date = new Date()
const startHourTime = await getCurrentHourTime()
AppStorage.setOrCreate('startHourTime', startHourTime)
@ -1003,19 +1013,19 @@ struct UserInfo {
this.isLoadingPopupVisible = false
return { code: -200 }
}
const drvexam = {
lsh: this.currentUser.lsh || '',
kskm: examSubject,
const drvexam: DrvexamType = {
lsh: "this.currentUser.lsh",
kskm: this.carInfo.examSubject,
ksxtbh: this.ksxtbh || '222',
sfzmhm: this.currentUser.sfzmhm || '',
ksysfzmhm: this.currentUser.ksy1sfzmhm || '',
ksxl: this.currentUser.xldm,
zp: photoBase64,
kssj: dateFormat(date) || '',
kchp: decodeURI(plateNo),
kchp: decodeURI(this.carInfo.plateNo),
Ksy2sfzmhm: this.currentUser.ksy2sfzmhm || ''
}
const param = {
const param: RegulatoryInterfaceParams = {
drvexam,
xtlb: '17',
//接口序列号
@ -1039,7 +1049,7 @@ struct UserInfo {
this.currentUser.id = '0'
DB.insertData("USER", this.currentUser).then(res => {
console.log("USER insert success",)
}).catch(err => {
}).catch((err: BusinessError) => {
console.log("USER insert fail", JSON.stringify(err))
})
// await upDateTableByArray('USER', [this.currentUser])
@ -1062,8 +1072,9 @@ struct UserInfo {
outClick() {
clearInterval(this.interval)
this.stopDeviceById()
globalThis.udpClient2 && globalThis.udpClient2?.setMsgCallBack(() => {
})
// TODO 缺失UDP
// globalThis.udpClient2 && globalThis.udpClient2?.setMsgCallBack(() => {
// })
}
// 几个按钮公共样式
@ -1082,7 +1093,7 @@ struct UserInfo {
TopLogo({ outFlag: $outFlag }).margin({ bottom: 10 })
Row() {
Row() {
ForEach(this.dataList, (item) => {
ForEach(this.dataList, (item: User) => {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Column() {
CommText({
@ -1137,10 +1148,10 @@ struct UserInfo {
Flex({ justifyContent: FlexAlign.SpaceBetween }) {
Row() {
Column() {
if (this.currentUser['kszp']) {
if (this.currentUser.kszp) {
Avatar({
ratio: this.ratio,
url: this.currentUser['kszp'] ? this.currentUser['kszp'] : ''
url: this.currentUser.kszp ? this.currentUser.kszp : ''
})
} else {
Avatar({
@ -1148,10 +1159,10 @@ struct UserInfo {
url: ""
})
}
if (this.currentUser['ksmjzp']) {
if (this.currentUser.ksmjzp) {
Avatar({
ratio: this.ratio,
url: this.currentUser['ksmjzp'] ? this.currentUser['ksmjzp'] : ''
url: this.currentUser.ksmjzp ? this.currentUser.ksmjzp : ''
})
} else {
@ -1163,8 +1174,12 @@ struct UserInfo {
}
Column() {
ForEach(this.labelBlocks, (item) => {
LabelBlock({ label: item.label, ratio: this.ratio, value: this.currentUser[item.key] })
ForEach(this.labelBlocks, (item: LabelBlockType) => {
LabelBlock({
label: item.label,
ratio: this.ratio,
value: GetCurrentUserKeyValue(this.currentUser, item.key)
})
})
}
}
@ -1284,10 +1299,10 @@ struct UserInfo {
// 上车准备弹窗
if (this.isBoardPrePareSetPopupShow) {
BoardPrePareSetPopup({
closePopup: (bool) => {
closePopup: () => {
this.isBoardPrePareSetPopupShow = false;
},
confirmMark: (kfdm) => {
confirmMark: (kfdm: SckType[]) => {
this.sczbkf = kfdm
}
})

View File

@ -0,0 +1,54 @@
import { User } from "../../model";
export const GetCurrentUserKeyValue = (user: User, key: string): string => {
switch (key) {
case "sfzmhm":
return user.sfzmhm;
case "xm":
return user.xm;
case "lsh":
return user.lsh;
case "ksy1":
return user.ksy1;
case "ksy2":
return user.ksy2;
case "id":
return user.id;
case "kszp":
return user.kszp;
case "ksmjzp":
return user.ksmjzp;
case "bz1":
return user.bz1;
case "jxmc":
return user.jxmc;
case "kchp":
return user.kchp;
case "kscx":
return user.kscx;
case "ksdd":
return user.ksdd;
case "kssycs":
return user.kssycs;
case "ksxl":
return user.ksxl;
case "ksy1sfzmhm":
return user.ksy1sfzmhm;
case "kszt":
return user.kszt;
case "xb":
return user.xb;
case "xh":
return user.xh;
case "xldm":
return user.xldm;
case "yycs":
return user.yycs;
case "ksy2sfzmhm":
return user.ksy2sfzmhm;
case "kslx":
return user.kslx || '';
default:
return '';
}
}

View File

@ -12,15 +12,6 @@ class UdpClient {
private disconnectEvents: Array<Function> = []
private dealMethod: DealMethod
private dealMessage() {
this.udp?.on("message", value => {
let result = this?.dealMethod(value.message)
this.messageEvents.forEach(cb => {
cb(result)
})
})
}
init(udpLocalIp: string, udpLocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) {
this.localIp = udpLocalIp
this.oppositeIp = udpOppositeIp
@ -70,12 +61,25 @@ class UdpClient {
})
})
}
private dealMessage() {
this.udp?.on("message", value => {
let result = this?.dealMethod(value.message)
this.messageEvents.forEach(cb => {
cb(result)
})
})
}
}
export const objUDPClient = new UdpClient()
// 中心心跳
export const centerUDPClient = new UdpClient()
// 中心GPS
// 顶灯
export const lightUDPClient = new UdpClient()
// 获取后置机信号
export const judgeUDPClient = new UdpClient()