Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
web-ci-test
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
test-ci
web-ci-test
Commits
969ff207
提交
969ff207
authored
6月 12, 2023
作者:
翁进城
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 【产品商城】详情中副图、视频未显示,规格数未显示正确的数字
上级
736a88b0
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
29 行增加
和
11 行删除
+29
-11
[id].page.tsx
pages/mall/detail/[id].page.tsx
+26
-11
index.tsx
pages/mall/detail/components/intentionModal/index.tsx
+3
-0
没有找到文件。
pages/mall/detail/[id].page.tsx
浏览文件 @
969ff207
...
...
@@ -13,7 +13,7 @@ import { Navigation } from "swiper";
// Import Swiper styles
import
"swiper/css"
;
import
"swiper/css/navigation"
;
import
api
,
{
GetLeaseGoodsDetailResp
}
from
"./api"
;
import
api
,
{
GetLeaseGoodsDetailResp
,
ProductSpecList
}
from
"./api"
;
import
IntentionModal
from
"./components/intentionModal"
;
import
{
UserContext
}
from
"~/lib/userProvider"
;
...
...
@@ -22,11 +22,25 @@ export default function MallDetail() {
const
[
visible
,
setVisible
]
=
useState
(
false
);
//商品图预览
const
router
=
useRouter
();
const
[
id
,
setId
]
=
useState
<
number
|
null
>
(
null
);
const
[
detail
,
setDetail
]
=
useState
<
GetLeaseGoodsDetailResp
|
null
>
(
null
);
//详情数据
const
[
detail
,
setDetail
]
=
useState
<
GetLeaseGoodsDetailResp
|
null
>
(
null
);
//详情数据
const
[
intentionModalOpen
,
setIntentionModalOpen
]
=
useState
(
false
);
//意向弹窗
const
[
productImg
,
setProductImg
]
=
useState
(
''
);
//展示的商品图
const
[
productImg
,
setProductImg
]
=
useState
(
""
);
//展示的商品图
const
[
previewIndex
,
setPreviewIndex
]
=
useState
(
0
);
//预览开始索引
const
[
checkItems
,
setCheckItems
]
=
useState
<
ProductSpecList
[]
>
([]);
//选中的规格
const
[
specCount
,
setSpecCount
]
=
useState
(
0
);
//规格数量
useEffect
(()
=>
{
if
(
detail
){
let
count
=
0
;
detail
.
goodsSpec
?.
forEach
(
good
=>
{
good
.
productSpecList
?.
forEach
(
product
=>
{
count
++
;
})
})
setSpecCount
(
count
);
}
},
[
detail
])
//打开意向modal
const
openIntentionModal
=
()
=>
{
...
...
@@ -55,7 +69,7 @@ export default function MallDetail() {
api
.
getLeaseGoodsDetail
({
goodsId
:
id
,
type
:
0
type
:
0
,
})
.
then
((
res
)
=>
{
setDetail
(
res
.
result
||
null
);
...
...
@@ -72,11 +86,12 @@ export default function MallDetail() {
detail=
{
detail
}
onOk=
{
handleIntentionOk
}
onCancel=
{
handleIntentionCancel
}
onChange=
{
(
items
:
ProductSpecList
[])
=>
setCheckItems
(
items
)
}
></
IntentionModal
>
<
div
className=
"page"
style=
{
{
marginTop
:
20
,
backgroundColor
:
"#fff"
}
}
>
<
div
style=
{
{
display
:
"none"
}
}
>
<
AImage
.
PreviewGroup
preview=
{
{
visible
,
onVisibleChange
:
(
vis
)
=>
setVisible
(
vis
)
}
}
preview=
{
{
visible
,
onVisibleChange
:
(
vis
)
=>
setVisible
(
vis
)
,
current
:
previewIndex
}
}
>
{
detail
?.
images
?.
map
((
item
)
=>
{
return
<
AImage
key=
{
item
.
id
}
src=
{
item
.
imgUrl
}
/>;
...
...
@@ -107,7 +122,7 @@ export default function MallDetail() {
onSlideChange=
{
()
=>
console
.
log
(
"slide change"
)
}
onSwiper=
{
(
swiper
)
=>
console
.
log
(
swiper
)
}
>
{
detail
?.
images
?.
map
((
item
)
=>
{
{
detail
?.
images
?.
map
((
item
,
i
)
=>
{
return
(
<
SwiperSlide
key=
{
item
.
id
}
>
<
AImage
...
...
@@ -117,7 +132,7 @@ export default function MallDetail() {
src=
{
item
.
imgUrl
}
fallback=
{
errImg
}
style=
{
{
cursor
:
"pointer"
}
}
onClick=
{
()
=>
setProductImg
(
item
.
imgUrl
)
}
onClick=
{
()
=>
{
setProductImg
(
item
.
imgUrl
),
setPreviewIndex
(
i
)}
}
/>
</
SwiperSlide
>
);
...
...
@@ -147,14 +162,14 @@ export default function MallDetail() {
选择
</
Col
>
<
Col
flex=
"auto"
className=
{
styles
.
font4
}
style=
{
{}
}
>
已选:
1
件
已选:
{
checkItems
.
length
}
件
</
Col
>
</
Row
>
</
Col
>
<
Col
>
<
Row
align=
"middle"
style=
{
{
cursor
:
"pointer"
}
}
>
<
Col
className=
{
styles
.
font4
}
onClick=
{
openIntentionModal
}
>
共
3
种可选
共
{
specCount
}
种可选
</
Col
>
<
Col
style=
{
{
marginLeft
:
9
}
}
>
<
DownOutlined
...
...
pages/mall/detail/components/intentionModal/index.tsx
浏览文件 @
969ff207
...
...
@@ -11,6 +11,7 @@ type Props = {
onOk
?:
()
=>
void
;
onCancel
:
()
=>
void
;
detail
:
GetLeaseGoodsDetailResp
|
null
;
onChange
?:
(
checkItems
:
ProductSpecList
[])
=>
void
;
};
export
default
function
IntentionModal
(
props
:
Props
)
{
const
[
checkedMap
,
setCheckedMap
]
=
useState
<
{
string
?:
boolean
}
>
({});
//通过索引记录选中的产品规格 例: {'1,1': true|false} props.detail?.goodsSpec[1].productSpecList[1]
...
...
@@ -32,6 +33,7 @@ export default function IntentionModal(props: Props) {
}
});
setCheckItems
(
list
);
props
.
onChange
&&
props
.
onChange
(
list
);
},
[
checkedMap
]);
//添加规格到购物车
...
...
@@ -117,6 +119,7 @@ export default function IntentionModal(props: Props) {
style=
{
{
width
:
"100%"
,
height
:
44
}
}
onClick=
{
onSubmit
}
loading=
{
loading
}
disabled=
{
checkItems
.
length
==
0
}
>
提交意向
</
Button
>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论