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