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
bb58baaf
Commit
bb58baaf
authored
Jun 15, 2019
by
wangshuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
确认支付页面金额计算
parent
6ac9a6fb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
35 deletions
+94
-35
src/components/order/index.js
+65
-23
src/components/order/order.scss
+29
-12
No files found.
src/components/order/index.js
View file @
bb58baaf
...
@@ -39,10 +39,13 @@ function OrderList(props) {
...
@@ -39,10 +39,13 @@ function OrderList(props) {
onClick
=
{()
=>
{
}}
onClick
=
{()
=>
{
}}
>
>
<
Link
to
=
{{
<
Link
to
=
{{
pathname
:
`/coupons?id=
${
course_id
}
`
,
pathname
:
`/coupons`
,
search
:
`?id=
${
course_id
}
`
,
state
:
{
state
:
{
from
:
'/order'
,
from
:
'/order'
,
a
:
'sldfasldjfsl'
}}}
>
}}}
>
{
/* <Link to='coupons' query={{id: course_id}} state={{from: '/order'}}> */
}
<
Flex
justify
=
'between'
>
<
Flex
justify
=
'between'
>
<
span
style
=
{{
color
:
'#333'
,
fontSize
:
'15px'
}}
>
优惠券
<
/span
>
<
span
style
=
{{
color
:
'#333'
,
fontSize
:
'15px'
}}
>
优惠券
<
/span
>
<
span
style
=
{{
fontSize
:
'14px'
,
color
:
'#999999'
}}
>
{
!
coupon_desc
?
(
coupon_num
===
0
?
'无'
:
`
${
coupon_num
}
张可用`
)
:
(
coupon_desc
)}
<
/span
>
<
span
style
=
{{
fontSize
:
'14px'
,
color
:
'#999999'
}}
>
{
!
coupon_desc
?
(
coupon_num
===
0
?
'无'
:
`
${
coupon_num
}
张可用`
)
:
(
coupon_desc
)}
<
/span
>
...
@@ -90,10 +93,11 @@ class Order extends Component {
...
@@ -90,10 +93,11 @@ class Order extends Component {
if
(
res
.
data
.
code
!==
200
)
{
if
(
res
.
data
.
code
!==
200
)
{
return
;
return
;
}
}
this
.
props
.
history
.
replace
(
`/payorder?oid=
${
res
.
data
.
data
.
oid
}
`
);
sessionStorage
.
removeItem
(
'orderUseCacheObj'
);
this
.
props
.
history
.
replace
(
`/payorder?oid=
${
res
.
data
.
data
.
order_id
}
`
);
});
});
}
}
// 使用余额
//
勾选取消勾选 是否
使用余额
useBalance
=
()
=>
{
useBalance
=
()
=>
{
let
useBalanceFlag
=
this
.
state
.
useBalance
;
let
useBalanceFlag
=
this
.
state
.
useBalance
;
this
.
setState
({
this
.
setState
({
...
@@ -103,22 +107,29 @@ class Order extends Component {
...
@@ -103,22 +107,29 @@ class Order extends Component {
this
.
cacheObj
=
{
this
.
cacheObj
=
{
...
this
.
state
...
this
.
state
}
}
sessionStorage
.
setItem
(
'orderUseCacheObj'
,
JSON
.
stringify
(
this
.
state
));
}
else
{
sessionStorage
.
removeItem
(
'orderUseCacheObj'
);
}
}
// console.log(useBalance);
this
.
computedMoney
(
useBalanceFlag
);
}
// 勾选取消勾选时:计算金额、优惠金额、优惠券等
computedMoney
=
(
useBalanceFlag
)
=>
{
let
totalSale
=
parseFloat
(
this
.
cacheObj
.
total
),
let
totalSale
=
parseFloat
(
this
.
cacheObj
.
total
),
userAccount
=
parseFloat
(
this
.
cacheObj
.
user_account
);
userAccount
=
parseFloat
(
this
.
cacheObj
.
user_account
);
const
{
discount
}
=
this
.
state
;
if
(
!
useBalanceFlag
)
{
if
(
!
useBalanceFlag
)
{
if
(
totalSale
>
userAccount
)
{
if
(
totalSale
>
userAccount
)
{
this
.
setState
({
this
.
setState
({
offset
:
userAccount
.
toFixed
(
2
),
offset
:
userAccount
.
toFixed
(
2
),
total
:
(
totalSale
-
userAccount
).
toFixed
(
2
),
total
:
(
totalSale
-
userAccount
).
toFixed
(
2
),
discount
:
userAccount
.
toFixed
(
2
),
discount
:
(
userAccount
+
parseFloat
(
discount
))
.
toFixed
(
2
),
});
});
}
else
{
}
else
{
this
.
setState
({
this
.
setState
({
offset
:
totalSale
.
toFixed
(
2
),
offset
:
totalSale
.
toFixed
(
2
),
total
:
0
,
total
:
0
,
discount
:
totalSale
.
toFixed
(
2
),
discount
:
(
totalSale
+
parseFloat
(
discount
))
.
toFixed
(
2
),
});
});
}
}
}
else
{
}
else
{
...
@@ -128,11 +139,25 @@ class Order extends Component {
...
@@ -128,11 +139,25 @@ class Order extends Component {
discount
:
this
.
cacheObj
.
discount
,
discount
:
this
.
cacheObj
.
discount
,
});
});
}
}
this
.
computedMoney
();
};
}
// 选择优惠券返回时根据是否勾选计算
// 计算金额、优惠金额、优惠券等
computedMoneyByCache
=
()
=>
{
computedMoney
=
()
=>
{
let
totalSale
=
parseFloat
(
this
.
cacheObj
.
total
),
userAccount
=
parseFloat
(
this
.
cacheObj
.
user_account
),
discount
=
parseFloat
(
this
.
cacheObj
.
discount
);
if
(
totalSale
>
userAccount
)
{
this
.
setState
({
offset
:
userAccount
.
toFixed
(
2
),
total
:
(
totalSale
-
userAccount
).
toFixed
(
2
),
discount
:
(
discount
+
userAccount
).
toFixed
(
2
),
});
}
else
{
this
.
setState
({
offset
:
totalSale
.
toFixed
(
2
),
total
:
0
,
discount
:
totalSale
.
toFixed
(
2
),
});
}
};
};
// 展示余额抵扣规则
// 展示余额抵扣规则
showInfo
=
()
=>
{
showInfo
=
()
=>
{
...
@@ -146,7 +171,13 @@ class Order extends Component {
...
@@ -146,7 +171,13 @@ class Order extends Component {
return
;
return
;
}
}
const
{
course
,
total
,
user_account
,
user_info
,
discount
}
=
res
.
data
.
data
;
const
{
course
,
total
,
user_account
,
user_info
,
discount
}
=
res
.
data
.
data
;
this
.
dataCache
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
.
data
));
this
.
cacheObj
=
{
perfect
:
user_info
,
orderList
:
course
,
user_account
,
total
,
discount
,
}
this
.
setState
({
this
.
setState
({
perfect
:
user_info
,
perfect
:
user_info
,
orderList
:
course
,
orderList
:
course
,
...
@@ -154,12 +185,19 @@ class Order extends Component {
...
@@ -154,12 +185,19 @@ class Order extends Component {
total
,
total
,
discount
,
discount
,
});
});
if
(
this
.
props
.
history
.
action
===
'PUSH'
)
{
sessionStorage
.
removeItem
(
'orderUseCacheObj'
);
}
else
{
const
cacheObj
=
sessionStorage
.
getItem
(
'orderUseCacheObj'
);
if
(
cacheObj
!==
null
)
{
this
.
setState
({
useBalance
:
true
});
this
.
computedMoneyByCache
();
}
}
})
})
// // 获取报名信息 获取课程列表 获取用户账户余额
// Promise.race([http.get(), http.get(), http.get()]).then(res=>{
// });
};
};
render
()
{
render
()
{
const
{
const
{
...
@@ -224,17 +262,21 @@ class Order extends Component {
...
@@ -224,17 +262,21 @@ class Order extends Component {
<
Flex
align
=
'center'
>
<
Flex
align
=
'center'
>
<
span
>
余额抵扣
<
/span
>
<
span
>
余额抵扣
<
/span
>
<
span
className
=
"order-balanceprice"
>
(
余额
:
<
i
className
=
"order-money"
>
{
`
${
user_account
}
元`
}
<
/i>
)
</
span
>
<
span
className
=
"order-balanceprice"
>
(
余额
:
<
i
className
=
"order-money"
>
{
`
${
user_account
}
元`
}
<
/i>
)
</
span
>
<
i
className
=
"iconfont iconiconfront-22"
onClick
=
{
this
.
showInfo
}
><
/i
>
<
i
className
=
"iconfont iconiconfront-22
question-mark
"
onClick
=
{
this
.
showInfo
}
><
/i
>
<
/Flex
>
<
/Flex
>
<
div
>
<
Flex
>
{
{
useBalance
?
(
useBalance
?
(
<
span
style
=
{{
color
:
'#FF2121'
,
fontSize
:
'15px'
,
marginRight
:
"6px"
}}
>
{
`-
${
offset
}
`
}
<
/span
>
<>
)
:
null
<
span
style
=
{{
color
:
'#FF2121'
,
fontSize
:
'15px'
,
marginRight
:
"6px"
}}
>
{
`-
${
offset
}
`
}
<
/span
>
<
i
className
=
{
`iconfont icondanseshixintubiao-5 balance-used`
}
onClick
=
{
throttle
(
this
.
useBalance
,
600
)}
><
/i
>
<
/
>
)
:
(
<
i
className
=
'circle-icon'
onClick
=
{
throttle
(
this
.
useBalance
,
600
)}
><
/i
>
)
}
}
<
i
className
=
{
`iconfont
${
useBalance
?
'icondanseshixintubiao-5'
:
'iconiconfront-3'
}
`
}
onClick
=
{
throttle
(
this
.
useBalance
,
600
)}
><
/i
>
<
/Flex
>
<
/div
>
<
/Flex
>
<
/Flex
>
<
/Item
>
<
/Item
>
<
/List
>
<
/List
>
...
...
src/components/order/order.scss
View file @
bb58baaf
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
.user-icon
{
.user-icon
{
font-size
:
28px
;
font-size
:
28px
;
flex-basis
:
40px
;
}
}
.order-cell
{
.order-cell
{
...
@@ -47,6 +48,7 @@
...
@@ -47,6 +48,7 @@
font-size
:
13px
;
font-size
:
13px
;
color
:
$color_333
;
color
:
$color_333
;
line-height
:
20px
;
line-height
:
20px
;
flex
:
1
1
auto
;
.name
{
.name
{
margin-bottom
:
10px
;
margin-bottom
:
10px
;
...
@@ -212,17 +214,33 @@
...
@@ -212,17 +214,33 @@
}
}
}
}
.order-balanceprice
{
.order-balance
{
color
:
$color_666
;
.order-balanceprice
{
font-size
:
$font_12
;
color
:
$color_666
;
font-size
:
$font_12
;
.order-money
{
color
:
#ff2121
;
.order-money
{
font-size
:
$font_12
!
important
;
color
:
#ff2121
;
font-weight
:
normal
;
font-size
:
$font_12
!
important
;
font-style
:
inherit
;
font-weight
:
normal
;
vertical-align
:
middle
;
font-style
:
inherit
;
margin
:
0
;
vertical-align
:
middle
;
margin
:
0
;
}
}
.am-list-content
.iconiconfront-22.question-mark
{
font-size
:
24px
;
}
.balance-used
{
font-size
:
24px
;
color
:
#0099FF
;
}
.circle-icon
{
width
:
20px
;
height
:
20px
;
border
:
1px
solid
#BFBFBF
;
border-radius
:
50%
;
margin-right
:
2px
;
}
}
}
}
...
@@ -232,7 +250,6 @@
...
@@ -232,7 +250,6 @@
.order-list
{
.order-list
{
.am-list-item
{
.am-list-item
{
padding-left
:
0
!
important
;
padding-left
:
0
!
important
;
}
}
}
}
...
...
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