由于项目上要做离线数据,且离线的数据哦拍照的数量有点多,可能多达100张+ 。之前测试了在线拍照 还是比较流畅,但是在离线状态下自己将手机设置为飞行模式,然后进行拍照发现拍了十多张后就卡死了,自己也做了图片压缩和删除临时图片地址还是不行
if (isProcessing) return;
isProcessing = true;
uni.chooseImage({
count: 8,
sourceType: ['camera'],
sizeType: ['compressed'],
sourceType: this.sourceType,
success: res => {
if (res.errMsg == 'chooseImage:ok') {
res.tempFilePaths.map(items => {
// #ifdef APP
if(items.indexOf(".jpg") !=-1){
uni.compressImage({
src: items,
quality: 30 ,
success:img=>{
uni.saveFile({
tempFilePath: img.tempFilePath,
success:res => {
var savedFilePath = res.savedFilePath;
item.fldImgList.push(savedFilePath)
if (item.fldImgList.length > 8) {
item.fldImgList = item.fldImgList.slice(0, 8);
}
uni.removeSavedFile({ filePath: items });
uni.removeSavedFile({ filePath: img.tempFilePath });
isProcessing = false
}
});
}
});
}else{
uni.saveFile({
tempFilePath: items,
success:async res => {
var savedFilePath = res.savedFilePath;
item.fldImgList.push(savedFilePath)
if (item.fldImgList.length > 8) {
item.fldImgList = item.fldImgList.slice(0, 8);
}
uni.removeSavedFile({ filePath: items });
isProcessing = false
}
});
}
// #endif
// #ifdef H5
item.fldImgList.push(items);
// #endif
});
}
}
});
isProcessing 为做的 一个全局便变量避免还未渲染的时候又点击拍照
item.fldImgList 为页面循环的数据列表的img集合,数据可能有50多个 每个都有拍照的要求。
HBuilder 的版本是 3.8.7
离线数据保存在sqlite的。
请问各位有什么好的解决办法吗? 也把相机的同步地理位置关了的!