Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈智峰
jinfa-platform
Commits
65fdba3d
Commit
65fdba3d
authored
Sep 03, 2020
by
GuanHua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:对接订单收货地址接口
parent
c870f334
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
19 deletions
+53
-19
index.tsx
src/pages/lxMall/commodityDetail/index.tsx
+1
-1
index.tsx
src/pages/lxMall/order/address/index.tsx
+39
-12
index.tsx
src/pages/lxMall/order/components/addAddress/index.tsx
+7
-4
common.less
src/pages/lxMall/order/components/common.less
+3
-1
request.ts
src/utils/request.ts
+3
-1
No files found.
src/pages/lxMall/commodityDetail/index.tsx
View file @
65fdba3d
...
...
@@ -99,7 +99,7 @@ const CommodityDetail = (props) => {
case
COMMODITY_TYPE
.
prompt
:
return
(
<>
<
div
className=
{
cx
(
styles
.
product_info_btn_item
,
styles
.
buy
)
}
onClick=
{
()
=>
history
.
push
(
'/order'
)
}
>
立即订购
</
div
>
<
div
className=
{
cx
(
styles
.
product_info_btn_item
,
styles
.
buy
)
}
onClick=
{
()
=>
history
.
push
(
`/order`
)
}
>
立即订购
</
div
>
<
div
className=
{
cx
(
styles
.
product_info_btn_item
,
styles
.
add
)
}
onClick=
{
()
=>
setAddSuccessVisible
(
true
)
}
>
<
img
className=
{
styles
.
btn_icon
}
src=
{
jinhuodanIcon
}
/>
<
span
>
加入进货单
</
span
>
...
...
src/pages/lxMall/order/address/index.tsx
View file @
65fdba3d
import
React
,
{
useState
}
from
'react'
import
React
,
{
useState
,
useEffect
}
from
'react'
import
{
Radio
}
from
'antd'
import
{
DownOutlined
}
from
'@ant-design/icons'
import
AddAddress
from
'../components/addAddress'
import
{
PublicApi
}
from
'@/services/api'
import
{
GetLogisticsReceiverAddressPageResponseDetail
}
from
'@/services/LogisticsApi'
import
styles
from
'./index.less'
const
Address
:
React
.
FC
=
()
=>
{
const
[
selectKey
,
setSelectKey
]
=
useState
<
number
>
()
const
[
expand
,
setExpand
]
=
useState
<
boolean
>
(
false
)
const
[
addressFormVisible
,
setAddressFormVisible
]
=
useState
<
boolean
>
(
false
)
const
[
addressList
,
setAddressList
]
=
useState
<
GetLogisticsReceiverAddressPageResponseDetail
[]
>
([])
const
mock_data
=
[
{
...
...
@@ -54,6 +57,23 @@ const Address: React.FC = () => {
}
]
useEffect
(()
=>
{
fetchAddressList
()
},
[])
const
fetchAddressList
=
()
=>
{
let
param
=
{
current
:
1
,
pageSize
:
50
}
//@ts-ignore
PublicApi
.
getLogisticsReceiverAddressPage
(
param
).
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
setAddressList
(
res
.
data
?.
data
)
}
})
}
const
handleSelect
=
(
e
:
any
)
=>
{
setSelectKey
(
e
.
target
.
value
)
}
...
...
@@ -67,12 +87,12 @@ const Address: React.FC = () => {
<
Radio
.
Group
className=
{
styles
.
address_raido_group
}
value=
{
selectKey
}
onChange=
{
handleSelect
}
>
<
div
className=
{
styles
.
address_list
}
>
{
mock_data
.
map
((
item
,
index
)
=>
(
!
expand
?
index
<
3
:
true
)
&&
(
addressList
.
map
((
item
,
index
)
=>
(
!
expand
?
index
<
3
:
true
)
&&
(
<
Radio
className=
{
styles
.
address_list_radio
}
value=
{
item
.
id
}
key=
{
`address_list_radio_${item.id}`
}
>
<
div
className=
{
styles
.
adderss_list_radio_line
}
>
<
span
>
{
item
.
n
ame
}
</
span
>
<
span
>
{
item
.
a
ddress
}
</
span
>
<
span
>
{
item
.
mobil
e
}
</
span
>
<
span
>
{
item
.
receiverN
ame
}
</
span
>
<
span
>
{
item
.
fullA
ddress
}
</
span
>
<
span
>
{
item
.
phon
e
}
</
span
>
{
item
.
isDefault
===
1
?
<
div
className=
{
styles
.
default_address
}
>
默认地址
</
div
>
:
<
div
className=
{
styles
.
set_default_address
}
>
设为默认地址
</
div
>
...
...
@@ -91,18 +111,25 @@ const Address: React.FC = () => {
}
</
div
>
</
Radio
.
Group
>
<
div
className=
{
styles
.
more_btn
}
onClick=
{
()
=>
setExpand
(
!
expand
)
}
>
<
span
>
{
expand
?
'收起'
:
'更多地址'
}
</
span
>
<
div
className=
{
styles
.
more_btn_icon
}
>
<
DownOutlined
rotate=
{
expand
?
180
:
0
}
/>
</
div
>
</
div
>
{
addressList
.
length
>
3
&&
(
<
div
className=
{
styles
.
more_btn
}
onClick=
{
()
=>
setExpand
(
!
expand
)
}
>
<
span
>
{
expand
?
'收起'
:
'更多地址'
}
</
span
>
<
div
className=
{
styles
.
more_btn_icon
}
>
<
DownOutlined
rotate=
{
expand
?
180
:
0
}
/>
</
div
>
</
div
>
)
}
<
AddAddress
title=
"新增收货地址"
visible=
{
addressFormVisible
}
onCancel=
{
()
=>
setAddressFormVisible
(
false
)
}
onOk=
{
()
=>
{
setAddressFormVisible
(
false
)
fetchAddressList
()
}
}
/>
</
div
>
)
}
...
...
src/pages/lxMall/order/components/addAddress/index.tsx
View file @
65fdba3d
...
...
@@ -45,6 +45,7 @@ const { onFieldValueChange$ } = FormEffectHooks
const
AddAddress
:
React
.
FC
<
AddAddressPropsType
>
=
(
props
)
=>
{
const
{
visible
=
false
,
title
,
onOk
,
onCancel
}
=
props
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
<
boolean
>
(
false
)
const
[
Options
,
setOptions
]
=
useState
([])
const
[
state
,
setState
]
=
useState
({
editable
:
true
})
const
[
provinceName
,
setProvinceName
]
=
useState
(
''
)
...
...
@@ -96,7 +97,6 @@ const AddAddress: React.FC<AddAddressPropsType> = (props) => {
* @return:
*/
const
formSubmit
=
(
values
)
=>
{
console
.
log
(
values
)
let
id
=
0
//0新建
let
type
=
2
//'1' 发货 '2'收货
let
value
=
{
...
values
}
...
...
@@ -107,10 +107,14 @@ const AddAddress: React.FC<AddAddressPropsType> = (props) => {
value
.
provinceName
=
provinceName
value
.
cityName
=
cityName
value
.
districtName
=
districtName
setConfirmLoading
(
true
)
PublicApi
.
postLogisticsReceiverAddressAdd
(
value
).
then
(
res
=>
{
setConfirmLoading
(
false
)
if
(
res
.
code
==
1000
)
{
onOk
()
}
}).
catch
(()
=>
{
setConfirmLoading
(
false
)
})
}
...
...
@@ -122,7 +126,6 @@ const AddAddress: React.FC<AddAddressPropsType> = (props) => {
const
useAreaEffects
=
()
=>
{
const
{
setFieldState
}
=
createFormActions
()
onFieldValueChange$
(
'provinceCode'
).
subscribe
(({
value
})
=>
{
console
.
log
(
value
)
setFieldState
(
'districtCode'
,
state
=>
{
state
.
value
=
''
})
...
...
@@ -143,7 +146,6 @@ const AddAddress: React.FC<AddAddressPropsType> = (props) => {
})
onFieldValueChange$
(
'cityCode'
).
subscribe
(({
value
})
=>
{
console
.
log
(
value
)
let
name
=
value
&&
value
.
split
(
'-'
).
length
>
1
?
value
.
split
(
'-'
)[
1
]
:
''
setCityName
(
name
)
setFieldState
(
'*(districtCode)'
,
state
=>
{
...
...
@@ -176,6 +178,7 @@ const AddAddress: React.FC<AddAddressPropsType> = (props) => {
onOk=
{
handleOk
}
width=
{
600
}
centered
confirmLoading=
{
confirmLoading
}
className=
{
styles
.
common_add_modal
}
onCancel=
{
onCancel
}
maskClosable=
{
false
}
...
...
src/pages/lxMall/order/components/common.less
View file @
65fdba3d
...
...
@@ -60,7 +60,9 @@
background-color: var(--mall_main_color);
border-color: var(--mall_main_color);
&:hover {
&:hover,
&:focus,
&:active {
color: #ffffff;
opacity: .9;
}
...
...
src/utils/request.ts
View file @
65fdba3d
...
...
@@ -55,6 +55,7 @@ const errorHandler = (error: ResponseError): IRequestError => {
const
defaultHeaders
=
{
'Content-Type'
:
'Application/json'
,
'source'
:
'1'
,
'environment'
:
'1'
,
'site'
:
GlobalConfig
.
global
.
siteId
.
toString
()
}
...
...
@@ -76,7 +77,8 @@ baseRequest.interceptors.request.use((url: string, options: RequestOptionsInit):
...
options
.
headers
,
userId
,
memberId
,
token
token
,
}
options
.
paramsSerializer
=
params
=>
{
return
qs
.
stringify
(
params
,
{
arrayFormat
:
'brackets'
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment