Commit e1dec8d0 by 杨北旺

优化授权

1 parent 20ea01e7
...@@ -170,8 +170,11 @@ Component({ ...@@ -170,8 +170,11 @@ Component({
wx.$api.showToast('保存成功') wx.$api.showToast('保存成功')
}, },
fail(err) { fail(err) {
const auth = _this.selectComponent('#auth') if(err.errMsg=='saveImageToPhotosAlbum:fail auth deny'){
auth.check() _this.triggerEvent('showAuth',true)
}
// const auth = _this.selectComponent('#auth')
// auth.check()
} }
} }
) )
......
...@@ -140,49 +140,41 @@ Component({ ...@@ -140,49 +140,41 @@ Component({
// 分享活动(复制链接) // 分享活动(复制链接)
copyActivityUrl(e) { copyActivityUrl(e) {
wx.getSetting({ let { item } = e.currentTarget.dataset
success: (res)=> { let thisPage = wx.$router.getPageInstance()
if(res.authSetting['scope.writePhotosAlbum']===false){ wx.$api.showLoading()
this.triggerEvent('showAuth',true) ActivityApi.getActivityPosters({id: item.id}).then(res => {
}else{ // var code= QR.createQrCodeImg(res.activityUrl);
let { item } = e.currentTarget.dataset // /*code是指图片base64格式数据*/
let thisPage = wx.$router.getPageInstance() // //声明文件系统
wx.$api.showLoading() // const fs = wx.getFileSystemManager();
ActivityApi.getActivityPosters({id: item.id}).then(res => { // //随机定义路径名称
// var code= QR.createQrCodeImg(res.activityUrl); // var times = new Date().getTime();
// /*code是指图片base64格式数据*/ // var codeimg = wx.env.USER_DATA_PATH + '/' + times + '.png';
// //声明文件系统 // //将base64图片写入
// const fs = wx.getFileSystemManager(); // fs.writeFile({
// //随机定义路径名称 // filePath: codeimg,
// var times = new Date().getTime(); // data: code.slice(22),
// var codeimg = wx.env.USER_DATA_PATH + '/' + times + '.png'; // encoding: 'base64',
// //将base64图片写入 // success: () => {
// fs.writeFile({ // thisPage.setData({
// filePath: codeimg, // sharePopupData: {
// data: code.slice(22), // imagePath: codeimg,
// encoding: 'base64', // activityName: res.activityName,
// success: () => { // address: res.activityAddressDetailName,
// thisPage.setData({ // posterImg: res.posterImg,
// sharePopupData: { // showSharePopup: true
// imagePath: codeimg, // },
// activityName: res.activityName, // })
// address: res.activityAddressDetailName, // }
// posterImg: res.posterImg, // });
// showSharePopup: true thisPage.setData({
// }, sharePopupData: {
// }) posterImg: res,
// } activityName: item.activityName,
// }); showSharePopup: true
thisPage.setData({ },
sharePopupData: { })
posterImg: res,
activityName: item.activityName,
showSharePopup: true
},
})
})
}
}
}) })
......
...@@ -217,6 +217,9 @@ Page({ ...@@ -217,6 +217,9 @@ Page({
*/ */
onShareAppMessage: function () { onShareAppMessage: function () {
}, },
authFail(){
},
toShowAuth(){ toShowAuth(){
this.setData({ this.setData({
showAuth:true showAuth:true
......
...@@ -39,11 +39,13 @@ ...@@ -39,11 +39,13 @@
<!-- 预约安装弹窗 --> <!-- 预约安装弹窗 -->
<install-popup show="{{showPopup}}" data="{{installItem}}" bind:hidePopup="hidePopup"></install-popup> <install-popup show="{{showPopup}}" data="{{installItem}}" bind:hidePopup="hidePopup"></install-popup>
<!-- 分享活动弹窗 --> <!-- 分享活动弹窗 -->
<share-popup data="{{sharePopupData}}"></share-popup> <share-popup bind:showAuth="toShowAuth" data="{{sharePopupData}}"></share-popup>
<!-- <van-popup show="{{ showSharePopup }}" round bind:close="onClose"> <!-- <van-popup show="{{ showSharePopup }}" round bind:close="onClose">
<image style="width: 352rpx; height: 352rpx;" src="{{imagePath}}"></image> <image style="width: 352rpx; height: 352rpx;" src="{{imagePath}}"></image>
</van-popup> --> </van-popup> -->
</view> </view>
</block> </block>
<authorize scopeType="writePhotosAlbum" bindfail="authFail" show="{{showAuth}}" id="auth"></authorize> <block wx:if="{{showAuth}}">
<authorize title="下载前需要获取您的‘添加到相册’权限,是否打开授权设置?" scopeType="writePhotosAlbum" buttonType="openSetting" bindfail="authFail" show="{{showAuth}}" id="auth"></authorize>
</block>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!