nebula/components/common/user/list.vue

82 lines
2.6 KiB
Vue
Raw Normal View History

2020-10-25 01:40:24 +08:00
<template>
<div class="wrapper">
2021-08-24 22:34:23 +08:00
<el-row :gutter="20">
2022-07-25 06:45:33 +08:00
<el-col :span="8" v-for="user in users.list" :key="user.idUser" style="margin-bottom: 1rem;">
2021-08-24 22:34:23 +08:00
<el-card shadow="always" :body-style="{textAlign: 'center', paddingBottom: '20'}">
<el-col :span="24">
<el-link target="_blank" :href="'/user/' + user.account" class="text-default" :underline="false">
<el-avatar :src="user.avatarUrl" style="width: 50px;height: 50px;"></el-avatar>
2020-10-25 01:40:24 +08:00
</el-link>
2021-08-24 22:34:23 +08:00
</el-col>
<el-col :span="24">
<el-link target="_blank" :href="'/user/' + user.account" class="text-default">
<span style="font-size: 20px;font-weight: bold;">{{ user.nickname }}</span>
</el-link>
</el-col>
<el-col :span="24" style="padding: 1rem 0;">
<small class="d-block text-muted" v-if="user.signature" v-html="user.signature"></small>
<small class="d-block text-muted" v-else>还没有介绍自己</small>
</el-col>
<el-col :span="24" style="padding: 2rem 0;">
<template v-if="!(userInfo && userInfo.idUser === user.idUser)">
2021-08-24 22:34:23 +08:00
<el-button v-if="isFollower(user.idUser)" size="medium" round @click="cancelFollowUser2(user.idUser)">取消关注</el-button>
<el-button v-else size="medium" round @click="followUser2(user.idUser)">关注</el-button>
</template>
</el-col>
</el-card>
2020-10-25 01:40:24 +08:00
</el-col>
<el-col v-show="!users" class="text-center">
这里什么都没有!
</el-col>
<el-col>
<div class="vertical-container text-center">
2022-07-25 06:45:33 +08:00
<el-pagination :hide-on-single-page="true"
2020-10-25 01:40:24 +08:00
layout="prev, pager, next"
2022-07-25 06:45:33 +08:00
:current-page="users.pageNum"
:total="users.total"
2020-10-25 01:40:24 +08:00
@current-change="currentChange">
</el-pagination>
</div>
</el-col>
</el-row>
</div>
</template>
<script>
2021-08-24 22:34:23 +08:00
import {mapState} from 'vuex';
2020-10-25 01:40:24 +08:00
export default {
name: "UserList",
2021-08-24 22:34:23 +08:00
computed: {
...mapState({
userInfo: state => state.oauth
})
},
2020-10-25 01:40:24 +08:00
props: {
users: Object
},
methods: {
onRouter(data) {
this.$router.push({
path: `/user/${data}`
})
},
currentChange(page) {
this.$emit('currentChange', page);
2021-08-24 22:34:23 +08:00
},
followUser2(idUser) {
this.$emit('followUser', idUser);
},
cancelFollowUser2(idUser) {
this.$emit('cancelFollowUser', idUser);
},
isFollower(idUser) {
return this.$store.getters["follow/isFollower"](idUser)
2020-10-25 01:40:24 +08:00
}
}
}
</script>
<style scoped>
</style>