chooseAndUploadVideo: function () {
const that = this;
wx.chooseMedia({
mediaType: ['video'],
sourceType: ['camera', 'album'],
maxDuration: 180,
camera: 'back',
success: (res) => {
const videoPath = res.tempFiles[0].tempFilePath;
that.uploadVideoToCloud(videoPath);
},
});
},
uploadVideoToCloud: function (videoPath) {
const cloudPath = 'GeXingVideos/' + Date.now() + '.mp4';
wx.cloud.uploadFile({
cloudPath: cloudPath,
filePath: videoPath,
success: res => {
const fileID = res.fileID;
wx.cloud.getTempFileURL({
fileList: [fileID],
success: urlRes => {
const videoUrl = urlRes.fileList[0].tempFileURL;
this.setData({
video_backgroundVid: videoUrl,
});
},
fail: err => {
wx.showToast({
title: '获取链接失败',
icon: 'none',
});
}
});
},
fail: err => {
wx.showToast({
title: '上传失败',
icon: 'none',
});
},
});
},
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。