diff --git a/components/uni-goods-nav/components/uni-goods-nav/uni-goods-nav.vue b/components/uni-goods-nav/components/uni-goods-nav/uni-goods-nav.vue index 05eef79..905c643 100644 --- a/components/uni-goods-nav/components/uni-goods-nav/uni-goods-nav.vue +++ b/components/uni-goods-nav/components/uni-goods-nav/uni-goods-nav.vue @@ -7,7 +7,7 @@ - + diff --git a/physical-merchants/classify/goodsDetail/goodsDetail.vue b/physical-merchants/classify/goodsDetail/goodsDetail.vue index a88b7f7..06ba2db 100644 --- a/physical-merchants/classify/goodsDetail/goodsDetail.vue +++ b/physical-merchants/classify/goodsDetail/goodsDetail.vue @@ -191,7 +191,7 @@ color: "#646566" }, { - icon: 'icon-y share', + icon: 'redo',//icon-y text: '分享', }, ], diff --git a/physical-merchants/classify/poster/poster.vue b/physical-merchants/classify/poster/poster.vue index 2475aac..fbc7688 100644 --- a/physical-merchants/classify/poster/poster.vue +++ b/physical-merchants/classify/poster/poster.vue @@ -118,33 +118,38 @@ // usingIn: this //在自定义组件下,第二个参数传入组件实例this }) - console.log(qrde, " qrde") - // 把当前画布指定区域的内容导出生成图片,并返回文件路径。 - uni.canvasToTempFilePath({ + const ctx = uni.createCanvasContext('qrImg'); + ctx.draw(true,setTimeout(() => { + uni.canvasToTempFilePath({ canvasId: 'qrImg', success: (res) => { uni.hideLoading() // 在H5平台下,tempFilePath 为 base64 - // console.log('yz-qr图片路径:', res) + console.log('二维码图片地址', res.tempFilePath) this.dataInfo.recommendCodeGoods = res.tempFilePath; - /* qrcode = null; */ - /* uni.getFileSystemManager().readFile({ - filePath: res.tempFilePath, //选择图片返回的相对路径 - encoding: 'base64', //编码格式 - success: res => { - // 成功的回调 - let base64 = 'data:image/jpeg;base64,' + res.data; - this.dataInfo.recommendCodeGoods = base64; - } - }); */ - }, fail: (err) => { uni.hideLoading(); - /* qrcode = null; */ console.log(err) } }, this); + }, 0)) + // 把当前画布指定区域的内容导出生成图片,并返回文件路径。 + // uni.canvasToTempFilePath({ + // canvasId: 'qrImg', + // success: (res) => { + // uni.hideLoading() + // // 在H5平台下,tempFilePath 为 base64 + // // console.log('yz-qr图片路径:', res) + // this.dataInfo.recommendCodeGoods = res.tempFilePath; + // /* qrcode = null; */ + // }, + // fail: (err) => { + // uni.hideLoading(); + // /* qrcode = null; */ + // console.log(err) + // } + // }, this); // console.log('绘制完成'); }, @@ -287,73 +292,98 @@ uni.hideLoading(); // #endif // #ifdef MP-WEIXIN + + this.savePosterPath(imgUrl) + // #endif + + }, + savePosterPath(url) { uni.showLoading({ - title: '海报下载中' + title: '海报下载中...' }); - // if (this.settingWritePhotosAlbum) { + //获取用户的当前设置。获取相册权限 uni.getSetting({ - success: res => { - if (res.authSetting['scope.writePhotosAlbum']) { - uni.saveImageToPhotosAlbum({ - filePath: imgUrl, + success: (res) => { + //如果没有相册权限 + if (!res.authSetting["scope.writePhotosAlbum"]) { + //向用户发起授权请求 + uni.authorize({ + scope: "scope.writePhotosAlbum", success: () => { - uni.hideLoading(); - uni.showToast({ - title: '保存成功' + //授权成功保存图片到系统相册 + uni.saveImageToPhotosAlbum({ + //图片路径,不支持网络图片路径 + filePath: url, + success: (res) => { + uni.hideLoading(); + return uni.showToast({ + title: "保存成功!", + }); + }, + fail: (res) => { + console.log(res.errMsg); + return uni.showToast({ + title: res.errMsg, + }); + }, + complete: (res) => { + uni.hideLoading(); + }, }); }, - fail() { + //授权失败 + fail: () => { uni.hideLoading(); - } + 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.showModal({ - title: '提示', - content: '请先在设置页面打开“保存相册”使用权限', - confirmText: '去设置', - cancelText: '算了', - success: data => { - if (data.confirm) { - - uni.openSetting(); - } + //如果已有相册权限,直接保存图片到系统相册 + uni.saveImageToPhotosAlbum({ + filePath: url, + success: (res) => { uni.hideLoading(); + return uni.showToast({ + title: "保存成功!", + }); }, - fail() { + fail: (res) => { uni.hideLoading(); - } + console.log(res.errMsg); + return uni.showToast({ + title: res.errMsg, + }); + }, + //无论成功失败都走的回调 + complete: (res) => { + uni.hideLoading(); + }, }); } }, - fail() { - uni.hideLoading(); - } + fail: (res) => { + uni.hideLoading() + }, }); - // } else { - // this.settingWritePhotosAlbum = true; - // uni.authorize({ - // scope: 'scope.writePhotosAlbum', - // success: () => { - // uni.saveImageToPhotosAlbum({ - // filePath: imgUrl, - // success: () => { - // uni.hideLoading(); - // uni.showToast({ - // title: '保存成功' - // }); - // }, - // fail(){ - // uni.hideLoading(); - // } - // }); - // }, - // fail(){ - // uni.hideLoading(); - // } - // }); - // } - // #endif - }, // 文字换行 drawtext(text, maxWidth) { diff --git a/physical-merchants/static/img/placard.png b/physical-merchants/static/img/placard.png index 33433e3..e2a9e2f 100644 Binary files a/physical-merchants/static/img/placard.png and b/physical-merchants/static/img/placard.png differ diff --git a/physical-merchants/static/img/share_wechat.png b/physical-merchants/static/img/share_wechat.png index f88a7a7..8d25a51 100644 Binary files a/physical-merchants/static/img/share_wechat.png and b/physical-merchants/static/img/share_wechat.png differ