?根據(jù)業(yè)務(wù)不同分別調(diào)用不用的api
例:weixin
1.使用獲取小程序用戶(hù)code。uni.loagin。
2.獲取用戶(hù)詳情。getUserInfo。
3.檢查用戶(hù)key是否過(guò)期,如果過(guò)期需要調(diào)用login獲取。uni.checkSession。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-508631.html
4.獲取用戶(hù)手機(jī)號(hào)api,需要指定一個(gè)button標(biāo)簽 具體看下面。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-508631.html
// 獲取code
uni.login({
provider: 'weixin',
success:res=>{
console.log(res.code);
}
});
// 獲取info
uni.getUserInfo({
provider: 'weixin',
success(res) {
console.log(res,'用戶(hù)詳情===========================')
}
})
// 檢查過(guò)期
uni.checkSession({
success: (res) => {
console.log(res)
}
})
// 獲取手機(jī)號(hào)
getPhoneNumber(e){
// 獲取用戶(hù)手機(jī)號(hào)所需的接口參數(shù)
console.log(e)
console.log(e.detail.errMsg) //判斷用戶(hù)是否允許獲取手機(jī)號(hào)
console.log(e.detail.iv) // 參數(shù) iv
console.log(e.detail.encryptedData) // 參數(shù)encryptedData
}
//獲取手機(jī)號(hào)
<button type="default" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">獲取手機(jī)號(hào)</button>
到了這里,關(guān)于uniapp 小程序登錄(獲取code && 手機(jī)號(hào))的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!