深圳或然科技官网
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.

323 lines
9.5 KiB

2 years ago
<template>
<div v-show="loaded"
class="wrap">
1 year ago
<!-- 人物详情不展示banner -->
<div v-if="form.articleTemplate !== 23 && !isPeople"
2 years ago
class="banner"
:style="{backgroundImage: form.bannerImg ? ('url(' + form.bannerImg + ')') : ''}">
{{ form.columnName }}
</div>
<div class="content">
<Breadcrumb ref="breadcrumb"
:data.sync="routes" />
<div class="article">
<div class="left">
<template v-if="!isPeople">
<h2>{{ form.title }}</h2>
2 years ago
<div class="meta">{{ form.source && form.source + ' | ' }} {{ form.author && form.author + ' | ' }} {{ form.releaseTime }}</div>
2 years ago
<div class="meta">{{ form.edit && $t('column.edit') + ':' + form.edit }} {{ form.audit && ' | ' + $t('column.auditor') + ':' + form.audit }} {{ form.label && ' | ' + $t('column.label') + ':' + form.label }}</div>
</template>
<p v-if="form.summary"
class="brief">{{ form.summary }}</p>
<div class="des"
1 year ago
id="mainBody"
2 years ago
v-html="form.mainBody"></div>
<div v-if="form.fileList && form.fileList.length"
class="annex">
<h6>{{$t('column.attachmentDownload')}}</h6>
<ul class="files">
<li v-for="(file, i) in form.fileList"
:key="i">
<span class="name">{{ file.fileName }}</span>
<span class="download"
@click="download(file)">{{$t('column.download')}}</span>
</li>
</ul>
</div>
</div>
<RightColumns ref="right"
:party="isParty" />
</div>
</div>
</div>
</template>
<script>
import Setting from '@/setting'
import Util from '@/libs/util'
import Breadcrumb from '@/components/breadcrumb'
import RightColumns from '@/components/rightColumns'
import mixins from '@/mixins/article'
export default {
mixins: [mixins],
data () {
return {
id: this.$route.query.articleId,
columnId: +this.$route.query.id,
2 years ago
preview: this.$route.query.preview,
2 years ago
loaded: false,
routes: [],
form: {},
columnBanner: '',
isParty: 0, // 组织机构
isPeople: 0, // 人物详情
gotBanner: 0
}
},
components: {
Breadcrumb,
RightColumns
},
watch: {
'$route' () {
this.id = this.$route.query.articleId
this.getInfo()
}
},
mounted () {
this.getColumnInfo()
},
methods: {
// 获取文章详情
getInfo () {
2 years ago
// 预览直接取缓存数据,不然就调接口
let cache = localStorage.getItem('article')
if (this.preview && cache) {
cache = JSON.parse(cache)
const temId = cache.articleTemplate
this.form = cache
2 years ago
this.routes = [
{
2 years ago
name: cache.columnName,
2 years ago
},
{
2 years ago
name: cache.title
2 years ago
}
]
2 years ago
if (temId == 69) this.isParty = 1 // 组织架构(articleTemplate=69)是另一套主题,加个class即可
if (temId == 72) this.isPeople = 1 // 人物详情(articleTemplate=72)要隐藏除了正文和摘要以外的所有字段
if (cache.releaseTime) cache.releaseTime = cache.releaseTime.split(' ')[0]
this.loaded = true
} else {
this.$post(`${this.api.findArticle}?id=${this.id}`).then(async ({ data }) => {
// 设置面包屑
const { columnName, path, id } = this.$route.query
this.routes = [
{
name: columnName || data.columnName,
path: path ? '/' + path : '',
query: {
id: id || data.columnId
}
},
{
1 year ago
name: data.columnName
2 years ago
}
2 years ago
]
// 文章被禁用了就直接返回
1 year ago
if (data.isDisable || !data.isRelease) {
2 years ago
this.$router.back()
} else {
const temId = data.articleTemplate
1 year ago
let path = `?articleId=${this.id}&id=${id}&columnName=${columnName || ''}&siteId=${data.siteId}&path=${path || ''}`
2 years ago
if (temId === 25 || temId === 26) { // 会议活动/期刊详情
this.$router.replace((temId === 25 ? '/article/activity' : '/publish/show') + path)
} else {
if (temId == 69) this.isParty = 1 // 组织架构(articleTemplate=69)是另一套主题,加个class即可
if (temId == 72) this.isPeople = 1 // 人物详情(articleTemplate=72)要隐藏除了正文和摘要以外的所有字段
data.releaseTime = data.releaseTime.split(' ')[0]
this.form = data
1 year ago
// 手动修复tinymce缩进bug(p标签下包裹多个子元素,p标签上只有text-indent,没有font-size,导致缩进2em的情况下未能缩进两个字符)
this.$nextTick(() => {
document.querySelectorAll('#mainBody p').forEach(e => {
try {
if (e.children.length && e.style.textIndent) {
e.style.fontSize = e.children[0].style.fontSize
}
} catch (e) { }
})
})
2 years ago
this.columnId = data.columnId
// 如果没上传banner
if (!data.bannerImg) {
1 year ago
const columns = await this.$post(this.api.listWithTree, Util.rsa({
2 years ago
siteId: this.site,
columnName: '',
templateId: '',
typeId: '',
isSort: 1
1 year ago
}))
2 years ago
this.getBanner(columns.data)
this.form.bannerImg = this.gotBanner ? this.columnBanner || require('@/assets/images/article-banner.png') : ''
}
2 years ago
2 years ago
// 浏览量+1
12 months ago
this.$post(`${this.api.articlePreview}?contentId=${this.id}`).then(res => { }).catch(err => { })
2 years ago
this.loaded = true
}
2 years ago
}
2 years ago
}).catch(err => { })
}
2 years ago
},
// 列表详情
getColumnInfo () {
this.columnId && this.$post(`${this.api.findColumn}?id=${this.columnId}`)
.then(({ data }) => {
if (data.detailStyleId == 69) this.isParty = 1
})
.catch((res) => { });
},
// 获取banner 规则:当前文章有上传的话,用上传的,没有上传的话,如果所属栏目有图片,读取栏目的(所属栏目没有的话读上级,上级没有就上上级,以此类推)都没有的话读取默认的
getBanner (data) {
for (const e of data) {
if (e.columnBanner && !this.gotBanner) this.columnBanner = e.columnBanner
if (e.id == this.columnId) {
this.gotBanner = 1
break
} else {
this.getBanner(e.children)
}
}
},
// 下载附件
download (e) {
Util.downloadFile(e.fileName, e.filePath)
},
}
};
</script>
<style lang="scss" scoped>
@import './editor.css';
.content {
width: 1200px;
/deep/ .el-breadcrumb {
font-size: 0.98rem;
}
}
.banner {
1 year ago
display: flex;
align-items: center;
2 years ago
height: 21.6rem;
1 year ago
padding-left: 10%;
font-size: 2rem;
2 years ago
font-weight: 600;
color: #fff;
12 months ago
background: url(../../assets/images/intro-bg.png) center center/cover no-repeat;
1 year ago
object-fit: cover;
2 years ago
}
.article {
display: flex;
justify-content: space-between;
.left {
width: 70%;
}
h2 {
font-size: 1.9rem;
color: #1c1c1c;
}
.meta {
margin: 1rem 0;
font-size: 0.88rem;
color: #9b9b9b;
}
.brief {
padding-bottom: 1.5rem;
1 year ago
margin: 1rem 0;
2 years ago
font-size: 1.2rem;
1 year ago
line-height: 1.6;
2 years ago
color: #606060;
border-bottom: 1px solid #d8d8d8;
}
/deep/.des {
1 year ago
// width: 100%;
// overflow: auto;
a {
color: rgb(0, 0, 238);
word-wrap: break-word;
}
2 years ago
img {
max-width: 100%;
1 year ago
object-fit: cover;
}
ul {
// padding-left: 40px;
list-style: disc;
li {
list-style: inherit;
}
}
ol {
// padding-left: 40px;
list-style: decimal;
li {
list-style: inherit;
}
2 years ago
}
}
.annex {
margin-top: 30px;
h6 {
padding-left: 8px;
margin-bottom: 20px;
font-size: 16px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
line-height: 1;
color: #333;
border-left: 4px solid #1583ff;
}
li {
display: flex;
align-items: center;
margin-bottom: 10px;
}
.name {
margin-right: 8px;
font-size: 14px;
}
.download {
color: #1583ff;
cursor: pointer;
}
}
}
1 year ago
2 years ago
@media (max-width: 1420px) {
.content {
width: 98%;
}
}
@media (max-width: 1200px) {
.article {
/deep/.des {
img {
max-width: 100%;
1 year ago
max-height: 15rem;
2 years ago
}
}
}
.banner {
font-size: 1.5rem;
}
.article {
flex-direction: column;
.left {
width: 100%;
h2 {
font-size: 1.5rem;
}
}
}
.article {
.des {
img {
height: 15rem !important;
}
}
}
1 year ago
.right {
width: 100%;
2 years ago
}
}
</style>