|
@@ -29,12 +29,22 @@
|
|
|
<el-row>
|
|
<el-row>
|
|
|
<el-col :md="18">
|
|
<el-col :md="18">
|
|
|
<el-button
|
|
<el-button
|
|
|
|
|
+ v-if="userAvatar.followed"
|
|
|
type="danger"
|
|
type="danger"
|
|
|
size="mini"
|
|
size="mini"
|
|
|
- :icon="followButton.icon"
|
|
|
|
|
|
|
+ icon="el-icon-check"
|
|
|
|
|
+ @click="unfollowUser(userAvatar.userId)"
|
|
|
|
|
+ >
|
|
|
|
|
+ <span>已关注</span>
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ v-else
|
|
|
|
|
+ type="danger"
|
|
|
|
|
+ size="mini"
|
|
|
|
|
+ icon="el-icon-plus"
|
|
|
@click="followUser(userAvatar.userId)"
|
|
@click="followUser(userAvatar.userId)"
|
|
|
>
|
|
>
|
|
|
- <span>{{ followButton.text }}</span>
|
|
|
|
|
|
|
+ <span>关注</span>
|
|
|
</el-button>
|
|
</el-button>
|
|
|
<el-button
|
|
<el-button
|
|
|
type="danger"
|
|
type="danger"
|
|
@@ -52,7 +62,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-import { checkRelation, followUser, unfollowUser } from '@/api/user'
|
|
|
|
|
|
|
+import { followUser, unfollowUser } from '@/api/user'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: 'UserAvatarCard',
|
|
name: 'UserAvatarCard',
|
|
@@ -89,21 +99,18 @@ export default {
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
followUser(userId) {
|
|
followUser(userId) {
|
|
|
- if (this.followButton.text === '关注') {
|
|
|
|
|
- followUser(userId).then(resp => {
|
|
|
|
|
- if (resp.code === 0) {
|
|
|
|
|
- this.followButton.text = '已关注'
|
|
|
|
|
- this.followButton.icon = 'el-icon-check'
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- } else {
|
|
|
|
|
- unfollowUser(userId).then(resp => {
|
|
|
|
|
- if (resp.code === 0) {
|
|
|
|
|
- this.followButton.text = '关注'
|
|
|
|
|
- this.followButton.icon = 'el-icon-plus'
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ followUser(userId).then(resp => {
|
|
|
|
|
+ if (resp.code === 0) {
|
|
|
|
|
+ this.userAvatar.followed = true
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ unfollowUser(userId) {
|
|
|
|
|
+ unfollowUser(userId).then(resp => {
|
|
|
|
|
+ if (resp.code === 0) {
|
|
|
|
|
+ this.userAvatar.followed = false
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
sendMessage(userId) {
|
|
sendMessage(userId) {
|
|
|
this.$notify.info({
|
|
this.$notify.info({
|