From 6107ca5c537a027e6f4d9717ebc5b96e0b9fa3ba Mon Sep 17 00:00:00 2001 From: jscyl13849007907 <13849007907@163.com> Date: Sat, 22 Mar 2025 16:45:40 +0800 Subject: [PATCH] =?UTF-8?q?app=20=E5=9B=BE=E7=89=87=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/service-modal/index.js | 38 ++++++++++++++++++++++++++++++++++++- components/service-modal/index.wxml | 6 ++++++ project.config.json | 2 +- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/components/service-modal/index.js b/components/service-modal/index.js index 16a7442..8ff1144 100644 --- a/components/service-modal/index.js +++ b/components/service-modal/index.js @@ -38,6 +38,42 @@ Component({ this.setData({ showModal: false }) - } + }, + saveImage: function (e) { + console.log('saveImage', e.currentTarget.dataset.src); + const imageUrl = e.currentTarget.dataset.src; + // 给出确认弹窗 + wx.downloadFile({ + url: imageUrl, + success: res => { + if (res.statusCode === 200) { + wx.saveImageToPhotosAlbum({ + filePath: res.tempFilePath, + success: () => { + wx.showToast({ + title: '保存成功', + icon: 'success' + }); + }, + fail: err => { + console.error('保存失败', err); + wx.showToast({ + title: '保存失败', + icon: 'none' + }); + } + }); + } + }, + fail: err => { + console.error('下载失败', err); + wx.showToast({ + title: '下载失败', + icon: 'none' + }); + } + }); + }, + } }) \ No newline at end of file diff --git a/components/service-modal/index.wxml b/components/service-modal/index.wxml index 87fb4dc..1a2cee2 100644 --- a/components/service-modal/index.wxml +++ b/components/service-modal/index.wxml @@ -16,7 +16,13 @@ 加载中... + + + + + + 长按识别二维码 diff --git a/project.config.json b/project.config.json index 577cad2..858bc26 100644 --- a/project.config.json +++ b/project.config.json @@ -44,7 +44,7 @@ "tabIndent": "insertSpaces", "tabSize": 2 }, - "appid": "wxe431e0b3abd9ae0b", + "appid": "wxb0dea4d11428c6a5", "packOptions": { "ignore": [], "include": []