Commit c4a3b37a authored by Mac's avatar Mac

保存视频

parent 2ad80a63
......@@ -32,7 +32,6 @@
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
},
"style": "v2",
"sitemapLocation": "sitemap.json",
"tabBar": {
"selectedColor": "#d4237a",
......
......@@ -714,6 +714,41 @@ Page({
result = Nyear + "-" + Nmonth + "-" + Ndate
}
return result;
}
},
down_sp:function(){
let VideoAddress = this.data.videoList[this.data.current].VideoAddress
wx.downloadFile({
url: VideoAddress, //仅为示例,并非真实的资源
success(res) {
// 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
if (res.statusCode === 200) {
wx.playVoice({
filePath: res.tempFilePath
})
}
wx.saveVideoToPhotosAlbum({
filePath: res.tempFilePath,
success:
function (data) {
wx.showModal({
title: '下载成功',
content: '视频以保存至您的手机',
confirmText:'确定',
success(res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
})
}
})
},
})
\ No newline at end of file
......@@ -22,10 +22,10 @@
<text class="btnBoxText">{{item.CommentNum}}</text>
</view>
<view class='btnTx'>
<button class='btnTx' bindtap="down_sp">
<image style="width:69rpx;height:62rpx" src='../../images/index/fx.png'></image>
</view>
</button>
<view class='btnTx' style="margin-top:20rpx">
<image style="width:69rpx;height:62rpx;marginTop:20rpx" src='../../images/index/sp.png'></image>
</view>
......
......@@ -337,3 +337,6 @@ slider{
color: #111111;
padding-left:20rpx
}
button::after{
border: none
}
......@@ -688,5 +688,41 @@ Page({
}
return result;
}
,
down_sp: function () {
let VideoAddress = this.data.videoList[this.data.current].VideoAddress
wx.downloadFile({
url: VideoAddress, //仅为示例,并非真实的资源
success(res) {
// 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
if (res.statusCode === 200) {
wx.playVoice({
filePath: res.tempFilePath
})
}
wx.saveVideoToPhotosAlbum({
filePath: res.tempFilePath,
success:
function (data) {
wx.showModal({
title: '下载成功',
content: '视频以保存至您的手机',
confirmText: '确定',
success(res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
})
}
})
},
})
\ No newline at end of file
......@@ -22,10 +22,10 @@
<text class="btnBoxText">{{item.CommentNum}}</text>
</view>
<view class='btnTx'>
<button class='btnTx' bindtap="down_sp">
<image style="width:69rpx;height:62rpx" src='../../../images/index/fx.png'></image>
</view>
</button>
<view class='btnTx' style="margin-top:20rpx">
<image style="width:69rpx;height:62rpx;marginTop:20rpx" src='../../../images/index/sp.png'></image>
</view>
......
......@@ -348,3 +348,6 @@ slider{
height: 40rpx;
}
button::after{
border: none
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment