• 公众号做分享功能


    引进js

    <script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js" type="text/javascript" charset="utf-8"></script>

    var link = window.location.href.split("#")[0];
    $.get("http://catcher.eeeeasy.com/index.php?route=gift/wx_common/jssdk",{
    url: link
    })
    .then(function(res) {
    let data = $.parseJSON(res)
    console.log(data)
    if (data.code == 200) {
    console.log(data);
    wx.config({
    debug: false,
    appId: 'wx87d9518bac6467ae',
    timestamp: data.list.timestamp,
    nonceStr: data.list.nonceStr,
    signature: data.list.signature,
    jsApiList: [
    'checkJsApi',
    'onMenuShareTimeline',
    'onMenuShareAppMessage',
    'onMenuShareQQ',
    'onMenuShareWeibo',
    'onMenuShareQZone',
    'chooseWXPay',
    'chooseImage',
    'uploadImage',
    'previewImage'
    ]
    });
    // wx.error(function(res){
    // // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
    // alert("error:"+JSON.stringify(res));
    // });
    var appId = 'wx87d9518bac6467ae';
    var imgURL = 'http://catcher.eeeeasy.com/yesic/qie/fang.png';
    var link = 'http://catcher.eeeeasy.com/yesic/index.html';
    var desc = 'YES!IC';
    var title = 'YES!IC';
    wx.ready(function () {
    setShare(); //定义函数
    });
    function setShare(){
    // 在这里调用 API,分享朋友圈
    wx.onMenuShareTimeline({
    title: title, // 分享标题
    link: link, // 分享链接
    desc:desc,
    imgUrl: imgURL, // 分享显示的缩略图
    success: function () {
    // 用户确认分享后执行的回调函数
    layer.msg('分享完成');
    },
    cancel: function () {
    // 用户取消分享后执行的回调函数
    // alert('淘气了哦,你取消分享');
    },fail: function (res) {
    alert(JSON.stringify(res));
    }
    });
    //分享给朋友
    wx.onMenuShareAppMessage({
    title: title, // 分享标题
    link: link, // 分享链接
    desc:desc,
    imgUrl: imgURL, // 分享显示的缩略图
    success: function () {
    // 用户确认分享后执行的回调函数
    layer.msg('分享完成');
    },
    cancel: function () {
    // 用户取消分享后执行的回调函数
    // alert('淘气了哦,你取消分享');
    },fail: function (res) {
    alert(JSON.stringify(res));
    }
    });
    }
    }
    })

  • 相关阅读:
    ubuntu中,终端命令行快速打开html文件方法
    Python清空文本内容的两种方法
    科大教学日历
    MJ瀑布流学习笔记
    iOS搜索框
    异步IO
    yield
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    15个常用的javaScript正则表达式
    Linux 升级 Python 至 3.x
  • 原文地址:https://www.cnblogs.com/weiwentaweb/p/10335605.html
Copyright © 2020-2023  润新知