提交 a955d0d5 作者: 曹云

Merge branch 'master' of ssh://git.mmcuav.cn:8222/root/sharefly-web-nextjs into caoyun

...@@ -18,7 +18,7 @@ export default function request(url: string, method: String = 'get', data?: any) ...@@ -18,7 +18,7 @@ export default function request(url: string, method: String = 'get', data?: any)
params.append(key, data[key]); params.append(key, data[key]);
}) })
url += params; url += '?' + params;
} }
break; break;
......
...@@ -5,51 +5,15 @@ export interface FilterOptionResp { ...@@ -5,51 +5,15 @@ export interface FilterOptionResp {
name: string name: string
} }
export default { export interface RegionResp {
category: (): Promise<Response<Array<FilterOptionResp>>> => { "childInfo": RegionResp[] | null,
return request('/pms/webProductMall/category'); "id": number,
}, "level": number,
brand: (): Promise<Response<Array<FilterOptionResp>>> => { "name": string,
return request('/pms/webDevice/brand'); "pid": number
},
model: (): Promise<Response<Array<FilterOptionResp>>> => {
return request('/pms/webDevice/model');
},
part: (): Promise<Response<Array<FilterOptionResp>>> => {
return request('/pms/webProductMall/parts');
},
quality: (): Promise<Response<Array<FilterOptionResp>>> => {
return request('/pms/webProductMall/quality');
},
region: (): Promise<Response<Array<FilterOptionResp>>> => {
return request('/pms/webDevice/getSecondDistrictInfo');
},
}
//商城接口
export const mallApi = {
category: (): Promise<Response<Array<FilterOptionResp>>> => {
return request('/pms/webProductMall/category');
},
brand: (): Promise<Response<Array<FilterOptionResp>>> => {
return request('/pms/webDevice/brand');
},
model: (): Promise<Response<Array<FilterOptionResp>>> => {
return request('/pms/webDevice/model');
},
part: (): Promise<Response<Array<FilterOptionResp>>> => {
return request('/pms/webProductMall/parts');
},
quality: (): Promise<Response<Array<FilterOptionResp>>> => {
return request('/pms/webProductMall/quality');
},
region: (): Promise<Response<Array<FilterOptionResp>>> => {
return request('/pms/webDevice/getSecondDistrictInfo');
},
} }
//设备租赁接口 export default {
export const leasingApi = {
category: (): Promise<Response<Array<FilterOptionResp>>> => { category: (): Promise<Response<Array<FilterOptionResp>>> => {
return request('/pms/webProductMall/category'); return request('/pms/webProductMall/category');
}, },
...@@ -65,7 +29,7 @@ export const leasingApi = { ...@@ -65,7 +29,7 @@ export const leasingApi = {
quality: (): Promise<Response<Array<FilterOptionResp>>> => { quality: (): Promise<Response<Array<FilterOptionResp>>> => {
return request('/pms/webProductMall/quality'); return request('/pms/webProductMall/quality');
}, },
region: (): Promise<Response<Array<FilterOptionResp>>> => { region: (): Promise<Response<Array<RegionResp>>> => {
return request('/pms/webDevice/getSecondDistrictInfo'); return request('/pms/webDevice/getSecondDistrictInfo');
}, },
} }
\ No newline at end of file
import { Space, Select } from 'antd'; import { Space, Select } from "antd";
import { useEffect, useState } from 'react'; import { useEffect, useState } from "react";
import styles from '../../index.module.scss'; import styles from "../../index.module.scss";
import api from '../../api'; import api, { RegionResp } from "../../api";
export default function RegionItem(){ type Props = {
const [productList, setProductList] = useState(Array<{}>); onChange: (item: RegionResp) => void;
};
export default function RegionItem(props: Props) {
const [provinceList, setProvinceList] = useState<RegionResp[]>([]);
const [cityList, setCityList] = useState<RegionResp[]>([]);
useEffect(() => { useEffect(() => {
setProductList([{}, {}, {}, {}, {}, {}]); api.region().then((res) => {
setProvinceList(res?.result || []);
});
}, []); }, []);
const onProvinceChange = (value: string) => { const onProvinceChange = (value: number, item: any) => {
console.log("省", value); console.log("省", value, item);
setCityList(item.childInfo || []);
props.onChange(item);
}; };
const onCityChange = (value: string) => { const onCityChange = (value: number, item: any) => {
console.log("市", value); console.log("市", value);
props.onChange(item);
}; };
return ( return (
<div className={styles.filterItem}> <div className={styles.filterItem}>
...@@ -27,27 +36,29 @@ export default function RegionItem(){ ...@@ -27,27 +36,29 @@ export default function RegionItem(){
popupMatchSelectWidth={false} popupMatchSelectWidth={false}
placeholder="选择省" placeholder="选择省"
onChange={onProvinceChange} onChange={onProvinceChange}
options={[ options={provinceList.map((item) => {
{ value: "jack", label: "Jack" }, return {
{ value: "lucy", label: "Lucy" }, ...item,
{ value: "Yiminghe", label: "yiminghe" }, value: item.id,
{ value: "disabled", label: "Disabled", disabled: true }, label: item.name,
]} };
})}
/> />
<Select <Select
bordered={false} bordered={false}
popupMatchSelectWidth={false} popupMatchSelectWidth={false}
placeholder="选择市" placeholder="选择市"
onChange={onCityChange} onChange={onCityChange}
options={[ options={cityList.map((item) => {
{ value: "jack", label: "Jack" }, return {
{ value: "lucy", label: "Lucy" }, ...item,
{ value: "Yiminghe", label: "yiminghe" }, value: item.id,
{ value: "disabled", label: "Disabled", disabled: true }, label: item.name,
]} };
})}
/> />
</Space> </Space>
</div> </div>
</div> </div>
); );
} }
...@@ -47,7 +47,9 @@ export default function Filter(props: Props) { ...@@ -47,7 +47,9 @@ export default function Filter(props: Props) {
marginBottom: 18, marginBottom: 18,
}} }}
> >
<RegionItem></RegionItem> <RegionItem
onChange={(item: FilterOptionResp) => onChange(item, "region")}
></RegionItem>
</div> </div>
)} )}
<div className={styles.filterWrap}> <div className={styles.filterWrap}>
......
...@@ -19,6 +19,18 @@ const nextConfig = { ...@@ -19,6 +19,18 @@ const nextConfig = {
}, },
]; ];
}, },
images: {
remotePatterns: [
{
protocol: "http",
hostname: "**",
},
{
protocol: "https",
hostname: "**",
},
],
},
pageExtensions: ["page.tsx", "page.ts", "page.jsx", "page.js"], pageExtensions: ["page.tsx", "page.ts", "page.jsx", "page.js"],
}; };
......
import request, { Response } from '~/api/request';
export interface ListPageGoodsInfoParams {
"brandId"?: number,
"districtId"?: number,
"modelId"?: number,
"pageNo": number,
"pageSize": number,
"partsId"?: number,
"productCategoryId"?: number,
"qualityId"?: number
}
export interface Goods {
"createTime": string,
"directoryId": number,
"directoryName": string,
"goodsName": string,
"goodsOneLevelTypeName": string,
"goodsTwoLevelTypeName": string,
"id": number,
"imgUrl": string,
"isCoupons": number,
"status": number
}
export interface ListPageGoodsInfoResp {
"pageNo": 1,
"pageSize": 10,
"list": Array<Goods>,
"totalCount": 0,
"totalPage": 0
}
export default {
//web-商品信息-分页
listPageGoodsInfo: (params: ListPageGoodsInfoParams): Promise<Response<ListPageGoodsInfoResp>> => {
return request('/pms/webProductMall/listPageGoodsInfo', 'post', params)
}
}
\ No newline at end of file
@import "~/styles/mixins.scss";
.productList { .productList {
.title { .title {
padding: 20px 10px 18px; padding: 20px 10px 18px;
...@@ -6,37 +8,47 @@ ...@@ -6,37 +8,47 @@
.main { .main {
display: flex; display: flex;
justify-content: space-between;
.ad { .adList {
display: flex;
flex-shrink: 0; flex-shrink: 0;
width: 260px; flex-direction: column;
height: 420px; gap: 12px;
margin-left: 16px;
background-color: gray; .ad {
width: 270px;
height: 422px;
background-color: #d8d8d8;
}
} }
} }
.listWrap { .listWrap {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
margin-left: -14px; gap: 12px;
height: fit-content;
.item { .item {
cursor: pointer; cursor: pointer;
width: 220px; width: 220px;
height: 326px; height: 205px;
background: #ffffff; background: #ffffff;
border-radius: 6px; border-radius: 6px;
margin-bottom: 15px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-between; justify-content: space-between;
padding-bottom: 18px; padding: 19px 0 18px;
margin-left: 14px;
.img { .imgBox {
width: 100%; width: 100%;
height: 220px; text-align: center;
.img {
width: 116px;
height: 116px;
}
} }
.title { .title {
...@@ -45,21 +57,15 @@ ...@@ -45,21 +57,15 @@
font-family: MicrosoftYaHeiUI-Bold, MicrosoftYaHeiUI; font-family: MicrosoftYaHeiUI-Bold, MicrosoftYaHeiUI;
font-weight: bold; font-weight: bold;
color: #333333; color: #333333;
line-height: 24px; @include ellipsis(1);
height: 48px;
display: -webkit-box; /* 使用弹性盒子布局 */
-webkit-line-clamp: 2; /* 显示行数 */
-webkit-box-orient: vertical; /* 垂直排列 */
overflow: hidden; /* 隐藏溢出部分 */
text-overflow: ellipsis; /* 使用省略号代替溢出部分 */
} }
.sellCount { .sellCount {
font-size: 14px; font-size: 12px;
font-family: MicrosoftYaHei; font-family: MicrosoftYaHei;
color: #ff552d; color: #ff552d;
padding-left: 20px; padding-left: 20px;
} }
} }
} }
} }
\ No newline at end of file
...@@ -3,27 +3,39 @@ import { Button, Select, Space, Tag } from "antd"; ...@@ -3,27 +3,39 @@ import { Button, Select, Space, Tag } from "antd";
import Layout from "~/components/layout"; import Layout from "~/components/layout";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import Image from 'next/image'; import Image from "next/image";
import Filter, { FilterResult } from "~/components/filter"; import Filter, { FilterResult } from "~/components/filter";
import { FilterOptionResp, mallApi } from "~/components/filter/api"; import api, { Goods } from "./api";
// 此函数在构建时被调用 // 此函数在构建时被调用
export async function getServerSideProps() { export async function getServerSideProps() {
return { return {
props: { props: {},
},
}; };
} }
type Props = { type Props = {};
};
export default function Mall(props: Props) { export default function Mall(props: Props) {
const router = useRouter(); const router = useRouter();
const [productList, setProductList] = useState(Array<{}>); const [productList, setProductList] = useState(Array<Goods>);
const [filterResult, setFilterResult] = useState<FilterResult>({});
useEffect(() => {
api
.listPageGoodsInfo({
brandId: 1,
pageNo: 1,
pageSize: 10,
})
.then((res) => {
setProductList(res.result?.list || []);
});
}, []);
const onFilterChange = (filterResult: FilterResult) => { const onFilterChange = (filterResult: FilterResult) => {
console.log('filterResult', filterResult) console.log("filterResult", filterResult);
} };
return ( return (
<Layout> <Layout>
<div className="page" style={{ paddingTop: "18px" }}> <div className="page" style={{ paddingTop: "18px" }}>
...@@ -43,16 +55,25 @@ export default function Mall(props: Props) { ...@@ -43,16 +55,25 @@ export default function Mall(props: Props) {
className={styles.item} className={styles.item}
onClick={() => router.push("/mall/detail/1")} onClick={() => router.push("/mall/detail/1")}
> >
<Image alt="" src="" className={styles.img}></Image> <div className={styles.imgBox}>
<div className={styles.title}> <Image
入云龙ll 1550入云龙ll 1550入云龙ll 1550入云龙ll 1550 alt=""
src={item.imgUrl}
className={styles.img}
width={116}
height={116}
></Image>
</div> </div>
<div className={styles.title}>{item.goodsName}</div>
<div className={styles.sellCount}>半年售12987</div> <div className={styles.sellCount}>半年售12987</div>
</li> </li>
); );
})} })}
</ul> </ul>
<div className={styles.ad}></div> <div className={styles.adList}>
<div className={styles.ad}></div>
<div className={styles.ad}></div>
</div>
</div> </div>
</div> </div>
</div> </div>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论