zoukankan      html  css  js  c++  java
  • 浅谈前端H5自定义分享实现方法

     引入jweinxin相关js文件,然后才可以做H5的分享
     <script src="js/jweixin-1.2.0.js"></script>
    let wxData = '';
    $.ajax({
        url: baseUrl + '/api/Invitation/inviteFriendsShare',
        type: "GET",
        data: {
            url: encodeURIComponent(window.location.href.split('#')[0])
        },
        success: function (res) {
            signPackage = res.data;
            var title = document.title;
            wxData = {
                "imgUrl": "https://img.boltshopvip.com/api/mtshare.png", //分享图标
                "title": "麻团小课堂 | 给孩子最好的通识启蒙课,足不出户看世界!", //分享标题
                "desc": '让知识陪孩子去远航!', //分享描述
                "link": "https://mtdd.jsxcloud.com/h5/index.html"
            };
            wx.config({
                debug: false,
                appId: signPackage.appId,
                timestamp: parseInt(signPackage.timestamp),
                nonceStr: signPackage.nonceStr,
                signature: signPackage.signature,
                jsApiList: [
                    'onMenuShareTimeline',
                    'onMenuShareAppMessage'
                ]
            });
        },
        fail: function (res) {
            console.log(res);
    
        }
    })
    wx.ready(function () {
        wx.onMenuShareTimeline({
            title: wxData.title,
            link: wxData.link,
            imgUrl: wxData.imgUrl,
            success: function () { 
          //分享成功后的回调
         } }); wx.onMenuShareAppMessage({ title: wxData.title, desc: wxData.desc, link: wxData.link, imgUrl: wxData.imgUrl, type:
    'link', dataUrl: '', success: function () {
          //分享成功后的回调
         }
        });
    });
  • 相关阅读:
    Postman界面了解
    HTTP之网关的分类
    HTTP之如何控制缓存
    HTTP之缓存是如何保持副本的新鲜的!
    jenkins安装笔记
    git管理gogs安装笔记
    Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    OneProxy学习笔记
    CentOS7使用笔记
    PHP Curl 请求同域的问题
  • 原文地址:https://www.cnblogs.com/teamemory/p/10978116.html
Copyright © 2011-2022 走看看