Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
web-ci-test
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
test-ci
web-ci-test
Commits
3524e2b9
提交
3524e2b9
authored
5月 22, 2023
作者:
翁进城
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
商城列表加载时优化
上级
9393282f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
61 行增加
和
48 行删除
+61
-48
index.module.scss
pages/mall/index.module.scss
+3
-1
index.page.tsx
pages/mall/index.page.tsx
+58
-47
没有找到文件。
pages/mall/index.module.scss
浏览文件 @
3524e2b9
...
...
@@ -15,6 +15,7 @@
flex-shrink
:
0
;
flex-direction
:
column
;
gap
:
12px
;
width
:
270px
;
.ad
{
width
:
270px
;
...
...
@@ -26,13 +27,14 @@
.listContent
{
width
:
100%
;
}
.listWrap
{
display
:
flex
;
flex-wrap
:
wrap
;
gap
:
12px
;
height
:
auto
;
height
:
856px
;
.item
{
cursor
:
pointer
;
...
...
pages/mall/index.page.tsx
浏览文件 @
3524e2b9
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
{
Empty
,
Pagination
,
Image
}
from
"antd"
;
import
{
Empty
,
Pagination
,
Image
,
Spin
}
from
"antd"
;
import
Layout
from
"~/components/layout"
;
import
styles
from
"./index.module.scss"
;
import
{
useRouter
}
from
"next/router"
;
import
Filter
,
{
AdapterResult
,
FilterResult
}
from
"~/components/filter"
;
import
api
,
{
Ad
,
Goods
,
ListPageGoodsInfoParams
}
from
"./api"
;
import
errImg
from
"~/assets/errImg"
;
// 此函数在构建时被调用
export
async
function
getServerSideProps
()
{
...
...
@@ -26,6 +27,7 @@ export default function Mall(props: Props) {
const
[
count
,
setCount
]
=
useState
(
0
);
//商品总数
const
[
abort
,
setAbort
]
=
useState
<
AbortController
|
null
>
(
null
);
//请求中断对你
const
[
adList
,
setAdList
]
=
useState
<
Array
<
Ad
>>
([]);
//广告列表
const
[
loading
,
setLoading
]
=
useState
(
false
);
useEffect
(()
=>
{
//中断前一次列表请求
...
...
@@ -38,6 +40,7 @@ export default function Mall(props: Props) {
if
(
!
abort
)
{
return
;
}
setLoading
(
true
);
api
.
listPageGoodsInfo
(
{
...
...
@@ -51,6 +54,7 @@ export default function Mall(props: Props) {
.
then
((
res
)
=>
{
setProductList
(
res
.
result
?.
list
||
[]);
setCount
(
res
.
result
?.
totalCount
||
0
);
setLoading
(
false
);
});
},
[
abort
]);
...
...
@@ -83,55 +87,61 @@ export default function Mall(props: Props) {
showResultItem
onChange=
{
onFilterChange
}
></
Filter
>
<
div
className=
{
styles
.
productList
}
>
<
div
className=
{
styles
.
title
}
>
四旋翼无人机
</
div
>
<
div
className=
{
styles
.
main
}
>
<
div
className=
{
styles
.
listContent
}
>
<
ul
className=
{
styles
.
listWrap
}
>
{
productList
.
map
((
item
,
i
)
=>
{
return
(
<
li
key=
{
i
}
className=
{
styles
.
item
}
onClick=
{
()
=>
router
.
push
(
"/mall/detail/"
+
item
.
id
)
}
>
<
div
className=
{
styles
.
imgBox
}
>
<
Image
alt=
""
src=
{
item
.
imgUrl
}
className=
{
styles
.
img
}
width=
{
116
}
height=
{
116
}
preview=
{
false
}
></
Image
>
</
div
>
<
div
className=
{
styles
.
title
}
>
{
item
.
goodsName
}
</
div
>
<
div
className=
{
styles
.
sellCount
}
>
半年售
{
(
Math
.
floor
(
Math
.
random
()
*
901
)
+
100
).
toFixed
(
0
)
}
</
div
>
</
li
>
);
})
}
{
productList
.
length
===
0
&&
(
<
Empty
style=
{
{
paddingTop
:
20
,
width
:
"100%"
,
textAlign
:
"center"
,
}
}
></
Empty
>
)
}
</
ul
>
<
Pagination
current=
{
pageParams
.
pageNo
}
showSizeChanger=
{
false
}
showQuickJumper
total=
{
count
}
onChange=
{
onPageChange
}
hideOnSinglePage=
{
true
}
style=
{
{
marginTop
:
20
}
}
/>
<
div
style=
{
{
flex
:
"auto"
}
}
>
<
Spin
spinning=
{
loading
}
delay=
{
500
}
>
<
div
className=
{
styles
.
listContent
}
>
<
ul
className=
{
styles
.
listWrap
}
>
{
productList
.
map
((
item
,
i
)
=>
{
return
(
<
li
key=
{
i
}
className=
{
styles
.
item
}
onClick=
{
()
=>
router
.
push
(
"/mall/detail/"
+
item
.
id
)
}
>
<
div
className=
{
styles
.
imgBox
}
>
<
Image
alt=
""
src=
{
item
.
imgUrl
}
className=
{
styles
.
img
}
width=
{
116
}
height=
{
116
}
preview=
{
false
}
></
Image
>
</
div
>
<
div
className=
{
styles
.
title
}
>
{
item
.
goodsName
}
</
div
>
<
div
className=
{
styles
.
sellCount
}
>
半年售
{
(
Math
.
floor
(
Math
.
random
()
*
901
)
+
100
).
toFixed
(
0
)
}
</
div
>
</
li
>
);
})
}
{
productList
.
length
===
0
&&
(
<
Empty
style=
{
{
paddingTop
:
20
,
width
:
"100%"
,
textAlign
:
"center"
,
}
}
></
Empty
>
)
}
</
ul
>
<
Pagination
current=
{
pageParams
.
pageNo
}
defaultPageSize=
{
pageParams
.
pageSize
}
showSizeChanger=
{
false
}
showQuickJumper
total=
{
count
}
onChange=
{
onPageChange
}
hideOnSinglePage=
{
true
}
style=
{
{
marginTop
:
20
}
}
/>
</
div
>
</
Spin
>
</
div
>
<
div
className=
{
styles
.
adList
}
>
...
...
@@ -144,6 +154,7 @@ export default function Mall(props: Props) {
width=
"270"
height=
"270"
preview=
{
false
}
fallback=
{
errImg
}
></
Image
>
);
})
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论