| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- 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 })
- },
- },
- })
|