|
|
<template>
|
|
|
<Layout class="author-page">
|
|
|
<LayoutHeader slot='header' theme="white">
|
|
|
<div ref="headerAuthor" class="header-author">
|
|
|
<div class="h-name flex">{{baseData.nickName}}</div>
|
|
|
<div class="h-more">
|
|
|
<div class="flex">
|
|
|
<WidgetAvatar v-if="baseData.headIco" class="h-headico" :src="baseData.headIco" :width="100" :height="100"></WidgetAvatar>
|
|
|
</div>
|
|
|
<div class="h-follow flex">
|
|
|
<WidgetFollow class="widget-follow" :author-uid="autherInfo.authorUid" :follow="isAttention" @on-follow="follow => onFollow(follow)"></WidgetFollow>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<template v-slot:opts>
|
|
|
<WidgetShare class="header-share"></WidgetShare>
|
|
|
</template>
|
|
|
</LayoutHeader>
|
|
|
<cube-sticky :pos="scrollY">
|
|
|
<cube-scroll
|
|
|
class="main-container"
|
|
|
:scroll-events="scrollEvents"
|
|
|
@scroll="scrollHandler">
|
|
|
<div ref="authorProfile" class="author-profile">
|
|
|
<span class="avatar-box">
|
|
|
<WidgetAvatar v-if="baseData.headIco" :src="baseData.headIco" :width="100" :height="100"></WidgetAvatar>
|
|
|
</span>
|
|
|
<div class="author-section">
|
|
|
<ul class="author-fans">
|
|
|
<li>
|
|
|
<span class="num">{{baseData.attCount}}</span>
|
|
|
<p class="name">
|
|
|
<span>关注</span>
|
|
|
</p>
|
|
|
</li>
|
|
|
<li>
|
|
|
<span class="num">{{baseData.fansCount}}</span>
|
|
|
<p class="name">
|
|
|
<span>粉丝</span>
|
|
|
</p>
|
|
|
</li>
|
|
|
<li>
|
|
|
<span class="num">{{baseData.praiseAndfavorite}}</span>
|
|
|
<p class="name">
|
|
|
<span>获赞与收藏</span>
|
|
|
</p>
|
|
|
</li>
|
|
|
</ul>
|
|
|
<div class="operate-wrap">
|
|
|
<label v-if="isOwner" class="operate-btn btn-user-edit">编辑个人资料</label>
|
|
|
<WidgetFollow v-else class="operate-btn" :author-uid="autherInfo.authorUid" :follow="isAttention" @on-follow="follow => onFollow(follow)"></WidgetFollow>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<p v-if="baseData.signature" class="author-desc">{{baseData.signature}}</p>
|
|
|
<cube-sticky-ele ele-key="11">
|
|
|
<FavTabBlock :tabs-num="tabsNum" :active-index="activeIndex" @change="changeTab"></FavTabBlock>
|
|
|
</cube-sticky-ele>
|
|
|
<div class="contant-list">
|
|
|
<WaterFall class="pannel-wrap" :list="list" :pos="scrollY"></WaterFall>
|
|
|
</div>
|
|
|
|
|
|
<div v-if="loadStatus" class="loading">
|
|
|
<Loading v-if="loadStatus === 1" class="load-icon" :size="20"></Loading>
|
|
|
<p v-else class="load-text">没有更多了</p>
|
|
|
</div>
|
|
|
</cube-scroll>
|
|
|
<template slot="fixed" slot-scope="props">
|
|
|
<FavTabBlock :tabs-num="tabsNum" :active-index="activeIndex" @change="changeTab"></FavTabBlock>
|
|
|
</template>
|
|
|
</cube-sticky>
|
|
|
</Layout>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import {assign, get} from 'lodash';
|
|
|
import {Scroll, Sticky, Loading} from 'cube-ui';
|
|
|
import CubeStickyEle from 'cube-ui/src/components/sticky/sticky-ele.vue';
|
|
|
import FavTabBlock from './components/fav-tab-block';
|
|
|
import WaterFall from './components/water-fall';
|
|
|
|
|
|
import {createNamespacedHelpers} from 'vuex';
|
|
|
const {mapActions} = createNamespacedHelpers('user');
|
|
|
|
|
|
export default {
|
|
|
name: 'userpage',
|
|
|
data() {
|
|
|
return {
|
|
|
autherInfo: {},
|
|
|
scrollEvents: ['scroll'],
|
|
|
scrollY: 0,
|
|
|
baseData: {},
|
|
|
isAttention: false,
|
|
|
isOwner: false,
|
|
|
tabsNum: [10, 0],
|
|
|
activeIndex: 0,
|
|
|
fetchInfo: {},
|
|
|
loadStatus: ''
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
this.autherInfo = {
|
|
|
authorUid: +this.$route.params.id,
|
|
|
authorType: this.$route.params.type
|
|
|
};
|
|
|
|
|
|
this.fetchBaseInfo();
|
|
|
this.fetchList();
|
|
|
},
|
|
|
mounted() {
|
|
|
let $dom = this.$refs.headerAuthor;
|
|
|
|
|
|
if ($dom.offsetHeight) {
|
|
|
this._animeDuration = 300;
|
|
|
import('animejs').then(({default: anime}) => {
|
|
|
this._animeEl = anime({
|
|
|
targets: $dom,
|
|
|
translateY: -$dom.offsetHeight,
|
|
|
easing: 'easeInOutSine',
|
|
|
duration: this._animeDuration,
|
|
|
autoplay: false
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
scrollY(top) {
|
|
|
let animePlayed = false;
|
|
|
|
|
|
if (top > this.$refs.authorProfile.offsetHeight) {
|
|
|
animePlayed = true;
|
|
|
}
|
|
|
|
|
|
if (!this._animePlayed === !animePlayed) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let start;
|
|
|
let self = this;
|
|
|
|
|
|
function step(timestamp) {
|
|
|
if (!start) {
|
|
|
start = timestamp
|
|
|
};
|
|
|
|
|
|
let progress = Math.floor(timestamp - start);
|
|
|
|
|
|
self._animeEl.seek(animePlayed ? progress : self._animeDuration - progress);
|
|
|
|
|
|
if (progress < self._animeDuration) {
|
|
|
window.requestAnimationFrame(step);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
window.requestAnimationFrame(step);
|
|
|
|
|
|
this._animePlayed = animePlayed;
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
list() {
|
|
|
return get(this.fetchInfo, `${this.activeIndex}.list`) || [];
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
...mapActions(['autherBaseInfo', 'autherAritcleNum', 'autherPubList', 'autherFavList']),
|
|
|
scrollHandler({ y }) {
|
|
|
this.scrollY = -y;
|
|
|
|
|
|
if (this.scrollY + 1000 > this.$el.offsetHeight) {
|
|
|
this._listTimer && clearTimeout(this._listTimer);
|
|
|
this._listTimer = setTimeout(() => {
|
|
|
this.fetchList();
|
|
|
}, 100);
|
|
|
}
|
|
|
},
|
|
|
changeTab(index) {
|
|
|
if (this.activeIndex !== index) {
|
|
|
this.activeIndex = index;
|
|
|
this.fetchList();
|
|
|
}
|
|
|
},
|
|
|
fetchBaseInfo() {
|
|
|
this.autherBaseInfo(this.autherInfo).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
this.baseData = res.data;
|
|
|
this.isOwner = res.data.isOwner;
|
|
|
this.isAttention = res.data.isAttention === 'Y';
|
|
|
}
|
|
|
});
|
|
|
|
|
|
this.autherAritcleNum(this.autherInfo).then(res => {
|
|
|
this.tabsNum = [get(res, 'data.articleCount'), get(res, 'data.favoriteCount')];
|
|
|
});
|
|
|
},
|
|
|
async fetchList() {
|
|
|
this.fetchInfo = this.fetchInfo || [];
|
|
|
|
|
|
if (this.syncing) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let info = this.fetchInfo[this.activeIndex] || {};
|
|
|
let result;
|
|
|
|
|
|
info.page = info.page || 1;
|
|
|
|
|
|
if (info.page >= info.totalPage) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let syncServiceName;
|
|
|
|
|
|
if (this.activeIndex === 1) {
|
|
|
syncServiceName = 'autherFavList';
|
|
|
} else {
|
|
|
syncServiceName = 'autherPubList';
|
|
|
}
|
|
|
|
|
|
if (this[syncServiceName]) {
|
|
|
this.syncing = true;
|
|
|
result = await this[syncServiceName](assign({
|
|
|
page: info.page,
|
|
|
lastedTime: info.lastedTime || ''
|
|
|
}, this.autherInfo));
|
|
|
this.syncing = false;
|
|
|
}
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
info.list = (info.list || []).concat(result.data.list);
|
|
|
info.page++;
|
|
|
info.totalPage = 10 || result.data.totalPage;
|
|
|
info.lastedTime = result.data.lastedTime;
|
|
|
}
|
|
|
|
|
|
if (info.page > info.totalPage) {
|
|
|
this.loadStatus = 2;
|
|
|
} else {
|
|
|
this.loadStatus = 1;
|
|
|
}
|
|
|
|
|
|
this.fetchInfo[this.activeIndex] = info;
|
|
|
|
|
|
this.fetchInfo = {...this.fetchInfo};
|
|
|
},
|
|
|
onFollow(follow) {
|
|
|
this.isAttention = follow;
|
|
|
}
|
|
|
},
|
|
|
components: {
|
|
|
CubeScroll: Scroll,
|
|
|
CubeSticky: Sticky,
|
|
|
CubeStickyEle,
|
|
|
Loading,
|
|
|
FavTabBlock,
|
|
|
WaterFall
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
.author-page {
|
|
|
box-sizing: border-box;
|
|
|
color: #4a4a4a;
|
|
|
}
|
|
|
|
|
|
.header-author {
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
position: relative;
|
|
|
|
|
|
.flex {
|
|
|
height: 100%;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
}
|
|
|
|
|
|
.h-name {
|
|
|
font-size: 36px;
|
|
|
font-weight: 500;
|
|
|
}
|
|
|
|
|
|
.h-more {
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
position: absolute;
|
|
|
top: 100%;
|
|
|
left: 0;
|
|
|
}
|
|
|
|
|
|
.h-headico {
|
|
|
width: 60px;
|
|
|
height: 60px;
|
|
|
}
|
|
|
|
|
|
.h-follow {
|
|
|
position: absolute;
|
|
|
top: 0;
|
|
|
right: -50px;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
.header-share {
|
|
|
margin-right: 26px;
|
|
|
color: #222;
|
|
|
font-weight: bold;
|
|
|
}
|
|
|
|
|
|
.author-profile {
|
|
|
padding: 24px 30px;
|
|
|
display: flex;
|
|
|
justify-content: space-between;
|
|
|
|
|
|
.avatar-box {
|
|
|
width: 150px;
|
|
|
height: 150px;
|
|
|
overflow: hidden;
|
|
|
border-radius: 50%;
|
|
|
|
|
|
> img {
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
display: block;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
.author-section {
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
justify-content: space-between;
|
|
|
}
|
|
|
|
|
|
.author-fans {
|
|
|
display: flex;
|
|
|
justify-content: flex-end;
|
|
|
padding-top: 4px;
|
|
|
padding-right: 54px;
|
|
|
|
|
|
li {
|
|
|
margin-left: 140px;
|
|
|
position: relative;
|
|
|
|
|
|
&:first-child {
|
|
|
margin-left: 0;
|
|
|
}
|
|
|
|
|
|
.num {
|
|
|
font-size: 28px;
|
|
|
font-weight: 500;
|
|
|
padding-bottom: 6px;
|
|
|
display: block;
|
|
|
}
|
|
|
|
|
|
.name {
|
|
|
position: absolute;
|
|
|
word-break: keep-all;
|
|
|
font-size: 20px;
|
|
|
font-weight: 300;
|
|
|
color: #9b9b9b;
|
|
|
margin-left: 50%;
|
|
|
|
|
|
> * {
|
|
|
position: relative;
|
|
|
left: -50%;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
.operate-wrap {
|
|
|
text-align: right;
|
|
|
|
|
|
.operate-btn {
|
|
|
width: calc(100% - 20px);
|
|
|
font-size: 23px;
|
|
|
line-height: 48px;
|
|
|
display: inline-block;
|
|
|
}
|
|
|
|
|
|
.btn-user-edit {
|
|
|
color: #222;
|
|
|
border: 1px solid #4a4a4a;
|
|
|
border-radius: 8px;
|
|
|
text-align: center;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
.author-desc {
|
|
|
margin: 20px 30px;
|
|
|
font-size: 24px;
|
|
|
font-weight: 300;
|
|
|
overflow: hidden;
|
|
|
text-overflow: ellipsis;
|
|
|
white-space: nowrap;
|
|
|
}
|
|
|
|
|
|
.loading {
|
|
|
padding: 20px 0;
|
|
|
|
|
|
.load-icon > span {
|
|
|
margin: auto;
|
|
|
}
|
|
|
|
|
|
.load-text {
|
|
|
text-align: center;
|
|
|
}
|
|
|
}
|
|
|
</style> |
...
|
...
|
|