我的wxml是:<button wx:else bindtap="GetUserInfo" >授权登录</button>
js:GetUserInfo: function (e) {
wx.getUserProfile({
desc: '正在获取', //不写不弹提示框
success: function (res) {
console.log("获取成功:", res)
},
fail: function (err) {
console.log("获取失败: ", err)
}
})
}
我这里只能在控制台下看到用户信息,希望哪位大神帮忙上一下代码把我的用户信息上传到云数据库!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
在success中发起请求,存入你想要放的地方
let userInfo = ev.detail.userInfo;
if (!this.data.logged && userInfo){
db.collection('users').add({
data:{
userPhoto:userInfo.avatarUrl,
nickName:userInfo.nickName,
signature:'',
phoneNumber:'',
weixinNumber:'',
links:0,
time: new Date()
}
}).then((res)=>{
console.log(res);
});
}
}
})
求!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!