重构公司简介详情页路由传参方式,使用数字编号替代标题

This commit is contained in:
scout 2025-02-27 13:44:44 +08:00
parent f0a16af306
commit 51d9b1d5d2
4 changed files with 52 additions and 42 deletions

View File

@ -137,26 +137,31 @@ const state = reactive({
title: t("companyprofil.news.carousel.item1.title"), title: t("companyprofil.news.carousel.item1.title"),
subTitle: t("companyprofil.news.carousel.item1.desc"), subTitle: t("companyprofil.news.carousel.item1.desc"),
imgUrl: carouselShow1, imgUrl: carouselShow1,
titleNo: 1,
}, },
{ {
title: t("companyprofil.news.carousel.item2.title"), title: t("companyprofil.news.carousel.item2.title"),
subTitle: t("companyprofil.news.carousel.item2.desc"), subTitle: t("companyprofil.news.carousel.item2.desc"),
imgUrl: carouselShow2, imgUrl: carouselShow2,
titleNo: 2,
}, },
{ {
title: t("companyprofil.news.carousel.item3.title"), title: t("companyprofil.news.carousel.item3.title"),
subTitle: t("companyprofil.news.carousel.item3.desc"), subTitle: t("companyprofil.news.carousel.item3.desc"),
imgUrl: carouselShow3, imgUrl: carouselShow3,
titleNo: 3,
}, },
{ {
title: t("companyprofil.news.carousel.item4.title"), title: t("companyprofil.news.carousel.item4.title"),
subTitle: t("companyprofil.news.carousel.item4.desc"), subTitle: t("companyprofil.news.carousel.item4.desc"),
imgUrl: carouselShow4, imgUrl: carouselShow4,
titleNo: 4,
}, },
{ {
title: t("companyprofil.news.carousel.item5.title"), title: t("companyprofil.news.carousel.item5.title"),
subTitle: t("companyprofil.news.carousel.item5.desc"), subTitle: t("companyprofil.news.carousel.item5.desc"),
imgUrl: carouselShow5, imgUrl: carouselShow5,
titleNo: 5,
}, },
], ],
}); });
@ -197,7 +202,7 @@ const handleCarouselClick = (item, event) => {
router.push({ router.push({
path: "/companyprofildetail", path: "/companyprofildetail",
query: { query: {
title: item.title, titleNo: item.titleNo ,
}, },
}); });
} }

View File

@ -137,26 +137,31 @@ const state = reactive({
title: t("companyprofil.news.carousel.item1.title"), title: t("companyprofil.news.carousel.item1.title"),
subTitle: t("companyprofil.news.carousel.item1.desc"), subTitle: t("companyprofil.news.carousel.item1.desc"),
imgUrl: carouselShow1, imgUrl: carouselShow1,
titleNo: 1,
}, },
{ {
title: t("companyprofil.news.carousel.item2.title"), title: t("companyprofil.news.carousel.item2.title"),
subTitle: t("companyprofil.news.carousel.item2.desc"), subTitle: t("companyprofil.news.carousel.item2.desc"),
imgUrl: carouselShow2, imgUrl: carouselShow2,
titleNo: 2,
}, },
{ {
title: t("companyprofil.news.carousel.item3.title"), title: t("companyprofil.news.carousel.item3.title"),
subTitle: t("companyprofil.news.carousel.item3.desc"), subTitle: t("companyprofil.news.carousel.item3.desc"),
imgUrl: carouselShow3, imgUrl: carouselShow3,
titleNo: 3,
}, },
{ {
title: t("companyprofil.news.carousel.item4.title"), title: t("companyprofil.news.carousel.item4.title"),
subTitle: t("companyprofil.news.carousel.item4.desc"), subTitle: t("companyprofil.news.carousel.item4.desc"),
imgUrl: carouselShow4, imgUrl: carouselShow4,
titleNo: 4,
}, },
{ {
title: t("companyprofil.news.carousel.item5.title"), title: t("companyprofil.news.carousel.item5.title"),
subTitle: t("companyprofil.news.carousel.item5.desc"), subTitle: t("companyprofil.news.carousel.item5.desc"),
imgUrl: carouselShow5, imgUrl: carouselShow5,
titleNo: 5,
}, },
], ],
}); });
@ -197,7 +202,7 @@ const handleCarouselClick = (item, event) => {
router.push({ router.push({
path: "/companyprofildetail", path: "/companyprofildetail",
query: { query: {
title: item.title, titleNo: item.titleNo ,
}, },
}); });
} }

