From 1ccb1ca6c5f97159f880ba039301d9e63141ab16 Mon Sep 17 00:00:00 2001 From: Qi <3194726156@qq.com> Date: Fri, 28 Mar 2025 15:20:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=8F=9C=E5=8D=95=E6=A0=8F?= =?UTF-8?q?=E3=80=81=E7=9F=A5=E8=AF=86=E5=BA=93=E8=83=8C=E6=99=AF=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/customer/CustomerDashboard.vue | 272 ++++++++++++++++++++--- src/views/customer/knowledgeBase.vue | 179 ++++++++++----- 2 files changed, 355 insertions(+), 96 deletions(-) diff --git a/src/views/customer/CustomerDashboard.vue b/src/views/customer/CustomerDashboard.vue index 34c0a7d..8e26444 100644 --- a/src/views/customer/CustomerDashboard.vue +++ b/src/views/customer/CustomerDashboard.vue @@ -3,20 +3,53 @@

中医药与心理健康

@@ -41,23 +74,31 @@ export default { name: 'CustomerDashboard', data () { return { - userAvatar: require('@/assets/user/1.jpg') + userAvatar: require('@/assets/user/1.jpg'), + showDropdown: '', + currentActive: '' } }, computed: { activeIndex () { - const path = this.$route.path - // 设置主菜单路径映射 - if (path.includes('/customer/knowledge-base') || path.includes('/customer/wellness-guide')) { - return '/customer/education' - } else if (path.includes('/customer/psychological-test') || path.includes('/customer/questionnaire')) { - return '/customer/assessment' - } else { - return path + // 如果当前有手动设置的活动项,优先使用 + if (this.currentActive) { + return this.currentActive } + + return this.$route.path } }, methods: { + handleNavigation (path) { + this.currentActive = path + this.$router.push(path) + // 不要立即隐藏下拉菜单,以便用户可以看到高亮效果 + // 采用延迟关闭方式 + setTimeout(() => { + this.showDropdown = '' + }, 300) + }, logout () { this.$router.push('/login') } @@ -89,33 +130,137 @@ export default { margin: 0 15px; } -.el-menu { +.custom-menu { display: flex; - background-color: transparent !important; - border: none; width: 100%; justify-content: center; + position: relative; } -.el-menu-item { +.menu-item { font-size: 15px; height: 56px; line-height: 56px; margin: 0 15px; padding: 0 10px; + cursor: pointer; + position: relative; + transition: all 0.3s; + border-bottom: 2px solid transparent; } -.el-sub-menu { - margin: 0 15px; +.menu-item.active, .dropdown-item.active { + color: #ffd04b; + background-color: rgba(255, 255, 255, 0.2); + border-bottom: 2px solid #ffd04b; } -.el-menu-item.is-active { - color: #ffd04b !important; - background-color: rgba(255, 255, 255, 0.2) !important; +.menu-item:hover { + color: #ffd04b; + background-color: rgba(255, 255, 255, 0.2); } -.el-menu-item:hover { - background: rgba(255, 255, 255, 0.2) !important; +.dropdown { + position: relative; +} + +.dropdown-title { + display: flex; + align-items: center; +} + +.dropdown-title:after { + content: ''; + display: inline-block; + margin-left: 5px; + border-top: 5px solid #fff; + border-right: 5px solid transparent; + border-left: 5px solid transparent; + transition: all 0.3s; +} + +.active .dropdown-title:after, +.dropdown:hover .dropdown-title:after { + border-top-color: #ffd04b; +} + +.dropdown-menu { + position: absolute; + top: 100%; + left: 50%; + transform: translateX(-50%); + min-width: 180px; + background: #ffffff; + box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.08), + 0 9px 28px 0 rgba(0, 0, 0, 0.05), + 0 12px 48px 16px rgba(0, 0, 0, 0.03); + border-radius: 4px; + z-index: 10; + padding: 4px 0; + margin-top: 8px; + transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1); +} + +.dropdown-menu:before, .dropdown-menu:after { + content: ''; + position: absolute; + left: 50%; + transform: translateX(-50%); +} + +.dropdown-menu:before { + top: -8px; + border-left: 8px solid transparent; + border-right: 8px solid transparent; + border-bottom: 8px solid rgba(0, 0, 0, 0.06); +} + +.dropdown-menu:after { + top: -7px; + border-left: 7px solid transparent; + border-right: 7px solid transparent; + border-bottom: 7px solid white; +} + +.dropdown-item { + color: #606266; + padding: 8px 16px; + line-height: 1.5; + cursor: pointer; + transition: all 0.15s; + font-size: 14px; + position: relative; + text-align: center; + white-space: nowrap; +} + +.dropdown-item.active { + background-color: rgba(76, 175, 80, 0.1); + color: #4CAF50; + font-weight: 500; + position: relative; + border-radius: 3px; +} + +.dropdown-item.active:before { + content: ''; + position: absolute; + left: 0; + top: 50%; + width: 4px; + height: 70%; + transform: translateY(-50%); + background-color: #4CAF50; + border-radius: 0 2px 2px 0; +} + +.dropdown-item:hover { + background-color: rgba(76, 175, 80, 0.05); + color: #4CAF50; +} + +.dropdown-item:active { + background-color: rgba(76, 175, 80, 0.15); } .user-avatar-container { @@ -149,11 +294,12 @@ export default { margin: 10px 0; } - .el-menu { + .custom-menu { width: 100%; + flex-wrap: wrap; } - .el-menu-item, .el-sub-menu { + .menu-item { margin: 0 5px; } @@ -163,5 +309,59 @@ export default { right: 0.5rem; margin-left: 0; } + + .dropdown-menu { + width: 100%; + } +} + + + diff --git a/src/views/customer/knowledgeBase.vue b/src/views/customer/knowledgeBase.vue index bd6934c..400dd62 100644 --- a/src/views/customer/knowledgeBase.vue +++ b/src/views/customer/knowledgeBase.vue @@ -66,22 +66,26 @@
@@ -368,25 +372,66 @@ export default { .knowledge-cover { position: relative; - height: 40vh; - min-height: 300px; - max-height: 500px; + height: 45vh; + min-height: 320px; + max-height: 550px; overflow: hidden; background-color: #000; width: 100%; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); } .cover-image { width: 100%; height: 100%; object-fit: cover; - opacity: 0.7; + opacity: 0.8; + position: absolute; + top: 0; + left: 0; + z-index: 0; + object-position: center top; +} + +.search-box { + position: absolute; + bottom: 60px; + left: 50%; + transform: translateX(-50%); + width: 80%; + max-width: 650px; + z-index: 2; +} + +.search-box .el-input { + border-radius: 8px; + overflow: hidden; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); +} + +.search-box .el-input >>> .el-input__inner { + height: 50px; + border-radius: 8px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); + font-size: 16px; + padding-left: 40px; +} + +.knowledge-cover::after { + content: ''; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: linear-gradient(rgba(0,0,0,0.3), rgba(0,0,0,0.6)); + z-index: 1; } .title-area { position: absolute; left: 0; - top: 30%; + top: 35%; width: 100%; text-align: center; color: #fff; @@ -410,29 +455,6 @@ export default { margin-right: auto; } -.search-box { - position: absolute; - bottom: 50px; - left: 50%; - transform: translateX(-50%); - width: 80%; - max-width: 600px; - z-index: 10; -} - -.search-box .el-input { - border-radius: 8px; - overflow: hidden; -} - -.search-box .el-input >>> .el-input__inner { - height: 50px; - border-radius: 8px; - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); - font-size: 16px; - padding-left: 40px; -} - .knowledge-content { padding: 50px 0 30px; width: 100%; @@ -557,31 +579,51 @@ export default { } .item-images { - display: grid; - grid-template-columns: repeat(3, 1fr); - gap: 10px; margin-bottom: 20px; + width: 100%; +} + +.single-image-container { + width: 100%; + display: flex; + justify-content: center; + margin-bottom: 15px; } .single-image { max-width: 100%; - height: auto; + border-radius: 8px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); max-height: 400px; + object-fit: contain; +} + +.image-grid { + display: grid; + gap: 10px; + width: 100%; +} + +.grid-count-2 { + grid-template-columns: repeat(2, 1fr); +} + +.grid-count-3 { + grid-template-columns: repeat(3, 1fr); +} + +.grid-count-4, .grid-count-many { + grid-template-columns: repeat(2, 1fr); +} + +.grid-image-container { + aspect-ratio: 1 / 1; border-radius: 8px; overflow: hidden; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); } .grid-image { - width: 100%; - height: 0; - padding-bottom: 100%; - position: relative; - border-radius: 8px; - overflow: hidden; -} - -.grid-image img { - position: absolute; width: 100%; height: 100%; object-fit: cover; @@ -721,6 +763,27 @@ export default { color: #333; } +@media screen and (min-width: 768px) { + .grid-count-3, .grid-count-many { + grid-template-columns: repeat(3, 1fr); + } + + .grid-count-4 { + grid-template-columns: repeat(2, 1fr); + grid-template-rows: repeat(2, 1fr); + } +} + +@media screen and (max-width: 576px) { + .grid-count-2, .grid-count-3, .grid-count-4, .grid-count-many { + grid-template-columns: repeat(2, 1fr); + } + + .single-image { + max-height: 300px; + } +} + @media screen and (max-width: 768px) { .knowledge-content { padding: 50px 15px 30px; @@ -734,10 +797,6 @@ export default { width: 90%; } - .item-images { - grid-template-columns: repeat(2, 1fr); - } - .page-title { font-size: 28px; }