Commit 5982d020 by chenwq

视频详情,下载

1 parent 6991d0e1
...@@ -18,7 +18,8 @@ Page({ ...@@ -18,7 +18,8 @@ Page({
videoUrl: '', videoUrl: '',
isShare: false,//是否是被分享出去 isShare: false,//是否是被分享出去
}, },
videoObj: {} videoObj: {},
showAuth: false
}, },
/** /**
...@@ -98,19 +99,35 @@ Page({ ...@@ -98,19 +99,35 @@ Page({
}, },
// 下载视频 // 下载视频
downVideo() { downVideo() {
const _this = this
let { videoObj } = this.data let { videoObj } = this.data
let url = videoObj.videoUrl let url = videoObj.videoUrl
wx.$api.showToast('正在下载视频...') wx.getSetting({
wx.downloadFile({ success: (res)=> {
url: url, if(res.authSetting['scope.writePhotosAlbum']===false){
success(res) { _this.setData({
if (res.statusCode === 200) { showAuth: true
wx.saveVideoToPhotosAlbum({ })
filePath: res.tempFilePath, }else{
wx.$api.showToast('正在下载视频...')
wx.downloadFile({
url: url,
success(res) { success(res) {
setTimeout(() => { if (res.statusCode === 200) {
wx.$api.showToast('下载成功!') wx.saveVideoToPhotosAlbum({
}, 2000) filePath: res.tempFilePath,
success(res) {
setTimeout(() => {
wx.$api.showToast('下载成功!')
}, 2000)
},
fail({ errMsg }) {
_this.setData({
showAuth: errMsg == "saveVideoToPhotosAlbum:fail auth deny",
})
}
})
}
} }
}) })
} }
......
{ {
"usingComponents": { "usingComponents": {
"gl-video-detail": "glsx-applet-component/video-detail/index", "gl-video-detail": "glsx-applet-component/video-detail/index",
"apply-button": "../../../pages/viewVideo/components/apply-button/index" "apply-button": "../../../pages/viewVideo/components/apply-button/index",
"authorize": "../../../components/Authorize/Authorize"
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -2,4 +2,7 @@ ...@@ -2,4 +2,7 @@
<gl-video-detail list="{{videoItem.videoList}}" index="{{videoItem.index}}" bindchooseVideo="chooseVideo"></gl-video-detail> <gl-video-detail list="{{videoItem.videoList}}" index="{{videoItem.index}}" bindchooseVideo="chooseVideo"></gl-video-detail>
<!-- 申请按钮 --> <!-- 申请按钮 -->
<apply-button wx:if="{{!isShare}}" bindvideodown="downVideo"></apply-button>
\ No newline at end of file \ No newline at end of file
<apply-button wx:if="{{!isShare}}" bindvideodown="downVideo"></apply-button>
<block wx:if="{{showAuth}}">
<authorize title="下载前需要获取您的‘添加到相册’权限,是否打开授权设置?" scopeType="writePhotosAlbum" buttonType="openSetting" bindfail="authFail" bindsuccess="authSuccess" show="{{showAuth}}"></authorize>
</block>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!