From f801863241dadbcc8cd2f8bd3fa243acaf7a7dab Mon Sep 17 00:00:00 2001 From: LinCyJang Date: Mon, 2 Jun 2025 12:34:53 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A3824=20=E3=80=90=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E3=80=91=E5=8D=83=E5=8E=BF=E6=97=85?= =?UTF-8?q?=E5=B1=85=E2=80=94=E5=BA=97=E9=93=BA=E5=88=86=E4=BA=AB=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=8C=89=E9=92=AE=E7=82=B9=E5=87=BB=E6=97=A0=E5=8F=8D?= =?UTF-8?q?=E5=BA=94=EF=BC=88=E4=BD=93=E9=AA=8C=E7=89=88=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg_product/views/sojoumStore.vue | 67 +++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) 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 => {