...
|
...
|
@@ -2,7 +2,10 @@ |
|
|
<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-name flex">
|
|
|
<span class="h-name-b">{{baseData.nickName}}</span>
|
|
|
<span v-if="baseData.sex" class="iconfont icon-women author-sex-icon" :class="`icon-${baseData.sex}`"></span>
|
|
|
</div>
|
|
|
<div class="h-more">
|
|
|
<div class="flex">
|
|
|
<WidgetAvatar v-if="baseData.headIco" class="h-headico" :src="baseData.headIco" :width="100" :height="100"></WidgetAvatar>
|
...
|
...
|
@@ -13,45 +16,45 @@ |
|
|
</div>
|
|
|
</div>
|
|
|
</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 v-for="(item, key) in fansList" :key="key">
|
|
|
<span class="num">{{baseData[key] || 0}}</span>
|
|
|
<p class="name"><span>{{item}}</span></p>
|
|
|
</li>
|
|
|
</ul>
|
|
|
<div class="operate-wrap">
|
|
|
<a v-if="isOwner" class="operate-btn btn-user-edit" href="//m.yohobuy.com/home/mydetails?openby:yohobuy={'action':'go.mineinfo'}">编辑个人资料</a>
|
|
|
<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" :query="linkQueryString"></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 class="fixed-tab">
|
|
|
<FavTabBlock v-if="tabFixed" :tabs-num="tabsNum" :active-index="activeIndex" @change="changeTab"></FavTabBlock>
|
|
|
</div>
|
|
|
|
|
|
<cube-scroll
|
|
|
class="main-container"
|
|
|
ref="scroll"
|
|
|
:scroll-events="['scroll', 'scroll-end']"
|
|
|
@scroll="onScrollHandle"
|
|
|
@scroll-end="onScrollEndHandle">
|
|
|
<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 v-for="(item, key) in fansList" :key="key">
|
|
|
<span class="num">{{baseData[key] || 0}}</span>
|
|
|
<p class="name"><span>{{item}}</span></p>
|
|
|
</li>
|
|
|
</ul>
|
|
|
<div class="operate-wrap">
|
|
|
<router-link v-if="isOwner" class="operate-btn btn-user-edit" :to="mineInfoUrl">编辑个人资料</router-link>
|
|
|
<WidgetFollow v-else class="operate-btn" :author-uid="autherInfo.authorUid" :follow="isAttention" @on-follow="follow => onFollow(follow)"></WidgetFollow>
|
|
|
</div>
|
|
|
</cube-scroll>
|
|
|
<template slot="fixed" slot-scope="props">
|
|
|
<FavTabBlock :tabs-num="tabsNum" :active-index="activeIndex" @change="changeTab"></FavTabBlock>
|
|
|
</template>
|
|
|
</cube-sticky>
|
|
|
</div>
|
|
|
</div>
|
|
|
<p v-if="baseData.signature" class="author-desc">{{baseData.signature}}</p>
|
|
|
<FavTabBlock :tabs-num="tabsNum" :active-index="activeIndex" @change="changeTab"></FavTabBlock>
|
|
|
<div ref="contantList" class="contant-list">
|
|
|
<WaterFall class="pannel-wrap" :list="list" :query="linkQueryString"></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>
|
|
|
</Layout>
|
|
|
</template>
|
|
|
|
...
|
...
|
@@ -60,7 +63,7 @@ |
|
|
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 WaterFall from './components/scroll-reveal';
|
|
|
|
|
|
import {createNamespacedHelpers} from 'vuex';
|
|
|
const {mapActions} = createNamespacedHelpers('user');
|
...
|
...
|
@@ -69,9 +72,9 @@ |
|
|
name: 'userpage',
|
|
|
data() {
|
|
|
return {
|
|
|
autherInfo: {},
|
|
|
scrollEvents: ['scroll'],
|
|
|
scrollY: 0,
|
|
|
mineInfoUrl: '//m.yohobuy.com/home/mydetails?openby:yohobuy={"action":"go.mineinfo"}',
|
|
|
autherInfo: {},
|
|
|
fansList: {
|
|
|
attCount: '关注',
|
|
|
fansCount: '粉丝',
|
...
|
...
|
@@ -80,6 +83,7 @@ |
|
|
baseData: {},
|
|
|
isAttention: false,
|
|
|
isOwner: false,
|
|
|
tabFixed: false,
|
|
|
tabsNum: [0, 0],
|
|
|
activeIndex: 0,
|
|
|
fetchInfo: {},
|
...
|
...
|
@@ -89,20 +93,6 @@ |
|
|
mounted() {
|
|
|
let $dom = this.$refs.headerAuthor;
|
|
|
|
|
|
if (!this.$route.params.id) {
|
|
|
try {
|
|
|
this.$sdk.getUser().then(res => {
|
|
|
if (get(res, 'uid') > 0) {
|
|
|
this.init({id: res.uid})
|
|
|
} else {
|
|
|
this.$sdk.goLogin();
|
|
|
}
|
|
|
});
|
|
|
} catch(e){
|
|
|
console.log(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ($dom.offsetHeight) {
|
|
|
this._animeDuration = 300;
|
|
|
import('animejs').then(({default: anime}) => {
|
...
|
...
|
@@ -117,23 +107,66 @@ |
|
|
}
|
|
|
},
|
|
|
activated() {
|
|
|
console.log('activated');
|
|
|
if (this.$route.params.id !== this.autherInfo.authorUid) {
|
|
|
if (this.$route.params.id && this.$route.params.id !== this.autherInfo.authorUid) {
|
|
|
this.init(this.$route.params);
|
|
|
}
|
|
|
},
|
|
|
beforeRouteUpdate(to, from, next) {
|
|
|
console.log('beforeRouteUpdate');
|
|
|
if (this.$route.params.id !== to.params.labelId) {
|
|
|
if (this.$route.params.id !== to.params.authorUid) {
|
|
|
this.init(to.params);
|
|
|
}
|
|
|
next();
|
|
|
},
|
|
|
watch: {
|
|
|
scrollY(top) {
|
|
|
computed: {
|
|
|
list() {
|
|
|
return get(this.fetchInfo, `${this.activeIndex}.list`) || [];
|
|
|
},
|
|
|
linkQueryString() {
|
|
|
return assign({}, this.autherInfo, {
|
|
|
type: ['publish', 'fav'][this.activeIndex]
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
...mapActions(['autherBaseInfo', 'autherAritcleNum', 'autherPubList', 'autherFavList', 'autherMineBaseInfo', 'autherMineAritcleNum', 'autherMinePubList', 'autherMineFavList']),
|
|
|
init(params) {
|
|
|
params = params || {};
|
|
|
|
|
|
this._apiNamePre = 'auther';
|
|
|
this.isOwner = !params.id;
|
|
|
this.tabFixed = false;
|
|
|
this.tabsNum = [0, 0];
|
|
|
this.activeIndex = 0;
|
|
|
this.fetchInfo = {};
|
|
|
|
|
|
if (!params.id) {
|
|
|
this._apiNamePre += 'Mine';
|
|
|
|
|
|
try {
|
|
|
this.$sdk.getUser().then(res => {
|
|
|
if (get(res, 'uid') > 0) {
|
|
|
this.fetchData(res.uid, 1);
|
|
|
} else {
|
|
|
this.$sdk.goLogin();
|
|
|
}
|
|
|
});
|
|
|
} catch(e){
|
|
|
console.log(e);
|
|
|
}
|
|
|
} else {
|
|
|
this.fetchData(params.id, params.type || 1);
|
|
|
}
|
|
|
},
|
|
|
fetchData(authorUid, authorType) {
|
|
|
this.autherInfo = {authorUid, authorType};
|
|
|
this.fetchBaseInfo();
|
|
|
this.fetchList();
|
|
|
},
|
|
|
onScrollHandle({y}) {
|
|
|
this.scrollY = -y;
|
|
|
let animePlayed = false;
|
|
|
|
|
|
if (top > this.$refs.authorProfile.offsetHeight) {
|
|
|
if (this.scrollY > this.$refs.authorProfile.offsetHeight) {
|
|
|
animePlayed = true;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -141,6 +174,8 @@ |
|
|
return;
|
|
|
}
|
|
|
|
|
|
this.tabFixed = animePlayed;
|
|
|
|
|
|
let start;
|
|
|
let self = this;
|
|
|
|
...
|
...
|
@@ -161,60 +196,33 @@ |
|
|
window.requestAnimationFrame(step);
|
|
|
|
|
|
this._animePlayed = animePlayed;
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
list() {
|
|
|
return get(this.fetchInfo, `${this.activeIndex}.list`) || [];
|
|
|
},
|
|
|
linkQueryString() {
|
|
|
return assign({}, this.autherInfo, {
|
|
|
type: ['publish', 'fav'][this.activeIndex]
|
|
|
})
|
|
|
},
|
|
|
linkTpl() {
|
|
|
return `/grass/article/{articleId}?authorUid=${this.autherInfo.authorUid}&authorType=${this.autherInfo.authorType}&type=${['publish', 'fav'][this.activeIndex]}`;
|
|
|
},
|
|
|
waterFallType() {
|
|
|
return ['publish', 'fav'][this.activeIndex];
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
...mapActions(['autherBaseInfo', 'autherAritcleNum', 'autherPubList', 'autherFavList', 'autherMineBaseInfo', 'autherMineAritcleNum', 'autherMinePubList', 'autherMineFavList']),
|
|
|
init(params) {
|
|
|
params = params || {};
|
|
|
|
|
|
this._apiNamePre = 'auther';
|
|
|
if (!params.id) {
|
|
|
this._apiNamePre += 'Mine';
|
|
|
}
|
|
|
|
|
|
this.autherInfo = {
|
|
|
authorUid: params.id,
|
|
|
authorType: params.type || 1
|
|
|
};
|
|
|
|
|
|
if (!params.id) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
this.fetchBaseInfo();
|
|
|
this.fetchList();
|
|
|
},
|
|
|
scrollHandler({ y }) {
|
|
|
this.scrollY = -y;
|
|
|
|
|
|
if (this.scrollY + 1000 > this.$el.offsetHeight) {
|
|
|
onScrollEndHandle(scroll) {
|
|
|
if (1000 - scroll.y > this.$refs.contantList.offsetHeight) {
|
|
|
this._listTimer && clearTimeout(this._listTimer);
|
|
|
this._listTimer = setTimeout(() => {
|
|
|
this.fetchList();
|
|
|
}, 100);
|
|
|
}, 50);
|
|
|
}
|
|
|
},
|
|
|
changeTab(index) {
|
|
|
if (this.activeIndex !== index) {
|
|
|
this.activeIndex = index;
|
|
|
|
|
|
let info = this.fetchInfo[index] || {};
|
|
|
|
|
|
info.page = 1;
|
|
|
info.lastedTime = '';
|
|
|
|
|
|
this.fetchList();
|
|
|
|
|
|
let top = this.$refs.authorProfile.offsetHeight;
|
|
|
|
|
|
if (this.scrollY > top) {
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.scroll.scrollTo(0, -top, 0);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
fetchBaseInfo() {
|
...
|
...
|
@@ -243,6 +251,7 @@ |
|
|
info.page = info.page || 1;
|
|
|
|
|
|
if (info.page > info.totalPage) {
|
|
|
this.loadStatus = 2;
|
|
|
return;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -257,6 +266,7 @@ |
|
|
if (this[syncServiceName]) {
|
|
|
this.syncing = true;
|
|
|
result = await this[syncServiceName](assign({
|
|
|
limit: 20,
|
|
|
page: info.page,
|
|
|
lastedTime: info.lastedTime || ''
|
|
|
}, this.autherInfo));
|
...
|
...
|
@@ -264,6 +274,10 @@ |
|
|
}
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
if (info.page === 1) {
|
|
|
info.list = [];
|
|
|
}
|
|
|
|
|
|
info.list = (info.list || []).concat(result.data.list || []);
|
|
|
info.page++;
|
|
|
info.totalPage = result.data.totalPage;
|
...
|
...
|
@@ -279,10 +293,13 @@ |
|
|
} else {
|
|
|
this.loadStatus = 1;
|
|
|
}
|
|
|
|
|
|
this.fetchInfo[this.activeIndex] = info;
|
|
|
|
|
|
this.fetchInfo = {...this.fetchInfo};
|
|
|
|
|
|
setTimeout(() => {
|
|
|
this.$refs.scroll.refresh();
|
|
|
}, 100);
|
|
|
},
|
|
|
goUserInfoEdit() {
|
|
|
if (this.$yoho.isYohoBuy) {
|
...
|
...
|
@@ -311,6 +328,12 @@ |
|
|
color: #4a4a4a;
|
|
|
}
|
|
|
|
|
|
.fixed-tab {
|
|
|
width: 100%;
|
|
|
position: absolute;
|
|
|
z-index: 2;
|
|
|
}
|
|
|
|
|
|
.header-author {
|
|
|
position: absolute;
|
|
|
left: 0;
|
...
|
...
|
@@ -328,6 +351,28 @@ |
|
|
.h-name {
|
|
|
font-size: 36px;
|
|
|
font-weight: 500;
|
|
|
|
|
|
.h-name-b {
|
|
|
max-width: 60%;
|
|
|
overflow: hidden;
|
|
|
text-overflow: ellipsis;
|
|
|
white-space: nowrap;
|
|
|
display: inline-block;
|
|
|
}
|
|
|
|
|
|
.author-sex-icon {
|
|
|
font-size: 28px;
|
|
|
padding-left: 10px;
|
|
|
padding-right: 0;
|
|
|
}
|
|
|
|
|
|
.icon-man {
|
|
|
color: #96d8f3;
|
|
|
}
|
|
|
|
|
|
.icon-women {
|
|
|
color: #f7c3e1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
.h-more {
|
...
|
...
|
@@ -361,6 +406,7 @@ |
|
|
padding: 24px 30px;
|
|
|
display: flex;
|
|
|
justify-content: space-between;
|
|
|
overflow: hidden;
|
|
|
|
|
|
.avatar-box {
|
|
|
width: 150px;
|
...
|
...
|
@@ -425,9 +471,11 @@ |
|
|
|
|
|
.operate-btn {
|
|
|
width: calc(100% - 20px);
|
|
|
height: 50px;
|
|
|
font-size: 23px;
|
|
|
line-height: 48px;
|
|
|
line-height: 50px;
|
|
|
display: inline-block;
|
|
|
box-sizing: border-box;
|
|
|
}
|
|
|
|
|
|
.btn-user-edit {
|
...
|
...
|
|