Compare commits
	
		
			4 Commits
		
	
	
		
			f4fbb5702d
			...
			18e04d029f
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 18e04d029f | |||
| 97768c336d | |||
| a117df4cac | |||
| 9c83bdae52 | 
| @ -137,27 +137,30 @@ export async function getSingleCenterTable(param) { | ||||
|       if (result) { | ||||
|         reslove(true) | ||||
|       } else { | ||||
|         promptAction.showDialog({ | ||||
|           title: '提示', | ||||
|           message: '联网更新失败,请检查网络后重新更新', | ||||
|           buttons: [ | ||||
|             { | ||||
|               text: '确认', | ||||
|               color: '#000000', | ||||
|             }, | ||||
|             { | ||||
|               text: '取消', | ||||
|               color: '#000000', | ||||
|             } | ||||
|           ], | ||||
|         }) | ||||
|           .then(data => { | ||||
|             reslove(false) | ||||
|           }) | ||||
|           .catch(err => { | ||||
|             reslove(false) | ||||
|           }) | ||||
| 
 | ||||
|         // promptAction.showToast({
 | ||||
|         //   title: '提示',
 | ||||
|         //   message: '联网更新失败,请检查网络后重新更新',
 | ||||
|         //   buttons: [
 | ||||
|         //     {
 | ||||
|         //       text: '确认',
 | ||||
|         //       color: '#000000',
 | ||||
|         //     },
 | ||||
|         //     {
 | ||||
|         //       text: '取消',
 | ||||
|         //       color: '#000000',
 | ||||
|         //     }
 | ||||
|         //   ],
 | ||||
|         // })
 | ||||
|         //   .then(data => {
 | ||||
|         //     reslove(false)
 | ||||
|         //   })
 | ||||
|         //   .catch(err => {
 | ||||
|         //     reslove(false)
 | ||||
|         //   })
 | ||||
|         promptAction.showToast({ | ||||
|           message: `联网更新失败,请检查网络后重新更新`, | ||||
|           duration: 3000 | ||||
|         }); | ||||
|         reslove(false) | ||||
|       } | ||||
|     }).catch((error) => { | ||||
|  | ||||
| @ -6,7 +6,7 @@ export async function getTCP() { | ||||
|   getSyncData('IpConfigTable').then(async (result:Array<any>)=>{ | ||||
|     console.log('result222',JSON.stringify(result)) | ||||
|     if(result.length){ | ||||
|       if(globalThis.TcpClient&&globalThis.TcpClient.closeTcp){ | ||||
|       if(globalThis.TcpClient&&globalThis.getCloseTcp){ | ||||
|         globalThis.TcpClient.closeTcp(async ()=>{ | ||||
|           // const tcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort)
 | ||||
|           // globalThis.TcpClient = tcpClient
 | ||||
|  | ||||
| @ -42,7 +42,7 @@ export async function getUDP() { | ||||
| export async function getUDP2() { | ||||
|   getSyncData('IpConfigTable').then(async (result:Array<any>)=>{ | ||||
|     if(result.length){ | ||||
|       if(globalThis.udpClient2&&globalThis.udpClient2.closeUdp){ | ||||
|       if(globalThis.udpClient2&&globalThis.closeHeartSocket){ | ||||
| 
 | ||||
|         globalThis.udpClient2.closeUdp(async ()=>{ | ||||
|           setTimeout(()=>{ | ||||
|  | ||||
| @ -39,11 +39,12 @@ export default class TcpClient { | ||||
|             console.log(TAG,'tcpreBind', this.localIp,this.localIpPort) | ||||
|             let promise=this.tcp.bind({ address:  this.localIp, port:parseInt(this.localIpPort), family: 1 }, err => { | ||||
|                 if (err) { | ||||
|                     globalThis.getCloseTcp=true | ||||
|                     hilog.info(0x0000, 'testTag', "tcpreBinderror:" + JSON.stringify(err)); | ||||
|                     resolve(true) | ||||
|                 } | ||||
|                 console.log('testTag,rebindtestTag tcp bind success'); | ||||
| 
 | ||||
|                 globalThis.getCloseTcp=false | ||||
|                 resolve(false) | ||||
| 
 | ||||
|             }) | ||||
| @ -62,11 +63,12 @@ export default class TcpClient { | ||||
|             let promise=this.tcp.bind({ address:  this.localIp, port:parseInt(this.localIpPort), family: 1 }, err => { | ||||
|                 if (err) { | ||||
|                     console.log('testTag tcp bind faile'); | ||||
| 
 | ||||
|                     globalThis.getCloseTcp=true | ||||
|                     hilog.info(0x0000, 'testTag', "tcpBinderror:" + JSON.stringify(err)); | ||||
|                     resolve(true) | ||||
|                     return | ||||
|                 } | ||||
|                 globalThis.getCloseTcp=false | ||||
|                 console.log('testTag tcp bind success'); | ||||
|                 resolve(false) | ||||
|             }) | ||||
| @ -101,8 +103,11 @@ export default class TcpClient { | ||||
|                         return; | ||||
|                     } | ||||
|                 }); | ||||
|                 globalThis.getCloseTcp=false | ||||
|                 resolve(true) | ||||
|             }).catch(err => { | ||||
|                 globalThis.getCloseTcp=true | ||||
| 
 | ||||
|                 console.log('testTagconnect,error') | ||||
|                 resolve(false) | ||||
|             }); | ||||
| @ -153,6 +158,7 @@ export default class TcpClient { | ||||
|             console.log(TAG,'tcpClose') | ||||
|             let promise = this.tcp.close(); | ||||
|             promise.then(() => { | ||||
|                 globalThis.getCloseTcp=true | ||||
|                 console.log(TAG,'tcpCloseSuccess') | ||||
|                 callback() | ||||
|                 reslove(true) | ||||
| @ -161,7 +167,5 @@ export default class TcpClient { | ||||
|                 reslove(false) | ||||
|             }); | ||||
|         }) | ||||
| 
 | ||||
| 
 | ||||
|     } | ||||
| } | ||||
| @ -57,7 +57,7 @@ export default class UdpClient { | ||||
| 
 | ||||
|       console.log(`${TAG},udpCLient udp rebind success`); | ||||
|     }).catch(err => { | ||||
| 
 | ||||
|       globalThis.closeUDPSocket=true | ||||
|       console.log(`${TAG},udpCLient udp rebind failed:${JSON.stringify(err)}`); | ||||
|     }); | ||||
|   } | ||||
| @ -73,7 +73,7 @@ export default class UdpClient { | ||||
|       globalThis.closeUDPSocket=false | ||||
|       console.log(`${TAG}udpCLient udp bind success`); | ||||
|     }).catch(err => { | ||||
| 
 | ||||
|       globalThis.closeUDPSocket=true | ||||
|       console.log(`${TAG}udpCLient udp bind failed:${JSON.stringify(err)}`); | ||||
|     }); | ||||
|   } | ||||
| @ -82,27 +82,37 @@ export default class UdpClient { | ||||
|   } | ||||
|   sendMsg(msg) { | ||||
|     console.log(TAG,'UdpSend1111',this.oppositeIp,this.oppositeIpPort) | ||||
|     this.udp.getState((err, data) => { | ||||
|       if (err) { | ||||
| 
 | ||||
|     let promise = this.udp.send({ | ||||
|       data: msg, | ||||
|       address: { | ||||
|         // address: '192.168.7.124',
 | ||||
|         // port: 30013,
 | ||||
|         // address: '192.168.7.124',
 | ||||
|         // port: 20022,
 | ||||
|         address: this.oppositeIp, | ||||
|         port: parseInt(this.oppositeIpPort), | ||||
|         family: 1 | ||||
|         console.log('getState fail'); | ||||
|         return; | ||||
|       } else { | ||||
|         let promise = this.udp.send({ | ||||
|           data: msg, | ||||
|           address: { | ||||
|             // address: '192.168.7.124',
 | ||||
|             // port: 30013,
 | ||||
|             // address: '192.168.7.124',
 | ||||
|             // port: 20022,
 | ||||
|             address: this.oppositeIp, | ||||
|             port: parseInt(this.oppositeIpPort), | ||||
|             family: 1 | ||||
|           } | ||||
|         }); | ||||
|         promise.then(() => { | ||||
|           console.log(`${TAG}udpCLient udp send success:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`); | ||||
|         }).catch(err => { | ||||
|           console.log(`${TAG}udpCLient udp send fail:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`); | ||||
|         }); | ||||
|       } | ||||
|     }); | ||||
|     promise.then(() => { | ||||
|       console.log(`${TAG}udpCLient udp send success:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`); | ||||
|     }).catch(err => { | ||||
|       console.log(`${TAG}udpCLient udp send fail:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`); | ||||
|     }); | ||||
|       console.log('getState success:' + JSON.stringify(data)); | ||||
|     }) | ||||
| 
 | ||||
|   } | ||||
|   onError(callback?){ | ||||
|    this.udp.on('error',async err => { | ||||
|      globalThis.closeUDPSocket=true | ||||
|      console.log(TAG,'udpError',JSON.stringify(err)) | ||||
|      await this.bindUdp() | ||||
|      await this.sendMsg('111') | ||||
| @ -115,7 +125,6 @@ export default class UdpClient { | ||||
|   } | ||||
| 
 | ||||
|   onMessage(callback?) { | ||||
| 
 | ||||
|     this.udp.on('message', value => { | ||||
|       console.log(TAG,'udponmessage') | ||||
|       // 收到的是ArrayBuffer 需要进行转换解析
 | ||||
| @ -187,14 +196,16 @@ export default class UdpClient { | ||||
|   } | ||||
| 
 | ||||
|   closeUdp(callback) { | ||||
|     globalThis.closeUDPSocket=true | ||||
|     this.udp.close(err => { | ||||
|       hilog.info(0x0000,TAG, 'udpCLient', 'close'); | ||||
| 
 | ||||
|       if (err) { | ||||
|         hilog.info(0x0000,TAG, 'udpCLient', 'closeonerror'); | ||||
|         globalThis.closeUDPSocket=false | ||||
| 
 | ||||
|       } else { | ||||
|         globalThis.closeUDPSocket=true | ||||
| 
 | ||||
|         this.udp.getState((err, data) => { | ||||
|           if (err) { | ||||
|             console.log('getState fail'); | ||||
|  | ||||
| @ -64,7 +64,7 @@ export default class UdpClientByCenter { | ||||
|             globalThis.closeHeartSocket=false | ||||
|             console.log(`${TAG} udp bind success`); | ||||
|         }).catch(err => { | ||||
| 
 | ||||
|             globalThis.closeHeartSocket=true | ||||
|             console.log(`${TAG} udp bind failed:${JSON.stringify(err)}`); | ||||
|         }); | ||||
|     } | ||||
| @ -81,7 +81,7 @@ export default class UdpClientByCenter { | ||||
|             globalThis.closeHeartSocket=false | ||||
|             console.log(`${TAG} udp bind success`); | ||||
|         }).catch(err => { | ||||
| 
 | ||||
|             globalThis.closeHeartSocket=true | ||||
|             console.log(`${TAG} udp bind failed:${JSON.stringify(err)}`); | ||||
|         }); | ||||
|     } | ||||
| @ -153,6 +153,7 @@ export default class UdpClientByCenter { | ||||
|     } | ||||
|     onError(callback?){ | ||||
|         this.udp.on('error',async err => { | ||||
|             globalThis.closeHeartSocket=true | ||||
|             callback&&callback() | ||||
|             // callback&&callback()
 | ||||
|             // this.closeUdp(()=>{
 | ||||
| @ -164,32 +165,40 @@ export default class UdpClientByCenter { | ||||
|         this.stashFn=callback?callback:()=>{} | ||||
|     } | ||||
|     sendMsg(param,context?) { | ||||
|         console.log('paramparam',JSON.stringify(param)) | ||||
|         if(context){ | ||||
|             this.context=context | ||||
|         } | ||||
|         this.sendId=param.id | ||||
|         console.log('sendMsg',JSON.stringify(param)) | ||||
|         const msgData=this.setWholeMsg(param) | ||||
|         // const msgData=this.setMsyBody('31','010000000000000')
 | ||||
|         let promise = this.udp.send({ | ||||
|             data: msgData, | ||||
|             address: { | ||||
|                 address: this.oppositeIp, | ||||
|                 port: parseInt(this.oppositeIpPort), | ||||
|         this.udp.getState((err, data) => { | ||||
|             if (err) { | ||||
|                 globalThis.closeHeartSocket=true | ||||
|                 return; | ||||
|             }else{ | ||||
|                 console.log('paramparam',JSON.stringify(param)) | ||||
|                 if(context){ | ||||
|                     this.context=context | ||||
|                 } | ||||
|                 this.sendId=param.id | ||||
|                 console.log('sendMsg',JSON.stringify(param)) | ||||
|                 const msgData=this.setWholeMsg(param) | ||||
|                 // const msgData=this.setMsyBody('31','010000000000000')
 | ||||
|                 let promise = this.udp.send({ | ||||
|                     data: msgData, | ||||
|                     address: { | ||||
|                         address: this.oppositeIp, | ||||
|                         port: parseInt(this.oppositeIpPort), | ||||
|                     } | ||||
|                 }); | ||||
|                 promise.then(() => { | ||||
|                     if(param.sendCallback){ | ||||
|                         param.sendCallback() | ||||
|                     } | ||||
|                     // if(this.sendId=='46'&¶m.callback){
 | ||||
|                     //     param.callback()
 | ||||
|                     // }
 | ||||
|                     console.log(`${TAG} udp send success:`); | ||||
|                 }).catch(err => { | ||||
|                     console.log(`${TAG} udp send fail:${JSON.stringify(err)}`); | ||||
|                 }); | ||||
|             } | ||||
|         }); | ||||
|         promise.then(() => { | ||||
|             if(param.sendCallback){ | ||||
|                 param.sendCallback() | ||||
|             } | ||||
|             // if(this.sendId=='46'&¶m.callback){
 | ||||
|             //     param.callback()
 | ||||
|             // }
 | ||||
|             console.log(`${TAG} udp send success:`); | ||||
|         }).catch(err => { | ||||
|             console.log(`${TAG} udp send fail:${JSON.stringify(err)}`); | ||||
|         }); | ||||
|         }) | ||||
| 
 | ||||
|     } | ||||
|     onMessage(callback,type?) { | ||||
|         this.udp.on('message', value => { | ||||
| @ -223,6 +232,7 @@ export default class UdpClientByCenter { | ||||
|                     if (err) { | ||||
|                         return; | ||||
|                     }else{ | ||||
|                         globalThis.closeHeartSocket=true | ||||
|                         if(!data.isisClose){ | ||||
|                             setTimeout(()=>{ | ||||
|                                 callback() | ||||
|  | ||||
| @ -538,7 +538,7 @@ struct Index { | ||||
|                 if (this.examSubject == 3) { | ||||
|                   Row() { | ||||
|                     Text('考试路线:').fontColor('#E5CCA1').fontSize(this.FONTSIZE) | ||||
|                     Text('线路6').fontColor('#FFAD33').fontSize(this.FONTSIZE) | ||||
|                     Text(`线路${globalThis.carInfo.wayno}`).fontColor('#FFAD33').fontSize(this.FONTSIZE) | ||||
|                   } | ||||
|                 } | ||||
| 
 | ||||
|  | ||||
| @ -2,6 +2,7 @@ import TopLogo from './compontents/TopLogo'; | ||||
| import MA_SYSTEMPARM from '../common/constants/MA_SYSTEMPARM'; | ||||
| import AccountTable from '../common/database/tables/AccountTable'; | ||||
| import { getSyncData } from '../common/service/initable'; | ||||
| import router from '@ohos.router'; | ||||
| 
 | ||||
| const cBg = $rawfile('judge/km3/road/luxian_pre.png'); | ||||
| const lBg = $rawfile('judge/km3/road/luxian_nor.png'); | ||||
| @ -17,20 +18,14 @@ export default struct Index { | ||||
| 
 | ||||
|   async aboutToAppear() { | ||||
|     //读取systemparam表的no1等于4的 | ||||
|     const db = new AccountTable(() => { | ||||
|     }, MA_SYSTEMPARM); | ||||
|     const systemParms: any = await getSyncData('MA_SYSTEMPARM') | ||||
|     systemParms.forEach((systemParm) => { | ||||
| 
 | ||||
|       //TODO 字段名称待修改 | ||||
|       const {no1,no2,no3,txt1,txt2} = systemParm; | ||||
|       if (no1 == 4) { | ||||
|         const temp = { no2, no3, txt1: decodeURI(txt1), txt2 } | ||||
|         if (this.roadObj[no2]) { | ||||
|           this.roadObj[no2].push(temp) | ||||
|         } else { | ||||
|           this.roadObj[no2] = temp | ||||
|         } | ||||
|         console.info('surenjun', JSON.stringify(temp)) | ||||
|         this.roadObj[no2] = no2 | ||||
|       } | ||||
|     }) | ||||
|   } | ||||
| @ -38,8 +33,8 @@ export default struct Index { | ||||
|   build() { | ||||
|     Column() { | ||||
|       TopLogo({ outFlag: $outFlag }) | ||||
|       List({}) { | ||||
|         ForEach(Reflect.ownKeys(this.roadObj), (roadIndex, index) => { | ||||
|       Flex({wrap:FlexWrap.Wrap,direction:FlexDirection.Row,justifyContent:FlexAlign.Start}){ | ||||
|         List({}) { | ||||
|           ListItem() { | ||||
|             Column() { | ||||
|               Row() { | ||||
| @ -49,7 +44,7 @@ export default struct Index { | ||||
|               .width(90) | ||||
|               .height(80) | ||||
| 
 | ||||
|               Text(`线路${index + 1 + ''}`) { | ||||
|               Text(`随机`) { | ||||
|               }.fontColor('#FFF2D9').fontSize(24).padding({ top: 10 }) | ||||
|             } | ||||
|           } | ||||
| @ -59,11 +54,41 @@ export default struct Index { | ||||
|           .height(220) | ||||
|           .margin({ left: 5, bottom: 10 }) | ||||
|           .onClick(async () => { | ||||
|             console.info(this.roadObj[roadIndex]) | ||||
|             const roadArr = Reflect.ownKeys(this.roadObj).map((roadKey) => { | ||||
|               return this.roadObj[roadKey] | ||||
|             }); | ||||
|             globalThis.carInfo.wayno = roadArr[Math.floor(Math.random()*roadArr.length)]; | ||||
|             router.pushUrl({ | ||||
|               url: 'pages/Judge', | ||||
|             }, router.RouterMode.Single); | ||||
|           }) | ||||
|         }) | ||||
|       }.lanes(5).margin({ top: 50, left: 15 }) | ||||
| 
 | ||||
|           ForEach(Reflect.ownKeys(this.roadObj), (roadIndex) => { | ||||
|             ListItem() { | ||||
|               Column() { | ||||
|                 Row() { | ||||
|                 } | ||||
|                 .backgroundImage(lBg, ImageRepeat.NoRepeat) | ||||
|                 .backgroundImageSize({ width: '100%', height: '100%' }) | ||||
|                 .width(90) | ||||
|                 .height(80) | ||||
|                 Text(`线路${this.roadObj[roadIndex] + ''}`) { | ||||
|                 }.fontColor('#FFF2D9').fontSize(24).padding({ top: 10 }) | ||||
|               } | ||||
|             } | ||||
|             .backgroundImage(cBg, ImageRepeat.NoRepeat) | ||||
|             .backgroundImageSize({ width: '100%', height: '100%' }) | ||||
|             .width(180) | ||||
|             .height(220) | ||||
|             .margin({ left: 5, bottom: 10 }) | ||||
|             .onClick(async () => { | ||||
|               globalThis.carInfo.wayno = this.roadObj[roadIndex]; | ||||
|               router.pushUrl({ | ||||
|                 url: 'pages/Judge', | ||||
|               }, router.RouterMode.Single); | ||||
|             }) | ||||
|           }) | ||||
|         }.lanes(8).margin({ top: 50, left: 15 }) | ||||
|       } | ||||
|     }.width('100%') | ||||
|     .height('100%') | ||||
|     .backgroundColor('#1A1A1A') | ||||
|  | ||||
| @ -28,8 +28,7 @@ struct Index { | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   @State @Watch('outClick') outFlag: boolean = false; | ||||
|   private vocObj = null; | ||||
|   @State @Watch('outClick') outFlag: boolean = false;  private vocObj = null; | ||||
|   scroller: Scroller = new Scroller() | ||||
|   build() { | ||||
|     Column() { | ||||
|  | ||||
| @ -642,14 +642,16 @@ struct UserInfo { | ||||
|               //   }); | ||||
|               //   return | ||||
|               // } | ||||
|               //TODO 科目三先写死 | ||||
|               globalThis.carInfo.examSubject = 3; | ||||
|               if (globalThis.singlePlay) { | ||||
|                 const {examSubject} = globalThis.carInfo; | ||||
|                 this.AccountTable.query('0', (result) => { | ||||
|                   if (result.length == 0) { | ||||
|                     this.AccountTable.insertData(this.currentUser, (id) => { | ||||
|                       this.AccountTable.query('0', (result) => { | ||||
|                         console.log(result) | ||||
|                         router.pushUrl({ | ||||
|                           url: 'pages/Judge', | ||||
|                           url: examSubject == 3 ? 'pages/Roads':'pages/Judge', | ||||
|                         }, router.RouterMode.Single); | ||||
|                         this.stopDeviceById() | ||||
|                       }) | ||||
| @ -658,7 +660,7 @@ struct UserInfo { | ||||
|                     this.AccountTable.updateData(this.currentUser, (id) => { | ||||
|                       this.AccountTable.query('0', (result) => { | ||||
|                         router.pushUrl({ | ||||
|                           url: 'pages/Judge', | ||||
|                           url: examSubject == 3?'pages/Roads':'pages/Judge', | ||||
|                         }, router.RouterMode.Single); | ||||
|                         this.stopDeviceById() | ||||
|                       }) | ||||
|  | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -3,7 +3,7 @@ | ||||
| //考试回放开关
 | ||||
| export const judgeConfig = { | ||||
|   //本地目录开关
 | ||||
|   isTrajectoryOpen: true, | ||||
|   isTrajectoryOpen: false, | ||||
|   //是否开启Udp
 | ||||
|   udpOpen:false, | ||||
|   // 本地模型地址
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user