首页 > 代码库 > 微信页面的分享,设置分享信息以及监听分享
微信页面的分享,设置分享信息以及监听分享
js端
<script src=http://www.mamicode.com/http://res.wx.qq.com/open/js/jweixin-1.0.0.js></script> //配置微信分享 wx.config({ debug: false, appId: ‘<?php echo $signPackage["appId"];?>‘, timestamp: ‘<?php echo $signPackage["timestamp"];?>‘, nonceStr: ‘<?php echo $signPackage["nonceStr"];?>‘, signature: ‘<?php echo $signPackage["signature"];?>‘, jsApiList: [ ‘checkJsApi‘, ‘onMenuShareTimeline‘, ‘onMenuShareAppMessage‘, ‘onMenuShareQQ‘, ‘onMenuShareWeibo‘ ] }); wx.ready(function () { //分享给好友 wx.onMenuShareAppMessage({ title: "{$content[‘title‘]}", desc: "{$content[‘desc‘]}", link: "{$content[‘link‘]}", imgUrl: "{$content[‘imgUrl‘]}", success: function (res) { $.ajax({ type: "POST", url: "{:U(‘Enroll/addGlod‘)}", data: {"act_id":act_id}, dataType: "json", success: function(data){ if(data.state==0){ layer.msg(‘出错了!‘) }else if(data.state==1){ layer.msg(‘分享成功<br>获得‘+data.glod+‘金币!‘); }else if(data.state==2){ layer.msg(‘分享成功<br>重复分享不增加金币!‘); } } }); }, cancel: function (res) { layer.msg(‘您取消了分享‘); }, fail: function (res) { layer.msg(‘产生了一个分享错误‘); } }); //分享到朋友圈 wx.onMenuShareTimeline({ title: "{$content[‘title‘]}", desc: "{$content[‘desc‘]}", link: "{$content[‘link‘]}", imgUrl: "{$content[‘imgUrl‘]}", success: function (res) { $.ajax({ type: "POST", url: "{:U(‘Enroll/addGlod‘)}", data: {"act_id":act_id}, dataType: "json", success: function(data){ if(data.state==0){ layer.msg(‘出错了!‘) }else if(data.state==1){ layer.msg(‘分享成功<br>获得‘+data.glod+‘金币!‘); }else if(data.state==2){ layer.msg(‘分享成功<br>重复分享不增加金币!‘); } } }); }, cancel: function (res) { layer.msg(‘您取消了分享‘); }, fail: function (res) { layer.msg(‘产生了一个分享错误‘); } }); });
其中像<?php echo $signPackage["appId"];?>这种是由php传递过来的参数
php端
/* 加载微信SDK */ import ( "ORG.Util.ThinkWechat" ); $weixin = new ThinkWechat (); $signPackage = $weixin->GetSignPackage(); $this->assign(‘signPackage‘,$signPackage);
微信页面的分享,设置分享信息以及监听分享
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。