2017-10-02 00:34:48 +00:00
|
|
|
<template>
|
2017-11-10 23:39:51 +00:00
|
|
|
<div class="user-image" :style="{backgroundImage: url}">
|
2017-10-02 00:34:48 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import googleHelper from '../services/providers/helpers/googleHelper';
|
|
|
|
|
|
|
|
const promised = {};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: ['userId'],
|
|
|
|
computed: {
|
|
|
|
url() {
|
|
|
|
const userInfo = this.$store.state.userInfo.itemMap[this.userId];
|
|
|
|
return userInfo && `url('${userInfo.imageUrl}')`;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
if (!promised[this.userId] && !this.$store.state.offline) {
|
|
|
|
promised[this.userId] = true;
|
|
|
|
googleHelper.getUser(this.userId)
|
|
|
|
.catch(() => {
|
|
|
|
promised[this.userId] = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.user-image {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
background-position: center;
|
|
|
|
background-size: contain;
|
|
|
|
}
|
|
|
|
</style>
|