uniapp如何获取微信和抖音小程序的用户图像及昵称?
网友回复
1、微信小程序之前的getuserprofile已经不能使用,微信官方的解释是:
现在只能使用新方案:
获取微信图像
<button type="balanced" open-type="chooseAvatar" @chooseavatar="onChooseavatar">点击获取图像</button>获取昵称
<input type="nickName" class="weui-input" :value="userName" @blur="bindblur" placeholder="请输入昵称" @input="bindinput" />
新的获取微信图像与昵称示例代码:
<template> <view class="containar"> <view class="avatarUrl"> <button type="balanced" open-type="chooseAvatar" @chooseavatar="onChooseavatar"> <image :src="avatarUrl" class="refreshIcon"></image> </button> </view> <view class="userName"> <text>昵称:</text> <input type="nickName" class="weui-input" :value="userName" @blur="bindblur" placeholder="请输入昵称" @input="bindinput" /> </view> <view class="btn"> <view class="btn-sub" @click="onSubmit">保存</view> </view> </view> </template> <script> export default { data() { return { avatarUrl: '', userName: '' }; }, onLoad(option) {}, methods: { bindblur(e) { this.userName = e.detail.value; // 获取微信昵称 }, bindinput(e) { this.userName = e.detail.value; // 获取微信昵称 }, onChooseavatar(e) { let self = this; let { avatarUrl ...
点击查看剩余70%
抖音小程序还可以使用getUserProfile
tt.getUserProfile({ success: (res) => { console.log('tt.getUserProfile success,获取的用户信息:', res); this.setData({ userI...
点击查看剩余70%