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
0e4f9fd4
Commit
0e4f9fd4
authored
Jan 08, 2021
by
GuanHua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 解决商品价格区间取值的问题
parent
0b917b15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
156 additions
and
136 deletions
+156
-136
index.tsx
src/pages/lxMall/commodityDetail/index.tsx
+31
-13
forgetPwd.tsx
src/pages/user/forgetPwd.tsx
+125
-123
index.ts
src/pages/user/schema/index.ts
+0
-0
No files found.
src/pages/lxMall/commodityDetail/index.tsx
View file @
0e4f9fd4
...
...
@@ -784,7 +784,7 @@ const CommodityDetail = (props) => {
*/
const
setCurrentPriceRange
=
(
uniPrice
)
=>
{
const
initPriceRange
=
uniPrice
cons
t
tempPriceRange
=
[]
le
t
tempPriceRange
=
[]
Object
.
keys
(
initPriceRange
).
forEach
((
key
)
=>
{
const
keyArr
=
key
.
split
(
'-'
)
const
min
=
keyArr
[
0
]
...
...
@@ -796,6 +796,11 @@ const CommodityDetail = (props) => {
price
:
initPriceRange
[
key
]
})
})
try
{
tempPriceRange
=
tempPriceRange
.
sort
((
a
,
b
)
=>
a
.
price
<
b
.
price
?
1
:
-
1
)
}
catch
(
error
)
{
console
.
log
(
error
)
}
setCommodityPriceInfo
(
tempPriceRange
)
}
...
...
@@ -892,12 +897,12 @@ const CommodityDetail = (props) => {
const
s1
=
arg1
.
toString
()
const
s2
=
arg2
.
toString
()
try
{
m
+=
s1
.
split
(
"."
)[
1
]
.
length
;
m
+=
s1
.
split
(
"."
)[
1
]
?
s1
.
split
(
"."
)[
1
].
length
:
0
}
catch
(
e
)
{
console
.
log
(
e
)
}
try
{
m
+=
s2
.
split
(
"."
)[
1
]
.
length
;
m
+=
s2
.
split
(
"."
)[
1
]
?
s2
.
split
(
"."
)[
1
].
length
:
0
}
catch
(
e
)
{
console
.
log
(
e
)
}
...
...
@@ -905,16 +910,12 @@ const CommodityDetail = (props) => {
}
/**
* 获取
金额区间中数量最大的区间
* 获取
和购买数量相差最小的区间价格
*/
const
getMaxCountRange
=
()
=>
{
let
maxItem
:
any
=
{}
for
(
const
item
of
commodityPriceInfo
)
{
if
(
Number
(
item
.
max
)
>
Number
(
maxItem
.
max
||
0
))
{
maxItem
=
item
}
}
return
maxItem
const
priceList
=
[...
commodityPriceInfo
]
const
result
=
priceList
.
sort
((
a
,
b
)
=>
Math
.
abs
(
Number
(
b
.
max
)
-
Number
(
buyCount
))
<
Math
.
abs
(
Number
(
a
.
min
)
-
Number
(
buyCount
))
?
1
:
-
1
)
return
result
[
0
]
}
/**
...
...
@@ -960,6 +961,23 @@ const CommodityDetail = (props) => {
return
result
}
const
checkItemInRang
=
(
item
)
=>
{
if
(
Number
(
item
.
min
)
<=
Number
(
buyCount
)
&&
Number
(
item
.
max
)
>=
Number
(
buyCount
))
{
return
true
}
else
{
const
temp
=
commodityPriceInfo
.
filter
(
item
=>
{
return
Number
(
buyCount
)
>=
Number
(
item
.
min
)
&&
Number
(
buyCount
)
<=
Number
(
item
.
max
)
})
if
(
isEmpty
(
temp
))
{
const
nearItem
=
getMaxCountRange
()
if
(
Number
(
nearItem
.
min
)
===
Number
(
item
.
min
))
{
return
true
}
}
return
false
}
}
return
(
<
Spin
spinning=
{
spinLoading
}
>
<
div
className=
{
styles
.
commodity_detail
}
>
...
...
@@ -980,7 +998,7 @@ const CommodityDetail = (props) => {
<
span
key=
{
`product_info_tags_item_${index}`
}
>
{
item
}{
index
!==
commodityDetail
?.
sellingPoint
.
length
-
1
?
' '
:
''
}
</
span
>
))
}
】
</>
</>
)
}
</
div
>
...
...
@@ -1000,7 +1018,7 @@ const CommodityDetail = (props) => {
<
div
className=
{
styles
.
prompt_goods_price_list
}
>
{
selectCommodityId
?
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
&&
checkItemInRang
(
item
)
)
?
styles
.
active
:
""
)
}
key=
{
`prompt_goods_price_list_item_${index}`
}
>
<
div
className=
{
styles
.
price
}
>
{
priceFormat
(
item
.
price
)
}
</
div
>
{
(
commodityDetail
?.
isMemberPrice
&&
(
parameter
||
parameter
===
0
))
&&
<
div
className=
{
styles
.
member_price
}
>
{
priceFormat
(
item
.
price
*
parameter
)
}
</
div
>
...
...
src/pages/user/forgetPwd.tsx
View file @
0e4f9fd4
This diff is collapsed.
Click to expand it.
src/pages/user/schema/index.ts
View file @
0e4f9fd4
This diff is collapsed.
Click to expand it.
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