粒子研究院前台前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

56 lines
1.4 KiB

import Util from '@/libs/util'
export default {
data() {
return {
active: +this.$route.query.id,
tabs: [],
}
},
mounted() {
this.getColumn()
},
methods: {
// 获取文章详情
getInfo() {
// 预览/详情
this.$post(this.api[this.preview ? 'getRedisCache' : 'findPage'], Util.rsa(this.id)).then(({ data }) => {
if (data.length) {
// state:已发布(1)则取theEditedJson,草稿(0)则取jsonBeforeEditing
const json = JSON.parse(this.preview ?
data :
data[data.length - 1][data[data.length - 1].state ? 'theEditedJson' : 'jsonBeforeEditing'])
this.modules = json
}
}).catch(err => {})
},
// 获取所有栏目
getColumn() {
this.$post(this.api.listWithTreeMenuVisible, Util.rsa({
siteId: this.site,
columnName: '',
templateId: '',
typeId: '',
isSort: 1
}))
.then(({ data }) => {
this.getParent(data)
})
.catch((err) => { });
},
// 获取父级
getParent(data, parent = {}) {
for (const e of data) {
if (e.id == this.id) {
this.tabs = parent.children
break
} else if (e.children.length) {
this.getParent(e.children, e)
}
}
},
// tab回调
tabChange(item) {
this.$router.push(`/${item.path}?id=${item.id}&siteId=${item.siteId}`)
},
}
};