vue history模式下 ios分享不走自定义的问题

ios会记录一进去的页面路径所以在,app.vue页面里存下进入页面的路径

created () {
    window.localStorage.setItem('sigUrl',window.location.href)
}

然后在公共封装的方法里进行判断

/**
       *
   * @desc   微信分享
   * @param parmas(url地址链接,title分享的标题,desc分享的描述,imgUrl分享的图片链接,success)
   */
  static wxShare(parmas) {
    // if(!parmas){
      var a = this.isWeiXinAndIos() ? window.localStorage.getItem('sigUrl') : window.location.href
    post('/im/queryScan.action', {
      url: a
    }).then(response => {
      if (response.data && response.respCode == 1001) {
        console.log('ddddddddddddddd')
        wx.config({
          debug: false, // 开启调试模式,调用的所有api的返回值会在客户端openAlert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
          appId: response.data.appId, // 必填,公众号的唯一标识
          timestamp: response.data.timestamp, // 必填,生成签名的时间戳
          nonceStr: response.data.nonceStr, // 必填,生成签名的随机串
          signature: response.data.signature, // 必填,签名,见附录1
          jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo',
            'onMenuShareQZone', 'updateAppMessageShareData', 'updateTimelineShareData'
          ]
          // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
        })

        wx.ready(function () {
          console.log('cccccc')
          // 微信分享的数据
          var shareData = {
            'imgUrl': parmas.imgUrl ? parmas.imgUrl : '默认', // 分享显示的缩略图地址
            'link': parmas.url ? parmas.url : window.location.href, // 分享地址
            'desc': parmas.desc ? parmas.desc : '默认', // 分享描述
            'title': parmas.title ? parmas.title : '默认', // 分享标题
            success: function () {
              parmas.success && parmas.success()
            }
          }
          wx.onMenuShareTimeline(shareData)
          wx.onMenuShareAppMessage(shareData)
          wx.onMenuShareQQ(shareData)
          wx.onMenuShareWeibo(shareData)
          wx.onMenuShareQZone(shareData)
        })
        wx.error(function (res) {
          console.log(res)
        })
      }
    })
    // }

  }

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值