微信分享和埋点

wxShare(info) {

let data = {};

data.title = info.title;

data.desc = info.desc;

data.link = `http://${window.location.host}/auth?${decodeURIComponent(getParam('state'))}`;  必须+http

data.imgUrl ="https://zm-bbs-images.oss-cn-hangzhou.aliyuncs.com/61ab07aedc674e19a84b3d2d9a54ec6f.png";

data.success = function() {

    // console.log("设置参数:"+JSON.stringify(data));

    // console.log('设置成功');

    ZMSDK.onEvent("H5_activity_share_guide_click");   埋点

}

const that = this;

wx.ready(function() {

    console.log('wx ready-------');

    that.wxConfig();

    if(wx.onMenuShareAppMessage){ //微信文档中提到这两个接口即将弃用,故判断

        console.log('1.0');

        console.log("分享参数:"+JSON.stringify(data));

        wx.onMenuShareAppMessage(data);//1.0 分享到朋友

        wx.onMenuShareTimeline(data);//1.0分享到朋友圈

    }else{

        console.log('1.4');

        console.log("分享参数:"+JSON.stringify(data));

        wx.updateAppMessageShareData(data);//1.4 分享到朋友

        wx.updateTimelineShareData(data);//1.4分享到朋友圈

    }

    wx.hideAllNonBaseMenuItem();

    wx.showMenuItems({

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

});

});

wx.error(function(res){

    console.log("分享失败描述:"+res);

})

},

你可能感兴趣的:(web前端js)