onShareAppMessage: function(res) {

   var that = this;

   if (res.from === 'button') { // 来自页面内按钮

     var nickName = "",

       avatarUrl = "",

       timestamp = that.data.timestamp;

     var time = util.formatTime(timestamp).substring(0, 16);


     new Promise(function(resolve, reject) {

       wx.getSetting({

         success(res) {

           if (res.authSetting['scope.userInfo']) {

             wx.getUserInfo({

               success: function(res) {

                 nickName = res.userInfo.nickName;

                 avatarUrl = res.userInfo.avatarUrl;

                 resolve();

               },

             })

           }

         }

       })

     }).then(() => {

       console.log(nickName + avatarUrl);

       return {

         title: 'xx,不服来战',

         path: '/pages/challenge/challenge?ratio=' + that.data.ratio + '&nickName=' + nickName + '&avatarUrl=' + avatarUrl + '&time=' + time + '&id=' + Date.parse(timestamp) + that.data.templv + Math.floor(Math.random() * 99999)

       }

     })

   }

 }

我要获取用户信息,传递到自定义转发页面,如代码所示return写在then代码块里,得到的是一个默认转发,自定义内容无效?return部分若不写then中,提取到onShareAppMessage代码块底部又因为异步处理而得不到用户信息

展开全部
收起
2回答
提交回答
  • 至过去的我

    2044人对此回答表示赞同

    我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多>
    发布于
  • Noah

    11人对此回答表示赞同

    你只能提前获取你转发需要的东西,这里面不能异步,不会等你的。

    展开
    11
    0回复
    发布于 6年前

    评论(0)

    收起评论

  • 潘多拉

    11人对此回答表示赞同

    可以提前获取到放到data里面,然后从data里面去取

    展开
    11
    0回复
    发布于 6年前

    评论(0)

    收起评论

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
咨询热线

13312967497

扫码添加业务即可随时咨询 还可领取小程序推广攻略

业务咨询: 13312967497
扫码咨询

扫码咨询套餐

回到顶部