Showing
4 changed files
with
207 additions
and
10 deletions
| ... | @@ -21,6 +21,8 @@ declare module 'vue' { | ... | @@ -21,6 +21,8 @@ declare module 'vue' { |
| 21 | ElOption: typeof import('element-ui/lib/option')['default'] | 21 | ElOption: typeof import('element-ui/lib/option')['default'] |
| 22 | ElRow: typeof import('element-ui/lib/row')['default'] | 22 | ElRow: typeof import('element-ui/lib/row')['default'] |
| 23 | ElSelect: typeof import('element-ui/lib/select')['default'] | 23 | ElSelect: typeof import('element-ui/lib/select')['default'] |
| 24 | + ElTabPane: typeof import('element-ui/lib/tab-pane')['default'] | ||
| 25 | + ElTabs: typeof import('element-ui/lib/tabs')['default'] | ||
| 24 | ElTooltip: typeof import('element-ui/lib/tooltip')['default'] | 26 | ElTooltip: typeof import('element-ui/lib/tooltip')['default'] |
| 25 | HagerBox: typeof import('./src/components/common/hagerBox.vue')['default'] | 27 | HagerBox: typeof import('./src/components/common/hagerBox.vue')['default'] |
| 26 | HagerCarousel: typeof import('./src/components/hagerCarousel.vue')['default'] | 28 | HagerCarousel: typeof import('./src/components/hagerCarousel.vue')['default'] | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2024-08-26 10:42:15 | 2 | * @Date: 2024-08-26 10:42:15 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-10-18 18:16:17 | 4 | + * @LastEditTime: 2024-10-20 17:01:09 |
| 5 | * @FilePath: /hager/src/route.js | 5 | * @FilePath: /hager/src/route.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -186,4 +186,13 @@ export default [{ | ... | @@ -186,4 +186,13 @@ export default [{ |
| 186 | }, | 186 | }, |
| 187 | }, | 187 | }, |
| 188 | ] | 188 | ] |
| 189 | +}, { | ||
| 190 | + path: '/search', | ||
| 191 | + name: '搜索结果', | ||
| 192 | + component: () => import('@/views/search'), | ||
| 193 | + meta: { | ||
| 194 | + title: '海格电器', | ||
| 195 | + tag: 'search' | ||
| 196 | + }, | ||
| 197 | + children: [] | ||
| 189 | }] | 198 | }] | ... | ... |
| ... | @@ -129,15 +129,15 @@ export default { | ... | @@ -129,15 +129,15 @@ export default { |
| 129 | } | 129 | } |
| 130 | } | 130 | } |
| 131 | .product-item-img { | 131 | .product-item-img { |
| 132 | - background-color: #f5f5f5; | 132 | + background-color: #f5f5f5; |
| 133 | - display: flex; | 133 | + display: flex; |
| 134 | - align-items: center; | 134 | + align-items: center; |
| 135 | - justify-content: center; | 135 | + justify-content: center; |
| 136 | - height: 18rem; | 136 | + height: 18rem; |
| 137 | - padding: 3rem; | 137 | + padding: 3rem; |
| 138 | - box-sizing: border-box; | 138 | + box-sizing: border-box; |
| 139 | - border-radius: 8px; | 139 | + border-radius: 8px; |
| 140 | - } | 140 | + } |
| 141 | .product-item-title { | 141 | .product-item-title { |
| 142 | text-align: center; | 142 | text-align: center; |
| 143 | margin-top: 0.75rem; | 143 | margin-top: 0.75rem; | ... | ... |
src/views/search.vue
0 → 100644
| 1 | +<!-- | ||
| 2 | + * @Date: 2024-10-20 16:57:48 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2024-10-20 18:28:43 | ||
| 5 | + * @FilePath: /hager/src/views/search.vue | ||
| 6 | + * @Description: 文件描述 | ||
| 7 | +--> | ||
| 8 | +<template> | ||
| 9 | + <div class="hager-search-page"> | ||
| 10 | + <hager-box> | ||
| 11 | + <div class="search-title">与“{{ keyword }}”相关的搜索结果</div> | ||
| 12 | + <el-tabs v-model="activeName" @tab-click="handleClick"> | ||
| 13 | + <el-tab-pane name="product"> | ||
| 14 | + <div slot="label" class="customer-label">产品 <span>2</span></div> | ||
| 15 | + <div class="search-product-list"> | ||
| 16 | + <div class="search-product-item" v-for="(item, index) in 6" :key="index"> | ||
| 17 | + <div class="search-product-item-img"> | ||
| 18 | + <el-image style="width: 100%; height: 100%;" src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg" fit="fit"></el-image> | ||
| 19 | + </div> | ||
| 20 | + <p @click="goToP(item)" class="search-product-item-title">acb hw 空气断路器</p> | ||
| 21 | + </div> | ||
| 22 | + </div> | ||
| 23 | + <div style="height: 5rem;"></div> | ||
| 24 | + </el-tab-pane> | ||
| 25 | + <el-tab-pane name="news"> | ||
| 26 | + <div slot="label" class="customer-label">新闻和解决方案 <span>3</span></div> | ||
| 27 | + <div style="margin-top: 1rem;" v-for="(item, index) in news_list" :key="index"> | ||
| 28 | + <el-breadcrumb separator="/"> | ||
| 29 | + <el-breadcrumb-item>首页</el-breadcrumb-item> | ||
| 30 | + <el-breadcrumb-item>新闻中心</el-breadcrumb-item> | ||
| 31 | + </el-breadcrumb> | ||
| 32 | + <div class="search-news-wrapper"> | ||
| 33 | + <div class="search-news-title" v-html="highlightKeyword(keyword, item.title)"></div> | ||
| 34 | + <div class="search-news-content" v-html="highlightKeyword(keyword, item.content)"></div> | ||
| 35 | + <div class="search-news-more"> | ||
| 36 | + <div class="search-news-more-btn" @click="goTo(item.id)">MORE</div> | ||
| 37 | + </div> | ||
| 38 | + </div> | ||
| 39 | + </div> | ||
| 40 | + </el-tab-pane> | ||
| 41 | + </el-tabs> | ||
| 42 | + </hager-box> | ||
| 43 | + </div> | ||
| 44 | +</template> | ||
| 45 | + | ||
| 46 | +<script> | ||
| 47 | +import mixin from 'common/mixin'; | ||
| 48 | +import hagerBox from '@/components/common/hagerBox'; | ||
| 49 | +import $ from 'jquery'; | ||
| 50 | + | ||
| 51 | +export default { | ||
| 52 | + components: { hagerBox }, | ||
| 53 | + mixins: [mixin.init], | ||
| 54 | + data () { | ||
| 55 | + return { | ||
| 56 | + activeName: 'product', | ||
| 57 | + keyword: this.$route.query.keyword, | ||
| 58 | + news_list: [{ | ||
| 59 | + id: '123', | ||
| 60 | + title: '海格电气全新智能型hw+空气断路器重磅上市', | ||
| 61 | + content: '11 月 24 日,海格电气在惠州举办了 2023 海格匠心之旅暨 hw+ 全系列新品发布会,面向中国市场正式推出了全新一代智能型 hw+ 空气断路器。海格电气管理层及员工代表,行业客户及合作伙伴等齐聚惠州工厂,共同见证海格电气新一代', | ||
| 62 | + }, { | ||
| 63 | + id: '456', | ||
| 64 | + title: '里程碑时刻!海格电气首台全新一代HW+空气断路器', | ||
| 65 | + content: '全新一代HW+空气断路器的整机下线,标志着海格电气在低压配电领域的进一步技术升级。作为海格电气在中国市场重磅推出的里程碑式产品,全新一代HW+空气断路器为大型建筑复杂、高负荷的用电需求提供高质量解决方案。', | ||
| 66 | + }] | ||
| 67 | + } | ||
| 68 | + }, | ||
| 69 | + mounted () { | ||
| 70 | + }, | ||
| 71 | + methods: { | ||
| 72 | + handleClick(tab, event) { | ||
| 73 | + console.log(tab, event); | ||
| 74 | + }, | ||
| 75 | + highlightKeyword (keyword, text) { | ||
| 76 | + // 创建一个正则表达式来查找关键词 | ||
| 77 | + var regex = new RegExp(`(${keyword})`, 'gi'); | ||
| 78 | + | ||
| 79 | + // 用 <span> 标签替换匹配到的关键词并加上高亮类 | ||
| 80 | + var highlightedText = text.replace(regex, '<span style="color: #00ABE5;">$1</span>'); | ||
| 81 | + | ||
| 82 | + return highlightedText; | ||
| 83 | + }, | ||
| 84 | + goTo (id) { | ||
| 85 | + this.$router.push({ | ||
| 86 | + path: '/news/detail', | ||
| 87 | + query: { | ||
| 88 | + id: id | ||
| 89 | + } | ||
| 90 | + }); | ||
| 91 | + } | ||
| 92 | + } | ||
| 93 | +} | ||
| 94 | +</script> | ||
| 95 | + | ||
| 96 | +<style lang="less" scoped> | ||
| 97 | + .hager-search-page { | ||
| 98 | + .search-title { | ||
| 99 | + font-size: 1.25rem; | ||
| 100 | + color: @secondary-color; | ||
| 101 | + margin: 2rem 0; | ||
| 102 | + font-weight: bold; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + .search-product-list { | ||
| 106 | + display: flex; | ||
| 107 | + flex-wrap: wrap; | ||
| 108 | + gap: 1rem; | ||
| 109 | + margin-top: 1rem; | ||
| 110 | + } | ||
| 111 | + .search-product-item { | ||
| 112 | + width: calc(33.33% - 1rem); | ||
| 113 | + &.xs { | ||
| 114 | + width: calc(50% - 1rem); | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + .search-product-item-img { | ||
| 118 | + background-color: #FFF; | ||
| 119 | + display: flex; | ||
| 120 | + align-items: center; | ||
| 121 | + justify-content: center; | ||
| 122 | + height: 18rem; | ||
| 123 | + padding: 3rem; | ||
| 124 | + box-sizing: border-box; | ||
| 125 | + border-radius: 5px; | ||
| 126 | + border: 1px solid #ECECEC; | ||
| 127 | + } | ||
| 128 | + .search-product-item-title { | ||
| 129 | + text-align: center; | ||
| 130 | + margin-top: 0.75rem; | ||
| 131 | + color: @text-color; | ||
| 132 | + &:hover { | ||
| 133 | + cursor: pointer; | ||
| 134 | + text-decoration: underline; | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + .search-news-wrapper { | ||
| 139 | + margin: 1.5rem 0; | ||
| 140 | + .search-news-title { | ||
| 141 | + font-size: 1.15rem; | ||
| 142 | + font-weight: bold; | ||
| 143 | + margin-bottom: 1rem; | ||
| 144 | + } | ||
| 145 | + .search-news-content { | ||
| 146 | + line-height: 2rem; | ||
| 147 | + } | ||
| 148 | + .search-news-more { | ||
| 149 | + display: flex; | ||
| 150 | + justify-content: flex-end; | ||
| 151 | + .search-news-more-btn { | ||
| 152 | + color: #F56400; | ||
| 153 | + padding: 0.5rem 2rem; | ||
| 154 | + border: 1px solid #F56400; | ||
| 155 | + &:hover { | ||
| 156 | + cursor: pointer; | ||
| 157 | + } | ||
| 158 | + } | ||
| 159 | + } | ||
| 160 | + } | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + :deep(.el-tabs__item.is-active, ) { | ||
| 164 | + color: @secondary-color; | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + :deep(.el-tabs__active-bar) { | ||
| 168 | + background-color: @secondary-color; | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + :deep(.el-tabs__item:hover) { | ||
| 172 | + color: @secondary-color; | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + :deep(.el-tabs__item) { | ||
| 176 | + color: @text-color; | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + .customer-label { | ||
| 180 | + font-size: 0.95rem; | ||
| 181 | + padding: 0 0.5rem; | ||
| 182 | + span { | ||
| 183 | + color: #F56400; | ||
| 184 | + } | ||
| 185 | + } | ||
| 186 | +</style> |
-
Please register or login to post a comment