|
微信分享朋友圈或发送朋友,都没有图片了,查了很久都没有查出问题来,求各位大侠指点,$signPackage已经直接解析输出的
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> //这个是微信的SDK接口文件
<script type="text/javascript" src="<?php echo $GLOBALS['SITE_HTTP_DOMAIN'];?>style/js/jquery-1.10.2.js"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['SITE_HTTP_DOMAIN'];?>style/js/jquery-1.8.3.min.js"></script>
<script>
var json_str = ''' + <?php echo $signPackage;?> + ''';
//console.log(json_str);
var signPackage = $.parseJSON(json_str);
$(function() {
var urlpath = signPackage.url;
//var imgUrl = "<?php echo empty($adimages) ? $GLOBALS['SITE_HTTP_DOMAIN'] . 'style/yinji_images/yinjilogo.jpg' : $GLOBALS['SITE_HTTP_DOMAIN'] . $adimages;?>";
var imgUrl = $('#mallimg').html();
var descinfo = "我们拥有石门最专业的旅拍摄影师、高级化妆师";
if(descinfo == ''){
descinfo = urlpath;
}
var dataForWeixin = {
title: "<?php echo $title;?>",
desc: descinfo,
link: urlpath,
imgUrl: imgUrl
};
wx.config({
debug: false,
appId: signPackage.appId,
timestamp: signPackage.timestamp,
nonceStr: signPackage.nonceStr,
signature: signPackage.signature,
jsApiList: [
'checkJsApi',
'onMenuShareTimeline',
'onMenuShareAppMessage',
'onMenuShareQQ',
'onMenuShareWeibo',
'hideMenuItems',
'showMenuItems',
'hideAllNonBaseMenuItem',
'showAllNonBaseMenuItem',
'chooseImage',
'previewImage',
'uploadImage',
'getNetworkType',
'hideOptionMenu',
'showOptionMenu'
]
});
wx.ready(function() {
// 2. 分享接口
// 2.1 监听“分享给朋友”,按钮点击、自定义分享内容及分享结果接口
wx.onMenuShareAppMessage({
title: dataForWeixin.title,
desc: dataForWeixin.desc,
link: dataForWeixin.link,
imgUrl: dataForWeixin.imgUrl,
trigger: function(res) {
// alert('用户点击发送给朋友');
},
success: function(res) {
_hmt.push(['_trackEvent', 'chocolate_friend', 'share_friend', 'wechat', 'friend']);
},
cancel: function(res) {
// alert('已取消');
},
fail: function(res) {
// alert(JSON.stringify(res));
}
});
// 2.2 监听“分享到朋友圈”按钮点击、自定义分享内容及分享结果接口
wx.onMenuShareTimeline({
title: dataForWeixin.title,
desc: dataForWeixin.desc,
link: dataForWeixin.link,
imgUrl: dataForWeixin.imgUrl,
trigger: function(res) {
// alert('用户点击分享到朋友圈');
},
success: function(res) {
_hmt.push(['_trackEvent', 'chocolate_friends', 'share_friends', 'wechat', 'friends']);
},
cancel: function(res) {
//alert('已取消');
},
fail: function(res) {
// alert(JSON.stringify(res));
}
});
});
//检测网络
wx.getNetworkType({
success: function (res) {
var nt = res.networkType;
if (nt!='wifi'){
alert('亲,您当前用的不是WIFI环境,加载较缓慢请稍后.');
}
}
});
wx.error(function(res) {
alert(res.errMsg);
});
});
</script>
|
|