提交 79e21e7c 作者: ZhangLingKun

功能:首页租赁跳转

上级 9ff69410
流水线 #7998 已通过 于阶段
in 5 分 11 秒
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Button } from 'antd'; import { Button } from 'antd';
import { useRouter } from 'next/router';
import { useDispatch } from 'react-redux';
import styled from 'styled-components'; import styled from 'styled-components';
import { HomeAPI } from '@/api'; import { HomeAPI } from '@/api';
import { InterListType } from '@/api/interface'; import { InterListType } from '@/api/interface';
import { ListBrandInfoType } from '@/api/interface/home'; import { ListBrandInfoType } from '@/api/interface/home';
import { setGlobalData } from '@/store/module/globalData';
// 列表类型 // 列表类型
type ListType = InterListType<ListBrandInfoType>; type ListType = InterListType<ListBrandInfoType>;
const TabView03 = () => { const TabView03 = () => {
// 导航钩子
const router = useRouter();
// store
const dispatch = useDispatch();
// 列表数据 // 列表数据
const [tabList, setTabList] = useState<ListType>([]); const [tabList, setTabList] = useState<ListType>([]);
// 获取云享商城分类 // 获取云享商城分类
...@@ -22,6 +29,24 @@ const TabView03 = () => { ...@@ -22,6 +29,24 @@ const TabView03 = () => {
// console.log('获取云享商城分类 --->', res); // console.log('获取云享商城分类 --->', res);
} }
}; };
// 跳转一级分类详情
const handleMain = (i: ListType[0]) => {
dispatch(
setGlobalData({
loadingSpinnerVisible: true,
}),
);
router.push(`/rent/${i?.id}`).then();
};
// 跳转二级分类详情
const handleSecond = (i: ListType[0], n: ListType[0]['modeInfoList'][0]) => {
dispatch(
setGlobalData({
loadingSpinnerVisible: true,
}),
);
router.push(`/rent/${i?.id}/${n?.id}`).then();
};
// 组件挂载 // 组件挂载
useEffect(() => { useEffect(() => {
getListBrandInfo().then(); getListBrandInfo().then();
...@@ -31,11 +56,18 @@ const TabView03 = () => { ...@@ -31,11 +56,18 @@ const TabView03 = () => {
{tabList.map((i, j) => ( {tabList.map((i, j) => (
<div key={j}> <div key={j}>
<div className={'tab-little flex-start'}> <div className={'tab-little flex-start'}>
<div className="title-name">{i.brandName}</div> <div className="title-name" onClick={() => handleMain(i)}>
{i.brandName}
</div>
</div> </div>
<div className="tab-list flex-start"> <div className="tab-list flex-start">
{i.modeInfoList?.map((n, m) => ( {i.modeInfoList?.map((n, m) => (
<Button type={'link'} key={m} className="list-item"> <Button
type={'link'}
key={m}
className="list-item"
onClick={() => handleSecond(i, n)}
>
{n.modeName} {n.modeName}
</Button> </Button>
))} ))}
......
...@@ -6,6 +6,7 @@ import styled from 'styled-components'; ...@@ -6,6 +6,7 @@ import styled from 'styled-components';
import { InterListType } from '@/api/interface'; import { InterListType } from '@/api/interface';
import { LeaseGoodsListType } from '@/api/interface/home'; import { LeaseGoodsListType } from '@/api/interface/home';
import { GlobalDataState } from '@/store/module/globalData'; import { GlobalDataState } from '@/store/module/globalData';
import { formatMoney } from '@/utils/money';
// 商品详情类型 // 商品详情类型
type GoodsInfoListType = InterListType<LeaseGoodsListType>[0]; type GoodsInfoListType = InterListType<LeaseGoodsListType>[0];
...@@ -23,13 +24,6 @@ const RentListItemView: React.FC<{ ...@@ -23,13 +24,6 @@ const RentListItemView: React.FC<{
const handleDetail = () => { const handleDetail = () => {
// router.push(`/service/detail/${detail?.id}`).then(); // router.push(`/service/detail/${detail?.id}`).then();
}; };
// 获取商品的单位
// const getPriceUnit = () => {
// const unit = globalData?.priceUnitList?.find(
// (i) => i.id === detail?.inspectionPriceUnitId,
// );
// return unit?.unitName || '次';
// };
return ( return (
<ProductItemWrap onClick={handleDetail}> <ProductItemWrap onClick={handleDetail}>
<div className="product-image"> <div className="product-image">
...@@ -43,30 +37,30 @@ const RentListItemView: React.FC<{ ...@@ -43,30 +37,30 @@ const RentListItemView: React.FC<{
<div className="product-title">{detail?.tradeName}</div> <div className="product-title">{detail?.tradeName}</div>
<div className="product-desc text-ellipsis">{detail?.sellingPoint}</div> <div className="product-desc text-ellipsis">{detail?.sellingPoint}</div>
<div className="product-desc flex-between"> <div className="product-desc flex-between">
{/* <div className="money"> */} <div className="money">
{/* {detail?.price ? ( */} {detail?.showPrice ? (
{/* <> */} <>
{/* <span className="label">¥</span> */} <span className="label"></span>
{/* <span */} <span
{/* className="num" */} className="num"
{/* title={`${formatMoney(detail?.price)}元起每${getPriceUnit()}`} */} title={`${formatMoney(detail?.showPrice)}元起每天`}
{/* > */} >
{/* {formatMoney(detail?.price)} */} {formatMoney(detail?.showPrice)}
{/* </span> */} </span>
{/* <div */} <span
{/* className="unit text-ellipsis" */} className="unit text-ellipsis"
{/* title={`${formatMoney(detail?.price)}元起每${getPriceUnit()}`} */} title={`${formatMoney(detail?.showPrice)}元起每天`}
{/* > */} >
{/* 起/{getPriceUnit()} */} 起/天
{/* </div> */} </span>
{/* </> */} </>
{/* ) : ( */} ) : (
{/* <span className="label">咨询报价</span> */} <span className="label">咨询报价</span>
{/* )} */} )}
{/* </div> */} </div>
{/* <div className="text text-ellipsis"> */} <div className="text text-ellipsis">
{/* 成交{Math.floor(detail.id * 3.14)}件 */} 成交{Math.floor(detail.id * 3.14)}
{/* </div> */} </div>
</div> </div>
<div className="product-store flex-start"> <div className="product-store flex-start">
<PropertySafetyFilled style={{ color: '#FF552D' }} /> <PropertySafetyFilled style={{ color: '#FF552D' }} />
...@@ -86,7 +80,7 @@ const ProductItemWrap = styled.div` ...@@ -86,7 +80,7 @@ const ProductItemWrap = styled.div`
position: relative; position: relative;
box-sizing: border-box; box-sizing: border-box;
width: calc((100% - (0.83rem * 5)) / 6); width: calc((100% - (0.83rem * 5)) / 6);
height: 16rem; height: 16.5rem;
border: 0.02rem solid #e3e3e3; border: 0.02rem solid #e3e3e3;
margin: 0 0.83rem 0.83rem 0; margin: 0 0.83rem 0.83rem 0;
padding: 0.67rem; padding: 0.67rem;
...@@ -120,7 +114,7 @@ const ProductItemWrap = styled.div` ...@@ -120,7 +114,7 @@ const ProductItemWrap = styled.div`
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
overflow: hidden; overflow: hidden;
margin-bottom: 0.33rem; //margin-bottom: 0.33rem;
max-height: 2rem; max-height: 2rem;
} }
.product-desc { .product-desc {
...@@ -129,7 +123,7 @@ const ProductItemWrap = styled.div` ...@@ -129,7 +123,7 @@ const ProductItemWrap = styled.div`
font-size: 12px; font-size: 12px;
font-weight: 400; font-weight: 400;
color: #999999; color: #999999;
margin-bottom: 0.1rem; //margin-bottom: 0.1rem;
align-items: baseline; align-items: baseline;
.label { .label {
width: 60%; width: 60%;
......
import React from 'react';
import { HomeAPI } from '@/api';
import { InterListType } from '@/api/interface';
import { ListBrandInfoType } from '@/api/interface/home';
import RentView from '@/pages/rent/_view';
import { wrapper } from '@/store';
// 分类列表类型
type CategoryListType = InterListType<ListBrandInfoType>;
// 每次加载页面都会执行
export const getServerSideProps = wrapper.getServerSideProps(
(_store) => async () => {
// 分类数据
let categoryList: CategoryListType = [];
// 获取各个目录及分类信息
const getCategoryInfo = async () => {
const res = await HomeAPI.getListBrandInfo({
pageNo: 1,
pageSize: 999,
});
if (res && res.code === '200') {
categoryList = res.result?.list || [];
}
};
// 依次获取接口数据
await (async () => {
await Promise.all([getCategoryInfo()]);
})();
return { props: { categoryList } };
},
);
const RentSecondView: React.FC<{
categoryList: CategoryListType;
}> = (props) => <RentView {...props} />;
export default RentSecondView;
import React from 'react';
import { HomeAPI } from '@/api';
import { InterListType } from '@/api/interface';
import { ListBrandInfoType } from '@/api/interface/home';
import RentView from '@/pages/rent/_view';
import { wrapper } from '@/store';
// 分类列表类型
type CategoryListType = InterListType<ListBrandInfoType>;
// 每次加载页面都会执行
export const getServerSideProps = wrapper.getServerSideProps(
(_store) => async () => {
// 分类数据
let categoryList: CategoryListType = [];
// 获取各个目录及分类信息
const getCategoryInfo = async () => {
const res = await HomeAPI.getListBrandInfo({
pageNo: 1,
pageSize: 999,
});
if (res && res.code === '200') {
categoryList = res.result?.list || [];
}
};
// 依次获取接口数据
await (async () => {
await Promise.all([getCategoryInfo()]);
})();
return { props: { categoryList } };
},
);
const RentMainView: React.FC<{
categoryList: CategoryListType;
}> = (props) => <RentView {...props} />;
export default RentMainView;
...@@ -3,11 +3,13 @@ import { HomeAPI } from '@/api'; ...@@ -3,11 +3,13 @@ import { HomeAPI } from '@/api';
import { InterListType } from '@/api/interface'; import { InterListType } from '@/api/interface';
import { ListBrandInfoType } from '@/api/interface/home'; import { ListBrandInfoType } from '@/api/interface/home';
import RentView from '@/pages/rent/_view'; import RentView from '@/pages/rent/_view';
import { wrapper } from '@/store';
// 分类列表类型 // 分类列表类型
type CategoryListType = InterListType<ListBrandInfoType>; type CategoryListType = InterListType<ListBrandInfoType>;
// 每次加载页面都会执行 // 每次加载页面都会执行
export async function getServerSideProps() { export const getServerSideProps = wrapper.getServerSideProps(
(_store) => async () => {
// 分类数据 // 分类数据
let categoryList: CategoryListType = []; let categoryList: CategoryListType = [];
// 获取各个目录及分类信息 // 获取各个目录及分类信息
...@@ -22,10 +24,11 @@ export async function getServerSideProps() { ...@@ -22,10 +24,11 @@ export async function getServerSideProps() {
}; };
// 依次获取接口数据 // 依次获取接口数据
await (async () => { await (async () => {
await getCategoryInfo(); await Promise.all([getCategoryInfo()]);
})(); })();
return { props: { categoryList } }; return { props: { categoryList } };
} },
);
const RentPageView: React.FC<{ const RentPageView: React.FC<{
categoryList: CategoryListType; categoryList: CategoryListType;
}> = (props) => <RentView {...props} />; }> = (props) => <RentView {...props} />;
......
...@@ -33,8 +33,7 @@ export const getServerSideProps = wrapper.getServerSideProps( ...@@ -33,8 +33,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
}; };
// 依次获取接口数据 // 依次获取接口数据
await (async () => { await (async () => {
await getIndustryListPages(); await Promise.all([getIndustryListPages(), getPriceUnitList()]);
await getPriceUnitList();
})(); })();
return { props: { categoryList } }; return { props: { categoryList } };
}, },
......
...@@ -33,8 +33,7 @@ export const getServerSideProps = wrapper.getServerSideProps( ...@@ -33,8 +33,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
}; };
// 依次获取接口数据 // 依次获取接口数据
await (async () => { await (async () => {
await getIndustryListPages(); await Promise.all([getIndustryListPages(), getPriceUnitList()]);
await getPriceUnitList();
})(); })();
return { props: { categoryList } }; return { props: { categoryList } };
}, },
......
...@@ -53,9 +53,11 @@ export const getServerSideProps = wrapper.getServerSideProps( ...@@ -53,9 +53,11 @@ export const getServerSideProps = wrapper.getServerSideProps(
}; };
// 依次获取接口数据 // 依次获取接口数据
await (async () => { await (async () => {
await getCompanyInspection(); await Promise.all([
await getCompanyInfo(); getCompanyInspection(),
await getPriceUnitList(); getCompanyInspection(),
getPriceUnitList(),
]);
})(); })();
return { props: { serviceDetail, storeDetail } }; return { props: { serviceDetail, storeDetail } };
}, },
......
...@@ -33,8 +33,7 @@ export const getServerSideProps = wrapper.getServerSideProps( ...@@ -33,8 +33,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
}; };
// 依次获取接口数据 // 依次获取接口数据
await (async () => { await (async () => {
await getIndustryListPages(); await Promise.all([getIndustryListPages(), getPriceUnitList()]);
await getPriceUnitList();
})(); })();
return { props: { categoryList } }; return { props: { categoryList } };
}, },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论