export function uploadVideo() {
return new Promise(resolve => {
uni.chooseVideo({
sourceType: ["album", "camera"],
success: path => {
// console.log(path);
const tempFilePath = path.tempFilePath;
showLoading("视频上传中...", 20000);
uni.uploadFile({
url: uploadUrl,
filePath: tempFilePath,
name: "file",
success: res => {
hideLoading(0);
if (res.statusCode !== 200) return toast("视频上传失败,请重试");
console.log(res.data);
resolve(previewUrl + res.data);
},
fail: err => {
hideLoading(0);
if (err.errMsg.includes("timeout")) {
toast("视频上传超时,请重试");
} else {
toast("视频上传失败,请重试");
}
console.log(err);
},
});
},
});
});
}