Created
October 8, 2017 17:58
-
-
Save gfelot/8e012d922c5b88a51e7310ff66998e0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template lang="html"> | |
<div class=""> | |
<navigation-drawer :gravatar="gravatar" @clicked="profileShow"/> | |
<h1 align="center" v-if="profile">Profile</h1> | |
<h1 align="center" v-else>Golf</h1> | |
</div> | |
</template> | |
<script> | |
import decode from 'jwt-decode' | |
import gravatar from 'gravatar' | |
import UserService from '@/services/UserService' | |
import navigationDrawer from '@/components/navigationDrawer' | |
export default { | |
data () { | |
return { | |
gravatar: '', | |
profile: true | |
} | |
}, | |
methods: { | |
profileShow (v) { | |
console.log(v) | |
this.profile = v | |
// console.log(this.profile) | |
} | |
}, | |
async mounted () { | |
const { token } = this.$store.state | |
const payload = decode(token) | |
const { userId } = payload | |
const userData = (await UserService.getInfo(userId, token)).data | |
this.$store.dispatch('setUser', userData) | |
const { email } = this.$store.state.user.email | |
const gravatarUrl = await gravatar.url(email, {protocol: 'https'}) | |
this.gravatar = `${gravatarUrl}?d=identicon` | |
// console.log(this.gravatar) | |
}, | |
components: { | |
navigationDrawer | |
} | |
} | |
</script> | |
<style scoped lang="css"> | |
h1 { | |
align: center; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment