wxml
<view bindtap="download" class="down">
<view>生成图片</view>
</view>
js
download: function () {
var that = this
wx.showLoading({
title: '加载中',
});
// 下载海报图片
wx.downloadFile({
url:‘图片路径’,
success(res) {
console.log(res)
wx.hideLoading();
// 图片保存到本地
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success(data) {
wx.showToast({
title: '保存成功',
icon: 'success',
duration: 2500
});
},
fail(err) {
console.log(err.errMsg);
if (err.errMsg === 'saveImageToPhotosAlbum:fail auth deny') {
wx.showToast({
title: "请允许访问相册后重试",
icon: "none",