This commit is contained in:
木瓜一块八 2025-08-01 16:17:33 +08:00
parent 3eedb6f8b4
commit c3e268c640
2 changed files with 95 additions and 67 deletions

View File

@ -267,7 +267,7 @@ export default {
},
methods: {
init_company_category() {
reqCompanyCategorySearch({ userid: '9KVhsVCJsW_29q3hRhMAr' }).then(res => {
reqCompanyCategorySearch({url_link:window.location.href}).then(res => {
if (res.status) {
this.company_category_list = []
for (let item of res.data) {
@ -292,7 +292,7 @@ export default {
},
init_product_category() {
reqGetProductCategorySearch({ userid: '9KVhsVCJsW_29q3hRhMAr' }).then(res => {
reqGetProductCategorySearch({ url_link: window.location.href,to_page: 'publish' }).then(res => {
if (res.status) {
this.typeList = buildCaTree(res.data)
console.log("2@@", this.typeList);

View File

@ -20,7 +20,7 @@
<!-- 新增的需求和商品radio按钮组 -->
<div class="radio-group-container">
<div class="radio-group">
<label class="radio-item" :class="{ active: selectedType === 'product' }">
<label class="radio-item" style="margin-right: 0px;" :class="{ active: selectedType === 'product' }">
<input type="radio" v-model="selectedType" value="product" @change="handleTypeChange">
<span class="radio-text">企业商品</span>
</label>
@ -48,9 +48,9 @@
<div class="category-title">公司类别</div>
<div class="category-tags">
<span v-for="company in companies" :key="company.id"
:class="['category-tag', { active: selectedCompany === company.id }]"
@click="selectCompany(company.id)">
{{ company.name }}
:class="['category-tag', { active: selectedCompanies.includes(company.value) }]"
@click="selectCompany(company.value)">
{{ company.label }}
</span>
</div>
</div>
@ -66,7 +66,8 @@
</div>
<!-- 返回 -->
<div class="back-btn" @click="$router.push('/ncmatchHome/index')">
<span><返回</span>
<span>
返回 </span>
</div>
</div>
</div>
@ -74,7 +75,7 @@
</template>
<script>
import { reqGetProductCategorySearch, reqGetSupplyAndDemandSquareList } from '@/api/ncmatch'
import { reqGetProductCategorySearch, reqGetSupplyAndDemandSquareList, reqCompanyCategorySearch } from '@/api/ncmatch'
export default {
name: 'supplyAndDemandSquare',
components: {
@ -82,58 +83,65 @@ export default {
},
data() {
return {
typeList:[],
page_size: 8,
current_page: 1,
typeList: [],
selectedType: 'product', //
selectedCategory: '', //
selectedCompany: 'company1', //
categories: [
{ id: 'category1', name: '云' },
{ id: 'category2', name: '国产算力' },
{ id: 'category3', name: 'NVIDIA' },
{ id: 'category4', name: '网络服务' },
{ id: 'category5', name: '一体机' },
{ id: 'category6', name: '硬件' },
{ id: 'category7', name: 'AI应用' },
{ id: 'category8', name: '其他' }
],
companies: [
{ id: 'company1', name: '龙头企业' },
{ id: 'company2', name: '骨干企业' },
{ id: 'company3', name: '科技型企业' },
{ id: 'company4', name: '专精特新企业' },
{ id: 'company5', name: '高新技术企业' },
{ id: 'company6', name: '科技小巨人领军企业' },
{ id: 'company7', name: '其他' }
],
selectedCompanies: [], //
categories: [],
companies: [],
productList: []
}
},
created() {
this.init_product_category()
this.initAllData()
},
methods: {
initAllData() {
Promise.all([
this.init_product_category(),
this.init_company_category()
]).then(() => {
this.initData(this.selectedCategory)
})
},
init_company_category() {
reqCompanyCategorySearch({ url_link: window.location.href }).then(res => {
if (res.status) {
this.company_category_list = []
for (let item of res.data) {
this.company_category_list.push({
label: item.company_category,
value: item.company_category
})
}
this.companies = this.company_category_list
}
})
},
selectCategory(categoryId) {
if(categoryId===this.selectedCategory) return;
if (categoryId === this.selectedCategory) return;
this.selectedCategory = categoryId
this.initData(this.selectedCategory)
},
init_product_category(product_category) {
reqGetProductCategorySearch({ userid: '9KVhsVCJsW_29q3hRhMAr' }).then(res => {
reqGetProductCategorySearch({ url_link: window.location.href, to_page: 'publish' }).then(res => {
if (res.status) {
let list = []
for(let item of res.data){
if(item.parentid === null){
for (let item of res.data) {
if (item.parentid === null) {
list.push({
label:item.product_category,
value:item.id
label: item.product_category,
value: item.id
})
}
}
this.selectedCategory = list[0].value
// this.selectedCategory = list[0].value
this.typeList = list
this.initData(this.selectedCategory)
console.log("2@@", this.typeList);
}
})
@ -143,12 +151,20 @@ export default {
console.log('切换到:', this.selectedType)
//
},
initData(product_category) {
reqGetSupplyAndDemandSquareList({product_category,to_page:"square",url_link:window.location.href}).then(res => {
initData() {
let ploay = {
product_category: this.selectedCategory,
to_page: "square",
url_link: window.location.href,
page_size: this.page_size,
current_page: this.current_page,
company_type: this.selectedCompanies.length > 0 ? this.selectedCompanies.join(",") : ""
}
reqGetSupplyAndDemandSquareList(ploay).then(res => {
if (res.status) {
if(res.data.length===0){
if (res.data.length === 0) {
this.productList = []
}else{
} else {
this.productList = res.data[0].product_list
}
@ -157,7 +173,16 @@ export default {
},
selectCompany(companyId) {
this.selectedCompany = companyId
const index = this.selectedCompanies.indexOf(companyId)
if (index > -1) {
//
this.selectedCompanies.splice(index, 1)
} else {
//
this.selectedCompanies.push(companyId)
}
console.log("this.selectedCompanies", this.selectedCompanies);
this.initData()
},
getProductList() {
this.productList = [
@ -219,7 +244,7 @@ export default {
</script>
<style scoped lang="scss">
.back-btn{
.back-btn {
width: 100%;
height: 40px;
line-height: 40px;
@ -229,14 +254,16 @@ export default {
margin-top: 20px;
font-size: 16px;
color: #666;
&:hover{
&:hover {
cursor: pointer;
color: #275AFF;
}
}
/* 新增的radio按钮组样式 */
.radio-group-container {
width: 100%!important;
width: 100% !important;
display: flex;
justify-content: flex-start;
// margin: 20px 0;
@ -299,7 +326,7 @@ export default {
}
.title {
color: #666!important;
color: #666 !important;
font-size: 36px;
margin: 25px;
@ -423,7 +450,8 @@ export default {
}
}
}
.no-data{
.no-data {
min-height: 500px;
display: flex;
justify-content: center;