微信小程序-获取用户信息和openid,session_key

发布于:2021-06-27 15:55:48

微信小程序-获取用户信息和openid,session_key, 1:微信小程序获取用户信息:比如常用的 avatarUrl (用户头像),nickName (用户名称) 等等, (1):获取用户信息调用 wx.getUserInfo 代码如下:

  onLoad() {


        const self=this;
        wx.login({
            success:function(res){
                if(res.code){
                    wx.request({
                        url:'https://api.weixin.qq.com/sns/jscode2session',
                        data:{
                            js_code:res.code,
                            appid:'wx4e52e409d4eb6f55',
                            secret:'f974a38467b9c1b0c2839eb21b9ad0ea',
                            grant_type:'authorization_code'
                        },
                        success:function(res){
                            self.userId=res.data;
                        }
                    })
                }else{
                    console.log('获取用户登录失败!'+res.errMsg)
                }
            },
            fail:function(res){
                    console.log('登录失败!'+res.errMsg)
            }
        })
        

    },


https://www.cnblogs.com/hjpqwer/p/9784692.html

阅读 109+

一片空白

父爱如山,不善表达。回想十多年前,总记得父亲有个宽厚的肩膀,小小的自己跨坐在上面,越过人山人海去看更广阔的天空,那个时候期望自己有一双翅膀,能够像鸟儿一样飞得高,看得远。虽然父亲有时会和自己开玩笑,但在做错事的时候会受到严厉的训斥。父亲有双粗糙的大手掌。