收藏
回答

updateAppMessageShareData没有执行,也没有报错,分享的设置没有生效?

let url = encodeURIComponent(window.location.href.split('#')[0])

      window.jssdkSign(url, (res=> {

        console.log('微信配置信息'res)

        window.wx.config({

          debug: false,

          appId: res.appId,

          timestamp: res.timestamp,

          nonceStr: res.noncestr,

          signature: res.signature,

          jsApiList: ['showMenuItems''updateAppMessageShareData']

        })

        window.wx.error(function (res) {

          console.error(res)

        })

        window.wx.ready(() => {

          window.wx.showMenuItems({

            menuList: ['menuItem:share:appMessage'],

            success: () => {

              console.log('menuItem:share:appMessage成功')

              this.updateShareInfo()

            },

            fail: (err=> {

              console.error(err)

            }

          })

        })

      })


updateShareInfo () {

      let shareInfo = this.shareInfo

      window.wx.updateAppMessageShareData({

        title: shareInfo.title,

        desc: shareInfo.desc,

        link: shareInfo.link,

        imgUrl: shareInfo.imgUrl,

        success: (res=> {

          console.log('分享朋友设置成功==' + res)

        },

        fail: (err=> {

          this.wechatShare()

          console.error('分享朋友设置失败==' + err)

        }

      })

    }




回答关注问题邀请回答
收藏
登录 后发表内容
问题标签