uni-app微信小程序授权登录


 

微信小程序授权登入代码

 

<button class='bottom' type='primary' open-type="getUserInfo" withCredentials="true" lang="zh_CN" @click="getUserInfo">授权微信</button>

getUserInfo() {
    uni.getUserProfile({
        lang: 'zh_CN',
        desc: '登录',
        success: infoRes => {
            this.userInfo=infoRes.userInfo; //用户信息,微信头像,昵称等等
            uni.login({
                success(res){
                    console.log(res.code)  //获取到的code
                }
            })            
        },
        fail(res) {
            uni.showToast({
                title:'登录授权失败',
                icon:'none',
            })
        }
    });
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM