当前位置:网站首页>uni-app微信小程序一键登录获取权限功能
uni-app微信小程序一键登录获取权限功能
2022-07-01 18:44:00 【黑白两客】
<button class="bottom size_30" type="primary" lang="zh_CN" @click="getUserInfo">
一键登录
</button>
//第一授权获取用户信息===》按钮触发
getUserInfo() {
// 展示加载框
uni.showLoading({
title: '加载中',
});
uni.getUserProfile({
desc: '登录后可同步数据',
success: async (obj) => {
uni.login({
provider: 'weixin',
success: (res) => {
uni.getUserInfo({
provider: 'weixin',
success: (info) => { //这里请求接口
const data = {
code: res.code,
userPhoto: info.userInfo.avatarUrl
}
addEditUser(data).then(res => {
if (res.code == 200) {
uni.setStorageSync('token', res
.data.token);
uni.setStorageSync(
'peopleInfo', res.data
.userEntity);
uni.reLaunch({ //信息更新成功后跳转到小程序首页
url: '/pages/home/index'
});
}
})
},
fail: () => {
uni.showToast({
title: "微信登录授权失败",
icon: "none"
});
}
})
},
});
},
fail: () => {
uni.showToast({
title: '授权已取消',
icon: 'error',
mask: true,
});
},
complete: () => {
// 隐藏loading
uni.hideLoading();
},
});
},

边栏推荐
- 原生js打造日程表-支持鼠标滚轮滚动选择月份-可以移植到任何框架中
- Appgallery connect scenario development practice - image storage and sharing
- Solidity - 合约结构 - 错误(error)- ^0.8.4版本新增
- 线程的并行、并发、生命周期
- 宝,运维100+服务器很头疼怎么办?用行云管家!
- [info() method in org.slf4j.logger]
- 论文阅读【Learning to Discretely Compose Reasoning Module Networks for Video Captioning】
- Les canaux de culture intensive s'efforcent de développer Fu Xin et Wei Shi jiajie pour organiser une conférence de formation sur les nouveaux produits
- Manufacturing SRM management system supplier all-round closed-loop management, to achieve procurement sourcing and process efficient collaboration
- Lake Shore continuous flow cryostat transmission line
猜你喜欢

精耕渠道共谋发展 福昕携手伟仕佳杰开展新产品培训大会

The market value evaporated by 74billion yuan, and the big man turned and entered the prefabricated vegetables

Chaos engineering platform chaosblade box new heavy release

微信公众号开发相关流程及功能介绍

Chinese and English instructions human soluble advanced glycation end products receptor (sRAGE) ELISA Kit

June issue | antdb database participated in the preparation of the "Database Development Research Report" and appeared on the list of information technology and entrepreneurship industries

Dlib+Opencv库实现疲劳检测

寶,運維100+服務器很頭疼怎麼辦?用行雲管家!

Cdga | if you are engaged in the communication industry, you should get a data management certificate

制造业SRM管理系统供应商全方位闭环管理,实现采购寻源与流程高效协同
随机推荐
Go Language Advanced
【pytorch记录】模型的分布式训练DataParallel、DistributedDataParallel
【org.slf4j.Logger中info()方法】
见证时代!“人玑协同 未来已来”2022弘玑生态伙伴大会开启直播预约
What must be done in graduation season before going to Shanhai
CDGA|从事通信行业,那你应该考个数据管理证书
Write it down once Net travel management background CPU Explosion Analysis
[English grammar] Unit1 articles, nouns, pronouns and numerals
Extensive reading of the paper [film: visual reasoning with a general condition layer]
Is PMP cancelled??
MFC中如何重绘CListCtrl的表头
[info() method in org.slf4j.logger]
Gameframework eating guide
云服务器ECS夏日省钱秘籍,这次@老用户快来领走
C-end dream is difficult to achieve. What does iFLYTEK rely on to support the goal of 1billion users?
论文阅读【Discriminative Latent Semantic Graph for Video Captioning】
Lake Shore—OptiMag 超导磁体系统 — OM 系列
【Go ~ 0到1 】 第五天 7月1 类型别名,自定义类型,接口,包与初始化函数
Redis 实现限流的三种方式
English grammar_ Adjective / adverb Level 3 - precautions