zoukankan      html  css  js  c++  java
  • uniApp h5分享实现

    前端需要传页面的url给后端,其中不包含#之后的内容,后端会返回timestamp、nonceStr、signature
    that.$http.post(that.$api.getH5Sign, {
        url: window.location.href.split('#')[0]
    }).then(res => {
        wxj.config({
            debug: true, // 开启调试模式
            appId: that.$config.weixinAppId, // 必填,公众号的唯一标识
            timestamp: res.data.timestamp, // 必填,生成签名的时间戳
            nonceStr: res.data.noncestr, // 必填,生成签名的随机串
            signature: res.data.sgture, // 必填,签名
            jsApiList: ["updateAppMessageShareData", "updateTimelineShareData"] // 必填,需要使用的JS接口列表
        });
        wxj.ready(function () { //需在用户可能点击分享按钮前就先调用              
             wxj.updateAppMessageShareData({
                title:that.detail.routeName, // 分享标题
                desc: that.detail.routeFeatures, // 分享描述
                link: window.location.href, // 分享链接,即要进入的页面的链接(其中的域名)必须与当前页面对应的公众号JS安全域名一致
                imgUrl: imgUrl, // 分享图标
            });
            wxj.updateTimelineShareData({
               title: that.detail.routeName, // 分享标题
               desc: that.detail.routeFeatures, // 分享描述
               link: window.location.href, //分享链接,即要进入的页面的链接(其中的域名)必须与当前页面对应的公众号JS安全域名一致
           imgUrl: imgUrl, // 分享图标
    })
    });
    })
  • 相关阅读:
    ES6 Symbol类型 附带:Proxy和Set
    why updating the Real DOM is slow, what is Virtaul DOM, and how updating Virtual DOM increase the performance?
    React高级指南
    池(Pool)
    计算机网络Intro
    React基础
    CommonJS 与 ES6 的依赖操作方法(require、import)
    webpack初识(biaoyansu)
    关于时间安排贪心算法正确性的证明
    DP总结
  • 原文地址:https://www.cnblogs.com/gao-xiaomeng/p/14298335.html
Copyright © 2011-2022 走看看