|
@@ -74,11 +74,41 @@ Component({
|
|
|
this.closeShow();
|
|
|
})
|
|
|
},
|
|
|
+ mySaveVideo() {
|
|
|
+ const that = this,
|
|
|
+ fileSelected = this.data.fileSelected;
|
|
|
+ const downloadTask = wx.downloadFile({
|
|
|
+ url: fileSelected.url,
|
|
|
+ filePath: wx.env.USER_DATA_PATH + '/' + new Date().valueOf() + '.mp4',
|
|
|
+ timeout: 600000,
|
|
|
+ success(res) {
|
|
|
+ console.log("下载", res)
|
|
|
+ that.saveVideo(res.filePath)
|
|
|
+ },
|
|
|
+ fail({
|
|
|
+ errMsg
|
|
|
+ }) {
|
|
|
+ if (errMsg == 'downloadFile:fail exceed max file size') wx.showToast({
|
|
|
+ title: '视频体积超大,无法保存!请尝试打开视频长按保存下载',
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ downloadTask.onProgressUpdate((res) => {
|
|
|
+ wx.showLoading({
|
|
|
+ title: `保存进度` + res.progress + `%`,
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ if (res.progress == 100) wx.hideLoading()
|
|
|
+ })
|
|
|
+ that.closeShow();
|
|
|
+ },
|
|
|
/* 文件下载 */
|
|
|
dowmLoad() {
|
|
|
- const that = this;
|
|
|
+ const that = this,
|
|
|
+ fileSelected = this.data.fileSelected;
|
|
|
wx.setClipboardData({
|
|
|
- data: this.data.fileSelected.url,
|
|
|
+ data: fileSelected.url,
|
|
|
success: function () {
|
|
|
wx.showToast({
|
|
|
title: '复制成功,将链接放置到浏览器中便可下载文件',
|
|
@@ -89,6 +119,48 @@ Component({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ saveVideo(filePath) {
|
|
|
+ const that = this;
|
|
|
+ wx.saveVideoToPhotosAlbum({
|
|
|
+ filePath,
|
|
|
+ success(res) {
|
|
|
+ console.log("保存", res)
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '视频已保存到系统相册',
|
|
|
+ showCancel: false
|
|
|
+ })
|
|
|
+ wx.hideLoading()
|
|
|
+ },
|
|
|
+ fail(err) {
|
|
|
+ console.log("保存失败", err)
|
|
|
+ if (err.errno == 103) {
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '未获取保存相册权限,无法保存!',
|
|
|
+ confirmText: "前去授权",
|
|
|
+ success({
|
|
|
+ confirm
|
|
|
+ }) {
|
|
|
+ if (confirm) wx.openSetting({
|
|
|
+ success(res) {
|
|
|
+ console.log(res.authSetting["scope.writePhotosAlbum"])
|
|
|
+ if (res.authSetting["scope.writePhotosAlbum"]) {
|
|
|
+ that.saveVideo(filePath)
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: '未获得授权',
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
/* 获得列表 */
|
|
|
getList(init = false) {
|
|
|
if (init.detail != undefined) init = init.detail;
|