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,8 +99,16 @@ Page({ ...@@ -98,8 +99,16 @@ Page({
}, },
// 下载视频 // 下载视频
downVideo() { downVideo() {
const _this = this
let { videoObj } = this.data let { videoObj } = this.data
let url = videoObj.videoUrl let url = videoObj.videoUrl
wx.getSetting({
success: (res)=> {
if(res.authSetting['scope.writePhotosAlbum']===false){
_this.setData({
showAuth: true
})
}else{
wx.$api.showToast('正在下载视频...') wx.$api.showToast('正在下载视频...')
wx.downloadFile({ wx.downloadFile({
url: url, url: url,
...@@ -111,6 +120,14 @@ Page({ ...@@ -111,6 +120,14 @@ Page({
setTimeout(() => { setTimeout(() => {
wx.$api.showToast('下载成功!') wx.$api.showToast('下载成功!')
}, 2000) }, 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
...@@ -3,3 +3,6 @@ ...@@ -3,3 +3,6 @@
<!-- 申请按钮 --> <!-- 申请按钮 -->
<apply-button wx:if="{{!isShare}}" bindvideodown="downVideo"></apply-button> <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!