前端配置微信JSSDK授权h5页面分享!

var _this=this;
//重点
var url = location.href.split(’#’)[0]
//重点

//配置微信分享
this.$axios
  .post("http://web-nfish.cn/wechat/info", {"url":url'})
  .then(function(response) {
    wx.config({
        debug: false, 
        appId: response.data.data.appId, 
        timestamp: response.data.data.timestamp,
        nonceStr: response.data.data.nonceStr,
        signature:response.data.data.signature,
        jsApiList: [response.data.data.jsApiList[0],response.data.data.jsApiList[1],response.data.data.jsApiList[2],response.data.data.jsApiList[3],response.data.data.jsApiList[4]]
    });
    wx.ready(function() {
      
      wx.onMenuShareAppMessage({
        title: '!',
        desc: ',!',
        link: url,
        imgUrl: 'http://web-nfish.cn/message/message.png',
        trigger: function(res) {
        },
        success: function(res) {
        },
        cancel: function(res) {
        },
        fail: function(res) {
        }
      });
      
      wx.onMenuShareTimeline({
        title:'!',
        desc: '邀到来!',
        link: url,
        imgUrl: 'http://web-nfish.cn/message/message.png',
        trigger: function(res) {
        },
        success: function(res) {
        },
        cancel: function(res) {
        },
        fail: function(res) {
        }
      });
    });
  })
  .catch(function(error) {});

你可能感兴趣的:(大雄)