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>
|
2017-11-15 08:12:56 +00:00
|
|
|
import userSvc from '../services/userSvc';
|
2018-09-19 08:59:22 +00:00
|
|
|
import store from '../store';
|
2017-10-02 00:34:48 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
props: ['userId'],
|
|
|
|
computed: {
|
|
|
|
url() {
|
2018-09-19 08:59:22 +00:00
|
|
|
const userInfo = store.state.userInfo.itemsById[this.userId];
|
2017-11-15 08:12:56 +00:00
|
|
|
return userInfo && userInfo.imageUrl && `url('${userInfo.imageUrl}')`;
|
2017-10-02 00:34:48 +00:00
|
|
|
},
|
|
|
|
},
|
2018-09-19 08:59:22 +00:00
|
|
|
watch: {
|
|
|
|
userId: {
|
|
|
|
handler: userId => userSvc.getInfo(userId),
|
|
|
|
immediate: true,
|
|
|
|
},
|
|
|
|
},
|
2017-10-02 00:34:48 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.user-image {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
2017-11-26 20:58:24 +00:00
|
|
|
background-color: #fff;
|
2017-10-02 00:34:48 +00:00
|
|
|
background-repeat: no-repeat;
|
|
|
|
background-position: center;
|
|
|
|
background-size: contain;
|
|
|
|
}
|
|
|
|
</style>
|