zoukankan      html  css  js  c++  java
  • 手机端微网站调取微信分享接口

    $.ajax({
        url: netUrl('getShareParam'),
        type: 'post',
        dataType: 'json',
        data: {
            url: location.href.split('#')[0]
        },
        xhrFields: {
            withCredentials: true
        },
        success: function(data) {
            var data = data.infor[0];
            wx.config({
                debug: false,
                appId: 'wxec28c9eb71df4cfb',
                timestamp: data.timestamp,
                nonceStr: data.nonceStr,
                signature: data.signature,
                jsApiList: [
                    'checkJsApi',
                    'onMenuShareTimeline', //获取“分享到朋友圈”按钮点击状态及自定义分享内容接口  
                    'onMenuShareAppMessage', //获取“分享给朋友”按钮点击状态及自定义分享内容接口  
                    'onMenuShareQQ', //获取“分享到QQ”按钮点击状态及自定义分享内容接口  
                    'onMenuShareQZone', //获取“分享到QQ空间”按钮点击状态及自定义分享内容接口  
                    'onMenuShareWeibo' //分享到微博
                ]
            });
            wx.ready(function() {
                // 分享到朋友
                wx.onMenuShareAppMessage({
                    title: s_title, // 分享标题
                    desc: s_desc, // 分享描述
                    link: s_link, // 分享链接
                    imgUrl: preUrl('assets/i/logo.png'), // 分享图标
                    type: 'link', // 分享类型,music、video或link,不填默认为link
                    dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
                    success: function() {
                        alert("ok")
                        window.location.href = history.go(-1);
    
                    },
                    cancel: function() {
                        // 用户取消分享后执行的回调函数
                        alert('取消')
    
                    }
                });
    
                // 分享到朋友圈
                wx.onMenuShareTimeline({
                    title: s_title, // 分享标题
                    desc: s_desc, // 分享描述
                    link: s_link, // 分享链接
                    imgUrl: preUrl('assets/i/logo.png'), // 分享图标
                    success: function() {
                        alert("ok")
                        window.location.href = history.go(-1);
    
                    },
                    cancel: function() {
                        // 用户取消分享后执行的回调函数
                        alert('取消')
    
                    }
                });
                // 分享到QQ
                wx.onMenuShareQQ({
                    title: s_title, // 分享标题
                    desc: s_desc, // 分享描述
                    link: s_link, // 分享链接
                    imgUrl: preUrl('assets/i/logo.png'), // 分享图标
                    success: function() {
                        alert("ok")
                        window.location.href = history.go(-1);
    
                    },
                    cancel: function() {
                        // 用户取消分享后执行的回调函数
                        alert('取消')
    
                    }
                });
                // 分享到腾讯微博
                wx.onMenuShareWeibo({
                    title: s_title, // 分享标题
                    desc: s_desc, // 分享描述
                    link: s_link, // 分享链接
                    imgUrl: preUrl('assets/i/logo.png'), // 分享图标
                    success: function() {
                        alert("ok")
                        window.location.href = history.go(-1);
    
                    },
                    cancel: function() {
                        // 用户取消分享后执行的回调函数
                        alert('取消')
    
                    }
                });
                // 分享到QQ空间
                wx.onMenuShareQZone({
                    title: s_title, // 分享标题
                    desc: s_desc, // 分享描述
                    link: s_link, // 分享链接
                    imgUrl: preUrl('assets/i/logo.png'), // 分享图标
                    success: function() {
                        alert("ok")
                        window.location.href = history.go(-1);
    
                    },
                    cancel: function() {
                        // 用户取消分享后执行的回调函数
                        alert('取消')
    
                    }
                });
            });
    
            wx.error(function(res) {
    
            });
    
        },
        error: function(e, request, settings) {
            alert(settings);
        }
    });

    微信分享使用微信默认分享,但我们可以设置分享的内容和分享到那个平台

  • 相关阅读:
    AgileEAS.NET平台视频会议培训第二辑简单插件开发应用演练(速度下载)
    给大家分享一个培训的PPT:面向构件的组织级开发模式探讨
    AgileEAS.NET SOA 中间件平台工作流系统介绍
    “医疗信息化行业之中的联发科” 我们在医疗行业中的定位及目标
    AgileEAS.NET SOA 平台5.1开发包介绍
    实例演示如何使用AgileEAS.NET SOA平台工作流进行业务流程自定义
    Silverlight企业应用开发实践AgileEAS.NET平台5.0 Silverlight支撑预览
    AgileEAS.NET平台视频会议培训第三辑插件的安装、配置以及账户权限系统演练
    Stream Part.6
    Stream Part.7
  • 原文地址:https://www.cnblogs.com/ouchen0312/p/7365842.html
Copyright © 2011-2022 走看看