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
shenshaokai
jinfa-platform
Commits
f94b9266
Commit
f94b9266
authored
Sep 14, 2020
by
GuanHua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:商品详情价格区间计算
parent
df4b56a3
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
21 deletions
+30
-21
index.tsx
src/components/InputNumber/index.tsx
+2
-0
index.less
src/components/Loading/index.less
+5
-0
index.tsx
src/components/Loading/index.tsx
+3
-0
index.tsx
src/pages/lxMall/commodityDetail/index.tsx
+8
-12
index.tsx
src/pages/lxMall/components/ChannelHeader/index.tsx
+2
-2
index.tsx
src/pages/lxMall/components/CommonHeader/index.tsx
+1
-2
index.tsx
src/pages/lxMall/purchaseOrder/index.tsx
+9
-5
No files found.
src/components/InputNumber/index.tsx
View file @
f94b9266
...
@@ -20,8 +20,10 @@ const InputNumber: React.FC<InputNumberPropsType> = (props) => {
...
@@ -20,8 +20,10 @@ const InputNumber: React.FC<InputNumberPropsType> = (props) => {
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
min
)
{
if
(
min
)
{
setMinCount
(
min
)
setMinCount
(
min
)
if
(
value
<
min
)
{
onChange
(
min
)
onChange
(
min
)
}
}
}
if
(
max
||
max
===
0
)
{
if
(
max
||
max
===
0
)
{
setMaxCount
(
max
)
setMaxCount
(
max
)
if
(
value
>
max
)
{
if
(
value
>
max
)
{
...
...
src/components/Loading/index.less
0 → 100644
View file @
f94b9266
.loading_container {
text-align: center;
padding: 66px 0;
}
\ No newline at end of file
src/components/Loading/index.tsx
View file @
f94b9266
import
React
,
{
Component
}
from
'react'
import
React
,
{
Component
}
from
'react'
import
{
Spin
}
from
'antd'
import
{
Spin
}
from
'antd'
import
styles
from
'./index.less'
class
Loading
extends
Component
{
class
Loading
extends
Component
{
render
()
{
render
()
{
return
(
return
(
<
div
className=
{
styles
.
loading_container
}
>
<
Spin
/>
<
Spin
/>
</
div
>
)
)
}
}
}
}
...
...
src/pages/lxMall/commodityDetail/index.tsx
View file @
f94b9266
...
@@ -61,7 +61,7 @@ const CommodityDetail = (props) => {
...
@@ -61,7 +61,7 @@ const CommodityDetail = (props) => {
const
[
commodityDetail
,
setCommodityDetail
]
=
useState
<
GetSearchShopStoreGetCommodityDetailResponse
>
()
const
[
commodityDetail
,
setCommodityDetail
]
=
useState
<
GetSearchShopStoreGetCommodityDetailResponse
>
()
const
[
attrAndValList
,
setAttrAndValList
]
=
useState
<
any
>
({})
const
[
attrAndValList
,
setAttrAndValList
]
=
useState
<
any
>
({})
const
[
selectAttrVal
,
setSelectAttrVal
]
=
useState
<
selectAttrValType
[]
>
([])
const
[
selectAttrVal
,
setSelectAttrVal
]
=
useState
<
selectAttrValType
[]
>
([])
const
[
stockCount
,
setStockCount
]
=
useState
<
number
>
(
0
)
const
[
stockCount
,
setStockCount
]
=
useState
<
number
>
(
200
0
)
const
[
commodityImgList
,
setCommodityImgList
]
=
useState
<
imgItemType
[]
>
([])
const
[
commodityImgList
,
setCommodityImgList
]
=
useState
<
imgItemType
[]
>
([])
const
[
commodityPriceInfo
,
setCommodityPriceInfo
]
=
useState
([])
const
[
commodityPriceInfo
,
setCommodityPriceInfo
]
=
useState
([])
const
[
parameter
,
setParameter
]
=
useState
<
number
>
()
// 权益参数
const
[
parameter
,
setParameter
]
=
useState
<
number
>
()
// 权益参数
...
@@ -75,12 +75,6 @@ const CommodityDetail = (props) => {
...
@@ -75,12 +75,6 @@ const CommodityDetail = (props) => {
fetchDetail
()
fetchDetail
()
},
[])
},
[])
useEffect
(()
=>
{
if
(
shopInfo
)
{
console
.
log
(
shopInfo
,
"shopInfo"
)
}
},
[
shopInfo
])
const
fetchDetail
=
()
=>
{
const
fetchDetail
=
()
=>
{
PublicApi
.
getSearchShopStoreGetCommodityDetail
({
commodityId
:
id
}).
then
(
res
=>
{
PublicApi
.
getSearchShopStoreGetCommodityDetail
({
commodityId
:
id
}).
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
if
(
res
.
code
===
1000
)
{
...
@@ -178,9 +172,10 @@ const CommodityDetail = (props) => {
...
@@ -178,9 +172,10 @@ const CommodityDetail = (props) => {
})
})
if
(
judgeArrisCommon
(
temp
,
selectAttrVal
))
{
if
(
judgeArrisCommon
(
temp
,
selectAttrVal
))
{
setSelectCommodityId
(
item
.
id
)
setSelectCommodityId
(
item
.
id
)
setCurrentPriceRange
(
item
.
unitPrice
)
setCurrentPriceRange
(
item
.
unitPrice
)
setAttrAndValList
(
item
)
setAttrAndValList
(
item
)
setStockCount
(
item
.
stockCount
)
setStockCount
(
item
.
stockCount
||
2000
)
}
}
}
}
}
}
...
@@ -350,12 +345,13 @@ const CommodityDetail = (props) => {
...
@@ -350,12 +345,13 @@ const CommodityDetail = (props) => {
}
}
setCurrentPriceRange
(
unitPriceAndPicList
[
0
].
unitPrice
)
setCurrentPriceRange
(
unitPriceAndPicList
[
0
].
unitPrice
)
setStockCount
(
unitPriceAndPicList
[
0
].
stockCount
)
setStockCount
(
unitPriceAndPicList
[
0
].
stockCount
||
2000
)
setCommodityImgList
(
tempImgList
)
setCommodityImgList
(
tempImgList
)
setAttributeList
(
tempAttrList
)
setAttributeList
(
tempAttrList
)
}
}
const
setCurrentPriceRange
=
(
uniPrice
)
=>
{
const
setCurrentPriceRange
=
(
uniPrice
)
=>
{
// console.log(JSON.stringify(uniPrice), "item.unitPrice")
let
initPriceRange
=
uniPrice
let
initPriceRange
=
uniPrice
let
tempPriceRange
=
[]
let
tempPriceRange
=
[]
Object
.
keys
(
initPriceRange
).
forEach
((
key
)
=>
{
Object
.
keys
(
initPriceRange
).
forEach
((
key
)
=>
{
...
@@ -421,7 +417,7 @@ const CommodityDetail = (props) => {
...
@@ -421,7 +417,7 @@ const CommodityDetail = (props) => {
unitPrice
=
commodityPriceInfo
[
0
]?.
price
unitPrice
=
commodityPriceInfo
[
0
]?.
price
}
else
{
}
else
{
let
temp
=
commodityPriceInfo
.
filter
(
item
=>
{
let
temp
=
commodityPriceInfo
.
filter
(
item
=>
{
return
Number
(
buyCount
)
>=
Number
(
item
.
min
)
&&
Number
(
buyCount
)
<
Number
(
item
.
max
)
return
Number
(
buyCount
)
>=
Number
(
item
.
min
)
&&
Number
(
buyCount
)
<
=
Number
(
item
.
max
)
})
})
unitPrice
=
temp
[
0
]?.
price
unitPrice
=
temp
[
0
]?.
price
}
}
...
@@ -440,7 +436,7 @@ const CommodityDetail = (props) => {
...
@@ -440,7 +436,7 @@ const CommodityDetail = (props) => {
unitPrice
=
commodityPriceInfo
[
0
]?.
price
unitPrice
=
commodityPriceInfo
[
0
]?.
price
}
else
{
}
else
{
let
temp
=
commodityPriceInfo
.
filter
(
item
=>
{
let
temp
=
commodityPriceInfo
.
filter
(
item
=>
{
return
Number
(
buyCount
)
>=
Number
(
item
.
min
)
&&
Number
(
buyCount
)
<
Number
(
item
.
max
)
return
Number
(
buyCount
)
>=
Number
(
item
.
min
)
&&
Number
(
buyCount
)
<
=
Number
(
item
.
max
)
})
})
unitPrice
=
temp
[
0
]?.
price
unitPrice
=
temp
[
0
]?.
price
}
}
...
@@ -529,7 +525,7 @@ const CommodityDetail = (props) => {
...
@@ -529,7 +525,7 @@ const CommodityDetail = (props) => {
<
div
className=
{
styles
.
prompt_goods_price_list
}
>
<
div
className=
{
styles
.
prompt_goods_price_list
}
>
{
{
commodityPriceInfo
&&
commodityPriceInfo
.
map
((
item
,
index
)
=>
(
commodityPriceInfo
&&
commodityPriceInfo
.
map
((
item
,
index
)
=>
(
<
div
className=
{
cx
(
styles
.
prompt_goods_price_list_item
,
(
commodityPriceInfo
.
length
>
1
&&
Number
(
buyCount
)
>=
item
.
min
&&
Number
(
buyCount
)
<
item
.
max
)
?
styles
.
active
:
""
)
}
key=
{
`prompt_goods_price_list_item_${index}`
}
>
<
div
className=
{
cx
(
styles
.
prompt_goods_price_list_item
,
(
commodityPriceInfo
.
length
>
1
&&
Number
(
buyCount
)
>=
item
.
min
&&
Number
(
buyCount
)
<
=
item
.
max
)
?
styles
.
active
:
""
)
}
key=
{
`prompt_goods_price_list_item_${index}`
}
>
<
div
className=
{
styles
.
price
}
>
{
priceFormat
(
item
.
price
)
}
</
div
>
<
div
className=
{
styles
.
price
}
>
{
priceFormat
(
item
.
price
)
}
</
div
>
{
{
(
commodityDetail
?.
isMemberPrice
&&
parameter
)
&&
<
div
className=
{
styles
.
member_price
}
>
{
priceFormat
(
item
.
price
*
parameter
)
}
</
div
>
(
commodityDetail
?.
isMemberPrice
&&
parameter
)
&&
<
div
className=
{
styles
.
member_price
}
>
{
priceFormat
(
item
.
price
*
parameter
)
}
</
div
>
...
...
src/pages/lxMall/components/ChannelHeader/index.tsx
View file @
f94b9266
...
@@ -9,9 +9,9 @@ interface HeaderPropsType {
...
@@ -9,9 +9,9 @@ interface HeaderPropsType {
const
Header
:
React
.
FC
<
HeaderPropsType
>
=
(
props
)
=>
{
const
Header
:
React
.
FC
<
HeaderPropsType
>
=
(
props
)
=>
{
const
{
shopInfo
}
=
props
const
{
shopInfo
}
=
props
const
[
searchType
,
setSearchType
]
=
useState
<
number
>
(
1
)
// 1:商品; 2:店铺
useEffect
(()
=>
{
useEffect
(()
=>
{
console
.
log
(
shopInfo
,
"shopInfo"
)
//
console.log(shopInfo, "shopInfo")
},
[
shopInfo
])
},
[
shopInfo
])
return
(
return
(
...
...
src/pages/lxMall/components/CommonHeader/index.tsx
View file @
f94b9266
import
React
from
'react'
import
React
from
'react'
import
{
Link
}
from
'umi'
import
{
Link
}
from
'umi'
import
logo
from
'@/theme/imgs/logo_w.png'
import
styles
from
'./index.less'
import
styles
from
'./index.less'
import
{
GlobalConfig
}
from
'@/global/config'
import
{
LAYOUT_TYPE
}
from
'@/constants'
import
{
LAYOUT_TYPE
}
from
'@/constants'
interface
ShopHeaderPropsType
{
interface
ShopHeaderPropsType
{
...
@@ -15,6 +13,7 @@ interface ShopHeaderPropsType {
...
@@ -15,6 +13,7 @@ interface ShopHeaderPropsType {
const
CommonHeader
:
React
.
FC
<
ShopHeaderPropsType
>
=
(
props
)
=>
{
const
CommonHeader
:
React
.
FC
<
ShopHeaderPropsType
>
=
(
props
)
=>
{
const
{
title
,
type
,
logoUrl
,
shopUrlParam
}
=
props
const
{
title
,
type
,
logoUrl
,
shopUrlParam
}
=
props
const
getHomeLink
=
()
=>
{
const
getHomeLink
=
()
=>
{
let
link
=
'/'
let
link
=
'/'
switch
(
type
)
{
switch
(
type
)
{
...
...
src/pages/lxMall/purchaseOrder/index.tsx
View file @
f94b9266
...
@@ -23,7 +23,6 @@ interface PurchaseOrderPropsType {
...
@@ -23,7 +23,6 @@ interface PurchaseOrderPropsType {
const
PurchaseOrder
:
React
.
FC
<
PurchaseOrderPropsType
>
=
(
props
)
=>
{
const
PurchaseOrder
:
React
.
FC
<
PurchaseOrderPropsType
>
=
(
props
)
=>
{
const
{
layoutType
,
shopInfo
,
shopUrlParam
}
=
props
const
{
layoutType
,
shopInfo
,
shopUrlParam
}
=
props
console
.
log
(
shopInfo
,
"shopInfo"
)
const
OrderStore
=
useLocalStore
(()
=>
store
.
OrderStore
)
const
OrderStore
=
useLocalStore
(()
=>
store
.
OrderStore
)
const
{
updateOrderInfo
}
=
OrderStore
const
{
updateOrderInfo
}
=
OrderStore
const
[
indeterminate
,
setIndeterminate
]
=
useState
<
boolean
>
(
false
)
const
[
indeterminate
,
setIndeterminate
]
=
useState
<
boolean
>
(
false
)
...
@@ -66,6 +65,8 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
...
@@ -66,6 +65,8 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
price
:
unitPrice
[
key
]
price
:
unitPrice
[
key
]
})
})
})
})
// TODO 暂时给个库存数量
item
.
stockCount
=
item
.
stockCount
||
2000
item
.
commodityUnitPrice
[
'priceRange'
]
=
tempPriceRange
item
.
commodityUnitPrice
[
'priceRange'
]
=
tempPriceRange
tempItem
.
orderList
=
[...
tempItem
.
orderList
,
item
]
tempItem
.
orderList
=
[...
tempItem
.
orderList
,
item
]
}
}
...
@@ -89,6 +90,8 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
...
@@ -89,6 +90,8 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
price
:
unitPrice
[
key
]
price
:
unitPrice
[
key
]
})
})
})
})
// TODO 暂时给个库存数量
item
.
stockCount
=
item
.
stockCount
||
2000
item
.
commodityUnitPrice
[
'priceRange'
]
=
tempPriceRange
item
.
commodityUnitPrice
[
'priceRange'
]
=
tempPriceRange
temp
.
orderList
=
[
item
]
temp
.
orderList
=
[
item
]
result
.
push
(
temp
)
result
.
push
(
temp
)
...
@@ -104,6 +107,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
...
@@ -104,6 +107,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
defaultCheckedList
:
item
.
orderList
.
map
(
item
=>
item
.
id
)
defaultCheckedList
:
item
.
orderList
.
map
(
item
=>
item
.
id
)
})
})
})
})
console
.
log
(
result
)
setOrderList
(
result
)
setOrderList
(
result
)
// !initChecked && setCheckedList(result.map(item => item.id))
// !initChecked && setCheckedList(result.map(item => item.id))
}
}
...
@@ -219,7 +223,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
...
@@ -219,7 +223,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
}
else
{
}
else
{
let
priceItem
:
any
=
{}
let
priceItem
:
any
=
{}
for
(
let
item
of
priceRange
)
{
for
(
let
item
of
priceRange
)
{
if
(
Number
(
item
.
min
)
<
count
&&
count
<=
Number
(
item
.
max
))
{
if
(
Number
(
item
.
min
)
<
=
count
&&
count
<=
Number
(
item
.
max
))
{
priceItem
=
item
priceItem
=
item
}
}
}
}
...
@@ -473,7 +477,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
...
@@ -473,7 +477,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
unitPrice
=
detail
.
priceRange
[
0
]?.
price
unitPrice
=
detail
.
priceRange
[
0
]?.
price
}
else
{
}
else
{
let
temp
=
detail
.
priceRange
.
filter
(
item
=>
{
let
temp
=
detail
.
priceRange
.
filter
(
item
=>
{
return
Number
(
count
)
>=
Number
(
item
.
min
)
&&
Number
(
count
)
<
Number
(
item
.
max
)
return
Number
(
count
)
>=
Number
(
item
.
min
)
&&
Number
(
count
)
<
=
Number
(
item
.
max
)
})
})
unitPrice
=
temp
[
0
]?.
price
unitPrice
=
temp
[
0
]?.
price
}
}
...
@@ -511,7 +515,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
...
@@ -511,7 +515,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
</
div
>
</
div
>
<
Checkbox
.
Group
value=
{
checkedList
}
onChange=
{
handleGroupChange
}
>
<
Checkbox
.
Group
value=
{
checkedList
}
onChange=
{
handleGroupChange
}
>
{
{
orderList
.
map
((
item
:
any
)
=>
(
orderList
&&
orderList
.
map
((
item
:
any
)
=>
(
<
div
className=
{
styles
.
order_list
}
key=
{
item
.
id
}
>
<
div
className=
{
styles
.
order_list
}
key=
{
item
.
id
}
>
<
div
className=
{
styles
.
order_list_shop_name
}
>
<
div
className=
{
styles
.
order_list_shop_name
}
>
<
Checkbox
<
Checkbox
...
@@ -552,7 +556,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
...
@@ -552,7 +556,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
}
}
</
div
>
</
div
>
<
div
className=
{
cx
(
styles
.
order_list_item_item
,
styles
.
count
)
}
>
<
div
className=
{
cx
(
styles
.
order_list_item_item
,
styles
.
count
)
}
>
<
InputNumber
disabled=
{
!
childItem
.
stockCount
}
max=
{
childItem
.
stockCount
||
0
}
min=
{
1
}
value=
{
childItem
.
count
}
onChange=
{
(
value
)
=>
handleCountChange
(
value
,
childItem
.
id
)
}
/>
<
InputNumber
disabled=
{
true
}
max=
{
childItem
.
stockCount
||
0
}
min=
{
1
}
value=
{
childItem
.
count
}
onChange=
{
(
value
)
=>
handleCountChange
(
value
,
childItem
.
id
)
}
/>
<
div
className=
{
styles
.
stock
}
>
(库存
{
numFormat
(
childItem
.
stockCount
)
}{
childItem
.
commodityUnitPrice
.
commodity
.
unitName
}
)
</
div
>
<
div
className=
{
styles
.
stock
}
>
(库存
{
numFormat
(
childItem
.
stockCount
)
}{
childItem
.
commodityUnitPrice
.
commodity
.
unitName
}
)
</
div
>
</
div
>
</
div
>
<
div
className=
{
cx
(
styles
.
order_list_item_item
,
styles
.
amount
)
}
>
<
div
className=
{
cx
(
styles
.
order_list_item_item
,
styles
.
amount
)
}
>
...
...
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