Files
jjx-web/pages/yellowPage/list.vue
T
2023-12-05 22:37:53 +08:00

329 lines
13 KiB
Vue

<template>
<view>
<top-bar></top-bar>
<common-header></common-header>
<category-bar></category-bar>
<view class="carousel">
<el-carousel height="170px">
<el-carousel-item v-for="item in 4" :key="item">
<image class="carousel-img"
src="/static/images/600fc93e6b85324b3ea1373ee264290d.jpg"
mode="aspectFill"></image>
</el-carousel-item>
</el-carousel>
</view>
<view class="filter-outer">
<el-form @submit.native.prevent label-width="80px">
<el-form-item label="关键词:" class="border-bottom pb-30">
<el-input @keyup.enter.native="getCompany()" clearable placeholder="输入关键字搜索" v-model="keyword">
<i slot="prefix" class="el-input__icon el-icon-getCompany"></i>
<el-button @click="getCompany()" type="primary" slot="append" style="border-radius: 0">搜索
</el-button>
</el-input>
</el-form-item>
<el-form-item label="行业类型:" class="border-bottom pb-30">
</el-form-item>
<el-form-item label="分类:" class="border-bottom pb-30">
<view class="flex justify-start items-center flex-wrap">
<text @click="clickedCateIndex = -1" class="pointer mr-25"
:class="[clickedCateIndex === -1 ? 'text-main selected-cate' : '']">全部
</text>
<view v-for="(item, index) in categoryTreeData" :key="index">
<text @click="clickedCateIndex = index" class="pointer mr-25"
:class="[clickedCateIndex === index ? 'text-main selected-cate' : '']"
v-if="index < 10">
{{ item.name }}
</text>
</view>
</view>
<view class="child-cate flex justify-start items-center flex-wrap" v-if="clickedCateIndex !== null">
<template v-if="clickedCateIndex === -1">
<text class="pointer mr-25" @click="selectCate(item._id)"
:class="[checkCategoryList.includes(item._id) ? 'text-main' : '']"
v-for="(item, index) in allChildCate" :key="index">{{ item.name }}
</text>
</template>
<template v-else>
<text class="pointer mr-25" @click="selectCate(item._id)"
:class="[checkCategoryList.includes(item._id) ? 'text-main' : '']"
v-for="(item, index) in categoryTreeData[clickedCateIndex].children" :key="index">
{{ item.name }}
</text>
</template>
</view>
</el-form-item>
<el-form-item label="城市" class="border-bottom pb-30">
<view class="flex justify-start items-center flex-wrap">
<text @click="selectProvince(-1)" class="pointer mr-25 flex-grow-0"
:class="[checkProvinceList.length === 0 ? 'text-main selected-cate' : '']">全国
</text>
<view v-for="(item, index) in provinceData" :key="index" class="flex-grow-0 pointer mr-25">
<text @click="selectProvince(item.code)"
:class="[checkProvinceList.includes(item.code)? 'text-main selected-cate' : '']"
v-if="index < 10 || showAllProvince">
{{ item.name }}
</text>
</view>
<text @click="showAllProvince = !showAllProvince" class="pointer mr-25">查看更多
</text>
</view>
</el-form-item>
<el-form-item label="已选择">
<view class="tags">
<el-tag v-for="(item, index) in checkCategoryArr" :key="index">{{ item.name }}</el-tag>
</view>
</el-form-item>
</el-form>
</view>
<view class="w-1200 flex justify-start items-start flex-wrap m-a">
<view v-for="(item, index) in companyList" :key="index" class="w-50p company-item">
<view class="p-40">
<view class="rounded shadow p-50 bg-white flex flex-col justify-start items-start">
<view class="flex justify-end w-100p">
<image class="authed" src="/static/images/authed.png" mode="aspectFit"
v-if="item.authStatus === 1"/>
<gap height="40" v-else/>
</view>
<view class="flex justify-start items-center">
<image :src="item.businessCard.logo" class="logo" v-if="item.businessCard" mode="aspectFill"/>
<image v-else src="/static/images/no-logo.jpg" class="logo" mode="aspectFill"/>
<view class="ml-35 flex flex-col justify-start items-start">
<text>{{ item.name }}</text>
<i class="el-icon-star-off text-main my-20"/>
<view class="flex justify-start items-center">
<i class="el-icon-user"/>
<text class="ml-10" v-if="item.manager">{{ item.manager.personName }}</text>
<text class="ml-20 text-28" v-if="item.businessCard">{{ item.businessCard.position }}</text>
</view>
</view>
</view>
<view class="flex justify-start items-center mt-20">
<i class="el-icon-map-location mr-15"/>
<view class="flex-col justify-start items-center">
<text>地址:</text>
<text v-if="item.manager">{{ item.manager.address }}</text>
</view>
</view>
<view class="flex justify-start items-center mt-20">
<i class="el-icon-phone mr-15"/>
<view class="flex-col justify-start items-center">
<text>电话:</text>
<text v-if="item.businessCard">{{ item.businessCard.phone }}</text>
</view>
</view>
<view class="flex justify-start items-center mt-20">
<i class="el-icon-mobile mr-15"/>
<view class="flex-col justify-start items-center">
<text>手机:</text>
<text v-if="item.businessCard">{{ item.businessCard.mobile }}</text>
</view>
</view>
<view class="flex justify-start items-center mt-20">
<i class="el-icon-message mr-15"/>
<view class="flex-col justify-start items-center">
<text>邮箱:</text>
<text v-if="item.businessCard">{{ item.businessCard.email }}</text>
</view>
</view>
<view class="flex justify-start items-center mt-20">
<i class="el-icon-data-board mr-15"/>
<view class="flex-col justify-start items-center">
<text>网址:</text>
<text v-if="item.businessCard">{{ item.businessCard.website }}</text>
</view>
</view>
<view class="flex justify-between items-center w-100p">
<view class="flex justify-start items-center mt-20">
<text class="text-main">主营业务:</text>
<text v-if="item.businessCard">{{ item.businessCard.mainBusiness }}</text>
</view>
<el-button type="primary" @click="showInfo(item._id)">查看详情</el-button>
</view>
</view>
</view>
</view>
</view>
<right-bar></right-bar>
<common-footer></common-footer>
</view>
</template>
<script>
import provinces from "@/uni_modules/vk-uview-ui/libs/address/provinces.json";
import Gap from "../../components/gap/gap.vue";
export default {
name: "list",
components: {Gap},
data() {
return {
categoryTreeData: [],
allChildCate: [],
clickedCateIndex: null,
checkCategoryList: [],
keyword: '',
provinceData: provinces,
checkProvinceList: [],
showAllProvince: false,
companyList: []
}
},
methods: {
getCategoryTreeData() {
vk.callFunction({
url: 'client/spot/category/pub/getTree',
title: '请求中...',
data: {},
success: (data) => {
this.categoryTreeData = data.rows
this.allChildCate = []
this.categoryTreeData.forEach(item => {
item.children.forEach(child => {
this.allChildCate.push(child)
})
})
}
});
},
selectCate(id) {
const index = this.checkCategoryList.indexOf(id)
if (index === -1) this.checkCategoryList.push(id)
else this.checkCategoryList.splice(index, 1)
this.getCompany()
},
selectProvince(code) {
if (code === -1) this.checkProvinceList = []
else {
const index = this.checkProvinceList.indexOf(code)
if (index === -1) this.checkProvinceList.push(code)
else this.checkProvinceList.splice(index, 1)
}
this.getCompany()
},
getCompany() {
vk.callFunction({
url: 'client/user/pub/getCompany',
title: '请求中...',
data: {
province: this.checkProvinceList,
keyword: this.keyword,
mainSpotCategoryIds: this.checkCategoryList,
},
success: (data) => {
this.companyList = data.rows.map(item => {
item.name = item.company.companyName
return item
})
}
});
},
showInfo(id){
vk.navigateTo({
url: `/pages/yellowPage/info?id=${id}`
})
}
},
onShow() {
this.getCategoryTreeData()
this.getCompany()
},
computed: {
checkCategoryArr() {
const arr = []
this.allChildCate.forEach(item => {
if (this.checkCategoryList.includes(item._id)) arr.push(item)
})
this.provinceData.forEach(item => {
if (this.checkProvinceList.includes(item.code)) {
arr.push(item)
}
})
return arr
}
}
}
</script>
<style lang="scss" scoped>
.carousel {
width: 1200px;
margin: 20px auto;
}
.carousel-img {
width: 100%;
height: 100%;
}
.goods-options {
background-color: #FFFFFF;
padding: 20px;
}
.filter-outer {
width: 1200px;
margin: 20px auto;
background-color: #FFFFFF;
padding: 20px;
}
.tags {
display: flex;
.el-tag {
margin-right: 10px;
}
}
.paginatio {
float: none;
width: 1200px;
margin: 20px auto;
display: flex;
justify-content: center;
}
.post-btn {
background: none;
}
.post-btn:hover {
background: #f6eae9;
color: #A92924;
}
.selected-cate {
border-bottom: 2px solid #BD3124;
line-height: 40rpx;
}
.child-cate {
background-color: #DB8382;
color: white;
margin-top: 10rpx;
border-radius: 15rpx;
padding: 0 20rpx;
}
.company-item {
font-size: 16px;
.authed {
height: 40px;
width: 60px;
}
.logo {
width: 100px;
height: 100px;
}
}
</style>