Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
web-ci-test
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
test-ci
web-ci-test
Commits
6f8be5da
提交
6f8be5da
authored
6月 12, 2023
作者:
曹云
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
ssh://git.mmcuav.cn:8222/iuav/csf-web
into feature/chuck
上级
7f71b3dd
412722ef
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
326 行增加
和
281 行删除
+326
-281
index.tsx
components/filter/compoents/typeInfo/index.tsx
+1
-1
index.tsx
...quipmentLeasing/detail/components/orderForGoods/index.tsx
+8
-7
[id].page.tsx
pages/mall/detail/[id].page.tsx
+214
-207
index.tsx
pages/mall/detail/components/intentionModal/index.tsx
+99
-62
index.tsx
pages/mall/detail/components/orderForGoods/index.tsx
+4
-4
没有找到文件。
components/filter/compoents/typeInfo/index.tsx
浏览文件 @
6f8be5da
...
...
@@ -23,7 +23,7 @@ export default function CategoryItem(props: Props) {
})
}
const
showCount
=
12
//展示数量
const
showCount
=
9
//展示数量
return
(
<
div
className=
{
styles
.
filterItem
}
>
...
...
pages/equipmentLeasing/detail/components/orderForGoods/index.tsx
浏览文件 @
6f8be5da
...
...
@@ -82,7 +82,8 @@ export default function OrderForGoods(props: PropsBox) {
if
(
res
.
code
===
'200'
)
{
message
.
success
(
'提交成功'
)
setPaymentDetail
(
res
.
result
)
setIsPaymentOpen
(
true
)
// setIsPaymentOpen(true)
setIsorderForGoods
(
false
)
}
else
{
message
.
error
(
res
.
message
)
}
...
...
@@ -340,7 +341,7 @@ export default function OrderForGoods(props: PropsBox) {
</
div
>
</
div
>
<
Modal
{
/*
<Modal
wrapClassName="Payment"
open={isPaymentOpen}
onOk={handleOkPayment}
...
...
@@ -365,7 +366,7 @@ export default function OrderForGoods(props: PropsBox) {
</div>
<div>云享飞账号: {userInfo?.uid}</div>
<div>付款方式: 可用(¥{paymentDetail?.balance})</div>
</
Modal
>
</Modal>
*/
}
<
Modal
wrapClassName=
"addAddress"
...
...
@@ -383,8 +384,8 @@ export default function OrderForGoods(props: PropsBox) {
preview=
{
{
visible
:
false
}
}
src=
{
window
.
location
.
href
.
includes
(
'https://test.iuav.shop/'
)
?
'https://pad-video-x.oss-cn-shenzhen.aliyuncs.com/image/app-iuav-
trial
.jpg'
:
'https://pad-video-x.oss-cn-shenzhen.aliyuncs.com/image/app-iuav-
formal
.jpg'
||
?
'https://pad-video-x.oss-cn-shenzhen.aliyuncs.com/image/app-iuav-
formal1
.jpg'
:
'https://pad-video-x.oss-cn-shenzhen.aliyuncs.com/image/app-iuav-
trial1
.jpg'
||
''
}
onClick=
{
()
=>
setAddressVisible
(
true
)
}
...
...
@@ -399,8 +400,8 @@ export default function OrderForGoods(props: PropsBox) {
<
Image
src=
{
window
.
location
.
href
.
includes
(
'https://test.iuav.shop/'
)
?
'https://pad-video-x.oss-cn-shenzhen.aliyuncs.com/image/app-iuav-
trial
.jpg'
:
'https://pad-video-x.oss-cn-shenzhen.aliyuncs.com/image/app-iuav-
formal
.jpg'
||
?
'https://pad-video-x.oss-cn-shenzhen.aliyuncs.com/image/app-iuav-
formal1
.jpg'
:
'https://pad-video-x.oss-cn-shenzhen.aliyuncs.com/image/app-iuav-
trial1
.jpg'
||
''
}
/>
...
...
pages/mall/detail/[id].page.tsx
浏览文件 @
6f8be5da
import
styles
from
"./index.module.scss"
;
import
Layout
from
"~/components/layout"
;
import
{
Space
,
Image
as
AImage
,
Row
,
Col
,
Button
,
Divider
,
Badge
}
from
"antd"
;
import
{
useContext
,
useEffect
,
useState
}
from
"react"
;
import
{
DownOutlined
,
RightOutlined
}
from
"@ant-design/icons"
;
import
Image
from
"next/image"
;
import
errImg
from
"~/assets/errImg"
;
import
{
useRouter
}
from
"next/router"
;
import
styles
from
'./index.module.scss'
import
Layout
from
'~/components/layout'
import
{
Space
,
Image
as
AImage
,
Row
,
Col
,
Button
,
Divider
,
Badge
}
from
'antd'
import
{
useContext
,
useEffect
,
useState
}
from
'react'
import
{
DownOutlined
,
RightOutlined
}
from
'@ant-design/icons'
import
Image
from
'next/image'
import
errImg
from
'~/assets/errImg'
import
{
useRouter
}
from
'next/router'
// Import Swiper React components
import
{
Swiper
,
SwiperSlide
}
from
"swiper/react"
;
import
{
Navigation
}
from
"swiper"
;
import
{
Swiper
,
SwiperSlide
}
from
'swiper/react'
import
{
Navigation
}
from
'swiper'
import
OrderForGoods
from
'./components/orderForGoods'
// Import Swiper styles
import
"swiper/css"
;
import
"swiper/css/navigation"
;
import
api
,
{
GetLeaseGoodsDetailResp
,
ProductSpecList
}
from
"./api"
;
import
IntentionModal
from
"./components/intentionModal"
;
import
{
UserContext
}
from
"~/lib/userProvider"
;
import
'swiper/css'
import
'swiper/css/navigation'
import
api
,
{
GetLeaseGoodsDetailResp
}
from
'./api'
import
IntentionModal
from
'./components/intentionModal'
import
{
UserContext
}
from
'~/lib/userProvider'
export
default
function
MallDetail
()
{
const
{
userInfo
,
setNeedLogin
}
=
useContext
(
UserContext
);
const
[
visible
,
setVisible
]
=
useState
(
false
);
//商品图预览
const
router
=
useRouter
();
const
[
id
,
setId
]
=
useState
<
number
|
null
>
(
null
);
const
[
detail
,
setDetail
]
=
useState
<
GetLeaseGoodsDetailResp
|
null
>
(
null
);
//详情数据
const
[
intentionModalOpen
,
setIntentionModalOpen
]
=
useState
(
false
);
//意向弹窗
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
]);
const
{
userInfo
,
setNeedLogin
}
=
useContext
(
UserContext
)
const
[
visible
,
setVisible
]
=
useState
(
false
)
//商品图预览
const
router
=
useRouter
()
const
[
id
,
setId
]
=
useState
<
number
|
null
>
(
null
)
const
[
detail
,
setDetail
]
=
useState
<
GetLeaseGoodsDetailResp
|
null
>
(
null
)
//详情数据
const
[
intentionModalOpen
,
setIntentionModalOpen
]
=
useState
(
false
)
//意向弹窗
const
[
productImg
,
setProductImg
]
=
useState
(
''
)
//展示的商品图
//打开意向modal
const
openIntentionModal
=
()
=>
{
if
(
userInfo
)
{
setIntentionModalOpen
(
true
)
;
setIntentionModalOpen
(
true
)
}
else
{
setNeedLogin
(
true
)
;
setNeedLogin
(
true
)
}
}
;
}
//提交意向
const
handleIntentionOk
=
()
=>
{
setIntentionModalOpen
(
false
)
;
}
;
setIntentionModalOpen
(
false
)
}
const
handleIntentionCancel
=
()
=>
{
setIntentionModalOpen
(
false
)
;
}
;
setIntentionModalOpen
(
false
)
}
useEffect
(()
=>
{
setId
(
Number
(
router
.
query
.
id
))
;
},
[
router
])
;
setId
(
Number
(
router
.
query
.
id
))
},
[
router
])
useEffect
(()
=>
{
if
(
id
)
{
...
...
@@ -71,12 +57,23 @@ export default function MallDetail() {
type
:
0
,
})
.
then
((
res
)
=>
{
setDetail
(
res
.
result
||
null
);
setProductImg
(
res
.
result
?.
images
?.[
0
]?.
imgUrl
||
""
);
});
setDetail
(
res
.
result
||
null
)
setProductImg
(
res
.
result
?.
images
?.[
0
]?.
imgUrl
||
''
)
const
wareList
=
res
.
result
?.
goodsSpec
.
map
(
(
item
)
=>
item
.
productSpecList
)
if
(
wareList
)
{
const
List
:
any
=
wareList
.
flat
()
setWareSkuList
(
List
)
}
})
}
},
[
id
])
;
},
[
id
])
//订单弹框
const
[
isorderForGoods
,
setIsorderForGoods
]
=
useState
(
false
)
const
[
wareSkuList
,
setWareSkuList
]
=
useState
<
any
>
()
const
[
mallDetail
,
setMallDetail
]
=
useState
<
any
>
()
return
(
<
Layout
>
{
/* 意向弹窗 */
}
...
...
@@ -85,179 +82,189 @@ export default function MallDetail() {
detail=
{
detail
}
onOk=
{
handleIntentionOk
}
onCancel=
{
handleIntentionCancel
}
onChange=
{
(
items
:
ProductSpecList
[])
=>
setCheckItems
(
items
)
}
setIsorderForGoods=
{
setIsorderForGoods
}
setMallDetail=
{
setMallDetail
}
></
IntentionModal
>
<
div
className=
"page"
style=
{
{
marginTop
:
20
,
backgroundColor
:
"#fff"
}
}
>
<
div
style=
{
{
display
:
"none"
}
}
>
<
AImage
.
PreviewGroup
preview=
{
{
visible
,
onVisibleChange
:
(
vis
)
=>
setVisible
(
vis
),
current
:
previewIndex
,
}
}
>
{
detail
?.
images
?.
map
((
item
)
=>
{
return
<
AImage
key=
{
item
.
id
}
src=
{
item
.
imgUrl
}
/>;
})
}
</
AImage
.
PreviewGroup
>
</
div
>
<
Space
size=
{
30
}
style=
{
{
padding
:
"22px 24px 0"
,
alignItems
:
"start"
}
}
{
!
isorderForGoods
?
(
<
div
className=
"page"
style=
{
{
marginTop
:
20
,
backgroundColor
:
'#fff'
}
}
>
{
/* 商品图 */
}
<
Space
size=
{
17
}
direction=
"vertical"
style=
{
{
width
:
300
}
}
>
<
AImage
preview=
{
{
visible
:
false
}
}
width=
{
300
}
height=
{
300
}
src=
{
productImg
}
onClick=
{
()
=>
setVisible
(
true
)
}
fallback=
{
errImg
}
style=
{
{
borderRadius
:
6
,
}
}
/>
<
Swiper
modules=
{
[
Navigation
]
}
spaceBetween=
{
6
}
slidesPerView=
{
5
}
onSlideChange=
{
()
=>
console
.
log
(
"slide change"
)
}
onSwiper=
{
(
swiper
)
=>
console
.
log
(
swiper
)
}
<
div
style=
{
{
display
:
'none'
}
}
>
<
AImage
.
PreviewGroup
preview=
{
{
visible
,
onVisibleChange
:
(
vis
)
=>
setVisible
(
vis
)
}
}
>
{
detail
?.
images
?.
map
((
item
,
i
)
=>
{
return
(
<
SwiperSlide
key=
{
item
.
id
}
>
<
AImage
preview=
{
false
}
width=
{
50
}
height=
{
50
}
src=
{
item
.
imgUrl
}
fallback=
{
errImg
}
style=
{
{
cursor
:
"pointer"
}
}
onClick=
{
()
=>
{
setProductImg
(
item
.
imgUrl
),
setPreviewIndex
(
i
);
}
}
/>
</
SwiperSlide
>
);
{
detail
?.
images
?.
map
((
item
)
=>
{
return
<
AImage
key=
{
item
.
id
}
src=
{
item
.
imgUrl
}
/>
})
}
</
Swiper
>
</
Space
>
<
Space
direction=
"vertical"
size=
{
17
}
>
<
div
className=
{
`${styles.font1} ${styles.ellipsis}`
}
>
{
detail
?.
goodsName
}
</
div
>
<
div
className=
{
`${styles.font2} ${styles.ellipsis2}`
}
style=
{
{}
}
>
{
detail
?.
goodsDetail
?.
goodsDesc
}
</
div
>
<
Space
size=
{
24
}
direction=
"vertical"
style=
{
{
padding
:
"24px 40px 0px 0"
,
width
:
470
,
}
}
>
<
Row
wrap=
{
false
}
justify=
"space-between"
>
<
Col
span=
{
12
}
>
<
Row
>
<
Col
flex=
"60px"
className=
{
styles
.
font3
}
>
选择
</
Col
>
<
Col
flex=
"auto"
className=
{
styles
.
font4
}
style=
{
{}
}
>
已选:
{
checkItems
.
length
}
件
</
Col
>
</
Row
>
</
Col
>
<
Col
>
<
Row
align=
"middle"
style=
{
{
cursor
:
"pointer"
}
}
>
<
Col
className=
{
styles
.
font4
}
onClick=
{
openIntentionModal
}
>
共
{
specCount
}
种可选
</
Col
>
<
Col
style=
{
{
marginLeft
:
9
}
}
>
<
DownOutlined
style=
{
{
fontSize
:
12
,
color
:
"RGBA(219, 219, 219, 1)"
,
}
}
</
AImage
.
PreviewGroup
>
</
div
>
<
Space
size=
{
30
}
style=
{
{
padding
:
'22px 24px 0'
,
alignItems
:
'start'
}
}
>
{
/* 商品图 */
}
<
Space
size=
{
17
}
direction=
"vertical"
style=
{
{
width
:
300
}
}
>
<
AImage
preview=
{
{
visible
:
false
}
}
width=
{
300
}
height=
{
300
}
src=
{
productImg
}
onClick=
{
()
=>
setVisible
(
true
)
}
fallback=
{
errImg
}
style=
{
{
borderRadius
:
6
,
}
}
/>
<
Swiper
modules=
{
[
Navigation
]
}
spaceBetween=
{
6
}
slidesPerView=
{
5
}
onSlideChange=
{
()
=>
console
.
log
(
'slide change'
)
}
onSwiper=
{
(
swiper
)
=>
console
.
log
(
swiper
)
}
>
{
detail
?.
images
?.
map
((
item
)
=>
{
return
(
<
SwiperSlide
key=
{
item
.
id
}
>
<
AImage
preview=
{
false
}
width=
{
50
}
height=
{
50
}
src=
{
item
.
imgUrl
}
fallback=
{
errImg
}
style=
{
{
cursor
:
'pointer'
}
}
onClick=
{
()
=>
setProductImg
(
item
.
imgUrl
)
}
/>
</
Col
>
</
Row
>
</
Col
>
</
Row
>
<
Row
wrap=
{
false
}
>
<
Col
flex=
"60px"
className=
{
styles
.
font3
}
>
送至
</
Col
>
<
Col
flex=
"auto"
style=
{
{
cursor
:
"pointer"
}
}
>
<
Space
size=
{
5
}
>
<
Image
alt=
""
width=
{
18
}
height=
{
18
}
src=
{
require
(
"./assets/locate.png"
)
}
></
Image
>
<
span
className=
{
`${styles.font3} ${styles.ellipsis}`
}
>
广东深圳市南山区万科云城创新谷6栋A座…
</
span
>
</
Space
>
<
div
className=
{
styles
.
font4
}
style=
{
{
marginTop
:
7
}
}
>
现货,22:00前下单,预计后天(8月30日)送达
</
div
>
</
Col
>
</
Row
>
</
SwiperSlide
>
)
})
}
</
Swiper
>
</
Space
>
<
Space
size=
{
12
}
style=
{
{
marginTop
:
123
}
}
>
<
Button
className=
{
styles
.
btn1
}
onClick=
{
openIntentionModal
}
>
加入购物车
</
Button
>
<
Button
className=
{
styles
.
btn2
}
type=
"primary"
onClick=
{
openIntentionModal
}
<
Space
direction=
"vertical"
size=
{
17
}
>
<
div
className=
{
`${styles.font1} ${styles.ellipsis}`
}
>
{
detail
?.
goodsName
}
</
div
>
<
div
className=
{
`${styles.font2} ${styles.ellipsis2}`
}
style=
{
{}
}
>
{
detail
?.
goodsDetail
?.
goodsDesc
}
</
div
>
<
Space
size=
{
24
}
direction=
"vertical"
style=
{
{
padding
:
'24px 40px 0px 0'
,
width
:
470
,
}
}
>
提交意向
</
Button
>
<
Space
size=
{
20
}
style=
{
{
marginLeft
:
19
}
}
>
<
div
style=
{
{
textAlign
:
"center"
,
cursor
:
"pointer"
}
}
>
<
Image
alt=
""
src=
{
require
(
"./assets/phone.png"
)
}
width=
{
20
}
height=
{
20
}
></
Image
>
<
div
className=
{
styles
.
font5
}
style=
{
{
marginTop
:
5
}
}
>
电话
</
div
>
</
div
>
<
div
style=
{
{
textAlign
:
"center"
,
cursor
:
"pointer"
}
}
>
<
Badge
count=
{
55
}
size=
"small"
>
<
Row
wrap=
{
false
}
justify=
"space-between"
>
<
Col
span=
{
12
}
>
<
Row
>
<
Col
flex=
"60px"
className=
{
styles
.
font3
}
>
选择
</
Col
>
<
Col
flex=
"auto"
className=
{
styles
.
font4
}
style=
{
{}
}
>
已选:1件
</
Col
>
</
Row
>
</
Col
>
<
Col
>
<
Row
align=
"middle"
style=
{
{
cursor
:
'pointer'
}
}
>
<
Col
className=
{
styles
.
font4
}
onClick=
{
openIntentionModal
}
>
共3种可选
</
Col
>
<
Col
style=
{
{
marginLeft
:
9
}
}
>
<
DownOutlined
style=
{
{
fontSize
:
12
,
color
:
'RGBA(219, 219, 219, 1)'
,
}
}
/>
</
Col
>
</
Row
>
</
Col
>
</
Row
>
<
Row
wrap=
{
false
}
>
<
Col
flex=
"60px"
className=
{
styles
.
font3
}
>
送至
</
Col
>
<
Col
flex=
"auto"
style=
{
{
cursor
:
'pointer'
}
}
>
<
Space
size=
{
5
}
>
<
Image
alt=
""
width=
{
18
}
height=
{
18
}
src=
{
require
(
'./assets/locate.png'
)
}
></
Image
>
<
span
className=
{
`${styles.font3} ${styles.ellipsis}`
}
>
广东深圳市南山区万科云城创新谷6栋A座…
</
span
>
</
Space
>
<
div
className=
{
styles
.
font4
}
style=
{
{
marginTop
:
7
}
}
>
现货,22:00前下单,预计后天(8月30日)送达
</
div
>
</
Col
>
</
Row
>
</
Space
>
<
Space
size=
{
12
}
style=
{
{
marginTop
:
123
}
}
>
<
Button
className=
{
styles
.
btn1
}
onClick=
{
openIntentionModal
}
>
加入购物车
</
Button
>
<
Button
className=
{
styles
.
btn2
}
type=
"primary"
onClick=
{
openIntentionModal
}
>
提交意向
</
Button
>
<
Space
size=
{
20
}
style=
{
{
marginLeft
:
19
}
}
>
<
div
style=
{
{
textAlign
:
'center'
,
cursor
:
'pointer'
}
}
>
<
Image
alt=
""
src=
{
require
(
"./assets/car.png"
)
}
src=
{
require
(
'./assets/phone.png'
)
}
width=
{
20
}
height=
{
20
}
></
Image
>
</
Badge
>
<
div
className=
{
styles
.
font5
}
style=
{
{
marginTop
:
5
}
}
>
购物车
<
div
className=
{
styles
.
font5
}
style=
{
{
marginTop
:
5
}
}
>
电话
</
div
>
</
div
>
</
div
>
<
div
style=
{
{
textAlign
:
'center'
,
cursor
:
'pointer'
}
}
>
<
Badge
count=
{
55
}
size=
"small"
>
<
Image
alt=
""
src=
{
require
(
'./assets/car.png'
)
}
width=
{
20
}
height=
{
20
}
></
Image
>
</
Badge
>
<
div
className=
{
styles
.
font5
}
style=
{
{
marginTop
:
5
}
}
>
购物车
</
div
>
</
div
>
</
Space
>
</
Space
>
</
Space
>
</
Space
>
</
Space
>
<
Divider
className=
{
styles
.
divider
}
>
商品详情
</
Divider
>
<
div
style=
{
{
textAlign
:
"center"
}
}
>
<
div
dangerouslySetInnerHTML=
{
{
__html
:
detail
?.
goodsDetail
?.
content
||
""
,
}
}
>
</
div
>
<
Divider
className=
{
styles
.
divider
}
>
商品详情
</
Divider
>
<
div
style=
{
{
textAlign
:
'center'
}
}
>
<
div
dangerouslySetInnerHTML=
{
{
__html
:
detail
?.
goodsDetail
?.
content
||
''
,
}
}
></
div
>
</
div
>
</
div
>
</
div
>
)
:
(
//订单
<
OrderForGoods
setIsorderForGoods=
{
setIsorderForGoods
}
detailData=
{
detail
}
mallDetail=
{
mallDetail
}
/>
)
}
</
Layout
>
)
;
)
}
pages/mall/detail/components/intentionModal/index.tsx
浏览文件 @
6f8be5da
import
{
Button
,
Col
,
Image
,
message
,
Modal
,
Row
,
Space
}
from
"antd"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
errImg
from
"~/assets/errImg"
;
import
{
GetLeaseGoodsDetailResp
,
ProductSpecList
}
from
"../../api"
;
import
styles
from
"./index.module.scss"
;
import
api
from
"./api"
;
import
Item
from
"antd/es/list/Item"
;
import
{
Button
,
Col
,
Image
,
message
,
Modal
,
Row
,
Space
,
InputNumber
,
}
from
'antd'
import
{
Dispatch
,
SetStateAction
,
useEffect
,
useState
}
from
'react'
import
errImg
from
'~/assets/errImg'
import
{
GetLeaseGoodsDetailResp
,
ProductSpecList
}
from
'../../api'
import
styles
from
'./index.module.scss'
import
api
from
'./api'
import
Item
from
'antd/es/list/Item'
type
Props
=
{
open
?:
boolean
;
onOk
?:
()
=>
void
;
onCancel
:
()
=>
void
;
detail
:
GetLeaseGoodsDetailResp
|
null
;
onChange
?:
(
checkItems
:
ProductSpecList
[])
=>
void
;
};
open
?:
boolean
onOk
?:
()
=>
void
onCancel
:
()
=>
void
detail
:
GetLeaseGoodsDetailResp
|
null
setIsorderForGoods
:
Dispatch
<
SetStateAction
<
boolean
>>
setMallDetail
:
Dispatch
<
SetStateAction
<
any
>>
}
export
default
function
IntentionModal
(
props
:
Props
)
{
const
[
checkedMap
,
setCheckedMap
]
=
useState
<
{
string
?:
boolean
}
>
({});
//通过索引记录选中的产品规格 例: {'1,1': true|false} props.detail?.goodsSpec[1].productSpecList[1]
const
[
checkItems
,
setCheckItems
]
=
useState
<
ProductSpecList
[]
>
([]);
//选中的规格
const
[
loading
,
setLoading
]
=
useState
(
false
);
//下单中
const
[
checkedMap
,
setCheckedMap
]
=
useState
<
{
string
?:
boolean
}
>
({})
//通过索引记录选中的产品规格 例: {'1,1': true|false} props.detail?.goodsSpec[1].productSpecList[1]
const
[
checkItems
,
setCheckItems
]
=
useState
<
ProductSpecList
[]
>
([])
//选中的规格
const
[
loading
,
setLoading
]
=
useState
(
false
)
//下单中
const
[
numValue
,
setNumValue
]
=
useState
<
number
|
null
>
(
1
)
//数量
useEffect
(()
=>
{
let
list
:
ProductSpecList
[]
=
[]
;
let
list
:
ProductSpecList
[]
=
[]
Object
.
keys
(
checkedMap
).
forEach
((
key
)
=>
{
if
(
checkedMap
[
key
as
keyof
typeof
checkedMap
])
{
let
arr
=
key
.
split
(
","
);
let
arr
=
key
.
split
(
','
)
let
item
=
props
.
detail
?.
goodsSpec
[
Number
(
arr
[
0
])].
productSpecList
[
Number
(
arr
[
1
])
]
;
]
if
(
item
)
{
list
.
push
(
item
)
;
list
.
push
(
item
)
}
}
})
;
setCheckItems
(
list
)
;
props
.
onChange
&&
props
.
onChange
(
list
);
},
[
checkedMap
])
;
})
setCheckItems
(
list
)
setNumValue
(
1
)
},
[
checkedMap
])
//添加规格到购物车
function
addProductSpec
(
goodsSpecIndex
:
number
,
productSpecIndex
:
number
)
{
let
temp
=
{}
;
let
temp
=
{}
//@ts-ignore
temp
[
`
${
goodsSpecIndex
}
,
${
productSpecIndex
}
`
]
=
//@ts-ignore
!
checkedMap
[
`
${
goodsSpecIndex
}
,
${
productSpecIndex
}
`
]
;
!
checkedMap
[
`
${
goodsSpecIndex
}
,
${
productSpecIndex
}
`
]
setCheckedMap
({
...
checkedMap
,
...
temp
,
});
})
}
//数量
const
onChangeNum
=
(
value
:
number
|
null
)
=>
{
console
.
log
(
'changed'
,
value
)
setNumValue
(
value
)
}
//提交
function
onSubmit
()
{
let
buyNum
=
0
;
let
mallSpecIds
:
number
[]
=
[]
;
let
buyNum
=
0
let
mallSpecIds
:
number
[]
=
[]
Object
.
keys
(
checkedMap
).
forEach
((
key
)
=>
{
if
(
checkedMap
[
key
as
keyof
typeof
checkedMap
])
{
buyNum
++
;
let
arr
=
key
.
split
(
","
);
buyNum
++
let
arr
=
key
.
split
(
','
)
let
specId
=
props
.
detail
?.
goodsSpec
[
Number
(
arr
[
0
])].
productSpecList
[
Number
(
arr
[
1
])
].
id
;
].
id
if
(
specId
)
{
mallSpecIds
.
push
(
specId
)
;
mallSpecIds
.
push
(
specId
)
}
}
})
;
})
if
(
buyNum
>
0
)
{
setLoading
(
true
)
;
setLoading
(
true
)
api
.
commitMallOrder
({
buyNum
,
buyNum
:
numValue
||
1
,
directoryId
:
1
,
goodsInfoId
:
props
.
detail
!
.
id
,
mallSpecIds
,
userAddressId
:
1
,
})
.
then
((
res
)
=>
{
if
(
res
.
code
==
"200"
)
{
message
.
success
(
"提交意向成功"
);
if
(
res
.
code
==
'200'
)
{
message
.
success
(
'提交意向成功'
)
//重置为未选中
let
temp
=
{
...
checkedMap
,
}
;
}
Object
.
keys
(
temp
).
forEach
((
key
)
=>
{
temp
[
key
as
keyof
typeof
temp
]
=
false
;
});
setCheckedMap
(
temp
);
props
.
onCancel
();
temp
[
key
as
keyof
typeof
temp
]
=
false
})
setCheckedMap
(
temp
)
props
.
onCancel
()
props
.
setIsorderForGoods
(
true
)
props
.
setMallDetail
({
...
res
.
result
,
buyNum
:
numValue
||
1
,
directoryId
:
1
,
goodsInfoId
:
props
.
detail
!
.
id
,
mallSpecIds
,
userAddressId
:
1
,
})
}
else
{
}
setLoading
(
false
)
;
setLoading
(
false
)
})
.
catch
((
err
)
=>
{
message
.
error
(
"提交意向失败"
);
console
.
log
(
"err"
,
err
);
setLoading
(
false
)
;
})
;
message
.
error
(
'提交意向失败'
)
console
.
log
(
'err'
,
err
)
setLoading
(
false
)
})
}
}
...
...
@@ -111,21 +136,20 @@ export default function IntentionModal(props: Props) {
style=
{
{
padding
:
0
}
}
className=
{
styles
.
model
}
footer=
{
<
div
style=
{
{
padding
:
"13px 36px"
}
}
>
<
div
style=
{
{
padding
:
'13px 36px'
}
}
>
<
Button
type=
"primary"
className=
{
styles
.
font5
}
style=
{
{
width
:
"100%"
,
height
:
44
}
}
style=
{
{
width
:
'100%'
,
height
:
44
}
}
onClick=
{
onSubmit
}
loading=
{
loading
}
disabled=
{
checkItems
.
length
==
0
}
>
提交意向
</
Button
>
</
div
>
}
>
<
Row
style=
{
{
padding
:
"22px 39px 12px 39px"
}
}
wrap=
{
false
}
>
<
Row
style=
{
{
padding
:
'22px 39px 12px 39px'
}
}
wrap=
{
false
}
>
<
Col
>
<
Image
width=
{
100
}
...
...
@@ -146,12 +170,12 @@ export default function IntentionModal(props: Props) {
className=
{
`${styles.font2} ${styles.ellipsis2}`
}
style=
{
{
marginTop
:
7
}
}
>
已选:
{
" "
}
已选:
{
' '
}
{
checkItems
.
map
((
item
)
=>
{
return
item
.
specName
;
return
item
.
specName
})
.
join
(
"+"
)
}
.
join
(
'+'
)
}
</
div
>
</
Col
>
</
Row
>
...
...
@@ -169,7 +193,7 @@ export default function IntentionModal(props: Props) {
>
{
item
.
goodsSpecName
}
</
div
>
<
Space
size=
{
10
}
direction=
"vertical"
style=
{
{
width
:
"100%"
}
}
>
<
Space
size=
{
10
}
direction=
"vertical"
style=
{
{
width
:
'100%'
}
}
>
{
item
.
productSpecList
?.
map
((
product
,
productSpecIndex
)
=>
{
return
(
<
Row
...
...
@@ -182,10 +206,10 @@ export default function IntentionModal(props: Props) {
border
:
checkedMap
[
`${goodsSpecIndex},${productSpecIndex}`
]
?
"1px solid #FF552D"
:
"1px solid #d6d6d6"
,
?
'1px solid #FF552D'
:
'1px solid #d6d6d6'
,
height
:
50
,
cursor
:
"pointer"
,
cursor
:
'pointer'
,
}
}
onClick=
{
()
=>
addProductSpec
(
goodsSpecIndex
,
productSpecIndex
)
...
...
@@ -207,14 +231,27 @@ export default function IntentionModal(props: Props) {
{
product
.
specName
}
</
Col
>
</
Row
>
)
;
)
})
}
</
Space
>
</
div
>
)
;
)
})
}
<
div
className=
{
styles
.
numBox
}
>
<
div
className=
{
styles
.
numLeft
}
>
<
div
className=
{
styles
.
label
}
>
数量
</
div
>
</
div
>
<
div
className=
{
styles
.
numRight
}
>
<
InputNumber
min=
{
1
}
max=
{
100
}
value=
{
numValue
}
onChange=
{
onChangeNum
}
/>
</
div
>
</
div
>
</
div
>
</
div
>
</
Modal
>
)
;
)
}
pages/mall/detail/components/orderForGoods/index.tsx
浏览文件 @
6f8be5da
...
...
@@ -283,8 +283,8 @@ export default function OrderForGoods(props: PropsBox) {
preview=
{
{
visible
:
false
}
}
src=
{
window
.
location
.
href
.
includes
(
'https://test.iuav.shop/'
)
?
'https://pad-video-x.oss-cn-shenzhen.aliyuncs.com/image/app-iuav-
trial
.jpg'
:
'https://pad-video-x.oss-cn-shenzhen.aliyuncs.com/image/app-iuav-
formal
.jpg'
||
?
'https://pad-video-x.oss-cn-shenzhen.aliyuncs.com/image/app-iuav-
formal1
.jpg'
:
'https://pad-video-x.oss-cn-shenzhen.aliyuncs.com/image/app-iuav-
trial1
.jpg'
||
''
}
onClick=
{
()
=>
setAddressVisible
(
true
)
}
...
...
@@ -299,8 +299,8 @@ export default function OrderForGoods(props: PropsBox) {
<
Image
src=
{
window
.
location
.
href
.
includes
(
'https://test.iuav.shop/'
)
?
'https://pad-video-x.oss-cn-shenzhen.aliyuncs.com/image/app-iuav-
trial
.jpg'
:
'https://pad-video-x.oss-cn-shenzhen.aliyuncs.com/image/app-iuav-
formal
.jpg'
||
?
'https://pad-video-x.oss-cn-shenzhen.aliyuncs.com/image/app-iuav-
formal1
.jpg'
:
'https://pad-video-x.oss-cn-shenzhen.aliyuncs.com/image/app-iuav-
trial1
.jpg'
||
''
}
/>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论