|
|
@@ -3,20 +3,157 @@
|
|
|
<nav-bar @click-left="$router.go(-1)">
|
|
|
<div class="tabs" slot="title">
|
|
|
<div class="tab-item" :class="{ active: tab === 0 }" @click="tab = 0">官答</div>
|
|
|
- <div class="tab-item" :class="{ active: tab === 1 }" @click="tab = 1">热议</div>
|
|
|
- <div class="tab-item" :class="{ active: tab === 2 }" @click="tab = 2">互动</div>
|
|
|
+ <div class="tab-item" :class="{ active: tab === 1 }" @click="tab = 1">话题</div>
|
|
|
+ <div class="tab-item" :class="{ active: tab === 2 }" @click="tab = 2">提问</div>
|
|
|
</div>
|
|
|
</nav-bar>
|
|
|
+ <van-empty v-if="empty" description="还未发布任何互动信息哦~">
|
|
|
+ <router-link :to="{ name: 'official' }" replace class="btn-lg" style="width:180px">去逛逛</router-link>
|
|
|
+ </van-empty>
|
|
|
+ <div class="list">
|
|
|
+ <div class="item" v-for="item in list" :key="item.id" @click="detail(item)">
|
|
|
+ <div class="info">
|
|
|
+ <van-image width="24" height="24" round fit="cover" :src="($store.state.userInfo || {}).avatar" />
|
|
|
+ <div class="name">{{ ($store.state.userInfo || {}).nickname }}</div>
|
|
|
+ <div class="desc">{{ item.comment ? '回复' : '发布' }}</div>
|
|
|
+ <img src="../assets/icon_more.png" class="icon" />
|
|
|
+ </div>
|
|
|
+ <template v-if="item.post && item.post.type === 'OFFICIAL'">
|
|
|
+ <div class="item-title">{{ item.post.content }}</div>
|
|
|
+ <div class="opt">
|
|
|
+ <div class="time">{{ toDate(item.createdAt) }}</div>
|
|
|
+ </div>
|
|
|
+ <div class="reply">
|
|
|
+ <img class="icon" src="../assets/interact_icon_answer.png" />
|
|
|
+ <div class="content-wrapper">
|
|
|
+ <div class="content" v-if="item.comment">{{ item.comment.content }}</div>
|
|
|
+ <div class="empty" v-else>暂未答复,请耐心等待!</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <template v-else-if="item.comment">
|
|
|
+ <div class="item-title">{{ item.comment.content }}</div>
|
|
|
+ <div class="opt">
|
|
|
+ <div class="time">{{ toDate(item.createdAt) }}</div>
|
|
|
+ <div class="opt-btn">
|
|
|
+ <img src="../assets/interact_icon_dislike.png" />
|
|
|
+ <div class="num">{{ item.comment.dislikeNum }}</div>
|
|
|
+ </div>
|
|
|
+ <div class="opt-btn">
|
|
|
+ <img src="../assets/interact_icon_like.png" />
|
|
|
+ <div class="num">{{ item.comment.likeNum }}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="orig-info">
|
|
|
+ <div class="info">
|
|
|
+ <div class="orig-title">{{ item.post.title }}</div>
|
|
|
+ <div class="type">{{ getType(item.post) }}</div>
|
|
|
+ </div>
|
|
|
+ <img
|
|
|
+ :src="
|
|
|
+ item.post.type === 'QA'
|
|
|
+ ? require('../assets/img_qa.png')
|
|
|
+ : require('../assets/img_topic.png')
|
|
|
+ "
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <div class="item-title">{{ item.post.title }}</div>
|
|
|
+ <div class="item-desc">{{ item.post.content }}</div>
|
|
|
+ <div class="opt">
|
|
|
+ <div class="time">{{ toDate(item.createdAt) }}</div>
|
|
|
+ <div class="opt-btn">
|
|
|
+ <img src="../assets/interact_icon_hot.png" />
|
|
|
+ <div class="num">{{ item.post.viewNum }}</div>
|
|
|
+ </div>
|
|
|
+ <div class="opt-btn">
|
|
|
+ <img src="../assets/interact_icon_comment.png" />
|
|
|
+ <div class="num">{{ item.post.commentNum }}</div>
|
|
|
+ </div>
|
|
|
+ <div class="opt-btn">
|
|
|
+ <img src="../assets/interact_icon_like.png" />
|
|
|
+ <div class="num">{{ item.post.likeNum }}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- tab: 0
|
|
|
+ tab: 0,
|
|
|
+ list: [],
|
|
|
+ empty: false
|
|
|
};
|
|
|
},
|
|
|
- methods: {}
|
|
|
+ created() {
|
|
|
+ this.getData();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getData() {
|
|
|
+ let type = '';
|
|
|
+ switch (this.tab) {
|
|
|
+ case 0:
|
|
|
+ type = 'OFFICIAL';
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ type = 'TOPIC';
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ type = 'QA';
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ this.$http.get('/post/my', { type }).then(res => {
|
|
|
+ this.list = res;
|
|
|
+ this.empty = res.length === 0;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getType(item) {
|
|
|
+ switch (item.type) {
|
|
|
+ case 'OFFICIAL':
|
|
|
+ return '官答';
|
|
|
+ case 'TOPIC':
|
|
|
+ return '话题';
|
|
|
+ case 'QA':
|
|
|
+ return '提问';
|
|
|
+ }
|
|
|
+ },
|
|
|
+ detail(item) {
|
|
|
+ if (item.post.del) {
|
|
|
+ this.$toast(`该${this.getType(item.post)}已删除`);
|
|
|
+ } else {
|
|
|
+ switch (item.post.type) {
|
|
|
+ case 'OFFICIAL':
|
|
|
+ this.$router.push({
|
|
|
+ name: 'officialDetail',
|
|
|
+ query: { id: item.post.id }
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case 'TOPIC':
|
|
|
+ this.$router.push({
|
|
|
+ name: 'forumDetail',
|
|
|
+ query: { id: item.post.id, type: 'forum' }
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case 'QA':
|
|
|
+ this.$router.push({
|
|
|
+ name: 'forumDetail',
|
|
|
+ query: { id: item.post.id, type: 'qa' }
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ tab() {
|
|
|
+ this.getData();
|
|
|
+ }
|
|
|
+ }
|
|
|
};
|
|
|
</script>
|
|
|
<style lang="less" scoped>
|
|
|
@@ -39,4 +176,127 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+.list {
|
|
|
+ .item {
|
|
|
+ padding: 20px 16px;
|
|
|
+ .flex-col();
|
|
|
+ position: relative;
|
|
|
+ &::after {
|
|
|
+ .setBottomLine();
|
|
|
+ left: 16px;
|
|
|
+ right: 16px;
|
|
|
+ }
|
|
|
+ .info {
|
|
|
+ color: @text3;
|
|
|
+ font-size: 13px;
|
|
|
+ line-height: 24px;
|
|
|
+ .flex();
|
|
|
+ .name {
|
|
|
+ margin-left: 6px;
|
|
|
+ }
|
|
|
+ .desc {
|
|
|
+ margin-left: 6px;
|
|
|
+ flex-grow: 1;
|
|
|
+ }
|
|
|
+ .icon {
|
|
|
+ width: 24px;
|
|
|
+ height: 24px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .item-title {
|
|
|
+ margin-left: 30px;
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: bold;
|
|
|
+ color: black;
|
|
|
+ line-height: 24px;
|
|
|
+ margin-top: 6px;
|
|
|
+ .ellipsisLn(2);
|
|
|
+ }
|
|
|
+ .item-desc {
|
|
|
+ color: @text3;
|
|
|
+ font-size: 14px;
|
|
|
+ line-height: 24px;
|
|
|
+ margin-top: 6px;
|
|
|
+ margin-left: 30px;
|
|
|
+ .ellipsisLn(2);
|
|
|
+ }
|
|
|
+ .opt {
|
|
|
+ margin: 6px -16px 0 30px;
|
|
|
+ .flex();
|
|
|
+ font-size: 13px;
|
|
|
+ .time {
|
|
|
+ color: @text4;
|
|
|
+ flex-grow: 1;
|
|
|
+ }
|
|
|
+ .opt-btn {
|
|
|
+ color: @text3;
|
|
|
+ .flex();
|
|
|
+ margin-left: 16px;
|
|
|
+ img {
|
|
|
+ width: 24px;
|
|
|
+ height: 24px;
|
|
|
+ }
|
|
|
+ .num {
|
|
|
+ width: 40px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .orig-info {
|
|
|
+ border-radius: 0px 16px 16px 16px;
|
|
|
+ background: @bg;
|
|
|
+ padding: 12px;
|
|
|
+ margin: 10px 0 0 30px;
|
|
|
+ .flex();
|
|
|
+ .info {
|
|
|
+ height: 70px;
|
|
|
+ flex-grow: 1;
|
|
|
+ .flex-col();
|
|
|
+ align-items: flex-start;
|
|
|
+ justify-content: space-between;
|
|
|
+ .orig-title {
|
|
|
+ color: @text2;
|
|
|
+ font-size: 14px;
|
|
|
+ line-height: 22px;
|
|
|
+ .ellipsisLn(2);
|
|
|
+ }
|
|
|
+ .type {
|
|
|
+ color: @text4;
|
|
|
+ line-height: 24px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ img {
|
|
|
+ width: 70px;
|
|
|
+ height: 70px;
|
|
|
+ margin-left: 12px;
|
|
|
+ min-width: 70px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .reply {
|
|
|
+ .flex();
|
|
|
+ margin: 8px 0 0 -2px;
|
|
|
+ align-items: flex-start;
|
|
|
+ .icon {
|
|
|
+ width: 26px;
|
|
|
+ height: 26px;
|
|
|
+ }
|
|
|
+ .content-wrapper {
|
|
|
+ margin: 8px 0 0 6px;
|
|
|
+ border-radius: 0px 16px 16px 16px;
|
|
|
+ background: @bg;
|
|
|
+ padding: 10px 12px;
|
|
|
+ font-size: 16px;
|
|
|
+ line-height: 26px;
|
|
|
+ flex-grow: 1;
|
|
|
+ .flex();
|
|
|
+ .content {
|
|
|
+ color: black;
|
|
|
+ .ellipsisLn(3);
|
|
|
+ }
|
|
|
+ .empty {
|
|
|
+ color: @text3;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|