对接数据
This commit is contained in:
41
pages/ToolDetail/components/CommentBtn.vue
Normal file
41
pages/ToolDetail/components/CommentBtn.vue
Normal file
@ -0,0 +1,41 @@
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
commentCount: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isActive: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="box flex flex-col items-center" :style="{background: !isActive && '#FFFFFF'}">
|
||||
<img :src="isActive ? '/ToolDetail/icon_comment_selected.png' : '/ToolDetail/icon_comment.png'" alt="" />
|
||||
<span :style="{color: isActive ? '#ffffffcc' : '#64748b'}">{{ commentCount }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.box {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 4px 6px 0 #0000000d;
|
||||
background: $header-backgroungd;
|
||||
padding: 5px;
|
||||
font-family: 'Poppins-Regular', serif;
|
||||
font-size: 12px;
|
||||
img {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
80
pages/ToolDetail/components/CommentItem.vue
Normal file
80
pages/ToolDetail/components/CommentItem.vue
Normal file
@ -0,0 +1,80 @@
|
||||
<template>
|
||||
<div class="comment-item-box flex border">
|
||||
<div class="comment-avatar flex-center">
|
||||
<img src="/logo/logo-rect.png" alt="" />
|
||||
</div>
|
||||
<div class="comment-content">
|
||||
<div class="comment-author">
|
||||
{{item.username || ''}}
|
||||
</div>
|
||||
<div class="date-wrap flex-top-left">
|
||||
<img src="/ToolDetail/icon_clock1.png" alt="" style="width: 16px; height: 16px;" />
|
||||
<span style="line-height: 18px">{{ item.createdAt || '' }}</span>
|
||||
</div>
|
||||
<p class="comment-text">
|
||||
{{ item.content || '' }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
}
|
||||
},
|
||||
props: {
|
||||
item: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.comment-item-box {
|
||||
gap: 15px;
|
||||
padding: 30px 0;
|
||||
.comment-avatar {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
@include gradient-circle-border($linear-gradient-start, $linear-gradient-end);
|
||||
img {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
}
|
||||
.comment-content {
|
||||
.comment-author {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
font-family: 'Poppins-SemiBold', serif;
|
||||
color: #1E293B;
|
||||
line-height: 27px;
|
||||
height: 27px;
|
||||
}
|
||||
.date-wrap {
|
||||
gap: 8px;
|
||||
font-family: 'Poppins-Regular', serif;
|
||||
font-size: 14px;
|
||||
color: #869EC2;
|
||||
margin-top: 3px;
|
||||
}
|
||||
.comment-text {
|
||||
margin-bottom: 0;
|
||||
margin-top: 13px;
|
||||
font-family: 'Poppins-Regular', serif;
|
||||
color: #64748B;
|
||||
}
|
||||
}
|
||||
}
|
||||
.border {
|
||||
border-bottom: 2px solid #f3f8fe;
|
||||
}
|
||||
</style>
|
||||
96
pages/ToolDetail/components/SimilarToolCard.vue
Normal file
96
pages/ToolDetail/components/SimilarToolCard.vue
Normal file
@ -0,0 +1,96 @@
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
category_slug: '',
|
||||
};
|
||||
},
|
||||
props: {
|
||||
config: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {}
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
goToToolDetail() {
|
||||
if (this.config.slug && this.category_slug) {
|
||||
this.$router.push('/detail?tool_slug=' + this.config.slug + '&category_slug=' + this.category_slug);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.category_slug = this.$route.query.category_slug;
|
||||
},
|
||||
watch: {
|
||||
'$route': function (newVal) {
|
||||
this.category_slug = newVal.query.category_slug;
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="similar-card-container" @click="goToToolDetail">
|
||||
<div class="title">
|
||||
<img :src="config.iconUrl || ''" alt="" />
|
||||
<span style="font-size: 18px">
|
||||
{{ config.name || '' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="text">
|
||||
{{ config.memo || '' }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.similar-card-container {
|
||||
background: #FFFFFF;
|
||||
box-shadow: 0 10px 30px 0 #0000000d;
|
||||
border-radius: 8px;
|
||||
padding: 16px 16px 10px;
|
||||
border: 1px solid #BACFFF;
|
||||
max-width: 305px;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
@include gradient-border($linear-gradient-start, $linear-gradient-end);
|
||||
}
|
||||
|
||||
&:active {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
img {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
span {
|
||||
color: $main-font-color;
|
||||
font-size: $big-font-size;
|
||||
font-weight: 600;
|
||||
font-family: 'Poppins-SemiBold', serif;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
|
||||
.text {
|
||||
color: $grey-color;
|
||||
font-family: 'Poppins-Regular', serif;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
97
pages/ToolDetail/components/ThumbBtn.vue
Normal file
97
pages/ToolDetail/components/ThumbBtn.vue
Normal file
@ -0,0 +1,97 @@
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
likeCount: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
id: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
default: 'tool',
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isActive: false,
|
||||
throttleTimer: null,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 添加点赞
|
||||
async addLike() {
|
||||
// 节流控制 - 如果已有定时器则阻止执行
|
||||
if (this.throttleTimer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 设置节流定时器
|
||||
this.throttleTimer = setTimeout(() => {
|
||||
this.throttleTimer = null;
|
||||
}, 3000);
|
||||
|
||||
if (!this.id) {
|
||||
// 清除定时器
|
||||
clearTimeout(this.throttleTimer);
|
||||
this.throttleTimer = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.type === 'tool') {
|
||||
const {data: res} = await this.$api.tool.clickToolLike(this.id);
|
||||
const {code} = res;
|
||||
if (code === 0) {
|
||||
this.$message.success('Like successful');
|
||||
this.$emit('like-success');
|
||||
} else {
|
||||
// 请求失败时清除定时器,允许重新点击
|
||||
clearTimeout(this.throttleTimer);
|
||||
this.throttleTimer = null;
|
||||
}
|
||||
} else {
|
||||
const {data: res} = await this.$api.article.clickArticleLike(this.id);
|
||||
const {code} = res;
|
||||
if (code === 0) {
|
||||
this.$message.success('Like successful');
|
||||
this.$emit('like-success');
|
||||
} else {
|
||||
// 请求失败时清除定时器,允许重新点击
|
||||
clearTimeout(this.throttleTimer);
|
||||
this.throttleTimer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="box flex flex-col items-center" :style="{background: !isActive && '#FFFFFF'}" @click="addLike">
|
||||
<img :src="isActive ? '/ToolDetail/icon_thumb_selected.png' : '/ToolDetail/icon_thumb.png'" alt="" />
|
||||
<span :style="{color: isActive ? '#ffffffcc' : '#64748b'}">{{ likeCount }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.box {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 4px 6px 0 #0000000d;
|
||||
background: $header-backgroungd;
|
||||
padding: 5px;
|
||||
font-family: 'Poppins-Regular', serif;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
img {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
&:active {
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user