You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.5 KiB
63 lines
2.5 KiB
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>test</title>
|
|
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
|
|
<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
$(function () {
|
|
var url="http://www.szcaee.cn/home/api/wxshare.html"
|
|
var link=location.href.split('#')[0]
|
|
// var link="http://www.szcaee.cn/wangpai/index-test.html?v=2"
|
|
var shareLink=encodeURIComponent(link)
|
|
var imgUrl="http://www.szcaee.cn/app/home/view/szwjs/index/Public/Img/wangpai.png"
|
|
$.ajax({url:url,data:{link:shareLink},success:function (resp) {
|
|
console.log(resp)
|
|
var res=$.parseJSON(resp)
|
|
var config=res.signPackage
|
|
var shareInfo=res.share
|
|
wx.config({
|
|
debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
|
appId: config.appId, // 必填,公众号的唯一标识
|
|
timestamp: config.timestamp, // 必填,生成签名的时间戳
|
|
nonceStr: config.nonceStr, // 必填,生成签名的随机串
|
|
signature: config.signature,// 必填,签名
|
|
jsApiList: [
|
|
'updateAppMessageShareData',
|
|
'updateTimelineShareData',
|
|
'onMenuShareTimeline',
|
|
'onMenuShareAppMessage'
|
|
] // 必填,需要使用的JS接口列表
|
|
});
|
|
wx.ready(function () {
|
|
|
|
//自定义“分享给朋友”及“分享到QQ”按钮的分享内容
|
|
wx.updateAppMessageShareData({
|
|
title: "test 标题", // 分享标题
|
|
desc: "test 描述", // 分享描述
|
|
link: config.url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
imgUrl: shareInfo.imgUrl, // 分享图标
|
|
success: function () {
|
|
// 设置成功
|
|
}
|
|
});
|
|
//获取“分享到朋友圈”按钮点击状态及自定义分享内容接口(即将废弃)
|
|
wx.updateTimelineShareData({
|
|
title: "test 标题", // 分享标题
|
|
link: config.url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
imgUrl: shareInfo.imgUrl, // 分享图标
|
|
success: function () {
|
|
// 设置成功
|
|
}
|
|
});})
|
|
}},)
|
|
})
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|
|
|