微信小程序获得微信头像和昵称
- 作者: admin
- 发布于 2019-01-03 09:43:04
- 来源:
- 栏目:解决方案
导语: { wx.getSetting({ success: res => { if (res.authSetting && res.authSetting['scope.userInfo']) { // 已经
{ wx.getSetting({ success: res => { if (res.authSetting && res.authSetting['scope.userInfo']) { // 已经授权,可以直接调用 getUserInfo 获取头像昵称 wx.getUserInfo({ success: function (data) { console.log(data.userInfo) // { // avatarUrl: '微信头像img文件path' // nickname: '微信昵称' // } } }) } else { this.showShouquan = true } } }) }
<template> <div> <van-dialog use-slot async-close :show="showShouquan" show-cancel-button confirm-button-open-type="getUserInfo" @close="cancelShouquan" @getuserinfo="getUserInfoFromWx"> <h4 class="wx-shouquan-title">微信授权</h4> <p class="wx-shouquan-content"> xxxxxxx小程序将获得您的微信头像、昵称等公开消息 </p> </van-dialog> <div> </template>
getUserInfoFromWx (e) { this.$store.state.user_userinfo = e.mp.detail.userInfo; this.showShouquan = false; }, cancelShouquan () { this.showShouquan = false; },
|
温馨提示:这篇文章没有解决您的问题?欢迎添加微信:18948083295,有微信小程序专业人员,保证有问必答。转载本站文章请注明转自http://www.okeydown.com/(微信小程序网)。