Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mr-julyedu
Overview
Overview
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
baiguangyao
mr-julyedu
Commits
437e88fb
Commit
437e88fb
authored
Oct 25, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
定金
parent
199214f8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
9 deletions
+21
-9
src/components/order/deposit/final-order/index.js
+21
-9
No files found.
src/components/order/deposit/final-order/index.js
View file @
437e88fb
...
...
@@ -340,7 +340,8 @@ class FinalDepositOrder extends Component {
}
else
{
selectedCourses
.
splice
(
index
,
1
)
}
return
{
selectedCourses
,
salePrice
:
this
.
getTotalPrice
(
selectedCourses
)}
let
totalPrice
=
this
.
getTotalPrice
(
selectedCourses
)
return
{
selectedCourses
,
salePrice
:
totalPrice
,
offset
:
this
.
getBalanceOffset
(
totalPrice
)}
})
}
...
...
@@ -352,10 +353,7 @@ class FinalDepositOrder extends Component {
moneyOffRules
=
this
.
state
.
moneyOffRules
}
=
{}
)
=>
{
let
totalPrice
=
0
totalPrice
+=
courses
.
reduce
((
accu
,
item
)
=>
{
return
accu
+
parseFloat
(
item
[
'sale_price'
])
},
0
)
let
totalPrice
=
this
.
getOriginTotalPrice
()
totalPrice
=
this
.
moneyOff
(
totalPrice
,
moneyOffRules
)
if
(
useBalance
)
{
totalPrice
-=
parseFloat
(
this
.
state
.
user_account
)
...
...
@@ -363,6 +361,7 @@ class FinalDepositOrder extends Component {
return
totalPrice
<
0
?
0
:
totalPrice
.
toFixed
(
2
)
}
//满减计算
moneyOff
=
(
totalPrice
,
moneyOffRules
=
this
.
state
.
moneyOffRules
)
=>
{
let
rules
=
moneyOffRules
.
sort
((
a
,
b
)
=>
b
.
full_amount
-
a
.
full_amount
)
let
result
=
parseFloat
(
totalPrice
)
...
...
@@ -382,17 +381,30 @@ class FinalDepositOrder extends Component {
useBalance
=
()
=>
{
this
.
setState
(
prevState
=>
{
const
useBalance
=
!
prevState
.
useBalance
let
offset
=
parseFloat
(
this
.
state
.
user_account
)
-
parseFloat
(
this
.
getTotalPrice
())
offset
=
offset
>
0
?
this
.
getTotalPrice
()
:
this
.
state
.
user_account
let
totalPrice
=
this
.
getTotalPrice
({
useBalance
})
return
{
useBalance
,
salePrice
:
this
.
getTotalPrice
({
useBalance
})
,
offset
salePrice
:
totalPrice
,
offset
:
this
.
getBalanceOffset
(
totalPrice
)
}
})
}
getOriginTotalPrice
=
({
courses
=
this
.
state
.
selectedCourses
}
=
{})
=>
{
return
courses
.
reduce
((
accu
,
item
)
=>
{
return
accu
+
parseFloat
(
item
[
'sale_price'
])
},
0
)
}
getBalanceOffset
=
()
=>
{
let
originalTotalPrice
=
this
.
getOriginTotalPrice
()
let
offset
=
parseFloat
(
this
.
state
.
user_account
)
-
parseFloat
(
originalTotalPrice
)
offset
=
offset
>=
0
?
originalTotalPrice
:
this
.
state
.
user_account
return
offset
}
render
()
{
const
{
orderId
,
...
...
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