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 30
30
collectImage : '/static/images/icon_collect.png' ,
31
31
shareImage : '' ,
32
32
isGroupon : false , //标识是否是一个参团购买
33
- soldout : false
33
+ soldout : false ,
34
+ canWrite : false
34
35
} ,
35
36
36
37
// 页面分享
@@ -42,7 +43,27 @@ Page({
42
43
path : '/pages/index/index?goodId=' + this . data . id
43
44
}
44
45
} ,
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
+ } ,
46
67
showShare : function ( ) {
47
68
this . sharePop . togglePopup ( ) ;
48
69
} ,
@@ -375,6 +396,33 @@ Page({
375
396
} ) ;
376
397
this . getGrouponInfo ( options . grouponId ) ;
377
398
}
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
+
378
426
} ,
379
427
380
428
onShow : function ( ) {
Original file line number Diff line number Diff line change 134
134
135
135
<!-- 底部按钮 -->
136
136
<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}}">
138
141
<image class="icon" src="../../images/goods-share.png" />
139
142
</view>
140
143
<view class="l l-cart" wx:if="{{!isGroupon}}">
You can’t perform that action at this time.
0 commit comments