@@ -75,22 +98,34 @@ import {mergeData} from 'common/js/common'
import axios from 'axios'
import {communicationMixin} from 'common/js/mixin.js'
export default {
+ props: {
+ otherUser: {
+ type: Object,
+ default() {
+ return {
+ info:{}
+ }
+ }
+ }
+ },
data() {
return {
listIndex: 0,
+ base: '../../../../static/avatar/60/',
fans: [],
- follows: [],
- base: '../../../../static/avatar/60/'
+ follows: []
}
},
methods: {
- initLink() {
- $('.sub-item').each((index,item)=> {
- $(item).on('click',(e)=> {
- $(item).addClass('is-active').siblings().removeClass('is-active')
- this.listIndex = index
- })
- })
+ enter(e) {
+ e.target.innerText = '取消关注'
+ },
+ leave(e) {
+ e.target.innerText = '已关注'
+ },
+ changeItem(e,index) {
+ $(e.target).addClass('is-active').siblings().removeClass('is-active')
+ this.listIndex = index
},
getFansList() {
axios.post('/follow/user/fans',{
@@ -107,9 +142,53 @@ import {communicationMixin} from 'common/js/mixin.js'
}).then((res)=> {
let users = res.data.result.users
let infos = res.data.result.infos
- this.follows = mergeData(users,infos)
+ this.follows = mergeData(users,infos)
})
},
+ followPeople(target_id,action,index,from) {
+ axios.post('/follow/followTarget',{
+ target_id: target_id,
+ action: action
+ }).then((res)=> {
+ if (res.data.status) {
+ alert(res.data.result.msg)
+ }
+
+ if (from==0) {
+ if (action==1) {
+ this.follows[index].flowerStatus = 1
+ }else {
+ this.follows[index].flowerStatus = 0
+ // 当在本人主页修改关注信息时
+ if (this.user._id == this.detail_user_id) {
+ // 当我取消关注了后我的关注列表要刷新,同时我的右侧关注数要减少
+ this.getFollowList()
+ // 粉丝列表状态没有同步,也需要刷新
+ this.getFansList()
+ communicationMixin.$emit('changeCount',0,0)
+ }
+ }
+ }else{
+ if (action==1) {
+ if (this.user._id == this.detail_user_id) {
+ this.fans[index].flowerStatus = 1
+ // 当我在我的粉丝列表中关注我的粉丝时
+ // 我的关注列表要刷新,同时我的右侧关注数要增加
+ this.getFollowList()
+ communicationMixin.$emit('changeCount',0,1)
+ }
+
+ }else {
+ this.fans[index].flowerStatus = 0
+ if (this.user._id == this.detail_user_id) {
+ // 当我取消关注我的粉丝时,我的关注列表要刷新,同时我的右侧关注数要减少
+ this.getFollowList()
+ communicationMixin.$emit('changeCount',0,0)
+ }
+ }
+ }
+ })
+ },
openList() {
communicationMixin.$on('openFollw',()=> {
this.listIndex = 0
@@ -119,11 +198,16 @@ import {communicationMixin} from 'common/js/mixin.js'
this.listIndex = 1
$('.sub-item').eq(1).addClass('is-active').siblings().removeClass('is-active')
})
+ communicationMixin.$on('reloadFollwer',()=> {
+ this.getFansList()
+ })
+ // 当改变用户时,因为缓存,也要刷新一次
+ communicationMixin.$emit('changeUser',()=> {
+ this.getFollowList()
+ this.getFansList()
+ })
}
},
- mounted() {
- this.initLink()
- },
created() {
this.openList()
this.getFollowList()
@@ -131,7 +215,8 @@ import {communicationMixin} from 'common/js/mixin.js'
},
computed: {
...mapGetters([
- 'detail_user_id'
+ 'detail_user_id',
+ 'user'
])
},
watch: {
diff --git a/src/pages/People/components/main-column.vue b/src/pages/People/components/main-column.vue
index f8c025b..b7db16d 100644
--- a/src/pages/People/components/main-column.vue
+++ b/src/pages/People/components/main-column.vue
@@ -4,21 +4,21 @@
+
@@ -36,6 +36,7 @@
diff --git a/src/pages/People/components/p-index.vue b/src/pages/People/components/p-index.vue
index 64c68a7..911021d 100644
--- a/src/pages/People/components/p-index.vue
+++ b/src/pages/People/components/p-index.vue
@@ -8,7 +8,7 @@
@changeFllowerStatus="changeFllowerStatus">
-
+
diff --git a/src/pages/People/components/scroll-header.vue b/src/pages/People/components/scroll-header.vue
index 5e62aad..96cbe3a 100644
--- a/src/pages/People/components/scroll-header.vue
+++ b/src/pages/People/components/scroll-header.vue
@@ -4,12 +4,12 @@