微信分享-js代码

// 微信分享
            var wx = require('wechat-sdk');
            rewardsResultService.getWechatInfo().then(function(data) {
                var conf = data;
                wx.config({
                  debug: false,
                  appId: 'wx34e783920b37ee91',
                  timestamp: conf.timestamp,
                  nonceStr: conf.noncestr,
                  signature: conf.signature,
                  jsApiList: ['onMenuShareAppMessage', 'onMenuShareTimeline','onMenuShareQQ']
                });
                configWeChatInterface();
            });

            var iconUrl = 'http://'+location.host+'/images/icon-200yuan.png';
            function configWeChatInterface() {
                //分享给朋友
                wx.onMenuShareAppMessage({
                  title: '一言不合就发红包,金蛛送您200元红包!',
                  desc: '一言不合就发红包,金蛛送您200元红包!',
                  link: location.href,
                  imgUrl: iconUrl,
                  type: 'link',
                  success: function() {
                      // alert('share success');
                  },
                  cancel: function() {

                  }
                });
                //分享到朋友圈
                wx.onMenuShareTimeline({
                  title: '一言不合就发红包,金蛛送您200元红包!',
                  link: location.href, // 分享链接
                  imgUrl: iconUrl
                });
                //分享到QQ
                wx.onMenuShareQQ({
                    title: '一言不合就发红包,金蛛送您200元红包!', // 分享标题
                    desc: '一言不合就发红包,金蛛送您200元红包!', // 分享描述
                    link: location.href, // 分享链接
                    imgUrl: iconUrl, // 分享图标
                    success: function () { 
                       // 用户确认分享后执行的回调函数
                    },
                    cancel: function () { 
                       // 用户取消分享后执行的回调函数
                    }
                });
            }

你可能感兴趣的:(js,微信,微信)