保存海报问题

main
liudan 8 months ago
parent 316969bcc2
commit 7080f785f9
  1. 60
      pages/users/user_spread_code/index.vue

@ -240,6 +240,7 @@
// this.$set(this, 'poster', spreadList[e.detail.current].poster); // this.$set(this, 'poster', spreadList[e.detail.current].poster);
}, },
savePosterPath(url) { savePosterPath(url) {
console.log(url,"url")
let that = this; let that = this;
// #ifdef MP // #ifdef MP
uni.getSetting({ uni.getSetting({
@ -248,6 +249,30 @@
uni.authorize({ uni.authorize({
scope: 'scope.writePhotosAlbum', scope: 'scope.writePhotosAlbum',
success() { success() {
console.log("授权成功")
uni.downloadFile({
url:url,
filePath:wx.env.USER_DATA_PATH+ "/res",
success: (res) => {
console.log(res,"uuuu77")
uni.saveImageToPhotosAlbum({
filePath: url,
success: function(res) {
that.$util.Tips({
title: '保存成功',
icon: 'success'
});
},
fail: function(res) {
that.$util.Tips({
title: '保存失败'
});
}
});
},
fail: function (res) {
console.log("2222", res)
uni.saveImageToPhotosAlbum({ uni.saveImageToPhotosAlbum({
filePath: url, filePath: url,
success: function(res) { success: function(res) {
@ -262,9 +287,40 @@
}); });
} }
}); });
}
})
},
fail:(err)=>{
console.log(err,"授权失败")
} }
}); });
} else { } else {
uni.downloadFile({
url:url,
filePath:wx.env.USER_DATA_PATH+ "/res",
success: (res) => {
console.log(res,"uuuu77")
uni.saveImageToPhotosAlbum({
filePath: url,
success: function(res) {
that.$util.Tips({
title: '保存成功',
icon: 'success'
});
},
fail: function(res) {
that.$util.Tips({
title: '保存失败'
});
}
});
},
fail: function (res) {
console.log("2222", res)
uni.saveImageToPhotosAlbum({ uni.saveImageToPhotosAlbum({
filePath: url, filePath: url,
success: function(res) { success: function(res) {
@ -279,6 +335,10 @@
}); });
} }
}); });
}
})
} }
} }
}); });

Loading…
Cancel
Save