Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
web-ci-test
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
test-ci
web-ci-test
Commits
40e08c40
提交
40e08c40
authored
5月 20, 2023
作者:
翁进城
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
对接商城广告
上级
fc6e072f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
52 行增加
和
15 行删除
+52
-15
index.ts
pages/mall/api/index.ts
+9
-0
index.page.tsx
pages/mall/index.page.tsx
+43
-15
没有找到文件。
pages/mall/api/index.ts
浏览文件 @
40e08c40
...
@@ -32,10 +32,18 @@ export interface ListPageGoodsInfoResp {
...
@@ -32,10 +32,18 @@ export interface ListPageGoodsInfoResp {
"totalPage"
:
0
"totalPage"
:
0
}
}
export
interface
Ad
{
id
:
number
;
imageUrl
:
string
;
}
export
default
{
export
default
{
//web-商品信息-分页
//web-商品信息-分页
listPageGoodsInfo
:
(
params
:
ListPageGoodsInfoParams
,
options
=
{}):
Promise
<
Response
<
ListPageGoodsInfoResp
>>
=>
{
listPageGoodsInfo
:
(
params
:
ListPageGoodsInfoParams
,
options
=
{}):
Promise
<
Response
<
ListPageGoodsInfoResp
>>
=>
{
return
request
(
'/pms/webProductMall/listPageGoodsInfo'
,
'post'
,
params
,
options
)
return
request
(
'/pms/webProductMall/listPageGoodsInfo'
,
'post'
,
params
,
options
)
},
//产品商城广告位
ad
:
():
Promise
<
Response
<
Array
<
Ad
>>>
=>
{
return
request
(
'/pms/webProductMall/ad'
)
}
}
}
}
\ No newline at end of file
pages/mall/index.page.tsx
浏览文件 @
40e08c40
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
{
Button
,
Empty
,
Pagination
,
Select
,
Space
,
Tag
}
from
"antd"
;
import
{
Empty
,
Pagination
,
Image
}
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
Filter
,
{
AdapterResult
,
FilterResult
}
from
"~/components/filter"
;
import
Filter
,
{
AdapterResult
,
FilterResult
}
from
"~/components/filter"
;
import
api
,
{
Goods
,
ListPageGoodsInfoParams
}
from
"./api"
;
import
api
,
{
Ad
,
Goods
,
ListPageGoodsInfoParams
}
from
"./api"
;
// 此函数在构建时被调用
// 此函数在构建时被调用
export
async
function
getServerSideProps
()
{
export
async
function
getServerSideProps
()
{
...
@@ -18,21 +17,23 @@ type Props = {};
...
@@ -18,21 +17,23 @@ 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
<
Goods
>>
([]);
const
[
productList
,
setProductList
]
=
useState
<
Array
<
Goods
>>
([]);
//商品列表
const
[
filterResult
,
setFilterResult
]
=
useState
<
AdapterResult
>
({});
const
[
filterResult
,
setFilterResult
]
=
useState
<
AdapterResult
>
({});
//筛选结果
const
[
pageParams
,
setPageParams
]
=
useState
({
const
[
pageParams
,
setPageParams
]
=
useState
({
pageNo
:
1
,
pageNo
:
1
,
pageSize
:
16
,
pageSize
:
16
,
});
});
//分页器对象
const
[
count
,
setCount
]
=
useState
(
0
);
const
[
count
,
setCount
]
=
useState
(
0
);
//商品总数
const
[
abort
,
setAbort
]
=
useState
<
AbortController
|
null
>
(
null
);
const
[
abort
,
setAbort
]
=
useState
<
AbortController
|
null
>
(
null
);
//请求中断对你
const
[
adList
,
setAdList
]
=
useState
<
Array
<
Ad
>>
([]);
//广告列表
useEffect
(()
=>
{
useEffect
(()
=>
{
//中断前一次请求
//中断前一次
列表
请求
abort
?.
abort
();
abort
?.
abort
();
setAbort
(
new
AbortController
());
setAbort
(
new
AbortController
());
},
[
filterResult
,
pageParams
]);
},
[
filterResult
,
pageParams
]);
//端口列表请求
useEffect
(()
=>
{
useEffect
(()
=>
{
api
api
.
listPageGoodsInfo
(
.
listPageGoodsInfo
(
...
@@ -50,7 +51,17 @@ export default function Mall(props: Props) {
...
@@ -50,7 +51,17 @@ export default function Mall(props: Props) {
});
});
},
[
abort
]);
},
[
abort
]);
const
onFilterChange
=
(
filterResult
:
FilterResult
,
adapterFilterResult
:
AdapterResult
)
=>
{
//广告请求
useEffect
(()
=>
{
api
.
ad
().
then
((
res
)
=>
{
setAdList
(
res
.
result
||
[]);
});
},
[]);
const
onFilterChange
=
(
filterResult
:
FilterResult
,
adapterFilterResult
:
AdapterResult
)
=>
{
console
.
log
(
"filterResult"
,
filterResult
,
adapterFilterResult
);
console
.
log
(
"filterResult"
,
filterResult
,
adapterFilterResult
);
setFilterResult
(
adapterFilterResult
);
setFilterResult
(
adapterFilterResult
);
};
};
...
@@ -79,7 +90,7 @@ export default function Mall(props: Props) {
...
@@ -79,7 +90,7 @@ export default function Mall(props: Props) {
<
li
<
li
key=
{
i
}
key=
{
i
}
className=
{
styles
.
item
}
className=
{
styles
.
item
}
onClick=
{
()
=>
router
.
push
(
"/mall/detail/
1"
)
}
onClick=
{
()
=>
router
.
push
(
"/mall/detail/
"
+
item
.
id
)
}
>
>
<
div
className=
{
styles
.
imgBox
}
>
<
div
className=
{
styles
.
imgBox
}
>
<
Image
<
Image
...
@@ -88,6 +99,7 @@ export default function Mall(props: Props) {
...
@@ -88,6 +99,7 @@ export default function Mall(props: Props) {
className=
{
styles
.
img
}
className=
{
styles
.
img
}
width=
{
116
}
width=
{
116
}
height=
{
116
}
height=
{
116
}
preview=
{
false
}
></
Image
>
></
Image
>
</
div
>
</
div
>
<
div
className=
{
styles
.
title
}
>
{
item
.
goodsName
}
</
div
>
<
div
className=
{
styles
.
title
}
>
{
item
.
goodsName
}
</
div
>
...
@@ -99,7 +111,13 @@ export default function Mall(props: Props) {
...
@@ -99,7 +111,13 @@ export default function Mall(props: Props) {
);
);
})
}
})
}
{
productList
.
length
===
0
&&
(
{
productList
.
length
===
0
&&
(
<
Empty
style=
{
{
paddingTop
:
20
,
width
:
'100%'
,
textAlign
:
"center"
}
}
></
Empty
>
<
Empty
style=
{
{
paddingTop
:
20
,
width
:
"100%"
,
textAlign
:
"center"
,
}
}
></
Empty
>
)
}
)
}
</
ul
>
</
ul
>
<
Pagination
<
Pagination
...
@@ -109,13 +127,23 @@ export default function Mall(props: Props) {
...
@@ -109,13 +127,23 @@ export default function Mall(props: Props) {
total=
{
count
}
total=
{
count
}
onChange=
{
onPageChange
}
onChange=
{
onPageChange
}
hideOnSinglePage=
{
true
}
hideOnSinglePage=
{
true
}
style=
{
{
marginTop
:
20
}
}
style=
{
{
marginTop
:
20
}
}
/>
/>
</
div
>
</
div
>
<
div
className=
{
styles
.
adList
}
>
<
div
className=
{
styles
.
adList
}
>
<
div
className=
{
styles
.
ad
}
></
div
>
{
adList
.
map
((
item
)
=>
{
<
div
className=
{
styles
.
ad
}
></
div
>
return
(
<
Image
key=
{
item
.
id
}
className=
{
styles
.
ad
}
src=
{
item
.
imageUrl
}
width=
"270"
height=
"270"
preview=
{
false
}
></
Image
>
);
})
}
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论