Zlpt_Portal/src/views/home/index.vue

409 lines
12 KiB
Vue
Raw Normal View History

2023-12-01 11:22:09 +08:00
<script setup lang="ts">
2023-12-04 17:42:11 +08:00
import EquipCard from 'components/equipCard.vue'
2023-12-05 17:05:54 +08:00
import NavMenu from 'components/Navmenu/index.vue'
import { getGoodsClassListApi } from 'http/api/home'
2023-12-10 01:43:50 +08:00
import { mainStore } from 'store/main'
2023-12-08 13:13:00 +08:00
import { getHotList } from 'http/api/equip'
2023-12-10 01:43:50 +08:00
import { reactive, ref } from 'vue'
import baseData from '@/assets/baseInformation.json'
2023-12-09 15:37:20 +08:00
2023-12-08 15:05:47 +08:00
const router = useRouter()
2023-12-05 17:05:54 +08:00
2023-12-08 20:30:52 +08:00
const leftNavList = ref([])
2023-12-09 17:03:25 +08:00
const loopList = ref([
'https://zlpt-1259760603.cos.ap-nanjing.myqcloud.com/488bab245180ebf9f1f3d7db5301be4.png',
'https://hzgyp-prod-1259451974.cos.ap-guangzhou.myqcloud.com/41cd93cefd76c28c967f07ad33b5e6fe1575746850588196864475.jpg',
'https://hzgyp-prod-1259451974.cos.ap-guangzhou.myqcloud.com/11800b353f4d1332b73f18bf0f2133a31575743878894452736462.jpg',
'https://hzgyp-prod-1259451974.cos.ap-guangzhou.myqcloud.com/85a09403e4328a37b2686d20b2fe717e20220728085635540.jpg'
])
2023-12-05 17:05:54 +08:00
// 获取商品分类
const getGoodsClassList = async () => {
const res = await getGoodsClassListApi()
console.log(res, '商品分类列表')
2023-12-08 20:30:52 +08:00
leftNavList.value = res.rows
2023-12-05 17:05:54 +08:00
}
getGoodsClassList()
2023-12-03 10:41:32 +08:00
2023-12-09 11:46:09 +08:00
const handlerGoodsDetails = (...arg) => {
2023-12-10 01:43:50 +08:00
const arr = arg.map((key, index) => {
2023-12-09 11:46:09 +08:00
return {
level: index + 1 + '',
2023-12-10 01:43:50 +08:00
typeId: key.id,
typeName: key.name
2023-12-09 11:46:09 +08:00
}
})
2023-12-01 11:22:09 +08:00
2023-12-09 11:46:09 +08:00
router.push({
2023-12-10 01:43:50 +08:00
name: 'equipList',
state: { typeTag: arr }
2023-12-09 11:46:09 +08:00
})
2023-12-03 10:41:32 +08:00
}
2023-12-04 09:12:38 +08:00
2023-12-09 15:37:20 +08:00
const goInformation = (id) => {
router.push({
2023-12-10 01:43:50 +08:00
path: `/consultationDetails/${id}`
2023-12-09 15:37:20 +08:00
})
}
const detailsList = ref([])
const handelInformation = () => {
2023-12-10 01:43:50 +08:00
detailsList.value = baseData.map((item) => {
2023-12-09 15:37:20 +08:00
return {
2023-12-10 01:43:50 +08:00
v_title: item.title,
v_content_info: '',
v_time: `[${item.create_time}]`,
id: item.id
2023-12-09 15:37:20 +08:00
}
})
}
handelInformation()
2023-12-08 15:05:47 +08:00
const hotDeviceList: any = ref([])
2023-12-08 13:13:00 +08:00
/* 获取热搜装备 */
const getHotDeviceList = async () => {
2023-12-08 15:05:47 +08:00
const res: any = await getHotList({ pageSize: 3 })
hotDeviceList.value = res.rows
2023-12-08 13:13:00 +08:00
console.log(res, '热搜装备111')
}
getHotDeviceList()
2023-12-08 15:05:47 +08:00
/* 热搜卡片点击跳转至详情页 */
const onClick = (val: any) => {
router.push(`/equipDetail/${val.id}`)
}
2023-12-01 11:22:09 +08:00
</script>
<template>
2023-12-01 15:00:37 +08:00
<div class="home-index-banner">
2023-12-03 10:41:32 +08:00
<div class="home-index">
2023-12-01 14:03:26 +08:00
<!-- 商品菜单导航以及轮播图区域 -->
<div class="home-goods">
<ul class="left-nav">
2023-12-02 14:18:00 +08:00
<!-- 左侧机械名称菜单按钮 -->
2023-12-03 10:41:32 +08:00
<li class="item-nav" v-for="item in leftNavList" :key="item.name">
{{ item.name }}
2023-12-02 14:18:00 +08:00
<ul class="sub-goods">
<!-- 级联框内 类别名称 -->
2023-12-08 20:30:52 +08:00
<li v-for="child in item.children" :key="child.id">
<span>{{ child.name }}</span>
2023-12-02 14:18:00 +08:00
<span>
<!-- 小类名称 -->
2023-12-03 10:41:32 +08:00
<a
v-for="son in child.children"
2023-12-08 20:30:52 +08:00
:key="son.id"
2023-12-10 01:43:50 +08:00
@click="handlerGoodsDetails(item, child, son)">
2023-12-08 20:30:52 +08:00
{{ son.name }}
2023-12-03 10:41:32 +08:00
</a>
2023-12-02 14:18:00 +08:00
</span>
</li>
</ul>
</li>
2023-12-01 13:00:16 +08:00
</ul>
2023-12-01 14:03:26 +08:00
<div class="right-content">
2023-12-02 14:18:00 +08:00
<!-- 轮播图上方导航按钮 -->
2023-12-05 17:05:54 +08:00
<NavMenu />
2023-12-02 14:18:00 +08:00
<!-- 轮播图 -->
2023-12-01 14:03:26 +08:00
<div class="swpier-img">
2023-12-09 18:34:56 +08:00
<el-carousel :interval="5000" arrow="always" height="437px">
2023-12-10 01:43:50 +08:00
<el-carousel-item v-for="(item, index) in loopList" :key="index">
2023-12-04 17:42:11 +08:00
<!-- <h3 text="2xl" justify="center">{{ item }}</h3> -->
2023-12-10 01:43:50 +08:00
<el-image style="width: 100%" :src="item" fit="cover" />
2023-12-01 14:03:26 +08:00
</el-carousel-item>
</el-carousel>
</div>
</div>
</div>
<!-- 热搜装备 -->
<div class="hot-equip">
<span>热搜装备</span>
<a>查看更多</a>
</div>
<ul class="equip-pic">
2023-12-08 15:05:47 +08:00
<li v-for="item in hotDeviceList" :key="item.maId" style="cursor: pointer">
<EquipCard
@onClick="onClick"
:company="item.companyName || '安徽博诺斯有限公司'"
:price="item.monthLeasePrice"
2023-12-09 15:37:20 +08:00
:tags="[item.maStatusStr || '待租', item.cityStr || '合肥']"
2023-12-08 15:05:47 +08:00
:name="item.modelName + item.deviceName"
:url="item.picUrl"
:id="item.maId" />
2023-12-01 17:02:05 +08:00
</li>
2023-12-01 14:03:26 +08:00
</ul>
<!-- 专题咨询 -->
<div class="hot-equip">
<span>专题资讯</span>
<a></a>
</div>
<ul class="consult-nav">
<li>
<a>资讯</a>
</li>
<li>
<a>专题</a>
</li>
<li>
<a>检验</a>
</li>
<li>
<a>保险</a>
</li>
</ul>
<div class="consult-content">
<!-- 左侧背景图片 -->
<div class="left-bg"></div>
<!-- 右侧信息 -->
<div class="right-consult">
2023-12-04 09:12:38 +08:00
<div
class="consult-box"
2023-12-09 15:37:20 +08:00
@click="goInformation(item.id)"
2023-12-04 09:12:38 +08:00
v-for="item in detailsList"
:key="item.v_time">
2023-12-01 14:03:26 +08:00
<div class="consult-title">
2023-12-09 15:37:20 +08:00
<h3>{{ item.v_title }}</h3>
2023-12-04 09:12:38 +08:00
<span>{{ item.v_time }}</span>
2023-12-01 14:03:26 +08:00
</div>
<div class="consult-info">
2023-12-04 09:12:38 +08:00
{{ item.v_content_info }}
2023-12-01 14:03:26 +08:00
</div>
</div>
2023-12-01 13:00:16 +08:00
</div>
</div>
</div>
</div>
2023-12-01 11:22:09 +08:00
</template>
2023-12-09 17:03:25 +08:00
<style lang="scss" scoped>
2023-12-10 01:43:50 +08:00
:deep(.el-carousel__container) {
.el-carousel__item {
.el-image {
2023-12-09 17:03:25 +08:00
height: 100%;
2023-12-10 01:43:50 +08:00
img {
2023-12-09 17:03:25 +08:00
}
}
}
}
2023-12-03 10:41:32 +08:00
.home-index-banner {
background-color: #fff;
padding: 20px 15px;
border-radius: 10px;
box-sizing: border-box;
}
2023-12-02 14:18:00 +08:00
2023-12-03 10:41:32 +08:00
.home-index {
.home-goods {
height: 500px;
2023-12-01 13:00:16 +08:00
display: flex;
2023-12-03 10:41:32 +08:00
.left-nav {
position: relative;
width: 200px;
height: 100%;
display: flex;
background-color: #f7f9fa;
flex-direction: column;
justify-content: space-around;
.item-nav {
2023-12-05 17:05:54 +08:00
// text-align: left;
// padding-left: 50px;
2023-12-03 10:41:32 +08:00
color: #8b8b8b;
height: 36px;
line-height: 36px;
2023-12-05 17:05:54 +08:00
text-align: center;
2023-12-03 10:41:32 +08:00
&:hover {
cursor: pointer;
color: #2282ff;
font-weight: bold;
background-color: #1abc9c;
2023-12-01 13:00:16 +08:00
2023-12-03 10:41:32 +08:00
.sub-goods {
display: block;
}
2023-12-02 14:18:00 +08:00
}
}
2023-12-01 13:00:16 +08:00
2023-12-03 10:41:32 +08:00
.sub-goods {
position: absolute;
display: none;
top: 0;
left: 200px;
width: 500px;
height: 100%;
background-color: #f5f4f4;
z-index: 999;
opacity: 0.9;
li {
margin: 15px 0;
color: #333;
font-weight: bold;
display: flex;
span:first-child {
width: 160px;
margin-left: 10px;
}
span a {
margin: 0 15px;
font-size: 14px;
font-weight: normal;
}
2023-12-01 13:00:16 +08:00
}
}
}
2023-12-03 10:41:32 +08:00
.right-content {
flex: 1;
height: 100%;
margin-left: 20px;
2023-12-01 13:00:16 +08:00
2023-12-03 10:41:32 +08:00
.swpier-img {
width: 100%;
2023-12-01 14:48:58 +08:00
height: 437px;
2023-12-03 10:41:32 +08:00
margin-top: 10px;
border-radius: 8px;
2023-12-01 14:48:58 +08:00
2023-12-03 10:41:32 +08:00
.el-carousel {
height: 437px;
}
2023-12-01 14:48:58 +08:00
2023-12-03 10:41:32 +08:00
.el-carousel__item h3 {
color: #475669;
opacity: 0.75;
line-height: 300px;
margin: 0;
text-align: center;
}
2023-12-01 14:48:58 +08:00
2023-12-03 10:41:32 +08:00
.el-carousel__item:nth-child(2n) {
background-color: #99a9bf;
}
2023-12-01 14:48:58 +08:00
2023-12-03 10:41:32 +08:00
.el-carousel__item:nth-child(2n + 1) {
background-color: #d3dce6;
}
}
2023-12-01 13:00:16 +08:00
}
}
2023-12-01 14:03:26 +08:00
2023-12-03 10:41:32 +08:00
.hot-equip {
margin-top: 30px;
height: 37px;
display: flex;
align-items: center;
justify-content: space-between;
2023-12-01 14:03:26 +08:00
2023-12-03 10:41:32 +08:00
span {
font-size: 18px;
font-weight: bold;
color: #333333;
}
2023-12-01 14:03:26 +08:00
2023-12-03 10:41:32 +08:00
a {
color: #9d9d9d;
font-size: 14px;
cursor: pointer;
}
2023-12-01 14:03:26 +08:00
}
2023-12-03 10:41:32 +08:00
.equip-pic {
display: flex;
align-items: center;
li {
2023-12-09 22:29:42 +08:00
width: calc((100% - 30px) / 3);
2023-12-10 01:43:50 +08:00
&:nth-child(2n) {
2023-12-09 22:29:42 +08:00
margin: 0 15px;
}
2023-12-03 10:41:32 +08:00
}
2023-12-01 14:03:26 +08:00
}
2023-12-03 10:41:32 +08:00
.consult-nav {
width: 100%;
2023-12-01 14:03:26 +08:00
height: 40px;
2023-12-03 10:41:32 +08:00
border-bottom: 1px solid #e0e0e0;
display: flex;
2023-12-01 14:03:26 +08:00
2023-12-03 10:41:32 +08:00
li {
height: 40px;
line-height: 40px;
margin: 0 15px;
&:hover {
border-bottom: 1px solid #2282ff;
cursor: pointer;
}
2023-12-01 14:03:26 +08:00
}
}
2023-12-03 10:41:32 +08:00
.consult-content {
margin-top: 20px;
2023-12-01 14:03:26 +08:00
height: 210px;
2023-12-03 10:41:32 +08:00
display: flex;
align-items: center;
2023-12-01 14:03:26 +08:00
2023-12-03 10:41:32 +08:00
.left-bg {
background: url(../../assets/img/home/2023_12_01_beijing2/left_bg.png) no-repeat;
background-size: cover;
width: 340px;
height: 210px;
}
2023-12-01 14:03:26 +08:00
2023-12-03 10:41:32 +08:00
.right-consult {
height: 210px;
flex: 1;
2023-12-04 09:12:38 +08:00
width: calc(100% - 340px);
// padding-left: 35px;
2023-12-09 15:37:20 +08:00
overflow-y: auto;
2023-12-03 10:41:32 +08:00
.consult-box {
2023-12-09 15:37:20 +08:00
margin-bottom: 10px;
//height: 70px;
2023-12-04 09:12:38 +08:00
padding-left: 15px;
cursor: pointer;
2023-12-03 10:41:32 +08:00
.consult-title {
height: 30px;
display: flex;
justify-content: space-between;
align-items: center;
2023-12-01 14:03:26 +08:00
2023-12-03 10:41:32 +08:00
h2 {
font-weight: bold;
}
2023-12-01 14:03:26 +08:00
2023-12-03 10:41:32 +08:00
span {
color: #827d7d;
font-size: 14px;
}
2023-12-01 14:03:26 +08:00
}
2023-12-03 10:41:32 +08:00
.consult-info {
width: calc(100% - 100px);
2023-12-09 15:37:20 +08:00
height: 10px;
2023-12-03 10:41:32 +08:00
line-height: 40px;
border-bottom: 1px dashed #979797;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
2023-12-01 14:03:26 +08:00
}
}
}
}
2023-12-01 15:00:37 +08:00
</style>