删除相册&&用户切换
This commit is contained in:
		
							parent
							
								
									71e51f4e7d
								
							
						
					
					
						commit
						9337adc8cc
					
				| @ -132,10 +132,10 @@ export class FileHelper { | ||||
|       var all_fileAsset = await photoFetchResult.getAllObjects(); | ||||
| 
 | ||||
|       var  uri_array=[] | ||||
|       console.log( 'baoyihu deletePictureOfAlbum  iterator begin' ); | ||||
|       console.log( 'baoyihu deletePictureOfAlbum  iterator begin',album_Name ); | ||||
|       for (let  onfile of all_fileAsset) | ||||
|       { | ||||
|         console.log( 'baoyihu deletePictureOfAlbum uri : ' + onfile.uri +', photoType : '+onfile.photoType+', displayName : '+onfile.displayName); | ||||
|         console.log(album_Name, 'baoyihu deletePictureOfAlbum uri : ' + onfile.uri +', photoType : '+onfile.photoType+', displayName : '+onfile.displayName); | ||||
|         uri_array.push(onfile.uri); | ||||
|       } | ||||
|       await this.userFileMgr.deleteAssets(uri_array); | ||||
| @ -146,21 +146,21 @@ export class FileHelper { | ||||
| 
 | ||||
|         let trashAlbum = await albumFetchResult.getFirstObject(); | ||||
|         trashAlbum.deleteAssets(all_fileAsset).then(() => { | ||||
|           console.log('baoyihu deletePictureOfAlbum trash ok : '); | ||||
|           console.log('baoyihu deletePictureOfAlbum trash ok : ',album_Name); | ||||
|         }).catch((err) => { | ||||
|           console.log('baoyihu deletePictureOfAlbum trash faild : '); | ||||
|           console.log('baoyihu deletePictureOfAlbum trash faild : ',album_Name); | ||||
|         }); | ||||
|       }catch (err) { | ||||
|         console.log('baoyihu deletePictureOfAlbum error: '+err); | ||||
|         console.log('baoyihu deletePictureOfAlbum error: '+err,album_Name); | ||||
|       } finally { | ||||
|         if (albumFetchResult != null) { | ||||
|           albumFetchResult.close(); | ||||
|         } | ||||
|       } | ||||
| 
 | ||||
|       console.log( 'baoyihu deletePictureOfAlbum delete end' ); | ||||
|       console.log( 'baoyihu deletePictureOfAlbum delete end',album_Name ); | ||||
|     } catch (err) { | ||||
|       console.log( 'baoyihu deletePictureOfAlbum failed with err: ' + err); | ||||
|       console.log( 'baoyihu deletePictureOfAlbum failed with err: ' + err,album_Name); | ||||
|     } finally { | ||||
|       if (photoFetchResult != null) { | ||||
|         photoFetchResult.close(); | ||||
|  | ||||
| @ -95,6 +95,7 @@ export async function setVideoParam() { | ||||
| 
 | ||||
| let fileFd | ||||
| export async function delHilog(day=7) { | ||||
|   return new Promise(async (reslove)=>{ | ||||
|     const fileUtil = new FileUtil(globalThis.context) | ||||
|     const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/hilogTime.txt'); | ||||
|     const folderPath = await fileUtil.initFolder(`/config`); | ||||
| @ -110,10 +111,13 @@ export async function delHilog(day=7) { | ||||
|         const date = dateFormat(new Date()).split(' ')[0] | ||||
|         fileUtil.addFile(`${folderPath}/hilogTime.txt`, date) | ||||
|         // deleteAllFileByPiC('pz', 1)
 | ||||
|       deleteAllPicturesFn() | ||||
|         await deleteAllPicturesFn() | ||||
|         reslove(true) | ||||
|         // fileUtil.addFile(`${folderPath}/hilogTime.txt`, JSON.stringify(num))
 | ||||
|       } | ||||
|     } | ||||
|   }) | ||||
| 
 | ||||
| } | ||||
| //配置流水号
 | ||||
| export async function setliushuiNum() { | ||||
|  | ||||
| @ -180,6 +180,7 @@ interface takePhotoParam { | ||||
| const fileHelper = new FileHelper(); | ||||
| 
 | ||||
| export async function delPic(day,type) { | ||||
|   return new Promise(async reslove=>{ | ||||
|     let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(globalThis.context); | ||||
|     console.info('albumGetAssetsDemoCallback'); | ||||
|     let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); | ||||
| @ -195,11 +196,13 @@ export async function delPic(day,type) { | ||||
|     let albums = await albumList.getAllObjects(); | ||||
|     for(let i=0;i<=albums.length;i++){ | ||||
|       let albumName=albums[i].albumName | ||||
|     console.log('albumNamealbumName',albumName) | ||||
|     if (isSevenDaysAgo(albumName, day)&&albumName!='jt'&&albumName!='pz') { | ||||
|       deleteAllFileByPiC(albums.albumName, type) | ||||
|       if (isSevenDaysAgo(albumName, day)  &&albumName!='jt'&&albumName!='pz') { | ||||
|        await deleteAllFileByPiC(albumName, type) | ||||
|       } | ||||
|     } | ||||
|     reslove(true) | ||||
|   }) | ||||
| 
 | ||||
|   return | ||||
| } | ||||
| 
 | ||||
| @ -224,9 +227,10 @@ export async function takePhoto(param, context, dir, flag = 1, callback?) { | ||||
|     return new Promise<takePhotoParam>(async (resolve, reject) => { | ||||
|       const time = await getCurrentTime() | ||||
|       const date = time.split(' ')[0] | ||||
|       // let dirName=dir?dir:date
 | ||||
|       let dirName=dir?dir:date | ||||
|       rtsp_server.getVideoSnapshot(context, video_uri, fileName,dirName, true,async (err, snapResult) => { | ||||
|         console.log('baoyihubaoyihu', video_uri, flag,fileName,dir, JSON.stringify(snapResult.fileSize)) | ||||
|         console.log('baoyihubaoyihu', video_uri, flag,fileName,dirName, JSON.stringify(snapResult.fileSize)) | ||||
|         console.log('getPhtot', JSON.stringify(snapResult)) | ||||
|         if(snapResult.result&&snapResult.errorCode==0){ | ||||
|           resolve({ | ||||
| @ -249,14 +253,15 @@ export async function takePhoto(param, context, dir, flag = 1, callback?) { | ||||
|   } | ||||
| } | ||||
| export async function deleteAllPicturesFn(){ | ||||
|    fileHelper.deleteAllPictures(); | ||||
|    deleteAllVideos(globalThis.context,photoAccessHelper.AlbumType.USER,photoAccessHelper.AlbumSubtype.VIDEO) | ||||
|    await fileHelper.deleteAllPictures(); | ||||
|    await deleteAllVideos(globalThis.context,photoAccessHelper.AlbumType.USER,photoAccessHelper.AlbumSubtype.VIDEO) | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| //type:1 是图片 2是视频
 | ||||
| export async function deleteAllFileByPiC(dirName, type = 1) { | ||||
|   // const fileHelper = new FileHelper();
 | ||||
|   console.log('deleteFileOfAlbum',dirName,type) | ||||
|   fileHelper.deleteFileOfAlbum(dirName, type); | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| import systemTime from '@ohos.systemDateTime'; | ||||
| import { expect } from '@ohos/hypium'; | ||||
| import FileUtil from './File'; | ||||
| export  function isSevenDaysAgo(date,days?) { | ||||
| export  function isSevenDaysAgo(date,days=2) { | ||||
|   const today = new Date(); // 当前日期
 | ||||
|   const target = new Date(date); // 需要判断的日期
 | ||||
|   console.info("listFile succeed1",JSON.stringify(target)); | ||||
| @ -11,8 +11,8 @@ export  function isSevenDaysAgo(date,days?) { | ||||
|   const diffDays = diff / (1000 * 60 * 60 * 24); // 将毫秒转换为天数
 | ||||
|   console.info("listFile succeed2",JSON.stringify(diffDays)); | ||||
|   // 如果差异天数正好是2,则原日期是当前日期的前2天
 | ||||
|   console.log('diffDays',diffDays) | ||||
|   return diffDays > (Number(days) || 2); | ||||
|   console.log('diffDays',diffDays,days) | ||||
|   return diffDays >= (Number(days) ); | ||||
| } | ||||
| // export async function writeLog(path,param){
 | ||||
| //   return
 | ||||
|  | ||||
| @ -22,6 +22,7 @@ import UdpEvent from '../common/utils/UdpEvent' | ||||
| import UIAbility from '@ohos.app.ability.UIAbility'; | ||||
| import { | ||||
|   deleteAllPicturesFn, | ||||
|   delPic, | ||||
|   endRecordVideo, getUserAlbumItemByDisplayName, saveStartRecordVideo } from '../common/service/videoService'; | ||||
| import imageBtn from './compontents/imageBtn' | ||||
| import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; | ||||
| @ -45,6 +46,7 @@ struct Index { | ||||
|   @State initParamFlag: boolean = false | ||||
|   @State fd: number = -1; | ||||
|   @State num: number = 0; | ||||
|   @State delLoading: boolean = true; | ||||
|   fileHelper = null; | ||||
|   private fileUtil: FileUtil | ||||
|   private interval = null; | ||||
| @ -297,6 +299,33 @@ struct Index { | ||||
|         // | ||||
|         .borderRadius(19 * this.ratio * this.dialogRatio) | ||||
|       } | ||||
|       if(this.delLoading){ | ||||
|         Column() { | ||||
|           Image($r('app.media.open_loading')) | ||||
|             .width(200 * globalThis.ratio) | ||||
|             .rotate({ angle: this.angle }) | ||||
|             .height(200 * globalThis.ratio) | ||||
|             .animation({ | ||||
|               duration: 5000, // 动画时长 | ||||
|               curve: Curve.EaseOut, // 动画曲线 | ||||
|               delay: 500, // 动画延迟 | ||||
|               iterations: -1, // 播放次数 | ||||
|               playMode: PlayMode.Normal, // 动画模式 | ||||
|             }) | ||||
|             .margin({ top: 30 * globalThis.ratio }) | ||||
| 
 | ||||
|           Text('正在清理本地资源文件,请稍候……') | ||||
|             .fontSize(24 * globalThis.ratio) | ||||
|             .margin({ top: 20 * globalThis.ratio }) | ||||
|             .fontWeight(400) | ||||
|         } | ||||
|         .visibility(this.loading ? Visibility.Visible : Visibility.Hidden) | ||||
|         .width(660 * globalThis.ratio) | ||||
|         .height(360 * globalThis.ratio) | ||||
|         .position({ x: 150 * globalThis.ratio, y: 98 * globalThis.ratio }) | ||||
|         .backgroundColor('#E6E3DF') | ||||
|         .borderRadius(19 * globalThis.ratio) | ||||
|       } | ||||
|       if (this.loading) { | ||||
|         Column() { | ||||
|           Image($r('app.media.open_loading')) | ||||
| @ -347,6 +376,7 @@ struct Index { | ||||
|     globalThis.lsh = '1111111111111' | ||||
|     globalThis.errorDialog = this.errorDialog | ||||
|     globalThis.udpEvent = new UdpEvent(); | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
|   aboutToDisappear() { | ||||
| @ -381,7 +411,6 @@ struct Index { | ||||
|       console.log("baoyihu after postMessage :", JSON.stringify(e.data)); | ||||
|       // @ts-ignore | ||||
|       let workData: WorkData = e.data; | ||||
|       this.loading = false | ||||
|       if (workData.isComplete) { | ||||
|         if(globalThis.singlePlay){ | ||||
|           router.pushUrl({ | ||||
| @ -389,7 +418,7 @@ struct Index { | ||||
|           }, router.RouterMode.Single) | ||||
|           return | ||||
|         } | ||||
|         getSyncData('MA_SYSSET').then(data => { | ||||
|         getSyncData('MA_SYSSET').then(async(data) => { | ||||
|           console.log('datadata', JSON.stringify(data)) | ||||
|           // @ts-ignore | ||||
|           data.forEach(sys => { | ||||
| @ -397,6 +426,10 @@ struct Index { | ||||
|             if(sys.v_no === '854'){ | ||||
|               globalThis.param854Str=sys.v_value | ||||
|             } | ||||
|             if(sys.v_no === '305'){ | ||||
|               delPic(Number(sys.v_value),1) | ||||
|               delPic(Number(sys.v_value),2) | ||||
|             } | ||||
|             if (sys.v_no === '824'&&decodeURIComponent(sys.v_value)=='0') { | ||||
|               // this.Param612Str= decodeURIComponent(sys.v_value) | ||||
|               router.pushUrl({ | ||||
| @ -411,6 +444,8 @@ struct Index { | ||||
|               }, router.RouterMode.Single) | ||||
|             } | ||||
|           }) | ||||
|           this.loading = false | ||||
| 
 | ||||
|         }); | ||||
| 
 | ||||
|       } | ||||
| @ -444,7 +479,6 @@ struct Index { | ||||
|     } | ||||
|   } | ||||
|   async onPageShow() { | ||||
|     console.log('ttttt', 1111) | ||||
|     await this.userAuth(); | ||||
|     let resourceManager = this.context.resourceManager; | ||||
| 
 | ||||
| @ -454,6 +488,7 @@ struct Index { | ||||
|     console.log('globalThis.singlePlay', globalThis.singlePlay) | ||||
|     if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) { | ||||
|       // setVideoParam() | ||||
| 
 | ||||
|       console.log('diyidiy') | ||||
|       this.context.resourceManager.getRawFileContent("welcome.wav").then(value => { | ||||
|         this.avPlayer.playAudio(['welcome.wav']) | ||||
| @ -551,23 +586,9 @@ struct Index { | ||||
|         this.heartMsg() | ||||
|       } | ||||
|     }, 1000) | ||||
|     this.createAlbum() | ||||
|     // | ||||
|     //按日期删除照片视频 | ||||
|     getSyncData('MA_SYSSET').then(data => { | ||||
|       console.log('datadata', JSON.stringify(data)) | ||||
|       if (data?.[0]){ | ||||
|         delHilog(7) | ||||
|         return | ||||
|       } | ||||
|       // @ts-ignore | ||||
|       data.forEach(sys => { | ||||
|         //判断是否能点开始考试 | ||||
|         if(sys.v_no === '305'){ | ||||
|           delHilog(Number(sys.v_value)) | ||||
|         } | ||||
|       }) | ||||
|     }); | ||||
|     this.createAlbum() | ||||
| 
 | ||||
|     //下载模型 | ||||
|     // await this.getModel() | ||||
|     // const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00] | ||||
|  | ||||
| @ -138,6 +138,7 @@ struct UserInfo { | ||||
|     this.avPlayer = new VoiceAnnounce(); | ||||
|   } | ||||
|   async onPageShow() { | ||||
|     this.isExamStart = false | ||||
|     this.startExam=false | ||||
|     this.updateTimeLimit = false | ||||
|     this.ksksLimit = false | ||||
| @ -216,8 +217,6 @@ struct UserInfo { | ||||
|     //   // @ts-ignore | ||||
|     //   this.currentUser=user | ||||
|     // } | ||||
| 
 | ||||
|     this.isExamStart = false | ||||
|     this.sczbkf = []; | ||||
|     initJudgeUdp() | ||||
| 
 | ||||
| @ -255,15 +254,19 @@ struct UserInfo { | ||||
|   async getCurrentStudent(id) { | ||||
|     let flag = false | ||||
|     // this.pageIndex | ||||
|     console.log('currentidid',id) | ||||
|     this.list.map((res, index) => { | ||||
|       console.log('tttt',res.sfzmhm,res.xm) | ||||
|       if (res.sfzmhm == id) { | ||||
|         flag = true | ||||
|         this.currentUser=EmptyCandidateObject | ||||
|         setTimeout(()=>{ | ||||
|           this.currentUser = res | ||||
|           this.currentUser.ksy2= globalThis.kgxm | ||||
|         },200) | ||||
| 
 | ||||
|         this.lsh = this.currentUser.lsh | ||||
|         globalThis.lsh = this.currentUser.lsh | ||||
|         globalThis.ksyh = this.currentUser.ksy1sfzmhm | ||||
|         globalThis.lsh = res.lsh | ||||
|         globalThis.ksyh = res.ksy1sfzmhm | ||||
|         const {examSubject} = globalThis.carInfo; | ||||
|         // this.currentUser.kszp=this.photo+res.kszp | ||||
|         // this.currentUser.ksmjzp=this.photo+this.currentUser.ksmjzp | ||||
| @ -497,10 +500,10 @@ struct UserInfo { | ||||
|             if(!Number(this.systemParam.Param305Str)){ | ||||
|               that.systemParam.Param305Str='2' | ||||
|             } | ||||
|             console.log('Param305Str',that.systemParam.Param305Str) | ||||
|             // console.log('Param305Str',that.systemParam.Param305Str) | ||||
|             // delHilog(this.Param305Str) | ||||
|             delPic(that.systemParam.Param305Str,1) | ||||
|             delPic(that.systemParam.Param305Str,2) | ||||
|             // delPic(that.systemParam.Param305Str,1) | ||||
|             // delPic(that.systemParam.Param305Str,2) | ||||
|           } | ||||
|         }) | ||||
| 
 | ||||
| @ -635,18 +638,22 @@ struct UserInfo { | ||||
|         dataList = this.list.length > 4 ? this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) : this.list; | ||||
| 
 | ||||
|         this.dataList = dataList | ||||
|         const flag=dataList.filter((res)=>{ | ||||
|            return res.sfzmhm==this.currentUser.sfzmhm | ||||
|         }).length?true:false | ||||
|         if(!this.currentUser.sfzmhm||this.currentUser.kssycs=='0'||!flag){ | ||||
|           if (this.dataList.length) { | ||||
|             setTimeout(()=>{ | ||||
|               this.currentUser = this.dataList[0] | ||||
|               this.currentUser.ksy2= globalThis.kgxm | ||||
|               globalThis.lsh=this.currentUser.lsh | ||||
|             },200) | ||||
|           // this.currentUser = this.dataList[0] | ||||
|             console.log('this.currentUser1',JSON.stringify(this.currentUser)) | ||||
| 
 | ||||
|           } else { | ||||
|             this.currentUser = EmptyCandidateObject | ||||
|           } | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         this.lsh = this.currentUser.lsh | ||||
|         globalThis.lsh = this.lsh | ||||
| @ -1057,7 +1064,7 @@ struct UserInfo { | ||||
|             .backgroundImage(item.sfzmhm != this.currentUser.sfzmhm ? $r('app.media.userbox2') : $r('app.media.userboxbg')) | ||||
|             .backgroundImageSize({ width: '100%', height: '100%' }) | ||||
|             .onClick(() => { | ||||
|               console.log('this.startExam',this.startExam,this.systemParam.Param364) | ||||
|               console.log('this.startExam',this.startExam,this.systemParam.Param364,this.isExamStart) | ||||
|               if ((this.isExamStart && !globalThis.singlePlay&&this.systemParam.Param341)||(this.startExam&&this.systemParam.Param364=='2')) { | ||||
|                 return | ||||
|               } | ||||
|  | ||||
| @ -39,7 +39,7 @@ export default class FilePhoto{ | ||||
|     }else{ | ||||
|       try { | ||||
|         console.info('surenjun','拍照开始') | ||||
|         const res = await takePhoto(params, this.context, 'pz/',2); | ||||
|         const res = await takePhoto(params, this.context, null,2); | ||||
|         console.info('surenjun','拍照结束' + JSON.stringify(res)) | ||||
|         return res.base64 | ||||
|       } catch (e) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user