1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| uni.showModal({ title: "提示", content: "是否下载该视频", showCancel: true, cancelText: '取消', confirmText: '下载', success: res => {
if (res.confirm) { that.downvideo = true const downloadTask = uni.downloadFile({ url: encodeURI(`${apiUrl}` + '/api/downvideo-web/downVideo/likeVideo?dangerId=' + that.id + '&&groupId=' + header().groupId), header: header(), success: (data) => { if (data.statusCode === 200) {
if (uni.getSystemInfoSync().platform == 'ios') data.tempFilePath = escape(data.tempFilePath)
filePath: data.tempFilePath, success: function(res) { uni.showToast({ title: '下载完成,请到相册查看', position: 'center', icon: 'none', duration: 2000 }); }, fail: (err) => { uni.showToast({ title: err, position: 'center', icon: 'none', duration: 2000 }); }, complete: () => { that.downvideo = false that.videoprogress = 0 } }); } }, fail: (err) => { uni.hideLoading() uni.showToast({ title: err || '未开通或没有权限', position: 'center', icon: 'none', duration: 2000 }); }, complete: () => { that.downvideo = false that.videoprogress = 0 } });
downloadTask.onProgressUpdate((res) => { if (this.videoprogress < 100) { this.videoprogress = res.progress } }); } } })
|