提交 bce05ae1 作者: ZhangLingKun

功能:样式优化

上级 8aab40f5
流水线 #7454 已通过 于阶段
in 4 分 53 秒
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { useRouter } from 'next/router';
import styled from 'styled-components'; import styled from 'styled-components';
import { HomeAPI } from '@/api'; import { HomeAPI } from '@/api';
import { InterDataType } from '@/api/interface'; import { InterDataType } from '@/api/interface';
...@@ -8,6 +9,8 @@ import { RecommendGoodsType } from '@/api/interface/home'; ...@@ -8,6 +9,8 @@ import { RecommendGoodsType } from '@/api/interface/home';
type ListType = InterDataType<RecommendGoodsType>; type ListType = InterDataType<RecommendGoodsType>;
const HomeProductView = () => { const HomeProductView = () => {
// 路由钩子
const router = useRouter();
// 推荐商品列表 // 推荐商品列表
const [recommendGoodsList, setRecommendGoodsList] = useState< const [recommendGoodsList, setRecommendGoodsList] = useState<
ListType[0]['mallGoodsList'] ListType[0]['mallGoodsList']
...@@ -33,6 +36,10 @@ const HomeProductView = () => { ...@@ -33,6 +36,10 @@ const HomeProductView = () => {
).salePrice || 0 ).salePrice || 0
); );
}; };
// 跳转详情
const handleDetail = async (item: ListType[0]['mallGoodsList'][0]) => {
await router.push(`/mall/product/${item.id}`);
};
// 组件挂载 // 组件挂载
useEffect(() => { useEffect(() => {
getRecommendGoodsList().then(); getRecommendGoodsList().then();
...@@ -40,7 +47,11 @@ const HomeProductView = () => { ...@@ -40,7 +47,11 @@ const HomeProductView = () => {
return ( return (
<HomeProductWrap> <HomeProductWrap>
{recommendGoodsList?.map((i, j) => ( {recommendGoodsList?.map((i, j) => (
<div className="product-item flex-start" key={j}> <div
className="product-item flex-start"
key={j}
onClick={() => handleDetail(i)}
>
<img <img
className="item-image" className="item-image"
src={`${i.resourcesList[0].url}?x-oss-process=image/quality,q_25`} src={`${i.resourcesList[0].url}?x-oss-process=image/quality,q_25`}
......
import React from 'react'; import React from 'react';
import { RightOutlined } from '@ant-design/icons'; import { RightOutlined } from '@ant-design/icons';
import { useRouter } from 'next/router';
import styled from 'styled-components'; import styled from 'styled-components';
const HomeTitleView = ({ title }: { title: string }) => { const HomeTitleView: React.FC<{ title: string; path?: string }> = ({
title,
path,
}) => {
// 路由钩子
const router = useRouter();
// 跳转详情
const handleDetail = async () => {
if (!path) return;
await router.push(path);
};
return ( return (
<HomeTitleWrap> <HomeTitleWrap onClick={handleDetail}>
<div className="title-text">{title}</div> <div className="title-text">{title}</div>
<div className="title-more flex-start"> <div className="title-more flex-start">
<div className="more-text">更多</div> <div className="more-text">更多</div>
......
...@@ -91,7 +91,7 @@ const ProductHeadView: React.FC<{ detail: DetailType }> = ({ detail }) => { ...@@ -91,7 +91,7 @@ const ProductHeadView: React.FC<{ detail: DetailType }> = ({ detail }) => {
useEffect(() => { useEffect(() => {
if (!detail) return; if (!detail) return;
getLowerSpec(); getLowerSpec();
console.log('detail --->', detail); // console.log('detail --->', detail);
}, [detail]); }, [detail]);
return ( return (
<ProductHeadWrap> <ProductHeadWrap>
...@@ -190,9 +190,9 @@ const ProductHeadWrap = styled.div` ...@@ -190,9 +190,9 @@ const ProductHeadWrap = styled.div`
box-sizing: border-box; box-sizing: border-box;
margin-right: 0.83rem; margin-right: 0.83rem;
display: flex; display: flex;
align-items: center; align-items: flex-start;
justify-content: flex-start; justify-content: flex-start;
padding: 0 1rem; padding: 2rem 1rem 2rem 1rem;
.product-swiper { .product-swiper {
position: relative; position: relative;
width: 22rem; width: 22rem;
...@@ -204,7 +204,7 @@ const ProductHeadWrap = styled.div` ...@@ -204,7 +204,7 @@ const ProductHeadWrap = styled.div`
width: calc(100% - 22rem); width: calc(100% - 22rem);
height: 100%; height: 100%;
box-sizing: border-box; box-sizing: border-box;
padding: 1rem 0 1rem 1rem; padding: 0 0 0 1rem;
//background: lightblue; //background: lightblue;
.content-title { .content-title {
width: 100%; width: 100%;
......
...@@ -50,7 +50,7 @@ const ProductStoreView: React.FC<{ detail: DetailType; store: StoreType }> = ({ ...@@ -50,7 +50,7 @@ const ProductStoreView: React.FC<{ detail: DetailType; store: StoreType }> = ({
<PhoneOutlined <PhoneOutlined
style={{ color: '#FF552D', transform: 'rotateY(180deg)' }} style={{ color: '#FF552D', transform: 'rotateY(180deg)' }}
/> />
<div className="text">进店逛逛</div> <div className="text">联系方式</div>
</div> </div>
</div> </div>
</ProductStoreWrap> </ProductStoreWrap>
......
...@@ -42,7 +42,7 @@ const HomeView = () => { ...@@ -42,7 +42,7 @@ const HomeView = () => {
{/* 品牌企业 */} {/* 品牌企业 */}
<HomeBrandView /> <HomeBrandView />
{/* 大家都在买 */} {/* 大家都在买 */}
<HomeTitleView title="大家都在买" /> <HomeTitleView title="大家都在买" path="/mall" />
{/* 推荐商品 */} {/* 推荐商品 */}
<HomeProductView /> <HomeProductView />
{/* 无人机服务 */} {/* 无人机服务 */}
......
...@@ -66,11 +66,13 @@ const MallProductView: React.FC<{ ...@@ -66,11 +66,13 @@ const MallProductView: React.FC<{
<ProductStoreView detail={productDetail} store={storeDetail} /> <ProductStoreView detail={productDetail} store={storeDetail} />
</div> </div>
<div className="product-title">商品详情</div> <div className="product-title">商品详情</div>
<div className="product-content"> <div className="product-richText">
{productDetail?.goodsDetails && (
<div <div
className="content-html" className="content-html"
dangerouslySetInnerHTML={{ __html: productDetail?.goodsDetails }} dangerouslySetInnerHTML={{ __html: productDetail?.goodsDetails }}
/> />
)}
</div> </div>
</ProductWrap> </ProductWrap>
</LayoutView> </LayoutView>
......
...@@ -33,7 +33,7 @@ export const ProductWrap = styled.div` ...@@ -33,7 +33,7 @@ export const ProductWrap = styled.div`
right: 40%; right: 40%;
} }
} }
.product-content { .product-richText {
position: relative; position: relative;
width: 100%; width: 100%;
margin-bottom: 3.5rem; margin-bottom: 3.5rem;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论