This commit is contained in:
hrx 2025-12-12 17:31:54 +08:00
parent 5416dac356
commit fec769fe4d
8 changed files with 331 additions and 21 deletions

View File

@ -4,7 +4,22 @@
<div class="top-tit"> <div class="top-tit">
开元云 开元云
</div> </div>
<!-- 搜索 -->
<div class="search">
<div class="search-box">
<div class="input">
<input
type="text"
placeholder="请输入产品名称"
v-model="searchValue"
@keyup.enter="handleSearch"
/>
</div>
<div class="search-btn" @click="handleSearch">
搜索
</div>
</div>
</div>
<!-- 供应商 --> <!-- 供应商 -->
<div v-if="cloudData.secMenu && cloudData.secMenu.length > 0" class="supplier-container"> <div v-if="cloudData.secMenu && cloudData.secMenu.length > 0" class="supplier-container">
<div <div
@ -32,6 +47,7 @@
v-for="product in thrMenu.value" v-for="product in thrMenu.value"
:key="product.id" :key="product.id"
class="box-item" class="box-item"
v-show="shouldShowProduct(product)"
> >
<!-- 标题 --> <!-- 标题 -->
<div class="item-tit"> <div class="item-tit">
@ -83,6 +99,8 @@ export default {
return { return {
cloudData: {}, cloudData: {},
activeSupplierIndex: 0, // activeSupplierIndex: 0, //
searchValue: '', //
isSearching: false, //
// //
showConsultDialog: false, showConsultDialog: false,
@ -116,6 +134,26 @@ export default {
} }
}, },
//
handleSearch() {
this.isSearching = !!this.searchValue.trim()
// API
console.log('搜索关键词:', this.searchValue)
},
//
shouldShowProduct(product) {
if (!this.isSearching) {
return true
}
//
const keyword = this.searchValue.toLowerCase().trim()
return (
(product.name && product.name.toLowerCase().includes(keyword)) ||
(product.description && product.description.toLowerCase().includes(keyword))
)
},
// //
selectSupplier(index) { selectSupplier(index) {
this.activeSupplierIndex = index this.activeSupplierIndex = index

View File

@ -4,6 +4,22 @@
<div class="top-tit"> <div class="top-tit">
开元云 开元云
</div> </div>
<!-- 搜索 -->
<div class="search">
<div class="search-box">
<div class="input">
<input
type="text"
placeholder="请输入产品名称"
v-model="searchValue"
@keyup.enter="handleSearch"
/>
</div>
<div class="search-btn" @click="handleSearch">
搜索
</div>
</div>
</div>
<!-- 供应商 --> <!-- 供应商 -->
<div class="supplier-container"> <div class="supplier-container">
@ -19,7 +35,7 @@
<!-- 只显示当前选中的供应商的产品 --> <!-- 只显示当前选中的供应商的产品 -->
<template v-if="cloudData.secMenu && cloudData.secMenu.length > 0 && activeSupplierIndex >= 0"> <template v-if="cloudData.secMenu && cloudData.secMenu.length > 0 && activeSupplierIndex >= 0">
<template v-for="thrMenu in cloudData.secMenu[activeSupplierIndex].thrMenu"> <template v-for="thrMenu in cloudData.secMenu[activeSupplierIndex].thrMenu">
<div v-for="product in thrMenu.value" :key="product.id" class="box-item"> <div v-for="product in thrMenu.value" :key="product.id" class="box-item" v-show="shouldShowProduct(product)">
<!-- 标题 --> <!-- 标题 -->
<div class="item-tit"> <div class="item-tit">
{{ product.name }} {{ product.name }}
@ -67,6 +83,8 @@ export default {
return { return {
cloudData: {}, cloudData: {},
activeSupplierIndex: 0, // activeSupplierIndex: 0, //
searchValue: '', //
isSearching: false, //
// //
showConsultDialog: false, showConsultDialog: false,
@ -98,6 +116,27 @@ export default {
} }
}, },
methods: { methods: {
//
handleSearch() {
this.isSearching = !!this.searchValue.trim()
console.log('搜索关键词:', this.searchValue)
},
//
shouldShowProduct(product) {
if (!this.isSearching) {
return true
}
//
const keyword = this.searchValue.toLowerCase().trim()
return (
(product.name && product.name.toLowerCase().includes(keyword)) ||
(product.description && product.description.toLowerCase().includes(keyword)) ||
(product.label && product.label.toLowerCase().includes(keyword)) ||
(product.ssecTitle && product.ssecTitle.toLowerCase().includes(keyword))
)
},
// //
showProductDesc(product) { showProductDesc(product) {
// label // label

View File

@ -111,8 +111,42 @@
.search { .search {
width: 100%; width: 100%;
margin: 0.2rem 0; margin: 0.2rem 0;
padding: 0.2rem;
}
.search .search-box {
display: flex; display: flex;
justify-content: space-between;
background-color: #f3f3f3;
border-radius: 0.24rem;
} }
.search .search-btn { .search .search-btn {
display: flex;
justify-content: center;
align-items: center;
font-size: 0.2rem; font-size: 0.2rem;
width: 18%;
color: #fff;
padding: 0.2rem 0;
background: linear-gradient(90deg, #1f70ff, #3a8cff);
border-bottom-right-radius: 0.24rem;
border-top-right-radius: 0.24rem;
font-size: 0.24rem;
}
.search .input {
width: 80%;
padding: 0.2rem 0;
padding-left: 0.2rem;
}
.search .input input {
border: none;
/* 去除边框 */
outline: none;
/* 去除焦点时的外框 */
background: none;
/* 去除背景色 */
padding: 0;
/* 去除内边距 */
margin: 0;
/* 去除外边距,根据需要设置 */
width: 100%;
} }

View File

@ -5,20 +5,24 @@
-webkit-background-clip: text; -webkit-background-clip: text;
-webkit-text-fill-color: transparent; -webkit-text-fill-color: transparent;
background-clip: text; background-clip: text;
font-size: .39rem; /* 增大30%: .3rem * 1.3 = .39rem */ font-size: .39rem;
/* 增大30%: .3rem * 1.3 = .39rem */
font-weight: bold; font-weight: bold;
margin: .3rem 0; margin: .3rem 0;
} }
.supplier-container { .supplier-container {
display: flex; display: flex;
flex-wrap: wrap; /* 允许换行 */ flex-wrap: wrap;
/* 允许换行 */
padding: .2rem .22rem; padding: .2rem .22rem;
gap: .15rem; /* 使用gap控制间距 */ gap: .15rem;
/* 使用gap控制间距 */
} }
.supplier { .supplier {
flex-shrink: 0; /* 防止收缩 */ flex-shrink: 0;
/* 防止收缩 */
.supplier-title { .supplier-title {
font-size: .28rem; font-size: .28rem;
@ -29,7 +33,8 @@
cursor: pointer; cursor: pointer;
transition: all 0.3s ease; transition: all 0.3s ease;
white-space: nowrap; /* 防止文字换行 */ white-space: nowrap;
/* 防止文字换行 */
&:hover { &:hover {
background-color: #e0e0e0; background-color: #e0e0e0;
@ -52,6 +57,7 @@
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-between; justify-content: space-between;
padding: 0 .3rem; padding: 0 .3rem;
.box-item { .box-item {
display: flex; display: flex;
width: 48%; width: 48%;
@ -69,19 +75,21 @@
border-color: #1f70ff; border-color: #1f70ff;
} }
.item-tit{ .item-tit {
font-size: .26rem; font-size: .26rem;
color: #000; color: #000;
font-weight: bold; font-weight: bold;
margin-bottom: .1rem; margin-bottom: .1rem;
} }
.item-detail{
.item-detail {
color: #666; color: #666;
font-size: .22rem; font-size: .22rem;
margin: .15rem 0; margin: .15rem 0;
line-height: 1.4; line-height: 1.4;
} }
.item-desc{
.item-desc {
color: #666; color: #666;
background-color: #f8f9fa; background-color: #f8f9fa;
font-size: .2rem; font-size: .2rem;
@ -90,11 +98,13 @@
margin-bottom: .15rem; margin-bottom: .15rem;
border: .01rem solid #e9ecef; border: .01rem solid #e9ecef;
} }
.item-btn{
.item-btn {
width: 100%; width: 100%;
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
.btn{
.btn {
background: linear-gradient(90deg, #1f70ff, #3a8cff); background: linear-gradient(90deg, #1f70ff, #3a8cff);
color: #fff; color: #fff;
padding: .08rem .2rem; padding: .08rem .2rem;
@ -113,11 +123,49 @@
} }
} }
} }
.search{
.search {
width: 100%; width: 100%;
margin: .2rem 0; margin: .2rem 0;
display: flex; padding: .2rem;
.search-btn{
.search-box {
display: flex;
justify-content: space-between;
background-color: #f3f3f3;
border-radius: .24rem;
}
.search-btn {
display: flex;
justify-content: center;
align-items: center;
font-size: .2rem; font-size: .2rem;
width: 18%;
color: #fff;
padding: .2rem 0;
background: linear-gradient(90deg, #1f70ff, #3a8cff);
border-bottom-right-radius: .24rem;
border-top-right-radius: .24rem;
font-size: .24rem;
}
.input {
width: 80%;
padding: .2rem 0;
padding-left: .2rem;
input {
border: none;
/* 去除边框 */
outline: none;
/* 去除焦点时的外框 */
background: none;
/* 去除背景色 */
padding: 0;
/* 去除内边距 */
margin: 0;
/* 去除外边距,根据需要设置 */
width: 100%;
}
} }
} }

View File

@ -117,3 +117,45 @@
transform: translateY(-0.02rem); transform: translateY(-0.02rem);
box-shadow: 0 0.04rem 0.1rem rgba(31, 112, 255, 0.3); box-shadow: 0 0.04rem 0.1rem rgba(31, 112, 255, 0.3);
} }
.search {
width: 100%;
margin: 0.2rem 0;
padding: 0.2rem;
}
.search .search-box {
display: flex;
justify-content: space-between;
background-color: #f3f3f3;
border-radius: 0.24rem;
}
.search .search-btn {
display: flex;
justify-content: center;
align-items: center;
font-size: 0.2rem;
width: 18%;
color: #fff;
padding: 0.2rem 0;
background: linear-gradient(90deg, #1f70ff, #3a8cff);
border-bottom-right-radius: 0.24rem;
border-top-right-radius: 0.24rem;
font-size: 0.24rem;
}
.search .input {
width: 80%;
padding: 0.2rem 0;
padding-left: 0.2rem;
}
.search .input input {
border: none;
/* 去除边框 */
outline: none;
/* 去除焦点时的外框 */
background: none;
/* 去除背景色 */
padding: 0;
/* 去除内边距 */
margin: 0;
/* 去除外边距,根据需要设置 */
width: 100%;
}

View File

@ -134,3 +134,48 @@
} }
} }
} }
.search {
width: 100%;
margin: .2rem 0;
padding: .2rem;
.search-box {
display: flex;
justify-content: space-between;
background-color: #f3f3f3;
border-radius: .24rem;
}
.search-btn {
display: flex;
justify-content: center;
align-items: center;
font-size: .2rem;
width: 18%;
color: #fff;
padding: .2rem 0;
background: linear-gradient(90deg, #1f70ff, #3a8cff);
border-bottom-right-radius: .24rem;
border-top-right-radius: .24rem;
font-size: .24rem;
}
.input {
width: 80%;
padding: .2rem 0;
padding-left: .2rem;
input {
border: none;
/* 去除边框 */
outline: none;
/* 去除焦点时的外框 */
background: none;
/* 去除背景色 */
padding: 0;
/* 去除内边距 */
margin: 0;
/* 去除外边距,根据需要设置 */
width: 100%;
}
}
}

View File

@ -4,7 +4,22 @@
<div class="top-tit"> <div class="top-tit">
开元云 开元云
</div> </div>
<!-- 搜索 -->
<div class="search">
<div class="search-box">
<div class="input">
<input
type="text"
placeholder="请输入产品名称"
v-model="searchValue"
@keyup.enter="handleSearch"
/>
</div>
<div class="search-btn" @click="handleSearch">
搜索
</div>
</div>
</div>
<!-- 供应商 --> <!-- 供应商 -->
<div v-if="cloudData.secMenu && cloudData.secMenu.length > 0" class="supplier-container"> <div v-if="cloudData.secMenu && cloudData.secMenu.length > 0" class="supplier-container">
<div <div
@ -32,6 +47,7 @@
v-for="product in thrMenu.value" v-for="product in thrMenu.value"
:key="product.id" :key="product.id"
class="box-item" class="box-item"
v-show="shouldShowProduct(product)"
> >
<!-- 标题 --> <!-- 标题 -->
<div class="item-tit"> <div class="item-tit">
@ -76,13 +92,14 @@ import { reqProductConsult } from '@/api/H5/index'
export default { export default {
components: { components: {
ProductConsultDialog, ProductConsultDialog,
}, },
data() { data() {
return { return {
cloudData: {}, cloudData: {},
activeSupplierIndex: 0, // activeSupplierIndex: 0, //
searchValue: '', //
isSearching: false, //
// //
showConsultDialog: false, showConsultDialog: false,
@ -116,6 +133,25 @@ export default {
} }
}, },
//
handleSearch() {
this.isSearching = !!this.searchValue.trim()
console.log('搜索关键词:', this.searchValue)
},
//
shouldShowProduct(product) {
if (!this.isSearching) {
return true
}
//
const keyword = this.searchValue.toLowerCase().trim()
return (
(product.name && product.name.toLowerCase().includes(keyword)) ||
(product.description && product.description.toLowerCase().includes(keyword))
)
},
// //
selectSupplier(index) { selectSupplier(index) {
this.activeSupplierIndex = index this.activeSupplierIndex = index

View File

@ -6,12 +6,19 @@
</div> </div>
<!-- 搜索 --> <!-- 搜索 -->
<div class="search"> <div class="search">
<div class="search-box">
<div class="input"> <div class="input">
<input type="text" placeholder="请输入产品名称" v-model="searchValue"></input> <input
type="text"
placeholder="请输入产品名称"
v-model="searchValue"
@keyup.enter="handleSearch"
/>
</div> </div>
<div class="search-btn"> <div class="search-btn" @click="handleSearch">
搜索 搜索
</div> </div>
</div>
</div> </div>
<!-- 供应商 --> <!-- 供应商 -->
<div v-if="cloudData.secMenu && cloudData.secMenu.length > 0" class="supplier-container"> <div v-if="cloudData.secMenu && cloudData.secMenu.length > 0" class="supplier-container">
@ -28,7 +35,7 @@
<template v-if="cloudData.secMenu && cloudData.secMenu.length > 0 && activeSupplierIndex >= 0"> <template v-if="cloudData.secMenu && cloudData.secMenu.length > 0 && activeSupplierIndex >= 0">
<template v-for="thrMenu in cloudData.secMenu[activeSupplierIndex].thrMenu"> <template v-for="thrMenu in cloudData.secMenu[activeSupplierIndex].thrMenu">
<!-- 循环每个分类下的产品 --> <!-- 循环每个分类下的产品 -->
<div v-for="product in thrMenu.value" :key="product.id" class="box-item"> <div v-for="product in thrMenu.value" :key="product.id" class="box-item" v-show="shouldShowProduct(product)">
<!-- 标题 --> <!-- 标题 -->
<div class="item-tit"> <div class="item-tit">
{{ product.name }} {{ product.name }}
@ -73,6 +80,8 @@ export default {
return { return {
cloudData: {}, cloudData: {},
activeSupplierIndex: 0, // activeSupplierIndex: 0, //
searchValue: '', //
isSearching: false, //
// //
showConsultDialog: false, showConsultDialog: false,
@ -106,6 +115,25 @@ export default {
} }
}, },
//
handleSearch() {
this.isSearching = !!this.searchValue.trim()
console.log('搜索关键词:', this.searchValue)
},
//
shouldShowProduct(product) {
if (!this.isSearching) {
return true
}
//
const keyword = this.searchValue.toLowerCase().trim()
return (
(product.name && product.name.toLowerCase().includes(keyword)) ||
(this.currentCategory && this.currentCategory.thrTitle && this.currentCategory.thrTitle.toLowerCase().includes(keyword))
)
},
// //
selectSupplier(index) { selectSupplier(index) {
this.activeSupplierIndex = index this.activeSupplierIndex = index