• 关于微信小程序分享提示{"errMsg":"config:ok"}


    提示

    {"errMsg":"config:ok"}

    {errMsg: "onMenuShareTimeline:ok"}

    {errMsg: "onMenuShareAppMessage"}

    原因很简单 

    大佬,是不是你wx.config函数中debug为true;

    看到网上说什么的都有,其实问题就是这么简单,

    看文档看文档多看官网文档重要的事情说三遍 ~

    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。


    wx.config({})成功以后 切记在
    wx.ready(function() {
    // 分享到朋友圈
    wx.onMenuShareTimeline({
    });
    // 分享给朋友
    wx.onMenuShareAppMessage({
    });
    });
    代码如下
    $.getJSON(
        "http://***:8888/?url=" +
          encodeURIComponent(window.location.href),
        function(result) {
          if (result.msg == "ok") {
            console.log(result.toString());
            var signature = result.signature;
            var timestamp = result.time_stamp;
            var nonce_str = result.nonce_str;
    
            wx.config({
              debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
              appId: "***********", // 必填,公众号的唯一标识
              timestamp: timestamp, // 必填,生成签名的时间戳
              nonceStr: nonce_str, // 必填,生成签名的随机串
              signature: signature, // 必填,签名,见附录1
              jsApiList: ["onMenuShareTimeline", "onMenuShareAppMessage"] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
            });
    
            wx.ready(function() {
              // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
              var img_url =
               "http://"+
                window.location.host +
                window.location.pathname +
                "static/image/share_logo.png";
              console.log(img_url);
              var title = $("h2.title").html();
              var link = window.location.href;
              // 分享到朋友圈
              wx.onMenuShareTimeline({
                imgUrl: img_url, // 分享图标
                link: link, // 分享链接
                desc: "", // 分享描述
                title: title, // 分享标题,
                success: function() {
                  // 用户确认分享后执行的回调函数
                  console.log("
                },
                cancel: function() {
                  // 用户取消分享后执行的回调函数
                  show_message("分享失败");
                }
              });
              // 分享给朋友
              wx.onMenuShareAppMessage({
                link: link, // 分享链接
                desc: "", // 分享描述
                title: title, // 分享标题,
                success: function() {
                  console.log("分享给朋友");
                  // 用户确认分享后执行的回调函数
                },
                cancel: function() {
                  // 用户取消分享后执行的回调函数
                }
              });
            });
          } else {
          }
        }
      );
    

      

  • 相关阅读:
    类模板机制
    C和C++中const的区别
    bitset
    静态库or动态库?
    多态原理探究
    程序从编译到运行过程
    对象的内存模型
    重载、重写(覆盖)和隐藏
    对继承和派生的理解
    对C++对象的理解
  • 原文地址:https://www.cnblogs.com/yuwen1995/p/9728603.html
Copyright © 2020-2023  润新知