108 lines
2.2 KiB
Vue
108 lines
2.2 KiB
Vue
<script setup>
|
|
import {onMounted, ref} from 'vue'
|
|
import {useRoute, useRouter} from 'vue-router'
|
|
|
|
import {ElMessage} from 'element-plus'
|
|
import {list as mockList, newsDetail as mockDetail} from './mock.js'
|
|
|
|
const route = useRoute()
|
|
const detail = route.query
|
|
const showLoad = ref(true)
|
|
|
|
const newsTitle = ref('')
|
|
const newsTime = ref('')
|
|
const newsSubTitle = ref('')
|
|
const newsCoverImg = ref('')
|
|
const newsContent = ref(null)
|
|
|
|
const router = useRouter()
|
|
|
|
onMounted(() => {
|
|
getDetail()
|
|
})
|
|
|
|
const getDetail = () => {
|
|
let query = {
|
|
slug: detail.slug,
|
|
}
|
|
getNewsDetail(query)
|
|
.then((res) => {
|
|
if (res.code === 0) {
|
|
let {content, cover_image, snapshot, datetime, title} = res.data
|
|
newsTitle.value = title
|
|
newsTime.value = datetime
|
|
newsSubTitle.value = snapshot
|
|
newsCoverImg.value = cover_image
|
|
newsContent.value = content
|
|
showLoad.value = false
|
|
} else {
|
|
ElMessage.error(res.msg)
|
|
showLoad.value = false
|
|
}
|
|
})
|
|
.catch((err) => {
|
|
showLoad.value = false
|
|
})
|
|
}
|
|
|
|
const toBack = () => {
|
|
router.back()
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="page flex column a-c" v-loading="showLoad">
|
|
<div v-if="newsTitle">
|
|
<h3 class="label">
|
|
{{ newsTitle }}
|
|
</h3>
|
|
<h3 class="time" v-if="newsTime">
|
|
{{ newsTime }}
|
|
</h3>
|
|
<div class="artical">
|
|
<div v-html="newsContent"></div>
|
|
</div>
|
|
</div>
|
|
<div v-else class="no-content">暂无内容</div>
|
|
<div class="back" @click="toBack">返回</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style lang="scss" scoped>
|
|
.page {
|
|
.label {
|
|
text-align: center;
|
|
margin: 64px 0 20px 0;
|
|
font-family: 'PingFang SC';
|
|
font-weight: 500;
|
|
font-size: 28px;
|
|
color: $black;
|
|
}
|
|
.time {
|
|
text-align: center;
|
|
font-family: 'PingFang SC';
|
|
font-weight: 500;
|
|
font-size: 20px;
|
|
margin-bottom: 20px;
|
|
}
|
|
.artical {
|
|
width: 1200px;
|
|
}
|
|
.no-content {
|
|
margin-top: 40px;
|
|
font-size: 32px;
|
|
}
|
|
.back {
|
|
margin-top: 40px;
|
|
padding: 10px 40px;
|
|
background: #0389ff;
|
|
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.25);
|
|
border-radius: 16px;
|
|
margin-bottom: 60px;
|
|
font-size: 20px;
|
|
color: $white;
|
|
cursor: pointer;
|
|
}
|
|
}
|
|
</style>
|