个人消息

This commit is contained in:
limqhz
2022-12-14 19:58:38 +08:00
parent 574e7c8ac1
commit b746aaaa83
7 changed files with 53 additions and 2 deletions

View File

@@ -0,0 +1,22 @@
Page({
data: {
hasUserAttar: false,
userInfo: {},
},
fetchWXAttar(){
wx.getUserProfile({
desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
console.log(res)
this.setData({
userInfo: res.userInfo,
hasUserAttar: true
})
},
fail: (e) => {
console.log(e);
}
})
}
});

View File

@@ -0,0 +1,4 @@
{
"usingComponents": {
}
}

View File

@@ -0,0 +1,12 @@
<t-cell wx:if="{{hasUserAttar}}" title="{{userInfo.nickName}}">
<view class="avatar" slot="left-icon">
<open-data type="userAvatarUrl" />
</view>
</t-cell>
<t-cell wx:else title="{{'用户名'}}" description="点击授权头像信息" bind:tap="fetchWXAttar">
<view class="avatar" slot="left-icon">
<open-data type="userAvatarUrl" />
</view>
</t-cell>
<t-cell title="昵称" description="{{'浙A88FU7'}}" />
<t-cell title="邮箱" description="{{'540344226@qq.com'}}" />

View File

@@ -0,0 +1,6 @@
.avatar {
width: 200rpx;
height: 200rpx;
border-radius: 50%;
overflow: hidden;
}

View File

@@ -26,6 +26,12 @@ Page({
})
},
viewMyAccount(){
wx.navigateTo({
url: '/pages/myself/account/index'
});
},
viewMyMessage(){
wx.navigateTo({
url: '/pages/myself/notify/index'

View File

@@ -9,7 +9,7 @@
<open-data type="userAvatarUrl" />
</view>
</t-cell>
<t-cell title="个人信息" hover arrow />
<t-cell title="个人信息" hover arrow bind:tap="viewMyAccount"/>
<t-cell title="我的消息" hover arrow bind:tap="viewMyMessage"/>
<t-cell title="常见问题" hover arrow bind:tap="viewQuestion"/>
<t-cell title="关于我们" hover arrow bind:tap="viewAboutUs"/>