function readTempFilePath(tempPath, callback) {
plus.io.requestFileSystem(plus.io.PRIVATE_DOC, function(fs) {
let path = plus.io.convertLocalFileSystemURL(tempPath)
fs.root.getFile(path, {
create: false
}, function(fileEntry) {
fileEntry.file(function(file) {
var fileReader = new plus.io.FileReader();
fileReader.readAsText(file, 'utf-8');
fileReader.onloadend = function(evt) {
console.log('读取成功')
}
});
}, function(err) {
console.log('err', err)
});
}, function(err) {
console.log('err', err)});
}
let promiseItem = new Promise((resolve, reject) => {
readTempFilePath(bookStorage.downList[startIndex].file, fileRes1 => {
if (fileRes.code == 0) {
console.log('读取文件成功1', fileRes1)
resolve(fileRes1)
} else {
reject(false)
}
})
Promise.all([promiseItem, promiseItem, ...]).then(res => {
console.log(res)
}).catch(e => {
console.log('报错了', e)
callback({code: 1})
})