Commit 09453039 by yanju

博客发布页可选子分类

parent 529ee59f
...@@ -72,7 +72,11 @@ export default { ...@@ -72,7 +72,11 @@ export default {
props: { props: {
selectType: String, selectType: String,
classList: Array, classList: Array,
placeholder: String placeholder: String,
childList:{
type:Array,
default:() => ([])
}
}, },
data(){ data(){
return{ return{
......
<template> <template>
<div>
<div class="tag-box"> <div class="tag-box">
<p v-if="!isHot" @click="handleClick">{{item.tag}}</p> <p v-if="!isHot" @click="handleClick">{{item.tag}}</p>
<div v-if="isHot" @click="handleClick">{{item.tag}}{{item.referenceCount}}</div> <div v-if="isHot" @click="handleClick">{{item.tag}}{{item.referenceCount}}</div>
<yun-icon v-if="item.childList" @click="handleClick" :style="{paddingRight:'5px',transform:showChildList?'rotate(180deg)':'rotate(0)'}" name="down_arrow" size="8px" :color="showChildList?'#00AAE6':'#999'"></yun-icon>
</div>
<div v-if="item.childList&&showChildList" >
<p class="tag-child" @click="handleChildClick(val.tag,val,tagId)" v-for="(val,index) in item.childList">{{val.tag}}</p>
</div> </div>
</div>
</template> </template>
<script> <script>
...@@ -16,10 +24,24 @@ export default { ...@@ -16,10 +24,24 @@ export default {
default: false default: false
} }
}, },
data(){
return{
showChildList:false
}
},
methods: { methods: {
handleClick(){ handleClick(){
console.log(this.item); if(this.item.childList){
this.showChildList = !this.showChildList;
}else {
this.$emit('select', this.item.tag, this.item.tagId); this.$emit('select', this.item.tag, this.item.tagId);
}
},
handleChildClick(tag,id){
this.$emit('select', tag, id);
} }
} }
} }
...@@ -27,7 +49,9 @@ export default { ...@@ -27,7 +49,9 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.tag-box{ .tag-box{
display: inline-block; @extend %flex-row-spb;
border-bottom: 1px solid #F4F8FA;
> div { > div {
display: inline-block; display: inline-block;
margin: 2*$length 5*$length 8*$length 8*$length; margin: 2*$length 5*$length 8*$length 8*$length;
...@@ -42,10 +66,26 @@ export default { ...@@ -42,10 +66,26 @@ export default {
@include fontStyle(14, 40, 500, #999, left); @include fontStyle(14, 40, 500, #999, left);
padding-left: 20*$length; padding-left: 20*$length;
@extend %cursorPointer; @extend %cursorPointer;
}
&:hover { &:hover {
background-color: #F4F8FA; background-color: #F4F8FA;
> p{
color: #00AAE6; color: #00AAE6;
}
}
} }
.tag-child {
@include fontStyle(12, 40, 500, #999, center);
padding-left: 20*$length;
@extend %cursorPointer;
box-sizing: border-box;
&:hover {
background-color: #F4F8FA;
color: #00AAE6;
} }
} }
......
...@@ -152,7 +152,7 @@ export default { ...@@ -152,7 +152,7 @@ export default {
if(blogListRes.code!==0){ if(blogListRes.code!==0){
redirect('/users/login'); redirect('/users/login');
} }
blogClassRes.data.forEach(item => { for (const item of blogClassRes.data) {
if (item.category === '云顶笔记') { if (item.category === '云顶笔记') {
if (store.state.userProfile.nickName === '云顶笔记') { if (store.state.userProfile.nickName === '云顶笔记') {
classList.push({ classList.push({
...@@ -161,13 +161,31 @@ export default { ...@@ -161,13 +161,31 @@ export default {
}) })
} }
} else { } else {
if(!item.leaf){
let childListData = await $axios.$get(config.api.get.BlogCategory.childList+item.categoryId+'/categories')
const childList =[];
childListData.data.map((val,index)=>{
childList.push({
tag: val.category,
tagId: val.categoryId,
})
})
classList.push({ classList.push({
tag: item.category, tag: item.category,
tagId: item.categoryId tagId: item.categoryId,
childList
});
}else{
classList.push({
tag: item.category,
tagId: item.categoryId,
}) })
} }
}); }
}
if (query.hasOwnProperty('id')) { if (query.hasOwnProperty('id')) {
const blogDetailRes = await $axios.$get(config.api.get.Blog.detail + query.id); const blogDetailRes = await $axios.$get(config.api.get.Blog.detail + query.id);
return { return {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment