微信小程序获取用户openId、手机号

微信手机

1个回答

写回答

Whoyhuh

2026-01-15 01:17

+ 关注

微信
微信

view @click=getUserInfo获取微信信息/view // 获取用户信息 getUserInfo() { if(this.isShow){//防止多次点击 this.isShow = false uni.getUserProfile ({ desc: 获取个人信息, success: (res) = { this.userInfo = res.userInfo this.isShow = true }, fAIl: getUserProfileFAIl = { this.isShow = true uni.showToast({ title: '授权失败', mask: false, duration: 1000, icon: 'none', }) } }) } },

button type=default open-type=getPhoneNumber @getphonenumber=ongetPhoneNumber授权获取手机号登录/button // 获取手机号码 ongetPhoneNumber(e) { if (e.detAIl.errMsg == getPhoneNumber:fAIl user deny) { //用户拒绝授权 //拒绝授权后弹出一些提示 uni.showToast({ title: '拒绝授权', mask: false, duration: 1000, icon: 'none', }) } else { //允许授权 app.postData('url',{ key: app.globalData.session_key, encryptedData: e.detAIl.encryptedData, iv: e.detAIl.iv }).then(res={ console.log(获取手机号码,res) this.mobile = res.data.phoneNumber uni.setStorageSync('xmfTel',res.data.phoneNumber) }).catch(err={ console.log(err) }) } },

举报有用(0分享收藏

Copyright © 2025 IZhiDa.com All Rights Reserved.

知答 版权所有 粤ICP备2023042255号