web分享

function share() {
    let wxShare;
    // 获取分享服务
    plus.share.getServices(function(s) {
        console.log(JSON.stringify(s));
        for (let i = 0; i < s.length; i++) {
            if (s[i].id == 'weixin') {
                wxShare = s[i];
                wxShare.send({
                    type: 'web',
                    content: "商品名称商品名称商品名 称商品名称",
                    href: "http://www.dcloud.io/",
                    // thumbs: ['img/no_person.png'],
                    extra: {
                        scene: 'WXSceneSession'
                    }
                }, function() {
                    alert("分享成功!");
                }, function(e) {
                    alert("分享失败:" + e.message);
                });
            }
        }
    }, function(e) {
        alert("获取分享服务列表失败: " + JSON.stringify(e));
    });
}

猜你喜欢

转载自www.cnblogs.com/XMBY/p/12724183.html