|
|
|
@ -3,13 +3,14 @@ import { ref, onMounted, computed, watch } from 'vue'; |
|
|
|
import { useRoute, useRouter } from 'vue-router'; |
|
|
|
import PageHeader from '../../components/PageHeader.vue'; |
|
|
|
import { useCasesStore } from '@/stores/cases'; |
|
|
|
import api from '@/api' |
|
|
|
|
|
|
|
const route = useRoute(); |
|
|
|
const router = useRouter(); |
|
|
|
const { selectedCase } = useCasesStore(); |
|
|
|
|
|
|
|
// 获取案例ID |
|
|
|
const caseId = computed(() => Number(route.params.id)); |
|
|
|
const caseId = computed(() => route.params.id); |
|
|
|
|
|
|
|
// 当前案例数据 |
|
|
|
const currentCase = ref(null); |
|
|
|
@ -45,23 +46,29 @@ const defaultCaseData = { |
|
|
|
const getCaseDetail = async () => { |
|
|
|
console.log('当前案例ID:', caseId.value); |
|
|
|
console.log('所有案例:', selectedCase.value); |
|
|
|
|
|
|
|
// 调用API获取案例详情 |
|
|
|
currentCase.value = await api.getCaseDetail(caseId.value); |
|
|
|
if (currentCase.value.data) { |
|
|
|
currentCase.value = currentCase.value.data; |
|
|
|
} |
|
|
|
|
|
|
|
// 尝试从selectedCase中获取数据 |
|
|
|
if (selectedCase.value && selectedCase.value.length > 0) { |
|
|
|
const currentCaseData = selectedCase.value[0]; |
|
|
|
console.log('使用的案例数据:', currentCaseData); |
|
|
|
// if (selectedCase.value && selectedCase.value.length > 0) { |
|
|
|
// const currentCaseData = selectedCase.value[0]; |
|
|
|
// console.log('使用的案例数据:', currentCaseData); |
|
|
|
|
|
|
|
// 处理图片路径,如果是数组则取第一个 |
|
|
|
if (currentCaseData.imageUrl && typeof currentCaseData.imageUrl === 'string') { |
|
|
|
currentCaseData.image = currentCaseData.imageUrl.split(',')[0]; |
|
|
|
} |
|
|
|
// // 处理图片路径,如果是数组则取第一个 |
|
|
|
// if (currentCaseData.imageUrl && typeof currentCaseData.imageUrl === 'string') { |
|
|
|
// currentCaseData.image = currentCaseData.imageUrl.split(',')[0]; |
|
|
|
// </span><span class="err"> pan> } |
|
|
|
|
|
|
|
currentCase.value = currentCaseData; |
|
|
|
} else { |
|
|
|
// 如果没有可用数据,使用默认的静态数据 |
|
|
|
console.log('使用默认的静态数据'); |
|
|
|
currentCase.value = defaultCaseData; |
|
|
|
} |
|
|
|
// currentCase.value = currentCaseData; |
|
|
|
// } else { |
|
|
|
// // 如果没有可用数据,使用默认的静态数据 |
|
|
|
// console.log('使用默认的静态数据'); |
|
|
|
// currentCase.value = defaultCaseData; |
|
|
|
// } |
|
|
|
}; |
|
|
|
|
|
|
|
// 返回案例列表 |
|
|
|
@ -154,6 +161,12 @@ onMounted(() => { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</section> |
|
|
|
|
|
|
|
<!-- 详情 --> |
|
|
|
<section class="case-gallery" v-if="currentCase.content"> |
|
|
|
<div class="container" v-html="currentCase.content"> |
|
|
|
</div> |
|
|
|
</section> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
@ -218,6 +231,24 @@ onMounted(() => { |
|
|
|
background-color: #0056b3; |
|
|
|
} |
|
|
|
|
|
|
|
.btn-outline { |
|
|
|
display: inline-block; |
|
|
|
padding: 10px 20px; |
|
|
|
background: transparent; |
|
|
|
color: #007bff; |
|
|
|
border: 2px solid #007bff; |
|
|
|
border-radius: 6px; |
|
|
|
text-decoration: none; |
|
|
|
font-weight: 500; |
|
|
|
transition: all 0.3s ease; |
|
|
|
} |
|
|
|
|
|
|
|
.btn-outline:hover { |
|
|
|
background: #007bff; |
|
|
|
color: white; |
|
|
|
transform: translateY(-2px); |
|
|
|
} |
|
|
|
|
|
|
|
.qrcode-image { |
|
|
|
max-width: 200px; |
|
|
|
margin: 0 auto; |
|
|
|
|