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
78e068f4
Commit
78e068f4
authored
Aug 22, 2019
by
FE
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cart btn update course detail
parent
eb75aa47
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
34 deletions
+65
-34
src/common/HeaderBar/index.js
+1
-1
src/components/detail/actions.js
+2
-1
src/components/detail/btnstatus/index.js
+31
-29
src/components/detail/index.js
+29
-1
src/components/sharePoster/index.js
+2
-2
No files found.
src/common/HeaderBar/index.js
View file @
78e068f4
...
@@ -30,7 +30,7 @@ class HeaderBar extends Component {
...
@@ -30,7 +30,7 @@ class HeaderBar extends Component {
}
}
{
{
toHref
&&
typeof
toHref
===
'function'
&&
toHref
&&
typeof
toHref
===
'function'
&&
<
i
className
=
'iconfont iconiconfront-68'
onClick
=
{
toHref
}
>
1
<
/i
>
<
i
className
=
'iconfont iconiconfront-68'
onClick
=
{
toHref
}
><
/i
>
}
}
{
{
toHref
&&
typeof
toHref
===
'string'
&&
toHref
&&
typeof
toHref
===
'string'
&&
...
...
src/components/detail/actions.js
View file @
78e068f4
...
@@ -21,7 +21,8 @@ export const fetchCoursesListIfNeeded = () => (dispatch, getState) => {
...
@@ -21,7 +21,8 @@ export const fetchCoursesListIfNeeded = () => (dispatch, getState) => {
}
}
export
const
getCourses
=
(
id
,
cb
)
=>
dispatch
=>
{
export
const
getCourses
=
(
id
,
cb
)
=>
dispatch
=>
{
const
courseId
=
id
?
id
:
getParam
(
'id'
);
const
courseId
=
id
?
id
:
getParam
(
'id'
);
return
http
.
get
(
`
${
API
.
home
}
/m/course/detail/
${
courseId
}
`
,).
then
((
res
)
=>
{
const
url
=
getParam
(
'dist_code'
)?
`
${
API
.
home
}
/m/course/detail/
${
courseId
}
/
${
getParam
(
'dist_code'
)}
`
:
`
${
API
.
home
}
/m/course/detail/
${
courseId
}
`
;
return
http
.
get
(
url
).
then
((
res
)
=>
{
if
(
res
.
data
.
code
===
200
)
{
if
(
res
.
data
.
code
===
200
)
{
dispatch
(
receiveCourseDetail
({
dispatch
(
receiveCourseDetail
({
...
res
.
data
.
data
...
res
.
data
.
data
...
...
src/components/detail/btnstatus/index.js
View file @
78e068f4
...
@@ -47,36 +47,36 @@ class BtnStatus extends Component {
...
@@ -47,36 +47,36 @@ class BtnStatus extends Component {
// this.getBargainInfo()
// this.getBargainInfo()
// }
// }
this
.
setState
({
this
.
setState
({
...
nextProps
.
data
.
course_info
,
courseInfo
:
data
,
countdown
:
nextProps
.
countdown
,
countdown
:
nextProps
.
countdown
,
});
});
}
}
// 加入购物车 type:1 加入购物车,2加入购物车并跳转到购物车页面去支付
//
//
加入购物车 type:1 加入购物车,2加入购物车并跳转到购物车页面去支付
toCart
=
(
type
)
=>
{
//
toCart = (type) => {
const
{
history
,
addCourseToCart
}
=
this
.
props
;
//
const { history, addCourseToCart } = this.props;
let
data
=
{
//
let data = {
course_id
:
getParam
(
'id'
)
//
course_id: getParam('id')
};
//
};
http
.
post
(
`
${
API
.
home
}
/m/cart/add`
,
data
).
then
((
res
)
=>
{
//
http.post(`${API.home}/m/cart/add`, data).then((res) => {
if
(
res
.
data
.
code
===
200
)
{
//
if (res.data.code === 200) {
if
(
type
===
1
)
{
//
if (type === 1) {
Toast
.
info
(
'已加入购物车'
,
2
)
//
Toast.info('已加入购物车', 2)
// this.props.getCourses()
//
// this.props.getCourses()
// document.location.reload()
//
// document.location.reload()
addCourseToCart
();
//
addCourseToCart();
}
else
{
//
} else {
history
.
replace
(
'/shopcart'
);
ß
//
history.replace('/shopcart');ß
}
//
}
}
else
if
(
res
.
data
.
code
===
15001
)
{
//
} else if (res.data.code === 15001) {
history
.
replace
(
'/shopcart'
);
//
history.replace('/shopcart');
}
else
if
(
res
.
data
.
code
===
4030
)
{
//
} else if (res.data.code === 4030) {
history
.
replace
(
'/passport'
);
//
history.replace('/passport');
}
else
{
//
} else {
Toast
.
info
(
res
.
data
.
msg
,
2
);
//
Toast.info(res.data.msg, 2);
}
//
}
})
//
})
};
//
};
// 返现课程的立即购买
// 返现课程的立即购买
signUpNow
=
()
=>
{
signUpNow
=
()
=>
{
if
(
this
.
props
.
user
.
hasError
)
{
if
(
this
.
props
.
user
.
hasError
)
{
...
@@ -234,10 +234,12 @@ class BtnStatus extends Component {
...
@@ -234,10 +234,12 @@ class BtnStatus extends Component {
}
}
render
()
{
render
()
{
console
.
log
(
this
.
state
);
// data 课程信息;barInfo 砍价信息
// data 课程信息;barInfo 砍价信息
const
{
data
:
info
=
{},
user
=
{}
}
=
this
.
props
;
const
{
user
=
{},
toCart
}
=
this
.
props
;
const
{
countdown
,
barInfo
}
=
this
.
state
;
const
{
countdown
,
barInfo
,
courseInfo
:
info
=
{}
}
=
this
.
state
;
const
uid
=
user
.
data
&&
user
.
data
.
uid
;
const
uid
=
user
.
data
&&
user
.
data
.
uid
;
console
.
log
(
info
.
in_cart
);
return
(
return
(
<
div
>
<
div
>
{
/*正常购买*/
}
{
/*正常购买*/
}
...
@@ -254,7 +256,7 @@ class BtnStatus extends Component {
...
@@ -254,7 +256,7 @@ class BtnStatus extends Component {
}
}
{
{
!
info
.
in_cart
&&
!
info
.
in_cart
&&
<
button
className
=
'btn btn-s bg-FCCD05'
onClick
=
{
e
=>
t
his
.
t
oCart
(
1
)}
>
加入购物车
<
/button
>
<
button
className
=
'btn btn-s bg-FCCD05'
onClick
=
{
e
=>
toCart
(
1
)}
>
加入购物车
<
/button
>
}
}
<
span
className
=
'btn btn-s bg-FD7700'
onClick
=
{
e
=>
this
.
simpleCourse
()}
>
立即报名
<
/span
>
<
span
className
=
'btn btn-s bg-FD7700'
onClick
=
{
e
=>
this
.
simpleCourse
()}
>
立即报名
<
/span
>
...
...
src/components/detail/index.js
View file @
78e068f4
...
@@ -110,6 +110,33 @@ class Detail extends Component {
...
@@ -110,6 +110,33 @@ class Detail extends Component {
// }
// }
// }
// }
// 加入购物车 type:1 加入购物车,2加入购物车并跳转到购物车页面去支付
toCart
=
(
type
)
=>
{
const
{
history
,
addCourseToCart
}
=
this
.
props
;
let
data
=
{
course_id
:
getParam
(
'id'
)
};
http
.
post
(
`
${
API
.
home
}
/m/cart/add`
,
data
).
then
((
res
)
=>
{
if
(
res
.
data
.
code
===
200
)
{
if
(
type
===
1
)
{
Toast
.
info
(
'已加入购物车'
,
2
)
// this.props.getCourses()
// document.location.reload()
addCourseToCart
();
this
.
fetchCourseInfo
();
}
else
{
history
.
replace
(
'/shopcart'
);
ß
}
}
else
if
(
res
.
data
.
code
===
15001
)
{
history
.
replace
(
'/shopcart'
);
}
else
if
(
res
.
data
.
code
===
4030
)
{
history
.
replace
(
'/passport'
);
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
);
}
})
};
invitedFriends
=
()
=>
{
invitedFriends
=
()
=>
{
const
{
course_title
,
image_name
,
course_id
,
pdd_group_info
,
pdd_group_info
:
{
groupon_member
,
groupon_member
:
{
number
},
price
}}
=
this
.
state
.
course
.
course_info
;
const
{
course_title
,
image_name
,
course_id
,
pdd_group_info
,
pdd_group_info
:
{
groupon_member
,
groupon_member
:
{
number
},
price
}}
=
this
.
state
.
course
.
course_info
;
if
(
browser
.
isWeixin
)
{
if
(
browser
.
isWeixin
)
{
...
@@ -312,7 +339,8 @@ class Detail extends Component {
...
@@ -312,7 +339,8 @@ class Detail extends Component {
data
=
{
course_info
}
data
=
{
course_info
}
user
=
{
this
.
props
.
user
}
user
=
{
this
.
props
.
user
}
invitedFriends
=
{
this
.
invitedFriends
}
invitedFriends
=
{
this
.
invitedFriends
}
addCourseToCart
=
{
this
.
props
.
addCourseToCart
}
// addCourseToCart={this.props.addCourseToCart}
toCart
=
{
this
.
toCart
}
history
=
{
this
.
props
.
history
}
history
=
{
this
.
props
.
history
}
/>
}
/>
}
...
...
src/components/sharePoster/index.js
View file @
78e068f4
...
@@ -56,7 +56,7 @@ class SharePoster extends Component {
...
@@ -56,7 +56,7 @@ class SharePoster extends Component {
let
qrCodeWidth
=
(
imgList
[
index
].
qr_code_width
*
$width
)
// 二维码宽度
let
qrCodeWidth
=
(
imgList
[
index
].
qr_code_width
*
$width
)
// 二维码宽度
let
qrCodeHeight
=
(
imgList
[
index
].
qr_code_height
*
$height
)
-
avatarHeight
/
2
// 二维码高度
let
qrCodeHeight
=
(
imgList
[
index
].
qr_code_height
*
$height
)
-
avatarHeight
/
2
// 二维码高度
let
qrCodeLink
=
`
/detail/
${
getParam
(
'courseId'
)}
/
${
getParam
(
'dist_code'
)}
`
let
qrCodeLink
=
`
https://m.julyedu.com/detail?id=
${
getParam
(
'courseId'
)}
&dist_code
${
getParam
(
'dist_code'
)}
`
var
canvas
=
document
.
getElementById
(
"canvas"
),
var
canvas
=
document
.
getElementById
(
"canvas"
),
context
=
canvas
.
getContext
(
"2d"
);
context
=
canvas
.
getContext
(
"2d"
);
...
@@ -156,7 +156,7 @@ class SharePoster extends Component {
...
@@ -156,7 +156,7 @@ class SharePoster extends Component {
// 获取二维码
// 获取二维码
getCodeWe
()
{
getCodeWe
()
{
let
_this
=
this
let
_this
=
this
let
qrCodeLink
=
`http
://m.julyedu.com/detail/
${
getParam
(
'courseId'
)}
/
${
getParam
(
'dist_code'
)}
`
let
qrCodeLink
=
`http
s://m.julyedu.com/detail?id=
${
getParam
(
'courseId'
)}
&dist_code=
${
getParam
(
'dist_code'
)}
`
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
resolve
=>
{
QRCode
.
toDataURL
(
qrCodeLink
,
{},
function
(
err
,
url
)
{
QRCode
.
toDataURL
(
qrCodeLink
,
{},
function
(
err
,
url
)
{
_this
.
setState
({
_this
.
setState
({
...
...
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