View File

@ -11,13 +11,13 @@
</div> </div>
<div class="tabs"> <div class="tabs">
<div class="tab-item" :class="{ <div class="tab-item" :class="{
active: currentTab === 'home', active: currentTab == 'home',
}" @click="handleTabClick('home')"> }" @click="handleTabClick('home')">
{{ t("home.nav.home") }} {{ t("home.nav.home") }}
</div> </div>
<div class="tab-item" :class="{ <div class="tab-item" :class="{
active: active:
currentTab === currentTab ==
'companyprofil', 'companyprofil',
}" @click=" }" @click="
handleTabClick( handleTabClick(
@ -28,7 +28,7 @@
</div> </div>
<div class="tab-item" :class="{ <div class="tab-item" :class="{
active: active:
currentTab === 'businessintroduction', currentTab == 'businessintroduction',
}" @click=" }" @click="
handleTabClick('businessintroduction') handleTabClick('businessintroduction')
"> ">
@ -48,7 +48,7 @@
<main class="px-[490px] "> <main class="px-[490px] ">
<section <section
className="section-first " className="section-first "
v-if="state.pageTitle === t('companyprofildetail.article1.title')" v-if="state.titleNo == 1"
style="background: #fff" style="background: #fff"
> >
@ -72,7 +72,7 @@
<div <div
class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]" class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]"
> >
<div v-if="state.pageTitle === t('companyprofildetail.article1.title')"> <div v-if="state.titleNo == 1">
<p>{{ t('companyprofildetail.article1.content[0]') }}</p> <p>{{ t('companyprofildetail.article1.content[0]') }}</p>
<p>{{ t('companyprofildetail.article1.content[1]') }}</p> <p>{{ t('companyprofildetail.article1.content[1]') }}</p>
<p>{{ t('companyprofildetail.article1.content[2]') }}</p> <p>{{ t('companyprofildetail.article1.content[2]') }}</p>
@ -90,7 +90,7 @@
<section <section
className="section-sec" className="section-sec"
v-if="state.pageTitle === t('companyprofildetail.article2.title')" v-if="state.titleNo == 2"
style="background: #fff" style="background: #fff"
> >
<div class="flex flex-wrap justify-center relative z-10 relative z-10"> <div class="flex flex-wrap justify-center relative z-10 relative z-10">
@ -113,7 +113,7 @@
<div <div
class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]" class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]"
> >
<div v-if="state.pageTitle === t('companyprofildetail.article2.title')"> <div v-if="state.titleNo == 2">
<p>{{ t('companyprofildetail.article2.content[0]') }}</p> <p>{{ t('companyprofildetail.article2.content[0]') }}</p>
<p>{{ t('companyprofildetail.article2.content[1]') }}</p> <p>{{ t('companyprofildetail.article2.content[1]') }}</p>
<p>{{ t('companyprofildetail.article2.content[2]') }}</p> <p>{{ t('companyprofildetail.article2.content[2]') }}</p>
@ -129,7 +129,7 @@
<section <section
className="section-third" className="section-third"
v-if="state.pageTitle === t('companyprofildetail.article3.title')" v-if="state.titleNo == 3"
style="background: #fff" style="background: #fff"
> >
<div class="flex flex-wrap justify-center relative z-10 relative z-10"> <div class="flex flex-wrap justify-center relative z-10 relative z-10">
@ -152,7 +152,7 @@
<div <div
class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]" class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]"
> >
<div v-if="state.pageTitle === t('companyprofildetail.article3.title')"> <div v-if="state.titleNo == 3">
<p>{{ t('companyprofildetail.article3.content[0]') }}</p> <p>{{ t('companyprofildetail.article3.content[0]') }}</p>
<p>{{ t('companyprofildetail.article3.content[1]') }}</p> <p>{{ t('companyprofildetail.article3.content[1]') }}</p>
<p>{{ t('companyprofildetail.article3.content[2]') }}</p> <p>{{ t('companyprofildetail.article3.content[2]') }}</p>
@ -169,7 +169,7 @@
<section <section
className="section-four" className="section-four"
v-if="state.pageTitle === t('companyprofildetail.article4.title')" v-if="state.titleNo == 4"
style="background: #fff" style="background: #fff"
> >
<div class="flex flex-wrap justify-center relative z-10 relative z-10"> <div class="flex flex-wrap justify-center relative z-10 relative z-10">
@ -192,7 +192,7 @@
<div <div
class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]" class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]"
> >
<div v-if="state.pageTitle === t('companyprofildetail.article4.title')"> <div v-if="state.titleNo == 4">
<p>{{ t('companyprofildetail.article4.content[0]') }}</p> <p>{{ t('companyprofildetail.article4.content[0]') }}</p>
<p>{{ t('companyprofildetail.article4.content[1]') }}</p> <p>{{ t('companyprofildetail.article4.content[1]') }}</p>
<p>{{ t('companyprofildetail.article4.content[2]') }}</p> <p>{{ t('companyprofildetail.article4.content[2]') }}</p>
@ -209,7 +209,7 @@
<section <section
className="section-five" className="section-five"
v-if="state.pageTitle === t('companyprofildetail.article5.title')" v-if="state.titleNo == 5"
style="background: #fff" style="background: #fff"
> >
<div class="flex flex-wrap justify-center relative z-10 relative z-10"> <div class="flex flex-wrap justify-center relative z-10 relative z-10">
@ -232,7 +232,7 @@
<div <div
class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]" class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]"
> >
<div v-if="state.pageTitle === t('companyprofildetail.article5.title')"> <div v-if="state.titleNo == 5">
<p>{{ t('companyprofildetail.article5.content[0]') }}</p> <p>{{ t('companyprofildetail.article5.content[0]') }}</p>
<p>{{ t('companyprofildetail.article5.content[1]') }}</p> <p>{{ t('companyprofildetail.article5.content[1]') }}</p>
<p>{{ t('companyprofildetail.article5.content[2]') }}</p> <p>{{ t('companyprofildetail.article5.content[2]') }}</p>
@ -290,20 +290,20 @@ const {
const router = useRouter(); const router = useRouter();
const state = reactive({ const state = reactive({
pageTitle: "", titleNo: "",
}); });
const currentArticleContent = computed(() => { const currentArticleContent = computed(() => {
const messages = t('companyprofildetail', {}, { resolveComponent: false }); const messages = t('companyprofildetail', {}, { resolveComponent: false });
if (state.pageTitle === messages.article1.title) { if (state.pageTitle == messages.article1.title) {
return messages.article1.content; return messages.article1.content;
} else if (state.pageTitle === messages.article2.title) { } else if (state.pageTitle == messages.article2.title) {
return messages.article2.content; return messages.article2.content;
} else if (state.pageTitle === messages.article3.title) { } else if (state.pageTitle == messages.article3.title) {
return messages.article3.content; return messages.article3.content;
} else if (state.pageTitle === messages.article4.title) { } else if (state.pageTitle == messages.article4.title) {
return messages.article4.content; return messages.article4.content;
} else if (state.pageTitle === messages.article5.title) { } else if (state.pageTitle == messages.article5.title) {
return messages.article5.content; return messages.article5.content;
} }
return []; return [];
@ -316,7 +316,7 @@ const handleTabClick = (tab) => {
const { currentTab } = useHome(); const { currentTab } = useHome();
const route = useRoute(); const route = useRoute();
onBeforeMount(() => { onBeforeMount(() => {
state.pageTitle = route.query.title; state.titleNo = route.query.titleNo;
}); });
onMounted(() => { onMounted(() => {
window.scrollTo(0, 0); window.scrollTo(0, 0);

View File

@ -11,13 +11,13 @@
</div> </div>
<div class="tabs"> <div class="tabs">
<div class="tab-item" :class="{ <div class="tab-item" :class="{
active: currentTab === 'home', active: currentTab == 'home',
}" @click="handleTabClick('home')"> }" @click="handleTabClick('home')">
{{ t("home.nav.home") }} {{ t("home.nav.home") }}
</div> </div>
<div class="tab-item" :class="{ <div class="tab-item" :class="{
active: active:
currentTab === currentTab ==
'companyprofil', 'companyprofil',
}" @click=" }" @click="
handleTabClick( handleTabClick(
@ -28,7 +28,7 @@
</div> </div>
<div class="tab-item" :class="{ <div class="tab-item" :class="{
active: active:
currentTab === 'businessintroduction', currentTab == 'businessintroduction',
}" @click=" }" @click="
handleTabClick('businessintroduction') handleTabClick('businessintroduction')
"> ">
@ -48,7 +48,7 @@
<main class="px-[490px] "> <main class="px-[490px] ">
<section <section
className="section-first " className="section-first "
v-if="state.pageTitle === t('companyprofildetail.article1.title')" v-if="state.titleNo == 1"
style="background: #fff" style="background: #fff"
> >
@ -72,7 +72,7 @@
<div <div
class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]" class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]"
> >
<div v-if="state.pageTitle === t('companyprofildetail.article1.title')"> <div v-if="state.titleNo == 1">
<p>{{ t('companyprofildetail.article1.content[0]') }}</p> <p>{{ t('companyprofildetail.article1.content[0]') }}</p>
<p>{{ t('companyprofildetail.article1.content[1]') }}</p> <p>{{ t('companyprofildetail.article1.content[1]') }}</p>
<p>{{ t('companyprofildetail.article1.content[2]') }}</p> <p>{{ t('companyprofildetail.article1.content[2]') }}</p>
@ -90,7 +90,7 @@
<section <section
className="section-sec" className="section-sec"
v-if="state.pageTitle === t('companyprofildetail.article2.title')" v-if="state.titleNo == 2"
style="background: #fff" style="background: #fff"
> >
<div class="flex flex-wrap justify-center relative z-10 relative z-10"> <div class="flex flex-wrap justify-center relative z-10 relative z-10">
@ -113,7 +113,7 @@
<div <div
class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]" class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]"
> >
<div v-if="state.pageTitle === t('companyprofildetail.article2.title')"> <div v-if="state.titleNo == 2">
<p>{{ t('companyprofildetail.article2.content[0]') }}</p> <p>{{ t('companyprofildetail.article2.content[0]') }}</p>
<p>{{ t('companyprofildetail.article2.content[1]') }}</p> <p>{{ t('companyprofildetail.article2.content[1]') }}</p>
<p>{{ t('companyprofildetail.article2.content[2]') }}</p> <p>{{ t('companyprofildetail.article2.content[2]') }}</p>
@ -129,7 +129,7 @@
<section <section
className="section-third" className="section-third"
v-if="state.pageTitle === t('companyprofildetail.article3.title')" v-if="state.titleNo == 3"
style="background: #fff" style="background: #fff"
> >
<div class="flex flex-wrap justify-center relative z-10 relative z-10"> <div class="flex flex-wrap justify-center relative z-10 relative z-10">
@ -152,7 +152,7 @@
<div <div
class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]" class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]"
> >
<div v-if="state.pageTitle === t('companyprofildetail.article3.title')"> <div v-if="state.titleNo == 3">
<p>{{ t('companyprofildetail.article3.content[0]') }}</p> <p>{{ t('companyprofildetail.article3.content[0]') }}</p>
<p>{{ t('companyprofildetail.article3.content[1]') }}</p> <p>{{ t('companyprofildetail.article3.content[1]') }}</p>
<p>{{ t('companyprofildetail.article3.content[2]') }}</p> <p>{{ t('companyprofildetail.article3.content[2]') }}</p>
@ -169,7 +169,7 @@
<section <section
className="section-four" className="section-four"
v-if="state.pageTitle === t('companyprofildetail.article4.title')" v-if="state.titleNo == 4"
style="background: #fff" style="background: #fff"
> >
<div class="flex flex-wrap justify-center relative z-10 relative z-10"> <div class="flex flex-wrap justify-center relative z-10 relative z-10">
@ -192,7 +192,7 @@
<div <div
class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]" class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]"
> >
<div v-if="state.pageTitle === t('companyprofildetail.article4.title')"> <div v-if="state.titleNo == 4">
<p>{{ t('companyprofildetail.article4.content[0]') }}</p> <p>{{ t('companyprofildetail.article4.content[0]') }}</p>
<p>{{ t('companyprofildetail.article4.content[1]') }}</p> <p>{{ t('companyprofildetail.article4.content[1]') }}</p>
<p>{{ t('companyprofildetail.article4.content[2]') }}</p> <p>{{ t('companyprofildetail.article4.content[2]') }}</p>
@ -209,7 +209,7 @@
<section <section
className="section-five" className="section-five"
v-if="state.pageTitle === t('companyprofildetail.article5.title')" v-if="state.titleNo == 5"
style="background: #fff" style="background: #fff"
> >
<div class="flex flex-wrap justify-center relative z-10 relative z-10"> <div class="flex flex-wrap justify-center relative z-10 relative z-10">
@ -232,7 +232,7 @@
<div <div
class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]" class="w-full px-[20px] text-[#455363] text-[16px] div-indent mt-[47px] mb-[275px]"
> >
<div v-if="state.pageTitle === t('companyprofildetail.article5.title')"> <div v-if="state.titleNo == 5">
<p>{{ t('companyprofildetail.article5.content[0]') }}</p> <p>{{ t('companyprofildetail.article5.content[0]') }}</p>
<p>{{ t('companyprofildetail.article5.content[1]') }}</p> <p>{{ t('companyprofildetail.article5.content[1]') }}</p>
<p>{{ t('companyprofildetail.article5.content[2]') }}</p> <p>{{ t('companyprofildetail.article5.content[2]') }}</p>
@ -290,20 +290,20 @@ const {
const router = useRouter(); const router = useRouter();
const state = reactive({ const state = reactive({
pageTitle: "", titleNo: "",
}); });
const currentArticleContent = computed(() => { const currentArticleContent = computed(() => {
const messages = t('companyprofildetail', {}, { resolveComponent: false }); const messages = t('companyprofildetail', {}, { resolveComponent: false });
if (state.pageTitle === messages.article1.title) { if (state.pageTitle == messages.article1.title) {
return messages.article1.content; return messages.article1.content;
} else if (state.pageTitle === messages.article2.title) { } else if (state.pageTitle == messages.article2.title) {
return messages.article2.content; return messages.article2.content;
} else if (state.pageTitle === messages.article3.title) { } else if (state.pageTitle == messages.article3.title) {
return messages.article3.content; return messages.article3.content;
} else if (state.pageTitle === messages.article4.title) { } else if (state.pageTitle == messages.article4.title) {
return messages.article4.content; return messages.article4.content;
} else if (state.pageTitle === messages.article5.title) { } else if (state.pageTitle == messages.article5.title) {
return messages.article5.content; return messages.article5.content;
} }
return []; return [];
@ -316,7 +316,7 @@ const handleTabClick = (tab) => {
const { currentTab } = useHome(); const { currentTab } = useHome();
const route = useRoute(); const route = useRoute();
onBeforeMount(() => { onBeforeMount(() => {
state.pageTitle = route.query.title; state.titleNo = route.query.titleNo;
}); });
onMounted(() => { onMounted(() => {
window.scrollTo(0, 0); window.scrollTo(0, 0);