This repository has been archived by the owner on Nov 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
392 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.