Skip to content

Commit 29f0f30

Browse files
wkztselinalinlinjava
authored andcommitted
update:对renard项目修改获取权限
1 parent 0e165c8 commit 29f0f30

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed

renard-wx/pages/goods/goods.js

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ Page({
3030
collectImage: '/static/images/icon_collect.png',
3131
shareImage: '',
3232
isGroupon: false, //标识是否是一个参团购买
33-
soldout: false
33+
soldout: false,
34+
canWrite: false
3435
},
3536

3637
// 页面分享
@@ -42,7 +43,27 @@ Page({
4243
path: '/pages/index/index?goodId=' + this.data.id
4344
}
4445
},
45-
46+
handleSetting: function(e) {
47+
var that = this;
48+
// console.log(e)
49+
if (!e.detail.authSetting['scope.writePhotosAlbum']) {
50+
wx.showModal({
51+
title: '警告',
52+
content: '不授权无法保存',
53+
showCancel: false
54+
})
55+
that.setData({
56+
canWrite: false
57+
})
58+
} else {
59+
wx.showToast({
60+
title: '保存成功'
61+
})
62+
that.setData({
63+
canWrite: true
64+
})
65+
}
66+
},
4667
showShare: function() {
4768
this.sharePop.togglePopup();
4869
},
@@ -375,6 +396,33 @@ Page({
375396
});
376397
this.getGrouponInfo(options.grouponId);
377398
}
399+
let that = this;
400+
wx.getSetting({
401+
success: function (res) {
402+
console.log(res)
403+
//不存在相册授权
404+
if (!res.authSetting['scope.writePhotosAlbum']) {
405+
wx.authorize({
406+
scope: 'scope.writePhotosAlbum',
407+
success: function () {
408+
that.setData({
409+
canWrite: true
410+
})
411+
},
412+
fail: function (err) {
413+
that.setData({
414+
canWrite: false
415+
})
416+
}
417+
})
418+
} else {
419+
that.setData({
420+
canWrite: true
421+
});
422+
}
423+
}
424+
})
425+
378426
},
379427

380428
onShow: function() {

renard-wx/pages/goods/goods.wxml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@
134134

135135
<!-- 底部按钮 -->
136136
<view class="bottom-btn">
137-
<view class="l l-collect" bindtap="showShare" wx:if="{{!isGroupon}}">
137+
<view class="l l-collect"open-type="openSetting" bindopensetting="handleSetting" wx:if="{{(!isGroupon) && (!canWrite) }}">
138+
<image class="icon" src="../../images/goods-share.png" />
139+
</view>
140+
<view class="l l-collect" bindtap="showShare" wx:if="{{!isGroupon && canWrite}}">
138141
<image class="icon" src="../../images/goods-share.png" />
139142
</view>
140143
<view class="l l-cart" wx:if="{{!isGroupon}}">

0 commit comments

Comments
 (0)