Commit 1fa597c2382f3cc650fc95b2ff5f255024ad7889
1 parent
6fe2f8db
二维码大小
Showing
2 changed files
with
84 additions
and
4 deletions
pages/businessCard/printCard.vue
| @@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
| 12 | </uni-section> | 12 | </uni-section> |
| 13 | 13 | ||
| 14 | <view class=" uni-card text-center" style="padding: 10px 0"> | 14 | <view class=" uni-card text-center" style="padding: 10px 0"> |
| 15 | - <image :src="qrUrl" style="width: 300rpx;height:300rpx;margin: 0 auto;"></image> | 15 | + <image :src="qrUrl" style="width: 300px;height:300px;margin: 0 auto;" @longpress="savePosterPath(qrUrl)"></image> |
| 16 | </view> | 16 | </view> |
| 17 | 17 | ||
| 18 | <view>长按上面二维码可以保存为图片</view> | 18 | <view>长按上面二维码可以保存为图片</view> |
| @@ -94,7 +94,7 @@ export default { | @@ -94,7 +94,7 @@ export default { | ||
| 94 | canvasId: 'qrcode', | 94 | canvasId: 'qrcode', |
| 95 | componentInstance: this, | 95 | componentInstance: this, |
| 96 | text: text, | 96 | text: text, |
| 97 | - size: 165, | 97 | + size: 130, |
| 98 | margin: 0, | 98 | margin: 0, |
| 99 | backgroundColor: '#ffffff', | 99 | backgroundColor: '#ffffff', |
| 100 | foregroundColor: '#000000', | 100 | foregroundColor: '#000000', |
| @@ -107,7 +107,87 @@ export default { | @@ -107,7 +107,87 @@ export default { | ||
| 107 | changeTime: function () { | 107 | changeTime: function () { |
| 108 | this.hour = this.numberValue | 108 | this.hour = this.numberValue |
| 109 | this.getCouponStaticQR() | 109 | this.getCouponStaticQR() |
| 110 | - } | 110 | + }, |
| 111 | + // 小程序保存图片 | ||
| 112 | + savePosterPath(url) { | ||
| 113 | + uni.downloadFile({ | ||
| 114 | + url, | ||
| 115 | + success: (resFile) => { | ||
| 116 | + console.log(resFile, "resFile"); | ||
| 117 | + if (resFile.statusCode === 200) { | ||
| 118 | + uni.getSetting({ | ||
| 119 | + success: (res) => { | ||
| 120 | + if (!res.authSetting["scope.writePhotosAlbum"]) { | ||
| 121 | + uni.authorize({ | ||
| 122 | + scope: "scope.writePhotosAlbum", | ||
| 123 | + success: () => { | ||
| 124 | + uni.saveImageToPhotosAlbum({ | ||
| 125 | + filePath: resFile.tempFilePath, | ||
| 126 | + success: (res) => { | ||
| 127 | + return uni.showToast({ | ||
| 128 | + title: "保存成功!", | ||
| 129 | + }); | ||
| 130 | + }, | ||
| 131 | + fail: (res) => { | ||
| 132 | + return uni.showToast({ | ||
| 133 | + title: res.errMsg, | ||
| 134 | + }); | ||
| 135 | + }, | ||
| 136 | + complete: (res) => {}, | ||
| 137 | + }); | ||
| 138 | + }, | ||
| 139 | + fail: () => { | ||
| 140 | + uni.showModal({ | ||
| 141 | + title: "您已拒绝获取相册权限", | ||
| 142 | + content: "是否进入权限管理,调整授权?", | ||
| 143 | + success: (res) => { | ||
| 144 | + if (res.confirm) { | ||
| 145 | + uni.openSetting({ | ||
| 146 | + success: (res) => { | ||
| 147 | + console.log(res.authSetting); | ||
| 148 | + }, | ||
| 149 | + }); | ||
| 150 | + } else if (res.cancel) { | ||
| 151 | + return uni.showToast({ | ||
| 152 | + title: "已取消!", | ||
| 153 | + }); | ||
| 154 | + } | ||
| 155 | + }, | ||
| 156 | + }); | ||
| 157 | + }, | ||
| 158 | + }); | ||
| 159 | + } else { | ||
| 160 | + uni.saveImageToPhotosAlbum({ | ||
| 161 | + filePath: resFile.tempFilePath, | ||
| 162 | + success: (res) => { | ||
| 163 | + return uni.showToast({ | ||
| 164 | + title: "保存成功!", | ||
| 165 | + }); | ||
| 166 | + }, | ||
| 167 | + fail: (res) => { | ||
| 168 | + return uni.showToast({ | ||
| 169 | + title: res.errMsg, | ||
| 170 | + }); | ||
| 171 | + }, | ||
| 172 | + complete: (res) => {}, | ||
| 173 | + }); | ||
| 174 | + } | ||
| 175 | + }, | ||
| 176 | + fail: (res) => {}, | ||
| 177 | + }); | ||
| 178 | + } else { | ||
| 179 | + return uni.showToast({ | ||
| 180 | + title: resFile.errMsg, | ||
| 181 | + }); | ||
| 182 | + } | ||
| 183 | + }, | ||
| 184 | + fail: (res) => { | ||
| 185 | + return uni.showToast({ | ||
| 186 | + title: res.errMsg, | ||
| 187 | + }); | ||
| 188 | + }, | ||
| 189 | + }); | ||
| 190 | + }, | ||
| 111 | } | 191 | } |
| 112 | } | 192 | } |
| 113 | </script> | 193 | </script> |
pages/businessCard/provideCard.vue
| @@ -98,7 +98,7 @@ export default { | @@ -98,7 +98,7 @@ export default { | ||
| 98 | canvasId: 'qrcode', | 98 | canvasId: 'qrcode', |
| 99 | componentInstance: this, | 99 | componentInstance: this, |
| 100 | text: text, | 100 | text: text, |
| 101 | - size: 165, | 101 | + size: 130, |
| 102 | margin: 0, | 102 | margin: 0, |
| 103 | backgroundColor: '#ffffff', | 103 | backgroundColor: '#ffffff', |
| 104 | foregroundColor: '#000000', | 104 | foregroundColor: '#000000', |