From 0e165c8fcab0fdea0006477bc507374036937b7f Mon Sep 17 00:00:00 2001 From: hanchao <1025276839@qq.com> Date: Tue, 19 Feb 2019 20:08:18 +0800 Subject: [PATCH] =?UTF-8?q?update:=E4=BF=AE=E6=94=B9=E5=9C=A8=E5=88=86?= =?UTF-8?q?=E4=BA=AB=E5=88=B0=E6=9C=8B=E5=8F=8B=E5=9C=88=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=EF=BC=8C=E7=AC=AC=E4=B8=80=E6=AC=A1=E5=BC=B9=E5=87=BA?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E6=8E=88=E6=9D=83=E4=BF=9D=E5=AD=98=E6=9D=83?= =?UTF-8?q?=E9=99=90=EF=BC=8C=E5=A6=82=E6=9E=9C=E7=82=B9=E5=90=A6=EF=BC=8C?= =?UTF-8?q?=E5=88=99=E5=90=8E=E7=BB=AD=E6=97=A0=E6=B3=95=E5=86=8D=E6=AC=A1?= =?UTF-8?q?=E5=BC=B9=E5=87=BA=E6=8E=88=E6=9D=83=E5=BC=B9=E7=AA=97=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E6=97=A0=E6=B3=95=E4=BF=9D=E5=AD=98=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- litemall-wx/pages/goods/goods.js | 51 ++++++++++++++++++++++++++++-- litemall-wx/pages/goods/goods.wxml | 6 +++- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/litemall-wx/pages/goods/goods.js b/litemall-wx/pages/goods/goods.js index 4138ac48..f372bf45 100644 --- a/litemall-wx/pages/goods/goods.js +++ b/litemall-wx/pages/goods/goods.js @@ -30,7 +30,8 @@ Page({ collectImage: '/static/images/icon_collect.png', shareImage: '', isGroupon: false, //标识是否是一个参团购买 - soldout: false + soldout: false, + canWrite: false, //用户是否获取了保存相册的权限 }, // 页面分享 @@ -53,7 +54,27 @@ Page({ return false; } }, - + handleSetting: function(e) { + var that = this; + // console.log(e) + if (!e.detail.authSetting['scope.writePhotosAlbum']) { + wx.showModal({ + title: '警告', + content: '不授权无法保存', + showCancel: false + }) + that.setData({ + canWrite: false + }) + } else { + wx.showToast({ + title: '保存成功' + }) + that.setData({ + canWrite: true + }) + } + }, // 保存分享图 saveShare: function() { let that = this; @@ -399,6 +420,32 @@ Page({ }); this.getGrouponInfo(options.grouponId); } + let that = this; + wx.getSetting({ + success: function (res) { + console.log(res) + //不存在相册授权 + if (!res.authSetting['scope.writePhotosAlbum']) { + wx.authorize({ + scope: 'scope.writePhotosAlbum', + success: function () { + that.setData({ + canWrite: true + }) + }, + fail: function (err) { + that.setData({ + canWrite: false + }) + } + }) + } else { + that.setData({ + canWrite: true + }); + } + } + }) }, onShow: function() { // 页面显示 diff --git a/litemall-wx/pages/goods/goods.wxml b/litemall-wx/pages/goods/goods.wxml index 2a256ded..99112c14 100644 --- a/litemall-wx/pages/goods/goods.wxml +++ b/litemall-wx/pages/goods/goods.wxml @@ -19,7 +19,11 @@ 分享给好友 - +