最近兩天小程序用戶登錄獲取到的用戶微信名稱都變成了"微信用戶",在網(wǎng)上找到的問題原因是getUserProfile API被收回微信社區(qū)
頭像昵稱填寫能力可以獲取用戶頭像和昵稱直接上代碼,如果有更好的方案請留言?。。。。。。。?span toymoban-style="hidden">文章來源地址http://www.zghlxwxcb.cn/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>
文章來源:http://www.zghlxwxcb.cn/news/detail-521781.html
到了這里,關(guān)于微信小程序獲取用戶信息nickname為“微信用戶”的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!