1、效果展示
2、关键代码
.wxml布局文件代码
.js逻辑文件代码
Page({data: {nickName:'',userInfoAvatar:'',sex:'',province:'',city:''}, onLoad: function () {var that=this; wx.getUserInfo({success: function(res){// successthat.setData({nickName:res.userInfo.nickName,userInfoAvatar:res.userInfo.avatarUrl,province:res.userInfo.province,city:res.userInfo.city})switch(res.userInfo.gender){case 0: that.setData({sex:'未知'})break;case 1: that.setData({sex:'男'})break;case 2: that.setData({sex:'女'})break;}},fail: function() {// failconsole.log("获取失败!")},complete: function() {// completeconsole.log("获取用户信息完成!")}})}})
3、源代码获取方式
百度云链接:/s/1jHGP1Vw
4、在获取用户登录信息过程中有遇到任何问题或者不明白的地方,可以添加我的微信进行咨询,感谢支持!微信号:FutureJet
5、觉得不错请打赏,您的十分满意是笔者的无限动力。