Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

Commit

Permalink
feat: 增加我的页面 收藏的动态, 我的投稿
Browse files Browse the repository at this point in the history
  • Loading branch information
boxshadow committed Apr 28, 2018
1 parent 30c74be commit bd74a1f
Show file tree
Hide file tree
Showing 11 changed files with 392 additions and 16 deletions.
17 changes: 17 additions & 0 deletions src/api/news.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { get } from "./api.js";
const uri = "/user/news/contributes";
/**
* 获取当前用户投稿列表
* @Author Wayne
* @DateTime 2018-04-28
* @Email [email protected]
* @param {Number} type [类型: 0: 已发布, 1: 待审核, 2: 已驳回]
* @return [Promise]
*/
export function getMyNews({ type = 0, limit = 15, after = 0 }) {
return get(uri, {
type,
limit,
after
});
}
6 changes: 5 additions & 1 deletion src/components/FeedCard/FeedCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</article>
</section>
</div>
<footer class="m-box-model m-card-foot m-bt1">
<footer v-if="showFooter" class="m-box-model m-card-foot m-bt1">
<div class="m-box m-aln-center m-card-tools m-lim-width">
<a class="m-box m-aln-center" @click.prevent="handleLike">
<svg class='m-style-svg m-svg-def'>
Expand Down Expand Up @@ -102,6 +102,10 @@ export default {
},
feed: {
required: true
},
showFooter: {
type: Boolean,
default: true
}
},
computed: {
Expand Down
8 changes: 6 additions & 2 deletions src/page/article/ArticleCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<main class="m-lim-width m-box-model m-art-card-main mt90">
<slot></slot>
</main>
<footer ref="foot" class="m-pos-f m-box m-aln-center m-justify-aro m-bt1 m-art-card-foot">
<footer v-if="canOprate" ref="foot" class="m-pos-f m-box m-aln-center m-justify-aro m-bt1 m-art-card-foot">
<slot name='foot'>
<a class="m-box-model m-aln-center" @click.prevent="handelLike">
<svg class='m-style-svg m-svg-def'>
Expand Down Expand Up @@ -70,6 +70,10 @@ export default {
liked: {
type: Boolean,
default: false
},
canOprate: {
type: Boolean,
default: true
}
},
methods: {
Expand Down Expand Up @@ -114,7 +118,7 @@ export default {
}
});
this.headroom.init();
this.footroom.init();
this.canOprate && this.footroom.init();
}
};
</script>
7 changes: 5 additions & 2 deletions src/page/news/newsDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<article-card
:liked="liked"
:loading="loading"
:canOprate="news.audit_status===0"
@on-like="likeNews"
@on-share="shareNews"
@on-more="moreAction"
Expand All @@ -19,7 +20,7 @@
<div class="m-art-body" v-html='body'></div>
<div class="m-box m-aln-center m-justify-bet m-art-foot">
<div class="m-flex-grow1 m-flex-shrink1 m-box m-aln-center m-art-like-list">
<template v-if='likeCount > 0'>
<template v-if='likeCount > 0 && audit_status===0'>
<ul class="m-box m-flex-grow0 m-flex-shrink0">
<li
:key="id"
Expand Down Expand Up @@ -48,17 +49,19 @@
<li>{{ commentCount | formatNum }}条评论</li>
</ul>
<comment-item
v-if="news.audit_status===0"
v-for="(comment) in pinnedCom"
:pinned="true"
:key="comment.id"
:comment="comment"/>
<comment-item
v-if="news.audit_status===0"
@click="replyComment"
v-for="(comment) in comments"
:key="comment.id"
:comment="comment"/>

<div class="m-box m-aln-center m-justify-center load-more-box">
<div v-if="news.audit_status===0" class="m-box m-aln-center m-justify-center load-more-box">
<span v-if="noMoreCom" class="load-more-ph">---没有更多---</span>
<span v-else class="load-more-btn" @click.stop="fetchNewsComments(maxComId)">
{{fetchComing ? "加载中..." : "点击加载更多"}}
Expand Down
20 changes: 10 additions & 10 deletions src/page/profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,7 @@
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#base-arrow-r"></use>
</svg>
</router-link>
<router-link to="/upgrade" tag="li" class="m-entry">
<svg class='m-style-svg m-svg-def m-entry-prepend'>
<use xlink:href="#profile-collect"></use>
</svg>
<span class="m-text-box m-flex-grow1">收藏</span>
<svg class="m-style-svg m-svg-def m-entry-append">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#base-arrow-r"></use>
</svg>
</router-link>
<router-link to="/upgrade" tag="li" class="m-entry">
<router-link to="/profile/news/released" tag="li" class="m-entry">
<svg class='m-style-svg m-svg-def m-entry-prepend'>
<use xlink:href="#profile-plane"></use>
</svg>
Expand Down Expand Up @@ -103,6 +94,15 @@
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#base-arrow-r"></use>
</svg>
</router-link>
<router-link to="/profile/collection/feeds" tag="li" class="m-entry">
<svg class='m-style-svg m-svg-def m-entry-prepend'>
<use xlink:href="#profile-collect"></use>
</svg>
<span class="m-text-box m-flex-grow1">收藏</span>
<svg class="m-style-svg m-svg-def m-entry-append">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#base-arrow-r"></use>
</svg>
</router-link>
</ul>
<ul class="m-box-model m-entry-group">
<router-link to="/upgrade" tag="li" class="m-entry">
Expand Down
144 changes: 144 additions & 0 deletions src/page/profile/children/profileNews.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<template>
<div class="p-profile-news">
<header class="m-box m-pos-f m-main m-bb1 m-head-top">
<div class="m-box m-aln-center m-flex-grow1 m-flex-base0">
<svg class="m-style-svg m-svg-def" @click="goBack">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#base-back"></use>
</svg>
</div>
<div class="m-box m-aln-center m-flex-grow1 m-flex-base0 m-justify-center m-head-top-title">
<span>我的投稿</span>
</div>
<div class="m-box m-aln-center m-flex-grow1 m-flex-base0 m-justify-end">

