下载视频、图片(saveImageToPhotosAlbum):download(e){constindex=e.currentTarget.dataset.indexconsturl=this.data.album[index].v_urlwx.downloadFile({url:url,success:function(res){wx.showToast({title:'开始下载',icon:'none'})//视频保存到本地wx.saveVideoToPhotosAlbum({filePath:res.tempFilePath,success:function(data){wx.hideLoading()wx.showModal({title:'提示',content:'您的影集已存入手机相册,赶快分享给好友吧',showCancel:false,})},fail:function(err){if(err.errMsg==="saveVideoToPhotosAlbum:fail:authdenied"||err.errMsg==="saveVideoToPhotosAlbum:failauthdeny"){//这边微信做过调整,必须要在按钮中触发,因此需要在弹框回调中进行调用wx.showModal({title:'提示',content:'需要您授权保存相册',showCancel:false,success:modalSuccess={wx.openSetting({success(settingdata){if(settingdata.authSetting['scope.writePhotosAlbum']){wx.showModal({title:'提示',content:'获取权限成功,再次点击下载即可保存',showCancel:false,})}else{wx.showModal({title:'提示',content:'获取权限失败,将无法保存到相册哦~',showCancel:false,})}},fail(failData){console.log("failData",failData)},complete(finishData){console.log("finishData",finishData)}})}})}},complete(res){wx.hideLoading()}})}})}

TAG标签: 微信小程序小程序下载微信图片

http://www.xiaochengxub.com/read-107987.html