From 1fa597c2382f3cc650fc95b2ff5f255024ad7889 Mon Sep 17 00:00:00 2001 From: liugongyu <290219706@qq.com> Date: Tue, 14 Jun 2022 09:23:23 +0800 Subject: [PATCH] 二维码大小 --- pages/businessCard/printCard.vue | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- pages/businessCard/provideCard.vue | 2 +- 2 files changed, 84 insertions(+), 4 deletions(-) diff --git a/pages/businessCard/printCard.vue b/pages/businessCard/printCard.vue index 9d181d5..0f24f1c 100644 --- a/pages/businessCard/printCard.vue +++ b/pages/businessCard/printCard.vue @@ -12,7 +12,7 @@ - + 长按上面二维码可以保存为图片 @@ -94,7 +94,7 @@ export default { canvasId: 'qrcode', componentInstance: this, text: text, - size: 165, + size: 130, margin: 0, backgroundColor: '#ffffff', foregroundColor: '#000000', @@ -107,7 +107,87 @@ export default { changeTime: function () { this.hour = this.numberValue this.getCouponStaticQR() - } + }, + // 小程序保存图片 + savePosterPath(url) { + uni.downloadFile({ + url, + success: (resFile) => { + console.log(resFile, "resFile"); + if (resFile.statusCode === 200) { + uni.getSetting({ + success: (res) => { + if (!res.authSetting["scope.writePhotosAlbum"]) { + uni.authorize({ + scope: "scope.writePhotosAlbum", + success: () => { + uni.saveImageToPhotosAlbum({ + filePath: resFile.tempFilePath, + success: (res) => { + return uni.showToast({ + title: "保存成功!", + }); + }, + fail: (res) => { + return uni.showToast({ + title: res.errMsg, + }); + }, + complete: (res) => {}, + }); + }, + fail: () => { + uni.showModal({ + title: "您已拒绝获取相册权限", + content: "是否进入权限管理,调整授权?", + success: (res) => { + if (res.confirm) { + uni.openSetting({ + success: (res) => { + console.log(res.authSetting); + }, + }); + } else if (res.cancel) { + return uni.showToast({ + title: "已取消!", + }); + } + }, + }); + }, + }); + } else { + uni.saveImageToPhotosAlbum({ + filePath: resFile.tempFilePath, + success: (res) => { + return uni.showToast({ + title: "保存成功!", + }); + }, + fail: (res) => { + return uni.showToast({ + title: res.errMsg, + }); + }, + complete: (res) => {}, + }); + } + }, + fail: (res) => {}, + }); + } else { + return uni.showToast({ + title: resFile.errMsg, + }); + } + }, + fail: (res) => { + return uni.showToast({ + title: res.errMsg, + }); + }, + }); + }, } } diff --git a/pages/businessCard/provideCard.vue b/pages/businessCard/provideCard.vue index ff97995..1197297 100644 --- a/pages/businessCard/provideCard.vue +++ b/pages/businessCard/provideCard.vue @@ -98,7 +98,7 @@ export default { canvasId: 'qrcode', componentInstance: this, text: text, - size: 165, + size: 130, margin: 0, backgroundColor: '#ffffff', foregroundColor: '#000000', -- libgit2 0.21.4