耽美漫画

WXML”

<img src=”{{img_url}}”>

<button bindtap=”saveImgToPhotosAlbumTap”>保存图片到手机相册</button>

JS:

var IMG_URL =”//图片链接 https开头
Page({
data:{
img_url:IMG_URL
},
saveImgToPhotosAlbumTap:function(){
wx.downloadFile({
url: IMG_URL,
success:function(res){
console.log(res)
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: function (res) {
console.log(res)
},
fail: function (res) {
console.log(res)
console.log(‘fail’)
}
})
},
fail:function(){
console.log(‘fail’)
}
})

}
})