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
201cd00e
Commit
201cd00e
authored
Aug 16, 2019
by
wangshuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
课程详情页到订单页逻辑梳理
parent
26dd2d75
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
33 deletions
+82
-33
src/components/classify/courselist.js
+2
-2
src/components/detail/btnstatus/index.js
+46
-16
src/components/order/index.js
+34
-15
No files found.
src/components/classify/courselist.js
View file @
201cd00e
...
...
@@ -140,8 +140,8 @@ class Classify extends Component {
<
p
className
=
'contact text-overflow-2'
>
{
item
.
desc
}
<
/p
>
<
div
className
=
'des'
>
{
!
item
.
is_buy
&&
<
p
className
=
"course-price"
>
<
span
className
=
"new"
>
¥
{
item
.
price
0
}
<
/span
>
<
span
className
=
"old"
>
¥
{
item
.
price
1
}
<
/span
>
<
span
className
=
"new"
>
¥
{
item
.
price
1
}
<
/span
>
<
span
className
=
"old"
>
¥
{
item
.
price
0
}
<
/span
>
<
/p
>
}
{
item
.
is_buy
&&
...
...
src/components/detail/btnstatus/index.js
View file @
201cd00e
...
...
@@ -25,6 +25,7 @@ class BtnStatus extends Component {
componentDidMount
()
{
// this.getBargainInfo()
this
.
group
=
false
;
}
...
...
@@ -78,9 +79,7 @@ class BtnStatus extends Component {
this
.
props
.
history
.
push
(
'/passport'
);
}
else
{
let
cidArr
=
JSON
.
stringify
([
Number
(
getParam
(
'id'
))]);
console
.
log
(
cidArr
);
http
.
get
(
`
${
API
[
'base-api'
]}
/m/cart/addtopreorder/
${
cidArr
}
?type=1`
).
then
((
res
)
=>
{
console
.
log
(
res
);
if
(
res
.
data
.
errno
===
0
)
{
this
.
props
.
history
.
push
(
"/order?id="
+
res
.
data
.
data
[
0
],
{
type
:
1
});
}
else
{
...
...
@@ -91,13 +90,18 @@ class BtnStatus extends Component {
};
// 普通课程的立即报名 要模拟结算过程
simpleCourse
=
()
=>
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/cart/addtopreorder/[
${
getParam
(
'id'
)}
]`
).
then
((
res
)
=>
{
if
(
res
.
data
.
errno
===
0
)
{
this
.
props
.
history
.
push
(
`/order?id=[
${
getParam
(
'id'
)}
]`
,
{
simple
:
1
})
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
);
}
})
if
(
this
.
props
.
user
.
hasError
)
{
// 未登录 去登陆
this
.
props
.
history
.
push
(
'/passport'
);
}
else
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/cart/addtopreorder/[
${
getParam
(
'id'
)}
]`
).
then
((
res
)
=>
{
if
(
res
.
data
.
errno
===
0
)
{
this
.
props
.
history
.
push
(
`/order?id=[
${
getParam
(
'id'
)}
]`
,
{
simple
:
1
})
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
);
}
})
}
};
// 格式化开课时间
formatDate
=
(
date
)
=>
{
...
...
@@ -112,7 +116,9 @@ class BtnStatus extends Component {
this
.
props
.
history
.
push
(
'/passport/login'
)
}
else
{
if
(
this
.
state
.
barInfo
.
bargain_status
===
2
)
{
this
.
toCart
(
2
)
// this.toCart(2)
// 新需求 不需要加入购物车 直接走普通课程的立即报名流程 跳到订单页
this
.
simpleCourse
();
}
else
{
// 取消砍价记录
this
.
setState
({
...
...
@@ -122,7 +128,30 @@ class BtnStatus extends Component {
}
}
};
// 一键开团
keyToGroup
=
()
=>
{
if
(
this
.
props
.
user
.
hasError
)
{
// 未登录 去登陆
this
.
props
.
history
.
push
(
'/passport'
);
return
;
}
this
.
props
.
history
.
push
(
`/order?id=
${
getParam
(
'id'
)}
`
,
{
group
:
1
})
};
// 砍完价去支付
bargainToOrder
=
()
=>
{
if
(
this
.
props
.
user
.
hasError
)
{
// 未登录 去登陆
this
.
props
.
history
.
push
(
'/passport'
);
}
else
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/cart/addtopreorder/[
${
getParam
(
'id'
)}
]`
).
then
((
res
)
=>
{
if
(
res
.
data
.
errno
===
0
)
{
this
.
props
.
history
.
push
(
`/order?id=[
${
getParam
(
'id'
)}
]`
,
{
simple
:
1
});
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
);
}
})
}
};
// 取消砍价
cancel
=
()
=>
{
...
...
@@ -135,7 +164,8 @@ class BtnStatus extends Component {
isShowOverlay
:
false
,
bargainStatus
:
''
,
})
window
.
location
.
href
=
'/shopcart'
// window.location.href = '/shopcart'
this
.
props
.
history
.
push
(
`/order?id=[
${
getParam
(
'id'
)}
]`
,
{
simple
:
1
})
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
)
}
...
...
@@ -242,15 +272,15 @@ class BtnStatus extends Component {
<
i
className
=
'iconfont iconerji'
><
/i
>
<
span
>
课程咨询
<
/span
>
<
/a
>
<
button
className
=
'btn btn-s bg-F4AAA7'
onClick
=
{
e
=>
this
.
toCart
(
2
)
}
>
<
button
className
=
'btn btn-s bg-F4AAA7'
onClick
=
{
this
.
simpleCourse
}
>
<
span
>
{
`¥
${
info
.
price1
}
`
}
<
/span
>
<
span
>
直接购买
<
/span
>
<
/button
>
<
button
className
=
'btn btn-s bg-E02E24'
>
<
Link
to
=
{
`/order?id=
${
getParam
(
'id'
)}
`
}
>
<
span
onClick
=
{
this
.
keyToGroup
}
>
<
span
>
{
`¥
${
info
.
pdd_group_info
.
price
}
`
}
<
/span
>
<
span
>
一键开团
<
/span
>
<
/
Link
>
<
/
span
>
<
/button
>
<
/div
>
...
...
@@ -291,7 +321,7 @@ class BtnStatus extends Component {
(
this
.
state
.
barInfo
.
bargain_status
===
0
||
this
.
state
.
barInfo
.
bargain_status
===
1
)
&&
(
uid
)
&&
<
button
className
=
'btn btn-s bg-E02E24'
>
<
span
>
¥
{
this
.
state
.
barInfo
.
amount
}
<
/span
>
<
span
onClick
=
{
e
=>
this
.
toCart
(
2
)
}
>
去支付
<
/span
>
<
span
onClick
=
{
this
.
bargainToOrder
}
>
去支付
<
/span
>
<
/button
>
}
<
/div
>
...
...
src/components/order/index.js
View file @
201cd00e
...
...
@@ -13,21 +13,25 @@ const Item = List.Item;
function
OrderList
(
props
)
{
console
.
log
(
props
);
const
listData
=
props
.
list
;
return
(
<
div
>
{
listData
.
map
((
item
,
index
)
=>
{
const
{
is_coupon
,
course_id
,
image_name
,
price1
,
price0
,
simpledescription
,
course_title
,
coupon_num
,
coupon_desc
}
=
item
;
const
{
is_coupon
,
course_id
,
image_name
,
price1
,
price0
,
simpledescription
,
course_title
,
coupon_num
,
coupon_desc
}
=
item
;
let
NewPrice
=
(
<
span
className
=
'order-newprice'
>
¥
{
price1
}
<
/span>
)
;
if
(
props
.
locationState
&&
props
.
locationState
.
group
)
{
NewPrice
=
(
<
span
className
=
'order-newprice'
>
¥
{
props
.
groupPrice
}
<
/span>
)
;
}
const
Info
=
(
<
div
className
=
"order-info"
>
<
Link
to
=
{
`/detail?id=
${
course_id
}
`
}
><
p
className
=
'order-title'
style
=
{{
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
whiteSpace
:
'nowrap'
}}
>
{
course_title
}
<
/p></
Link
>
<
p
className
=
'order-content'
style
=
{{
WebkitBoxOrient
:
'vertical'
,
WebkitLineClamp
:
'2'
,
wordBreak
:
'break-all'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
display
:
'-webkit-box'
}}
>
{
simpledescription
}
<
/p
>
<
p
className
=
'order-des'
>
{
/*// 这里根据类型判断 来显示什么价格 拼团还是砍价 还是特训营*/
}
{
props
.
courseId
===
undefined
?
(
<
span
className
=
'order-newprice'
>
¥
{
price1
}
<
/span>
)
:
(
<span className='order-newprice'>¥{price0}</
span
>
)
}
{
/*{*/
}
{
/* props.courseId === undefined ? (<span className='order-newprice'>¥{price1}</span>) : (<span className='order-newprice'>¥{price0}</span>)*/
}
{
/*}*/
}
{
NewPrice
}
<
span
className
=
'order-price'
>
¥
{
price0
}
<
/span
>
<
/p
>
<
/div
>
...
...
@@ -47,8 +51,7 @@ function OrderList(props) {
pathname
:
`/coupons`
,
search
:
`?id=
${
course_id
}
`
,
state
:
{
from
:
'/order'
,
a
:
'sldfasldjfsl'
from
:
'/order'
}}}
>
{
/* <Link to='coupons' query={{id: course_id}} state={{from: '/order'}}> */
}
<
Flex
justify
=
'between'
>
...
...
@@ -177,7 +180,10 @@ class Order extends Component {
};
// 公共方法 存储数据
publicGetData
=
(
res
)
=>
{
const
{
course
,
total
,
user_account
,
user_info
,
discount
}
=
res
.
data
.
data
;
let
{
course
,
total
,
user_account
,
user_info
,
discount
}
=
res
.
data
.
data
;
if
(
this
.
props
.
location
.
state
&&
this
.
props
.
location
.
state
.
group
===
1
)
{
total
=
this
.
groupPrice
;
}
this
.
cacheObj
=
{
perfect
:
user_info
,
orderList
:
course
,
...
...
@@ -210,6 +216,7 @@ class Order extends Component {
componentDidMount
()
{
let
_this
=
this
;
console
.
log
(
this
.
props
.
location
.
state
);
// 返现课程 立即报名 需要带上type = 1
if
(
this
.
props
.
location
.
state
&&
this
.
props
.
location
.
state
.
type
===
1
)
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/order/preorder?type=1`
).
then
((
res
)
=>
{
if
(
res
.
data
.
errno
===
200
)
{
...
...
@@ -220,21 +227,32 @@ class Order extends Component {
}
})
}
else
if
(
this
.
props
.
location
.
state
&&
this
.
props
.
location
.
state
.
simple
===
1
)
{
http
.
get
(
`
${
API
.
home
}
/m/order/preorder`
).
then
(
res
=>
{
if
(
res
.
data
.
code
===
200
)
{
// 普通课程立即报名 不带 type = 1
http
.
get
(
`
${
API
[
'base-api'
]}
/m/order/preorder`
).
then
(
res
=>
{
if
(
res
.
data
.
errno
===
200
)
{
this
.
publicGetData
(
res
);
this
.
publicLocalStorage
();
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
);
}
});
}
else
if
(
this
.
props
.
location
.
state
&&
this
.
props
.
location
.
state
.
group
===
1
){
// 获取一键开团的课程
Promise
.
all
([
http
.
get
(
`
${
API
[
'base-api'
]}
/m/order/preorder`
),
http
.
get
(
`
${
API
.
home
}
/m/course/detail/
${
getParam
(
'id'
)}
`
)]).
then
(
resList
=>
{
console
.
log
(
resList
);
let
courseInfo
=
resList
[
0
],
orderInfo
=
resList
[
1
];
this
.
groupPrice
=
orderInfo
.
data
.
data
.
course_info
.
pdd_group_info
.
price
;
this
.
publicGetData
(
courseInfo
);
this
.
publicLocalStorage
();
});
}
else
{
if
(
getParam
(
'id'
))
{
Promise
.
all
([
http
.
get
(
`
${
API
.
home
}
/m/del_cart_order/
${
getParam
(
'id'
)}
`
),
http
.
get
(
`
${
API
.
home
}
/m/order/preorder`
)]).
then
(
res
=>
{
Promise
.
all
([
http
.
get
(
`
${
API
.
home
}
/m/del_cart_order/
${
getParam
(
'id'
)}
`
),
http
.
get
(
`
${
API
[
'base-api'
]
}
/m/order/preorder`
)]).
then
(
res
=>
{
console
.
log
(
res
);
let
preorder
=
res
[
1
],
orderList
=
preorder
.
data
.
data
.
course
;
if
(
preorder
.
data
.
code
!==
200
)
{
if
(
preorder
.
data
.
errno
!==
200
)
{
Toast
.
info
(
preorder
.
data
.
msg
,
2
);
return
;
}
...
...
@@ -244,6 +262,7 @@ class Order extends Component {
})
}
else
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/order/preorder`
).
then
((
res
)
=>
{
alert
(
'为了验证什么条件下会走这段代码'
);
if
(
res
.
data
.
errno
!==
200
)
{
Toast
.
info
(
res
.
data
.
msg
,
2
);
return
;
...
...
@@ -279,9 +298,9 @@ class Order extends Component {
state
:
{
type
:
this
.
props
.
location
.
state
?
this
.
props
.
location
.
state
.
type
:
null
,
id
:
getParam
(
'id'
)}
}}
className
=
"order-information"
>
<
i
className
=
"iconfont iconiconfront-6 order-addsize"
><
/i
>
<
i
className
=
"iconfont iconiconfront-6 order-addsize"
/
>
<
div
className
=
"order-infotext"
>
完善报名信息
<
/div
>
<
i
className
=
"iconfont iconiconfront-70 order-next"
><
/i
>
<
i
className
=
"iconfont iconiconfront-70 order-next"
/
>
<
/Link
>
}
{
...
...
@@ -315,7 +334,7 @@ class Order extends Component {
<
/div
>
}
<
div
className
=
"order-list"
>
<
OrderList
list
=
{
orderList
}
compute
=
{
this
.
computedMoney
}
courseId
=
{
getParam
(
'id'
)}
isaist
=
{
this
.
props
.
location
.
state
?
this
.
props
.
location
.
state
.
type
:
null
}
/
>
<
OrderList
list
=
{
orderList
}
compute
=
{
this
.
computedMoney
}
courseId
=
{
getParam
(
'id'
)}
locationState
=
{
this
.
props
.
location
.
state
}
groupPrice
=
{
this
.
groupPrice
}
/
>
<
/div
>
<
div
className
=
"order-balance"
>
<
List
>
...
...
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