首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >微信分享一切OK,测试能够生成签名、ticket,但分享的时候就是没有缩略图?

微信分享一切OK,测试能够生成签名、ticket,但分享的时候就是没有缩略图?

提问于 2021-04-07 10:24:07
回答 0关注 0查看 164

上代码:

<script>

var pagetUrl = window.location.href;

$(function () {

//--微信JS配置

if (wx != null && wx != undefined) {

if (pagetUrl.indexOf("#") > 0) {

pagetUrl = str.substring(0, pagetUrl.indexOf("#"));

            }

$.ajax({

url: "wx.aspx",

type: "post",

data: {},

dataType: "json",

success: function (data) {

var ticket = data.ticket;

var timestamp = new Date().getTime();

var noncestr = timestamp.toString().substring(4);

var url = location.href;

var imgUrl = "http://www.house8.net/ziyundongqu/images/heading.png";

var sgin = getSign(ticket, url, timestamp, noncestr);

wx.config({

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

appId: 'wxbf2cee2f63e13903', // 必填,公众号的唯一标识

timestamp: timestamp, // 必填,生成签名的时间戳

nonceStr: noncestr, // 必填,生成签名的随机串

signature: sgin,// 必填,签名,见附录1

jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage']

// 必填,需要使用的JS接口列表,所有JS接口列表见附录2

                    });

wx.ready(function () {

wx.onMenuShareTimeline({

title: "紫云东区",

link: url,

imgUrl: imgUrl,

success: function () {

//alert("分享成功");

                            },

fail: function (res) {

alert("分享失败");

                            }

                        });

wx.onMenuShareAppMessage({

title: "紫云东区",

desc: "紫云东区二期",

link: url,

imgUrl: imgUrl,

success: function () {

alert("分享成功");

                            },

fail: function (res) {

alert("分享失败");

                            }

                        });

wx.error(function(res) {

alert(res.errMsg);

                        });

                    });

                },

complete: function (XMLHttpRequest, textStatus) {

if (textStatus == 'timeout') {

var xmlhttp = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHttp");

xmlhttp.abort();

$(".box").html("网络超时!");

                    }

$("#inp").val("点击获取数据");

                },

error: function (XMLHttpRequest, textStatus) {

console.log(XMLHttpRequest);  //XMLHttpRequest.responseText    XMLHttpRequest.status   XMLHttpRequest.readyState

console.log(textStatus);

$(".box").html("服务器错误!");

                }

            });

        }

    });

</script>

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档