From 9a618adeffaa02cd8e1c1c0aec3de8a50f612704 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Mon, 19 Aug 2024 14:54:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=88=E6=A1=86userlist=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/constants/USER.ts | 6 ++-- entry/src/main/ets/common/service/initable.ts | 5 +++ entry/src/main/ets/common/utils/request.ts | 7 ++++- entry/src/main/ets/pages/ExaminerLogin.ets | 8 ++--- entry/src/main/ets/pages/Index.ets | 31 +++++++++++-------- entry/src/main/ets/pages/UserInfo.ets | 30 +++++++++++------- entry/src/main/ets/pages/judgeSDK/judge.ts | 2 +- 7 files changed, 56 insertions(+), 33 deletions(-) diff --git a/entry/src/main/ets/common/constants/USER.ts b/entry/src/main/ets/common/constants/USER.ts index b5b4b985..f5d82a25 100644 --- a/entry/src/main/ets/common/constants/USER.ts +++ b/entry/src/main/ets/common/constants/USER.ts @@ -18,15 +18,15 @@ CommonConstants { /** * Rdb database config. */ - static readonly STORE_CONFIG = { name: 'user.db' }; + static readonly STORE_CONFIG = { name: 'USER.db' }; /** * Account table config. */ static readonly ACCOUNT_TABLE = { tableName: 'USER', - sqlCreate: 'CREATE TABLE IF NOT EXISTS USER(id TEXT,sfzmhm TEXT,xm CHAR(20), lsh TEXT, kszp TEXT,ksdd TEXT,kssycs TEXT,kslx TEXT,kscx TEXT,ksxl TEXT)', - columns: ['id','sfzmhm','xm','lsh','kszp','ksdd','kssycs','kslx','kscx','ksxl'] + sqlCreate: 'CREATE TABLE IF NOT EXISTS USER(id INTEGER PRIMARY KEY AUTOINCREMENT,sfzmhm TEXT,xm CHAR(20), lsh TEXT, kszp TEXT,ksdd TEXT,kssycs TEXT,kslx TEXT,kscx TEXT,ksxl TEXT,ksy1 TEXT)', + columns: ['id','sfzmhm','xm','lsh','kszp','ksdd','kssycs','kslx','kscx','ksxl','ksy1'] }; /** diff --git a/entry/src/main/ets/common/service/initable.ts b/entry/src/main/ets/common/service/initable.ts index 8f0fef0b..49d733d7 100644 --- a/entry/src/main/ets/common/service/initable.ts +++ b/entry/src/main/ets/common/service/initable.ts @@ -91,6 +91,11 @@ function sqlInsertCommonFn(tableName, resultArr, context?, delFlag = true) { // console.log('表长度',result.length,tableName) if (result.length == 0) { + console.log('sqlsqlinsert',resultArr.length) + if(resultArr.length==0){ + resolve(false) + return + } let INSERT_SQL = "INSERT INTO " + tableName + " (" + map[tableName].ACCOUNT_TABLE.columns.toString() + ") VALUES " diff --git a/entry/src/main/ets/common/utils/request.ts b/entry/src/main/ets/common/utils/request.ts index 41cd6e44..14390ade 100644 --- a/entry/src/main/ets/common/utils/request.ts +++ b/entry/src/main/ets/common/utils/request.ts @@ -75,7 +75,10 @@ export default async function request(req: any) { if(res.head.resultCode === '0'){ return res }else{ + globalThis.type='1' const resultMessage = res?.body?.resultMessage || res?.head?.resultMessage + AppStorage.SetOrCreate('errorMsg', 1); + globalThis.title=decodeURIComponent(resultMessage) prompt.showToast({ message: decodeURIComponent(resultMessage), duration: 3000 @@ -90,6 +93,9 @@ export default async function request(req: any) { if(resObj.resultCode === '0') { return res }else { + globalThis.type='1' + AppStorage.SetOrCreate('errorMsg', 1); + globalThis.title=decodeURIComponent(resObj.resultMessage) prompt.showToast({ message: decodeURIComponent(resObj.resultMessage), duration: 3000 @@ -102,7 +108,6 @@ export default async function request(req: any) { return false } const code = e?.code; - prompt.showToast({ message: e?.message, duration: 5000 diff --git a/entry/src/main/ets/pages/ExaminerLogin.ets b/entry/src/main/ets/pages/ExaminerLogin.ets index 6083a598..7a1d8153 100644 --- a/entry/src/main/ets/pages/ExaminerLogin.ets +++ b/entry/src/main/ets/pages/ExaminerLogin.ets @@ -93,10 +93,10 @@ export default struct Index { console.log('res?.examinerLoginRsp?.head?.resultCode',res?.examinerLoginRsp?.head?.resultCode,JSON.stringify(res)) this.errorDialog.close() if(res?.examinerLoginRsp?.head?.resultCode=='1'){ - this.type='1' - this.title=decodeURIComponent(res.examinerLoginRsp.head.resultMessage) - console.log('this.titlt',this.title) - this.errorDialog.open() + // this.type='1' + // this.title=decodeURIComponent(res.examinerLoginRsp.head.resultMessage) + // console.log('this.titlt',this.title) + // this.errorDialog.open() return } router.pushUrl({ diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index b6e29bf1..28f7b03b 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -42,19 +42,19 @@ struct Index { private context = getContext(this) as common.UIAbilityContext; private title = '' private type = '2' - // dialogControllerTwo: CustomDialogController = new CustomDialogController({ - // builder: errorMsgDialog({ - // title: this.title, - // type: this.type, - // cancel: () => { - // }, - // confirm: () => { - // } - // }), - // customStyle: true, - // alignment: DialogAlignment.Center, - // }, - // ) + errorDialog: CustomDialogController = new CustomDialogController({ + builder: errorMsgDialog({ + title: globalThis.title, + type: globalThis.type, + cancel: () => { + }, + confirm: () => { + } + }), + customStyle: true, + alignment: DialogAlignment.Center, + }, + ) @Styles commStyle(){ @@ -445,6 +445,11 @@ struct Index { if (this.num >= 3) { this.heartMsg() } + const data=AppStorage.Get('errorMsg'); // returns 47 + console.log('1123',data) + if(data==1){ + this.errorDialog.open() + } }, 1000) //下载模型 // await this.getModel() diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index f9bb7465..0d3ef90b 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -132,6 +132,9 @@ struct UserInfo { this.list =await getSyncData('USERLIST') // @ts-ignore const data=await getSyncData('USER') + console.log('datadata',JSON.stringify(data)); + console.log('datadata2',JSON.stringify(this.list)) + const user=data[0] if(user&&Number(user.kssycs)){ this.list.forEach(res=>{ @@ -140,15 +143,24 @@ struct UserInfo { this.getCurrentStudent(res.sfzmhm) } }) - }else if(user&&!Number(user.kssycs)){ + + }else if(user&&(user.kssycs=='0'||user.kssycs=='')){ + console.log('datadatadatadata') this.list=this.list.filter(res=>{ return res.sfzmhm!=user.sfzmhm }) + this.pageIndex=0 + this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) + if(this.dataList.length){ + this.currentUser=this.dataList[0] + }else{ + this.currentUser=EmptyCandidateObject + } } this.list.forEach((res,index)=>{ res.id=index.toString() }) - await upDateTableByArray('USERLIST', this.list) + await upDateTableByArray('USERLIST', this.list||[]) // 如果是单机模式则模拟假数据 //获取sysset表数据 @@ -444,20 +456,14 @@ struct UserInfo { this.errorDialog.open() const param = `${Md5.Instance.get_md5(globalThis.carInfo.carId + globalThis.carInfo.examinationRoomId + globalThis.username)}${globalThis.carInfo.carId}${globalThis.carInfo.examinationRoomId}${globalThis.username}` getExaminationStudentInfo(param).then(async (res) => { + this.errorDialog.close() setTimeout(() => { this.updateTimeLimit = true }, 30000) this.updateTimeLimit = false - if (!res||res?.examinerLoginRsp?.head?.resultCode=='1') { - this.dataList = [] - this.currentUser = EmptyCandidateObject - this.errorMsg = decodeURI(res.getExaminationStudentInfoRsp.head.resultMessage) - this.type='1' - this.title=res.getExaminationStudentInfoRsp.head.resultMessage + if (!res||res?.getExaminationStudentInfoRsp?.head?.resultCode=='1') { return } - this.errorDialog.close() - let dataList = [] this.list = [] @@ -474,13 +480,15 @@ struct UserInfo { } this.list = JSON.parse(JSON.stringify(dataList)) - this.list.forEach(listData => { + this.list.forEach((listData,index) => { + listData.id=index.toString() for (let i in listData) { listData[i] = decodeURI(listData[i]) } listData.kszp = this.photo + listData.kszp listData.ksmjzp = this.photo + listData.ksmjzp }) + await upDateTableByArray('USERLIST', this.list||[]) dataList = this.list.length > 4 ? this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) : this.list; this.dataList = dataList diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ts b/entry/src/main/ets/pages/judgeSDK/judge.ts index 39b71eb1..1971bd00 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ts +++ b/entry/src/main/ets/pages/judgeSDK/judge.ts @@ -929,7 +929,7 @@ export default class Judge { } } - const USER = getSyncData('USER'); + const USER =await getSyncData('USER'); await upDateTableByArray('USER', [{...USER[0],kssycs:kssycs == 2 ? 1 : 0}]) console.info(judgeTag, `考试成绩:${totalScore}`)