Blame view

apps/pages/userpage/author-follow.vue 1.36 KB
yyq authored
1 2
<template>
  <Layout class="author-follow-page">
yyq authored
3 4
    <LayoutHeader slot='header' theme="white" class="author-page-header">{{isMine ? '我' : 'TA'}}的关注</LayoutHeader>
    <UserList ref="userList" :on-fetch="onFetch"></UserList>
yyq authored
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  </Layout>
</template>

<script>
import {assign, get} from 'lodash';
import {Scroll, Loading} from 'cube-ui';
import UserList from './components/user-list';
import {createNamespacedHelpers} from 'vuex';
const {mapActions} = createNamespacedHelpers('user');

export default {
  name: 'authorFollow',
  data() {
    return {
      isMine: false
    };
  },
  created() {
    this._baseParams = {
      authorType: this.$route.params.type || 1,
      limit: 20,
    };
  },
yyq authored
28
  activated() {
yyq authored
29
    this.init(this.$route.params);
yyq authored
30 31 32
    this.$refs.userList.init();
  },
  beforeRouteUpdate(to, from, next) {
yyq authored
33
    this.init(to.params)
yyq authored
34 35 36
    this.$refs.userList.init();
    next();
  },
yyq authored
37 38
  methods: {
    ...mapActions(['authorAttentionList', 'authorMineAttentionList']),
yyq authored
39 40 41 42 43 44 45
    init(params) {
      this.isMine = !params.id;

      if (!this.isMine) {
        this._baseParams.authorUid = params.id;
      }
    },
yyq authored
46 47 48 49 50 51 52 53 54 55 56
    onFetch({page, lastedTime}) {
      let params = Object.assign({page, lastedTime}, this._baseParams);

      return this.isMine ? this.authorMineAttentionList(params) : this.authorAttentionList(params);
    }
  },
  components: {
    UserList
  }
}
</script>