美文网首页
vue 分享自定义微信分享

vue 分享自定义微信分享

作者: w龙 | 来源:发表于2019-09-26 09:34 被阅读0次
         //获取并保存微信用户信息
            getSign() {
              var _that = this;
              _that.loading = true;
               axios({
                 url: this.imgUrl+"/rest/vvm.wechat.config",
                 method: "POST",
                 data: {
                  "h":{
                    "t":"4d092ee240779ae8a34678593390422f" // 请求校验token
                  },
                  "d":{
                    "a":1, // 必传1
                    "u":window.location.href.split('#')[0], // 需要访问的url
                    "orderId":_that.orderId
                  }
                 },
                 headers: {
                   "content-type": "application/json"
                 }
               }).then(function(res) {
               var datas = res.data.d;
               _that.loading = false;
               // 分享配置
               wx.config({
                 debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
                 appId: datas.appId, // 必填,企业号的唯一标识
                 timestamp: datas.timestamp, // 必填,生成签名的时间戳
                 nonceStr: datas.nonceStr, // 必填,生成签名的随机串
                 signature: datas.signature, // 必填,签名,见附录1
                 jsApiList: ["onMenuShareTimeline", "onMenuShareAppMessage",'hideMenuItems']
               });
               wx.ready(function() {
                wx.hideMenuItems({// 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3
                   menuList: ['menuItem:share:qq', 'menuItem:share:QZone','menuItem:openWithSafari']
                  });
               //分享到朋友圈
                wx.onMenuShareTimeline({
                  title: "【我要免邮】点赞助力减免邮费领豪礼",
                  link:_that.links+'/payment_page/prize.html?orderId='+ _that.orderId,
                  imgUrl: _that.links+'/luckyLottery/images/shareLogo.png',
                  success: function() {
                    weui.toast("分享成功");
                  },
                  cancel: function() {
                  }
                });
                //分享给朋友
                wx.onMenuShareAppMessage({
                  title: "【我要免邮】点赞助力减免邮费领豪礼",
                  desc: "万水千山总是情,帮我点赞行不行",
                  link:_that.links+'/payment_page/prize.html?orderId='+ _that.orderId,
                  imgUrl: _that.links+'/luckyLottery/images/shareLogo.png',
                  success: function() {
                    weui.toast("分享成功");
                  },
                  cancel: function() {
                  }
                });
              });
             },function(err){
               _that.loading = false;
             });
            },
    

    相关文章

      网友评论

          本文标题:vue 分享自定义微信分享

          本文链接:https://www.haomeiwen.com/subject/xbsoectx.html