<button @click="login" type="default" open-type="getUserInfo">登录</button>
login() {
var that = this
uni.getUserProfile({
desc:"weixin", // 指明用途,这个参数是必须的
success:function(res){
console.log(res)
uni.login({
success: async (res) => {
console.log("----------", res);
uni.request({
url: http +`请求地址${res.code}`,
success(res) {
console.log(11, res.data.data.openid)
}
})
},
})
}
})
},
uniapp小程序登录
最新推荐文章于 2024-09-23 14:41:22 发布
该博客详细介绍了如何使用微信小程序的`uni.getUserProfile`和`uni.login`接口获取用户信息并进行登录操作。首先,通过点击按钮触发登录函数,然后调用`uni.getUserProfile`获取用户基本信息,接着利用`uni.login`获取登录code,最后将code发送到后台服务器换取openid。
摘要由CSDN通过智能技术生成