File tree Expand file tree Collapse file tree 2 files changed +54
-3
lines changed
Expand file tree Collapse file tree 2 files changed +54
-3
lines changed Original file line number Diff line number Diff line change 3030 collectImage : '/static/images/icon_collect.png' ,
3131 shareImage : '' ,
3232 isGroupon : false , //标识是否是一个参团购买
33- soldout : false
33+ soldout : false ,
34+ canWrite : false , //用户是否获取了保存相册的权限
3435 } ,
3536
3637 // 页面分享
@@ -53,7 +54,27 @@ Page({
5354 return false ;
5455 }
5556 } ,
56-
57+ handleSetting : function ( e ) {
58+ var that = this ;
59+ // console.log(e)
60+ if ( ! e . detail . authSetting [ 'scope.writePhotosAlbum' ] ) {
61+ wx . showModal ( {
62+ title : '警告' ,
63+ content : '不授权无法保存' ,
64+ showCancel : false
65+ } )
66+ that . setData ( {
67+ canWrite : false
68+ } )
69+ } else {
70+ wx . showToast ( {
71+ title : '保存成功'
72+ } )
73+ that . setData ( {
74+ canWrite : true
75+ } )
76+ }
77+ } ,
5778 // 保存分享图
5879 saveShare : function ( ) {
5980 let that = this ;
@@ -399,6 +420,32 @@ Page({
399420 } ) ;
400421 this . getGrouponInfo ( options . grouponId ) ;
401422 }
423+ let that = this ;
424+ wx . getSetting ( {
425+ success : function ( res ) {
426+ console . log ( res )
427+ //不存在相册授权
428+ if ( ! res . authSetting [ 'scope.writePhotosAlbum' ] ) {
429+ wx . authorize ( {
430+ scope : 'scope.writePhotosAlbum' ,
431+ success : function ( ) {
432+ that . setData ( {
433+ canWrite : true
434+ } )
435+ } ,
436+ fail : function ( err ) {
437+ that . setData ( {
438+ canWrite : false
439+ } )
440+ }
441+ } )
442+ } else {
443+ that . setData ( {
444+ canWrite : true
445+ } ) ;
446+ }
447+ }
448+ } )
402449 } ,
403450 onShow : function ( ) {
404451 // 页面显示
Original file line number Diff line number Diff line change 1919 <image class='sharebtn_image' src='/static/images/wechat.png'></image>
2020 <view class='sharebtn_text'>分享给好友</view>
2121 </button>
22- <button class="savesharebtn" bindtap="saveShare" wx:if="{{!isGroupon}}">
22+ <button class="savesharebtn" open-type="openSetting" bindopensetting="handleSetting" wx:if="{{(!isGroupon) && (!canWrite)}}" >
23+ <image class='sharebtn_image' src='/static/images/friend.png'></image>
24+ <view class='sharebtn_text'>发朋友圈</view>
25+ </button>
26+ <button class="savesharebtn" bindtap="saveShare" wx:if="{{!isGroupon && canWrite}}">
2327 <image class='sharebtn_image' src='/static/images/friend.png'></image>
2428 <view class='sharebtn_text'>发朋友圈</view>
2529 </button>
You can’t perform that action at this time.
0 commit comments