小程序 之生成海报与保存到本地

一、效果图

 

 二、代码

<button wx:if="{{is_authorize==false}}" open-type="openSetting" class="weui-btn mini-btn font-size16" style="margin-top: 0;background-color: #5DBF44;color: #fff;line-height:90rpx;width:100%;padding:0">保存名片海报后分享</button>
        <button wx:else bindtap="saveHaibao" class="weui-btn mini-btn font-size16" style="margin-top: 0;background-color: #5DBF44;color: #fff;line-height:90rpx;width:100%;padding:0">保存名片海报后分享</button>

 

onShow:function (){
    wx.getSetting({
      success(res){
      console.log(res)
        _this.setData({
          is_authorize: res.authSetting['scope.writePhotosAlbum']
        })
      }
    })
}

 

saveHaibao(){
    wx.saveImageToPhotosAlbum({
      filePath: _this.data.url,
      success(res){
      console.log(res)
        if (res.errMsg == 'saveImageToPhotosAlbum:ok') {
            _this.showImage()
        }
      }
    })
}

 

posted @ 2020-05-09 09:37  样子2018  阅读(280)  评论(0编辑  收藏  举报