import { getNavBarLayout } from '../../utils/nav-bar' Component({ properties: { nickname: { type: String, value: '未登录', }, avatar: { type: String, value: '', }, loggedIn: { type: Boolean, value: false, }, loggingIn: { type: Boolean, value: false, }, }, data: { headerPaddingTop: 64, avatarFailed: false, }, observers: { avatar() { this.setData({ avatarFailed: false }) }, }, lifetimes: { attached() { const { statusBarHeight, navHeight } = getNavBarLayout() this.setData({ headerPaddingTop: statusBarHeight + navHeight, }) }, }, methods: { onLoginTap() { if (!this.data.loggingIn) { this.triggerEvent(this.data.loggedIn ? 'editprofile' : 'login') } }, onNicknameTap() { if (this.data.loggedIn && !this.data.loggingIn) { this.triggerEvent('editprofile') } }, onAvatarError() { this.setData({ avatarFailed: true }) }, }, })