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代码块底部又因为异步处理而得不到用户信息