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, // 分享图标
    })
    });
    })
  • 相关阅读:
    SQL学习
    FOR XML PATH
    IOS学习网址
    weak nonatomic strong等介绍(ios)
    UVALive3045 POJ2000 ZOJ2345 Gold Coins
    UVA713 UVALive5539 POJ1504 ZOJ2001 Adding Reversed Numbers
    UVA713 UVALive5539 POJ1504 ZOJ2001 Adding Reversed Numbers
    UVA439 POJ2243 HDU1372 ZOJ1091 Knight Moves【BFS】
    UVA439 POJ2243 HDU1372 ZOJ1091 Knight Moves【BFS】
    UVA10905 Children's Game
  • 原文地址:https://www.cnblogs.com/gao-xiaomeng/p/14298335.html
Copyright © 2011-2022 走看看