Commit bd8605c1 by luyt

feat:视频下载

1 parent 33775768
...@@ -28,7 +28,18 @@ Component({ ...@@ -28,7 +28,18 @@ Component({
*/ */
methods: { methods: {
videoDown(){ videoDown(){
this.triggerEvent('videodown') let that = this
wx.showModal({
// title: '提示',
content: '是否下载视频',
success (res) {
if (res.confirm) {
that.triggerEvent('videodown')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
}, },
apply(){ apply(){
wx.$router.go('/packagesList/apply/pages/apply') wx.$router.go('/packagesList/apply/pages/apply')
......
...@@ -97,7 +97,29 @@ Page({ ...@@ -97,7 +97,29 @@ Page({
title: videoitem.name, title: videoitem.name,
}); });
}, },
// 视频下载
downVideo() {
let {videoitem} = this.data
let url = videoitem.videoUrl
console.log(url)
wx.$api.showToast('正在下载视频...')
wx.downloadFile({
url: url,
success(res) {
// console.log(res,111)
if (res.statusCode === 200) {
wx.saveVideoToPhotosAlbum({
filePath: res.tempFilePath,
success(res) {
setTimeout(() => {
wx.$api.showToast('下载成功!')
}, 2000)
}
})
}
}
})
},
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
......
...@@ -28,4 +28,4 @@ ...@@ -28,4 +28,4 @@
</view> </view>
<!-- 申请按钮 --> <!-- 申请按钮 -->
<apply-button wx:if="{{!isShare}}" ></apply-button> <apply-button wx:if="{{!isShare}}" bindvideodown="downVideo"></apply-button>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!