</div>
</header>

<main style="padding-top: .9rem">
<div class="m-pos-f m-box m-aln-center m-justify-bet m-sub-nav m-bb1 m-main">
<router-link replace exact tag="div" exact-active-class="active" to="/profile/news/released" class="m-sub-nav-item">
<a>已发布</a>
</router-link>
<router-link replace exact tag="div" exact-active-class="active" to="/profile/news/auditing" class="m-sub-nav-item">
<a>投稿中</a>
</router-link>
<router-link replace exact tag="div" exact-active-class="active" to="/profile/news/rejected" class="m-sub-nav-item">
<a>被驳回</a>
</router-link>
</div>
<load-more
style="padding-top: .9rem"
ref='loadmore'
:onRefresh='onRefresh'
:onLoadMore='onLoadMore'>
<news-item
v-for="news in newsList"
:news="news"
:key="news.id"
/>
</load-more>
</main>
</div>
</template>
<script>
import _ from "lodash";
import { getMyNews } from "@/api/news.js";
import newsItem from "@/page/news/components/newsItem.vue";
export default {
components: {
newsItem
},
data() {
const released = new Map();
const auditing = new Map();
const rejected = new Map();
return {
released,
auditing,
rejected,
ChangeTracker: 1
};
},
methods: {
formatNews(newsList) {
newsList.forEach(news => {
this.$data[this.type].set(news.id, news);
this.ChangeTracker += 1;
});
},
onRefresh() {
getMyNews({ ...this.params }).then(({ data }) => {
this.formatNews(data);
this.$refs.loadmore.topEnd(!(data.length < this.params.limit));
});
},
onLoadMore() {
getMyNews({ ...this.params }).then(({ data = [] }) => {
this.formatNews(data);
this.$refs.loadmore.bottomEnd(data.length < this.params.limit);
});
}
},
computed: {
newsList() {
return (
this.type &&
this.ChangeTracker &&
Array.from(this.$data[this.type].values())
);
},
type() {
return this.$route.params.type;
},
after() {
const last = _.last(this.newsList);
return last ? last.id : 0;
},
typeParam() {
if (this.type === "released") {
return 0;
}
if (this.type === "rejected") {
return 3;
}
return 1;
},
params() {
const { typeParam: type, after } = this;
return {
type,
after,
limit: 15
};
}
},
watch: {
type(val) {
this.isCurrentView && val && this.$refs.loadmore.beforeRefresh();
}
},
activated() {
this.isCurrentView = true;
},
deactivated() {
this.isCurrentView = false;
}
};
</script>
<style lang="less">
.p-profile-news {
.m-sub-nav {
top: 90px;
z-index: 2;
.m-sub-nav-item {
height: 100%;
line-height: 90px;
&.router-link-active {
color: #333;
border-bottom: 4px solid #59b6d7;
}
}
}
}
</style>
60 changes: 60 additions & 0 deletions src/page/profile/collection.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<template>
<div class="p-profile-collection">
<header class="m-box m-pos-f m-main m-bb1 m-head-top">
<div class="m-box m-aln-center m-flex-grow1 m-flex-base0">
<svg class="m-style-svg m-svg-def" @click="goBack">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#base-back"></use>
</svg>
</div>
<div class="m-box m-aln-center m-flex-grow1 m-flex-base0 m-justify-center m-head-top-title">
<span>我的收藏</span>
</div>
<div class="m-box m-aln-center m-flex-grow1 m-flex-base0 m-justify-end">
</div>
</header>
<main style="padding-top: .9rem">
<div class="m-pos-f m-box m-aln-center m-justify-bet m-sub-nav m-bb1 m-main">
<router-link replace exact tag="div" exact-active-class="active" to="/profile/collection/feeds" class="m-sub-nav-item">
<a>动态</a>
</router-link>
<router-link replace exact tag="div" exact-active-class="active" to="/profile/collection/news" class="m-sub-nav-item">
<a>资讯</a>
</router-link>
<router-link replace exact tag="div" exact-active-class="active" to="/profile/collection/answers" class="m-sub-nav-item">
<a>回答</a>
</router-link>
<router-link replace exact tag="div" exact-active-class="active" to="/profile/collection/posts" class="m-sub-nav-item">
<a>帖子</a>
</router-link>
</div>
<keep-alive>
<router-view></router-view>
</keep-alive>
<!-- <profile-collection-news v-if="type === 'news'" />
<profile-collection-feeds v-if="type === 'feeds'" />
<profile-collection-answers v-if="type === 'answers'" />
<profile-collection-posts v-if="type === 'posts'" /> -->
</main>
</div>
</template>
<script>
export default {
name: "profile-collection"
};
</script>
<style lang="less">
.p-profile-collection {
.m-sub-nav {
top: 90px;
z-index: 2;
.m-sub-nav-item {
height: 100%;
line-height: 90px;
&.router-link-active {
color: #333;
border-bottom: 4px solid #59b6d7;
}
}
}
}
</style>
Loading

0 comments on commit bd74a1f

Please sign in to comment.