最近两天小程序用户登录获取到的用户微信名称都变成了"微信用户",在网上找到的问题原因是getUserProfile API被收回微信社区
头像昵称填写能力可以获取用户头像和昵称直接上代码,如果有更好的方案请留言!!!!!!!!文章来源地址https://www.toymoban.com/news/detail-521781.html
<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>
文章来源:https://www.toymoban.com/news/detail-521781.html
到了这里,关于微信小程序获取用户信息nickname为“微信用户”的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!