async function chooseAndUploadMedia(maxDuration = 15,
respCallback = function(ret) {
return ret
}) {
return new Promise((resolve, reject) => {
wx.chooseMedia({
sourceType: ["album", "camera"],
mediaType: ['video'],
maxDuration: maxDuration,
camera: "back",
success(ret) {
const tempFilePaths = ret.tempFiles;
let num = 1;
let urls = [];
console.log('tempFilePaths', ret)
tempFilePaths.forEach(async (path, pathIdx) => {
wx.showLoading({
mask: true,
title: '正在上传 ' + num + '/' + tempFilePaths.length
});
let {
fileUrl
} = await 你自己的上传方法({
filePath: path.tempFilePath
}).catch(自定义的错误提示)
urls.push(fileUrl)
wx.hideLoading();
if (urls.length === tempFilePaths.length) {
resolve(urls)
}
});
},
fail(ret) {
console.log('选择这里失败了', ret)
reject(ret);
}
})
})
}
async function chooseAndUploadMedia(maxDuration = 15,
respCallback = function(ret) {
return ret
}) {
return new Promise((resolve, reject) => {
wx.chooseMedia({
sourceType: ["album", "camera"],
mediaType: ['video'],
maxDuration: maxDuration,
camera: "back",
success(ret) {
const tempFilePaths = ret.tempFiles;
let num = 1;
let urls = [];
console.log('tempFilePaths', ret)
tempFilePaths.forEach(async (path, pathIdx) => {
wx.showLoading({
mask: true,
title: '正在上传 ' + num + '/' + tempFilePaths.length
});
let {
fileUrl
} = await 你自己的上传方法({
filePath: path.tempFilePath
}).catch(自定义的错误提示)
urls.push(fileUrl)
wx.hideLoading();
if (urls.length === tempFilePaths.length) {
resolve(urls)
}
});
},
fail(ret) {
console.log('选择这里失败了', ret)
reject(ret);
}
})
})
}