diff --git a/pkg_product/views/sojoumStore.vue b/pkg_product/views/sojoumStore.vue index 49bb744..4a33ea0 100644 --- a/pkg_product/views/sojoumStore.vue +++ b/pkg_product/views/sojoumStore.vue @@ -380,6 +380,73 @@ export default { this.getFarmerData() }, methods: { + saveImg() { + const _this = this + uni.getSetting({ + success: getRes => { + if (getRes.authSetting["scope.writePhotosAlbum"]) { + _this.downloadImage() + } else { + uni.authorize({ + scope: "scope.writePhotosAlbum", + success: () => { + _this.downloadImage() + }, + fail: () => { + uni.openSetting({ + success: openRes => { + console.log(typeof openRes, openRes) + }, + fail: () => { + uni.showToast({ + title: "请在设置中打开对应权限", + icon: "none" + }) + } + }) + } + }) + } + }, + fail: (err) => { + console.log(err, 2) + } + }) + }, + downloadImage() { + const _this = this + const randomID = () => Math.random().toString(36).substring(2) + uni.downloadFile({ + url: this.posterUrl, // 网络图片的地址 + filePath: wx.env.USER_DATA_PATH + "/share_" + randomID() + ".png", // 指定的本地文件路径 + success: downRes => { + uni.saveImageToPhotosAlbum({ + filePath: downRes.filePath, // 临时文件地址 + success: function () { + uni.showToast({ + title: "保存成功", + icon: "success", + success() { + _this.showShare = false + } + }) + }, + fail: function (err) { + uni.showToast({ + title: err, + icon: "none" + }) + } + }) + }, + fail: function (err) { + uni.showToast({ + title: err.errMsg, + icon: "error" + }) + } + }) + }, changeShare() { uni.showLoading() postJiaLouShare(this.id).then(res => {