微信小程序获取用户信息nickname为“微信用户”

最近两天小程序用户登录获取到的用户微信名称都变成了"微信用户",在网上找到的问题原因是getUserProfile API被收回微信社区
在这里插入图片描述
头像昵称填写能力可以获取用户头像和昵称直接上代码,如果有更好的方案请留言!!!!!!!!

<template>
	<view>
		<button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
			<image class="avatar" :src="avatarUrl"></image>
		</button>
		<view class="petName">
			<view class="petName_name">昵称</view>
			<input type="nickname" v-model="nickname" class="weui-input" placeholder="请输入昵称" />
		</view>
		<view class="ensure" @click="ascertain">确定</view>
	</view>
</template>

<script>
	const defaultAvatarUrl =
		'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
	export default {
		data() {
			return {
				avatarUrl: defaultAvatarUrl,
				nickname:''
			}
		},
		methods: {
			onChooseAvatar(e) {
				console.log(e);
				const {
					avatarUrl
				} = e.detail
				this.avatarUrl=avatarUrl
			},
			ascertain(){
				uni.navigateBack({
					delta:1
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.avatar-wrapper{
		height: 300rpx;
		text-align: center;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.avatar{
		width: 100rpx;
		height: 100rpx;
	}
	.petName{
		padding: 0 20rpx;
		height: 100rpx;
		display: flex;
		align-items: center;
		.petName_name{
			width: 150rpx;
		}
	}
	.ensure{
		position: fixed;
		bottom: 0;
		width: 100%;
		height: 80rpx;
		background: #07C160;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>
  • 5
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值