1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- (function(){
- // var init = {
- // url:window.location.href.split('#')[0],
- // share: {
- // title: '',
- // desc: '',
- // imgUrl: './img/share_img.jpg?v=v72',
- // link:window.location.href.split('#')[0]
- // }
- // };
- /*
- $.ajax({
- url:"",
- type:"post",
- dataType:"json",
- data:{
- url:encodeURIComponent(init.url),
- t: new Date().getTime()
- },
- success:function(result){
- console.log(result);
- if(!result){
- return false;
- }
- wx.config({
- debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
- appId: result.appId, // 必填,公众号的唯一标识
- timestamp: result.timestamp, // 必填,生成签名的时间戳
- nonceStr: result.nonceStr, // 必填,生成签名的随机串
- signature: result.signature,// 必填,签名,见附录1
- jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage','closeWindow','checkJsApi','translateVoice']
- })
- }
- });
- //绑定微信分享事件
- try{
- wx.ready(function(){
- //设置分享后的回调函数
- var callback={
- success:function (msg){
- msg=JSON.stringify(msg).toLowerCase();
- if(msg.indexOf('timeline')>-1){
- //分享到朋友圈
- }else if(msg.indexOf('message')>-1){
- //分享到给朋友
- }
- }
- };
- wx.onMenuShareTimeline($.extend({},init.share,callback));
- wx.onMenuShareAppMessage($.extend({},init.share,callback));
- });
- }catch(e){
- var msg="错误:微信js-sdk未引用或者错误!";
- try{
- console.log(msg);
- }catch(e){
- alert(msg);
- }
- return;
- }
- */
-
- })();
|