globalThis 修改

This commit is contained in:
lvyuankang 2025-02-12 13:17:00 +08:00
parent 4f34fc484c
commit f888171929
13 changed files with 96 additions and 106 deletions

View File

@ -4,8 +4,7 @@ import { initCarInfoCache } from '../../api/index'
//考官登录信息 //考官登录信息
export async function examinerLoginService(params) { export async function examinerLoginService(params) {
let res: any = await examinerLogin(params) let res: any = await examinerLogin(params)
AppStorage.setOrCreate('examinerInfo', res?.examinerLoginRsp?.body)
globalThis.examinerInfo = res?.examinerLoginRsp?.body || {}
console.log('jiangsong1: examinerLoginService' + JSON.stringify(res)) console.log('jiangsong1: examinerLoginService' + JSON.stringify(res))
//{"examinerLoginRsp":{"head":{"resultCode":"0","resultMessage":"%E8%80%83%E8%AF%95%E5%91%98%E7%99%BB%E5%BD%95-%E6%88%90%E5%8A%9F","time":"2023-06-01 10:06:39"},"body":{"code":"006","name":"%E8%80%836","statusRgpp":"1"}}} //{"examinerLoginRsp":{"head":{"resultCode":"0","resultMessage":"%E8%80%83%E8%AF%95%E5%91%98%E7%99%BB%E5%BD%95-%E6%88%90%E5%8A%9F","time":"2023-06-01 10:06:39"},"body":{"code":"006","name":"%E8%80%836","statusRgpp":"1"}}}
return res return res
@ -14,7 +13,6 @@ export async function examinerLoginService(params) {
//获取考车信息 //获取考车信息
export async function initParseCarInfo(params) { export async function initParseCarInfo(params) {
let res: any = await initCarInfoCache(params) let res: any = await initCarInfoCache(params)
// globalThis.parseCarInfo=res.examinerLoginRsp.body
console.log('jiangsong1: examinerLoginService' + JSON.stringify(res)) console.log('jiangsong1: examinerLoginService' + JSON.stringify(res))
//{"examinerLoginRsp":{"head":{"resultCode":"0","resultMessage":"%E8%80%83%E8%AF%95%E5%91%98%E7%99%BB%E5%BD%95-%E6%88%90%E5%8A%9F","time":"2023-06-01 10:06:39"},"body":{"code":"006","name":"%E8%80%836","statusRgpp":"1"}}} //{"examinerLoginRsp":{"head":{"resultCode":"0","resultMessage":"%E8%80%83%E8%AF%95%E5%91%98%E7%99%BB%E5%BD%95-%E6%88%90%E5%8A%9F","time":"2023-06-01 10:06:39"},"body":{"code":"006","name":"%E8%80%836","statusRgpp":"1"}}}
return res return res

View File

@ -26,16 +26,15 @@ async function getliushuiNum(data) {
for (let i = 0; str.length <= 5; i++) { for (let i = 0; str.length <= 5; i++) {
str = '0' + str str = '0' + str
} }
globalThis.lshNo = str AppStorage.setOrCreate('lshNo',str)
} else { } else {
num = 0 num = 0
let str = num.toString() let str = num.toString()
for (let i = 0; str.length <= 5; i++) { for (let i = 0; str.length <= 5; i++) {
str = '0' + str str = '0' + str
} }
globalThis.lshNo = str AppStorage.setOrCreate('lshNo',str)
} }
} }
export async function deleteAllFIleLog(path) { export async function deleteAllFIleLog(path) {
@ -221,13 +220,12 @@ export async function takePhotoFn(context) {
spzd1: false, spzd1: false,
zdyz: '5', zdyz: '5',
} }
globalThis.spzd = { const spzd = {
spzd1: false, spzd1: false,
spzd2: false, spzd2: false,
spzd3: false, spzd3: false,
spzd4: false, spzd4: false,
} }
globalThis.takePhotoNum = 0
const map = {} const map = {}
const fileUtil = new FileUtil(context) const fileUtil = new FileUtil(context)
const fileData = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/config3.txt'); const fileData = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/config3.txt');
@ -252,7 +250,7 @@ export async function takePhotoFn(context) {
return return
} }
console.log('takePhototakePhoto', JSON.stringify(data)) console.log('takePhototakePhoto', JSON.stringify(data))
const zdyz = globalThis.param854Str ? Number(globalThis.param854Str) : Number(param.zdyz) const zdyz = AppStorage.get('param854Str') ? Number(AppStorage.get('param854Str')) : Number(param.zdyz)
console.log('takePhototakePhoto', JSON.stringify(zdyz),) console.log('takePhototakePhoto', JSON.stringify(zdyz),)
if (Number(data.fileSize) <= (zdyz * 1000)) { if (Number(data.fileSize) <= (zdyz * 1000)) {
@ -261,11 +259,13 @@ export async function takePhotoFn(context) {
message: `视频遮挡`, message: `视频遮挡`,
duration: 3000 duration: 3000
}); });
globalThis.spzd[key1] = true spzd[key1] = true
} else { } else {
map[key1] = false map[key1] = false
globalThis.spzd[key1] = false spzd[key1] = false
} }
AppStorage.setOrCreate('spzd',spzd)
setTimeout(() => { setTimeout(() => {
takePhotoFn() takePhotoFn()
}, 3000) }, 3000)
@ -273,26 +273,23 @@ export async function takePhotoFn(context) {
} }
} }
globalThis.takePhotoNum++
if (globalThis.takePhotoNum >= 20) {
globalThis.takePhotoNum = 0
// deleteAllFileByPiC('jt')
}
}, 3000) }, 3000)
} }
let fd let fd
const devPath = "/dev/ttyS3" const devPath = "/dev/ttyS3"
let chuankoufd
function openChuankouFn(callback) { function openChuankouFn(callback) {
console.log('SerialOpen in indexservice, path=' + devPath) console.log('SerialOpen in indexservice, path=' + devPath)
//TODO 自动挡车不读取串口 //TODO 自动挡车不读取串口
testNapi.SerialOpenAsync(devPath, (fd) => { testNapi.SerialOpenAsync(devPath, (fd) => {
globalThis.fd = fd; chuankoufd=fd
globalThis.num = 0 // AppStorage.setOrCreate('fd',fd)
// AppStorage.setOrCreate('num',0)
let parity = 0x4e; // 'N' let parity = 0x4e; // 'N'
let ret = testNapi.SerialSetAsync(globalThis.fd, 115200, 0, 8, 1, parity, (ret) => { let ret = testNapi.SerialSetAsync(chuankoufd, 115200, 0, 8, 1, parity, (ret) => {
callback() callback()
}); });
}); });
@ -301,15 +298,14 @@ function openChuankouFn(callback) {
function getChuankouFnMsg() { function getChuankouFnMsg() {
let timeout = 50000; // 2秒超时 let timeout = 50000; // 2秒超时
let databuff = [0x61, 0xAA, 0x0A, 0X15, 0X00]; // send ABCDE let databuff = [0x61, 0xAA, 0x0A, 0X15, 0X00]; // send ABCDE
testNapi.SerialSendAsync(globalThis.fd, databuff, (ret) => { testNapi.SerialSendAsync(chuankoufd, databuff, (ret) => {
testNapi.SerialRecvAsync(globalThis.fd, timeout, (revTestInfo) => { testNapi.SerialRecvAsync(chuankoufd, timeout, (revTestInfo) => {
const message = revTestInfo?.recevedBuf?.toString() const message = revTestInfo?.recevedBuf?.toString()
if (message == '') { if (message == '') {
globalThis.num = 1
// clearInterval(chuankou) // clearInterval(chuankou)
testNapi.SerialClose(globalThis.fd); testNapi.SerialClose(chuankoufd);
globalThis.fd = null chuankoufd= null
setTimeout(() => { setTimeout(() => {
getChuankouFn() getChuankouFn()
}, 2000) }, 2000)
@ -323,7 +319,7 @@ function getChuankouFnMsg() {
} else if (msg.length < 12) { } else if (msg.length < 12) {
} else { } else {
globalThis.chuankoMsg = msg[9] AppStorage.setOrCreate('chuankoMsg',msg[9])
} }
setTimeout(() => { setTimeout(() => {
@ -336,14 +332,13 @@ function getChuankouFnMsg() {
}); });
}); });
// let revTestInfo = testNapi?.SerialRecv(globalThis.fd, timeout);
} }
let chuankou let chuankou
export async function getChuankouFn() { export async function getChuankouFn() {
if (globalThis.fd) { if (chuankoufd) {
return return
} }
openChuankouFn(getChuankouFnMsg) openChuankouFn(getChuankouFnMsg)

View File

@ -30,6 +30,7 @@ import FileUtil from '../../common/utils/File';
import { GlobalConfig } from '../../config/index'; import { GlobalConfig } from '../../config/index';
import prompt from '@ohos.promptAction'; import prompt from '@ohos.promptAction';
import DB, { ColumnType } from '../database/DbSql'; import DB, { ColumnType } from '../database/DbSql';
import App from '@system.app';
//读表 //读表
//参数平台 //参数平台
@ -345,7 +346,8 @@ export async function delSyncTable(tableName, context?) {
//获取车模、场地模型 //获取车模、场地模型
export async function getEsCarModel(context) { export async function getEsCarModel(context) {
const date = new Date() const date = new Date()
if (!globalThis.timeInfo?.paraKdid) { const timeInfo=AppStorage.get('timeInfo')
if (!timeInfo?.paraKdid) {
prompt.showToast({ prompt.showToast({
message: 'paraKdid获取失败', message: 'paraKdid获取失败',
duration: 3000 duration: 3000
@ -358,10 +360,10 @@ export async function getEsCarModel(context) {
{ {
"rtkType": "1", //1:车模 2:场地模型 "rtkType": "1", //1:车模 2:场地模型
"rspType": "0", //返回类型 "rspType": "0", //返回类型
"paraKdid": globalThis.timeInfo.paraKdid, //参数平台kdid "paraKdid": timeInfo.paraKdid, //参数平台kdid
"examinationRoomId": globalThis.timeInfo.kdid, //考试平台kdid "examinationRoomId": timeInfo.kdid, //考试平台kdid
// "carMac":"MAC-HCPAD-210", // "carMac":"MAC-HCPAD-210",
"carMac": globalThis.deviceNo "carMac": AppStorage.get('deviceNo')
} }
} }
const venueStr = { const venueStr = {
@ -370,10 +372,10 @@ export async function getEsCarModel(context) {
{ {
"rtkType": "2", //1:车模 2:场地模型 "rtkType": "2", //1:车模 2:场地模型
"rspType": "0", //返回类型 "rspType": "0", //返回类型
"paraKdid": globalThis.timeInfo.paraKdid, //参数平台kdid "paraKdid": timeInfo.paraKdid, //参数平台kdid
"examinationRoomId": globalThis.timeInfo.kdid, //考试平台kdid "examinationRoomId": timeInfo.kdid, //考试平台kdid
// "carMac":"MAC-HCPAD-210", // "carMac":"MAC-HCPAD-210",
"carMac": globalThis.deviceNo "carMac": AppStorage.get('deviceNo')
} }
} }

View File

@ -14,14 +14,14 @@ export async function getDeviceInfo(context) {
message: `请先进行设备注册`, message: `请先进行设备注册`,
duration: 3000 duration: 3000
}); });
globalThis.type = '1' AppStorage.setOrCreate('type', 1)
globalThis.title = decodeURIComponent('请先进行设备注册') AppStorage.setOrCreate('title', '请先进行设备注册')
globalThis.errorDialog.open() globalThis.errorDialog.open()
resolve('') resolve('')
} else { } else {
const fileData = JSON.parse(data) const fileData = JSON.parse(data)
globalThis.deviceNo = fileData.deviceName
console.log('globalThis.deviceNo', globalThis.deviceNo) AppStorage.setOrCreate('deviceNo', fileData.deviceName)
// getCarInfo() // getCarInfo()
resolve(fileData.deviceName) resolve(fileData.deviceName)
} }
@ -31,19 +31,18 @@ export async function getDeviceInfo(context) {
//获取考车信息 //获取考车信息
export async function getCarInfo() { export async function getCarInfo() {
let date = new Date(); let date = new Date();
console.log('globalThis.carInfo2222', globalThis.deviceNo)
let params = { time: dateFormat(date), deviceNo: globalThis.deviceNo }; let params = { time: dateFormat(date), deviceNo: AppStorage.get('deviceNo') };
let res: any = await obtainCarExamInfo(params) let res: any = await obtainCarExamInfo(params)
if (!res?.obtainCarExamInfoRsp?.body) { if (!res?.obtainCarExamInfoRsp?.body) {
// router.pushUrl({ // router.pushUrl({
// url: 'pages/Register', // url: 'pages/Register',
// }, router.RouterMode.Single); // }, router.RouterMode.Single);
} else { } else {
globalThis.carInfo = res.obtainCarExamInfoRsp.body const carInfo=res.obtainCarExamInfoRsp.body
console.log('globalThis.carInfo2222', JSON.stringify(res)); carInfo.plateNo= decodeURIComponent(carInfo.plateNo)
// globalThis.carInfo.carId=res.obtainCarExamInfoRsp.body.carId AppStorage.setOrCreate('carInfo',carInfo)
globalThis.carInfo.plateNo = decodeURIComponent(globalThis.carInfo.plateNo)
} }
return res return res
} }

View File

@ -44,6 +44,7 @@ export default class EntryAbility extends UIAbility {
AppStorage.setOrCreate('lsh','0000000000000') AppStorage.setOrCreate('lsh','0000000000000')
AppStorage.setOrCreate('statue',1)//考试状态 AppStorage.setOrCreate('statue',1)//考试状态
AppStorage.setOrCreate('signNum',0)//心跳指令编号 AppStorage.setOrCreate('signNum',0)//心跳指令编号
AppStorage.setOrCreate('deviceNo',0)//设备号
AppStorage.setOrCreate('baseInfo',{ AppStorage.setOrCreate('baseInfo',{
hasAuth:false, hasAuth:false,
version:GlobalConfig.version.jn.km3[0], version:GlobalConfig.version.jn.km3[0],
@ -54,7 +55,6 @@ export default class EntryAbility extends UIAbility {
pathDir: this.context.filesDir, pathDir: this.context.filesDir,
context: this.context, context: this.context,
isJudgeInitBool:false, isJudgeInitBool:false,
deviceNo:''//设备号
}) })

View File

@ -291,4 +291,4 @@ export const VideoConfigData: VideoConfig = {
spzd2: false, spzd2: false,
spzd1: false, spzd1: false,
zdyz: '500' zdyz: '500'
} }

View File

@ -1,3 +1,5 @@
import common from '@ohos.app.ability.common'
export interface User { export interface User {
sfzmhm: string sfzmhm: string
xm: string xm: string
@ -72,4 +74,15 @@ export interface VideoConfig {
export interface CommonType { export interface CommonType {
key: string; key: string;
}
export interface baseInfo {
hasAuth: boolean,
version:string,
judgeVersion:string,
tcpSendNum:number,
videoVersion:string,
ratio:number,
pathDir:string,
context:common.UIAbilityContext,
isJudgeInitBool:boolean,
} }

View File

@ -5,6 +5,7 @@ import TopLogo from './compontents/TopLogo';
import testNapi from '@ohos.hiserialsdk'; import testNapi from '@ohos.hiserialsdk';
import { dateFormat } from '../common/utils/tools'; import { dateFormat } from '../common/utils/tools';
import { DwMapData, PassData, RealNumData, StackValueData, WarnFlagData, WarnFlagTipData } from '../mock'; import { DwMapData, PassData, RealNumData, StackValueData, WarnFlagData, WarnFlagTipData } from '../mock';
import { baseInfo } from '../model/Common';
@Entry @Entry
@Component @Component
@ -36,11 +37,13 @@ struct Index {
@State devPath: string = "/dev/ttyS3" @State devPath: string = "/dev/ttyS3"
@State stopFlag: boolean = false @State stopFlag: boolean = false
@State fromIndex: boolean = false @State fromIndex: boolean = false
@State carinfo: object = {}
private vocObj: ESObject; private vocObj: ESObject;
// private AccountTable = new AccountTable(()=>{},CommonConstants); // private AccountTable = new AccountTable(()=>{},CommonConstants);
aboutToAppear() { aboutToAppear() {
const that = this const that = this
this.carInfo=AppStorage.get('carInfo')
this.vocObj = new voiceService(async (status: string, val: string) => { this.vocObj = new voiceService(async (status: string, val: string) => {
if (!that.breakFlag) { if (!that.breakFlag) {
return return
@ -93,7 +96,7 @@ struct Index {
if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) { if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) {
return return
} }
globalThis.chuankoMsg = msg[9] AppStorage.setOrCreate('chuankoMsg', msg[9])
if (msg[9] == this.dwMap[this.index]) { if (msg[9] == this.dwMap[this.index]) {
this.warnFlag[this.index] = '2' this.warnFlag[this.index] = '2'
} }
@ -115,25 +118,7 @@ struct Index {
// //
carConfigurationInfoFn() { carConfigurationInfoFn() {
// const fileUtil = new FileUtil(context) if (AppStorage.get('singlePlay')) {
// const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/deviceNo.txt');
// if (data === '' || data === undefined) {
// promptAction.showToast({
// message: `请先进行设备注册`,
// duration: 3000
// });
// globalThis.type='1'
// globalThis.title=decodeURIComponent('请先进行设备注册')
// globalThis.errorDialog.open()
// resolve('')
// } else {
// const fileData=JSON.parse(data)
// globalThis.deviceNo = fileData.deviceName
// console.log('globalThis.deviceNo', globalThis.deviceNo)
// // getCarInfo()
// resolve(fileData.deviceName)
// }
if (globalThis.singlePlay) {
const str = const str =
"1:5;2:5;3:5;4:5;5:5;6:5;7:5;8:5;9:5;10:5;11:5;12:5;13:5;14:5;15:5;16:5;17:5;18:5;19:5;20:5;21:5;22:2;23:5;24:5" "1:5;2:5;3:5;4:5;5:5;6:5;7:5;8:5;9:5;10:5;11:5;12:5;13:5;14:5;15:5;16:5;17:5;18:5;19:5;20:5;21:5;22:2;23:5;24:5"
const data = str.split(';') const data = str.split(';')
@ -148,12 +133,13 @@ struct Index {
this.checkListCopy = JSON.parse(JSON.stringify(this.checkList)) this.checkListCopy = JSON.parse(JSON.stringify(this.checkList))
return return
} }
const baseInfo=AppStorage.get('baseInfo') as baseInfo
//模拟真实数据 //模拟真实数据
const param = { const param = {
"body": "body":
{ {
"carIdString": globalThis.carInfo.carId, //考车ID "carIdString": this.carInfo.carId, //考车ID
"deviceNo": globalThis.deviceNo "deviceNo": baseInfo.deviceNo
} }
} }
@ -284,15 +270,15 @@ struct Index {
type: 1, type: 1,
name: flag ? 'zjwtg.wav' : 'zjtg.wav' name: flag ? 'zjwtg.wav' : 'zjtg.wav'
}) })
if (globalThis.singlePlay) { if (AppStorage.get('singlePlay')) {
return return
} }
let date = new Date(); let date = new Date();
const data = { const data = {
time: dateFormat(date), time: dateFormat(date),
carId: globalThis.carInfo.carId, carId: this.carInfo.carId,
examinationRoomId: globalThis.carInfo.examinationRoomId, examinationRoomId: this.carInfo.examinationRoomId,
plateNo: globalThis.carInfo.plateNo, plateNo: this.carInfo.plateNo,
flag: flag ? 'N' : 'Y', flag: flag ? 'N' : 'Y',
condition: flag ? '自检不通过' : '自检通过' condition: flag ? '自检不通过' : '自检通过'
} }
@ -321,11 +307,9 @@ struct Index {
that.passArray[index] = true that.passArray[index] = true
if (index == 2) { if (index == 2) {
let flag = false let flag = false
console.log('globalThis.spzd[key]', globalThis.spzd) const spzd=AppStorage.get('spzd')
for (let key in pzd) {
for (let key in globalThis.spzd) { if (spzd[key]) {
console.log('globalThis.spzd[key]', globalThis.spzd[key])
if (globalThis.spzd[key]) {
that.warnFlag[index] = '1' that.warnFlag[index] = '1'
flag = true flag = true
} }

View File

@ -93,16 +93,16 @@ struct Index {
if (this.limit) { if (this.limit) {
return return
} }
const carInfo=AppStorage.get('carInfo')
const param: UserLoginType = { const param: UserLoginType = {
carId: globalThis.carInfo.carId as string, carId: carInfo.carId as string,
examinationRoomId: globalThis.carInfo.examinationRoomId as string, examinationRoomId: carInfo.examinationRoomId as string,
username: this.inputTextArr[0], username: this.inputTextArr[0],
password: Md5.Instance.get_md5(this.inputTextArr[1]) password: Md5.Instance.get_md5(this.inputTextArr[1])
} }
this.type = '2' this.type = '2'
this.errorDialog.open() this.errorDialog.open()
this.limit = true this.limit = true
console.log('carInfo', JSON.stringify(globalThis.carInfo))
try { try {
// TODO // TODO
examinerLoginService(param).then((res: ESObject) => { examinerLoginService(param).then((res: ESObject) => {
@ -126,10 +126,9 @@ struct Index {
}, router.RouterMode.Single); }, router.RouterMode.Single);
console.log('res11', JSON.stringify(res)) console.log('res11', JSON.stringify(res))
globalThis.ksyxm = res.examinerLoginRsp.body.ksyxm const examinerLoginInfo=res.examinerLoginRsp.body
globalThis.kgxm = res.examinerLoginRsp.body.name examinerLoginInfo.username= this.inputTextArr[0]
AppStorage.setOrCreate('examinerLoginInfo',examinerLoginInfo)
globalThis.username = this.inputTextArr[0]
}).catch((err: BusinessError) => { }).catch((err: BusinessError) => {
console.log('jiangsong12', JSON.stringify(err)) console.log('jiangsong12', JSON.stringify(err))
this.errorDialog.close() this.errorDialog.close()

View File

@ -18,7 +18,7 @@ import UdpEvent from '../common/utils/UdpEvent';
import { delPic } from '../service/videoService'; import { delPic } from '../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 {baseInfo} from '../model/Common'
// import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; // import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
@Entry @Entry
@ -30,7 +30,7 @@ struct Index {
@State hasAuth: boolean = false; @State hasAuth: boolean = false;
@State dialogVisiable: boolean = false; @State dialogVisiable: boolean = false;
@State singlePlay: boolean = false; @State singlePlay: boolean = false;
@State baseInfo: object = { }; @State baseInfo: baseInfo = {};
@State deviceId: string = ''; @State deviceId: string = '';
@State angle: number = 0 @State angle: number = 0
@State dialogRatio: number = 0.8 @State dialogRatio: number = 0.8
@ -363,16 +363,10 @@ struct Index {
this.dialogVisiable = false this.dialogVisiable = false
this.angle = 0 this.angle = 0
this.loading = false this.loading = false
const baseInfo=AppStorage.get('baseInfo') AppStorage.set('lsh','1111111111111')
baseInfo.lsh = '1111111111111'
AppStorage.setOrCreate('baseInfo',baseInfo)
globalThis.errorDialog = this.errorDialog globalThis.errorDialog = this.errorDialog
globalThis.udpEvent = new UdpEvent(); globalThis.udpEvent = new UdpEvent();
getSyncData('MA_SYSSET').then(async data => { getSyncData('MA_SYSSET').then(async data => {
console.log('datadata', JSON.stringify(data))
// @ts-ignore
// @ts-ignore // @ts-ignore
data.forEach(async sys => { data.forEach(async sys => {
//判断是否能点开始考试 //判断是否能点开始考试
@ -527,7 +521,7 @@ struct Index {
async onPageShow() { async onPageShow() {
console.log('ttttt', 1111) console.log('ttttt', 1111)
this.singlePlay=AppStorage.get('singlePlay') this.singlePlay=AppStorage.get('singlePlay')
this.baseInfo=AppStorage.get('baseInfo') this.baseInfo=AppStorage.get('baseInfo') as baseInfo
await this.userAuth(); await this.userAuth();
if (this.singlePlay == undefined || this.singlePlay == null) { if (this.singlePlay == undefined || this.singlePlay == null) {
// setVideoParam() // setVideoParam()

View File

@ -21,7 +21,6 @@ struct Index {
private context = getContext(this) as common.UIAbilityContext; private context = getContext(this) as common.UIAbilityContext;
onPageShow() { onPageShow() {
// this.plateNo=globalThis.carInfo.plateNo
console.log('createDeviceManagerstart') console.log('createDeviceManagerstart')
try { try {
deviceManager.createDeviceManager('com.oh.dts', (error: string, value: deviceManager.DeviceManager) => { deviceManager.createDeviceManager('com.oh.dts', (error: string, value: deviceManager.DeviceManager) => {
@ -32,7 +31,7 @@ struct Index {
this.deviceName = value.getLocalDeviceInfoSync().deviceName this.deviceName = value.getLocalDeviceInfoSync().deviceName
this.deviceNo = value.getLocalDeviceInfoSync().deviceId.substring(0, 10).toUpperCase() this.deviceNo = value.getLocalDeviceInfoSync().deviceId.substring(0, 10).toUpperCase()
this.ip = 'MAC-' + this.deviceNo this.ip = 'MAC-' + this.deviceNo
globalThis.deviceNo = 'MAC-' + this.deviceNo AppStorage.setOrCreate('deviceNo','MAC-' + this.deviceNo)
}); });
} catch (error) { } catch (error) {
@ -53,7 +52,8 @@ struct Index {
this.subType = '2' this.subType = '2'
} }
this.ip = 'MAC-' + this.deviceNo this.ip = 'MAC-' + this.deviceNo
globalThis.deviceNo = this.ip AppStorage.setOrCreate('deviceNo', this.ip)
}) })
Text('网卡').fontSize(34 * this.ratio).fontColor('#FFE0B2').margin({ right: 98.5 * this.ratio }) Text('网卡').fontSize(34 * this.ratio).fontColor('#FFE0B2').margin({ right: 98.5 * this.ratio })
} }
@ -66,7 +66,7 @@ struct Index {
this.subType = '3' this.subType = '3'
} }
this.ip = 'DISK-' + this.deviceNo this.ip = 'DISK-' + this.deviceNo
globalThis.deviceNo = this.ip AppStorage.setOrCreate('deviceNo', this.ip)
// this.ip = ip // this.ip = ip
}) })
Text('硬盘').fontSize(34 * this.ratio).fontColor('#FFE0B2').margin({ right: 83 * this.ratio }) Text('硬盘').fontSize(34 * this.ratio).fontColor('#FFE0B2').margin({ right: 83 * this.ratio })
@ -124,8 +124,7 @@ struct Index {
const fileUtil = new FileUtil(this.context) const fileUtil = new FileUtil(this.context)
const folderPath = await fileUtil.initFolder(`/config`); const folderPath = await fileUtil.initFolder(`/config`);
fileUtil.addFile(`${folderPath}/deviceNo.txt`, JSON.stringify(param)) fileUtil.addFile(`${folderPath}/deviceNo.txt`, JSON.stringify(param))
globalThis.deviceNo = this.ip AppStorage.setOrCreate('deviceNo', this.ip)
console.log('globalThis.deviceNo', globalThis.deviceNo)
// upDateTableByArray('DeviceInfoTable', [{ deviceId: this.ip }]) // upDateTableByArray('DeviceInfoTable', [{ deviceId: this.ip }])
registrationDeviceNo(param).then((res: ESObject) => { registrationDeviceNo(param).then((res: ESObject) => {
if (res.registrationDeviceNoRsp.head.resultCode == '0') { if (res.registrationDeviceNoRsp.head.resultCode == '0') {

View File

@ -1,4 +1,5 @@
import router from '@ohos.router' import router from '@ohos.router'
import { baseInfo } from '../model/Common'
import TopLogo from './compontents/TopLogo' import TopLogo from './compontents/TopLogo'
@Entry @Entry
@ -9,6 +10,9 @@ struct Index {
@State version: string = '' @State version: string = ''
@State hasAuth: boolean = false; @State hasAuth: boolean = false;
@State url: string = '' @State url: string = ''
@State baseinfo: baseinfo = {}
@State carInfo: object = {}
@State @Watch('outClick') outFlag: boolean = false; @State @Watch('outClick') outFlag: boolean = false;
// private vocObj = null; // private vocObj = null;
@ -68,7 +72,7 @@ struct Index {
} }
.margin({ left: 24 * this.ratio }) .margin({ left: 24 * this.ratio })
Text('考车号:' + globalThis.carInfo.carNo) Text('考车号:' + this.carInfo.carNo)
.fontColor('#CCAE7A') .fontColor('#CCAE7A')
.fontSize(22 * this.ratio) .fontSize(22 * this.ratio)
.margin({ right: 24 * this.ratio }) .margin({ right: 24 * this.ratio })
@ -89,9 +93,11 @@ struct Index {
aboutToAppear() { aboutToAppear() {
// this.vocObj = new voiceService(async (status, val, next) => { // this.vocObj = new voiceService(async (status, val, next) => {
// }); // });
this.carNum = globalThis.carInfo.plateNo; this.carInfo=AppStorage.get('carInfo')
this.version = globalThis.version; this.baseinfo=AppStorage.get('baseinfo') as baseInfo
this.hasAuth = globalThis.hasAuth; this.carNum = this.carInfo.plateNo;
this.version = baseinfo.version;
this.hasAuth = baseinfo.hasAuth;
} }
outClick() { outClick() {

View File

@ -583,7 +583,8 @@ struct Index {
} }
aboutToAppear() { aboutToAppear() {
this.ratio = globalThis.ratio const radio=AppStorage.get('ratio') as number
this.ratio = radio
this.openFlag = true this.openFlag = true
const fileUtil = new FileUtil(this.context) const fileUtil = new FileUtil(this.context)
this.fileUtil = fileUtil this.fileUtil = fileUtil