123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- (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;
- }
- */
- })();
- function posterShare(href){
- //海报页面
- $.post("./user/getWxConfigParam?url=" + href, {}, function(resp) {
- if (resp.code == 'error') {
- console.log(resp.code);
- }else{
- wx.config({
- debug: false,
- appId: 'wx749c84daac654e1e',
- timestamp: resp.data.timestamp,
- nonceStr: resp.data.noncestr,
- signature: resp.data.sign,
- jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone', 'showOptionMenu', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem']
- });
- wx.ready(function(){
- const share = {
- title: "我为你精心准备的美味,快享用吧!",
- desc: "",
- imgUrl: "http://wx.ttkuaiban.com/minigame/images/share_picture.png",
- link: href,
- success: function() {
- $.post("./prize/luckDrawAddShare", {uid: id}, function(resp) {
- if (resp.code == 'error') {
- console.log(resp.code);
- }else{
- window.location.href = "http://wx.ttkuaiban.com/minigame/lottery.html";
- }
- });
- },
- cancel: function() {}
- };
- wx.onMenuShareAppMessage(share);
- wx.onMenuShareTimeline(share);
- wx.onMenuShareQQ(share);
- wx.onMenuShareQZone(share);
- wx.onMenuShareWeibo(share);
- });
- wx.error(function(res){
- console.log(res);
- });
- };
- });
- }
|