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
c9f13cb3
Commit
c9f13cb3
authored
Oct 31, 2019
by
wangshuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
与APP交互
parent
ee07b94a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
117 additions
and
84 deletions
+117
-84
src/components/blessingPreheat/banner/index.js
+22
-19
src/components/blessingPreheat/collectBlessing/index.js
+2
-2
src/components/blessingPreheat/courseList/index.js
+38
-32
src/components/blessingPreheat/index.js
+29
-19
src/components/blessingPreheat/levelTest/index.js
+26
-12
No files found.
src/components/blessingPreheat/banner/index.js
View file @
c9f13cb3
...
...
@@ -40,7 +40,7 @@ class Banner extends Component {
}
componentWillUnmount
()
{
window
.
removeEventListener
(
'scroll'
,
throttle
(
this
.
calcNavActive
,
100
))
}
...
...
@@ -57,28 +57,31 @@ class Banner extends Component {
}
let
el
=
document
.
querySelector
(
`#
${
navs
[
_index
].
id
}
`
)
let
nav
=
document
.
querySelector
(
'#main-nav'
)
let
top
=
el
.
offsetTop
if
(
y
<=
this
.
navTop
)
{
nav
.
classList
.
remove
(
'fixed'
)
}
else
{
!
nav
.
classList
.
contains
(
'fixed'
)
&&
nav
.
classList
.
add
(
'fixed'
)
}
if
(
el
)
{
let
top
=
el
.
offsetTop
if
(
swipeDirection
===
'up'
)
{
if
(
y
+
30
+
30
>=
top
)
{
this
.
setState
({
index
:
_index
})
if
(
y
<=
this
.
navTop
)
{
nav
.
classList
.
remove
(
'fixed'
)
}
else
{
!
nav
.
classList
.
contains
(
'fixed'
)
&&
nav
.
classList
.
add
(
'fixed'
)
}
}
else
{
if
(
y
+
30
+
20
<=
top
)
{
this
.
setState
({
index
:
_index
})
if
(
swipeDirection
===
'up'
)
{
if
(
y
+
30
+
30
>=
top
)
{
this
.
setState
({
index
:
_index
})
}
}
else
{
if
(
y
+
30
+
20
<=
top
)
{
this
.
setState
({
index
:
_index
})
}
}
this
.
prevY
=
y
}
this
.
prevY
=
y
}
toSection
=
(
i
,
e
)
=>
{
...
...
src/components/blessingPreheat/collectBlessing/index.js
View file @
c9f13cb3
...
...
@@ -114,9 +114,9 @@ class CollectBlessing extends Component {
}
{
index
===
0
&&
(
!
isLogin
||
!
isSign
)
&&
<
Link
to
=
'/passport'
className
=
"collect-blessing__content"
>
<
span
onClick
=
{
toLogin
}
className
=
"collect-blessing__content"
>
点击
<
br
/>
签到
<
/
Link
>
<
/
span
>
}
{
index
===
1
&&
...
...
src/components/blessingPreheat/courseList/index.js
View file @
c9f13cb3
...
...
@@ -221,39 +221,45 @@ class CourseList extends Component {
}
toReceiveCoupon
(
id
,
key
=
''
)
{
http
.
post
(
`
${
API
.
home
}
/sys/activity/coupon/receive`
,
{
course_id
:
id
}).
then
(
res
=>
{
const
{
code
,
msg
}
=
res
.
data
;
if
(
code
===
200
)
{
Toast
.
info
(
'领取成功~'
,
2
,
null
,
false
);
let
obj
=
{};
obj
[
key
]
=
{
isMore
:
this
.
state
[
key
][
'isMore'
],
course
:
this
.
state
[
key
][
'course'
].
map
(
item
=>
{
if
(
item
.
course_id
===
id
)
{
return
Object
.
assign
({},
item
,
{
course_status
:
2
});
}
return
item
;
}),
courseList
:
this
.
state
[
key
][
'courseList'
].
map
(
item
=>
{
if
(
item
.
course_id
===
id
)
{
return
Object
.
assign
({},
item
,
{
course_status
:
2
});
}
return
item
;
}),
const
{
isLogin
,
toLogin
}
=
this
.
props
;
if
(
isLogin
)
{
http
.
post
(
`
${
API
.
home
}
/sys/activity/coupon/receive`
,
{
course_id
:
id
}).
then
(
res
=>
{
const
{
code
,
msg
}
=
res
.
data
;
if
(
code
===
200
)
{
Toast
.
info
(
'领取成功~'
,
2
,
null
,
false
);
let
obj
=
{};
obj
[
key
]
=
{
isMore
:
this
.
state
[
key
][
'isMore'
],
course
:
this
.
state
[
key
][
'course'
].
map
(
item
=>
{
if
(
item
.
course_id
===
id
)
{
return
Object
.
assign
({},
item
,
{
course_status
:
2
});
}
return
item
;
}),
courseList
:
this
.
state
[
key
][
'courseList'
].
map
(
item
=>
{
if
(
item
.
course_id
===
id
)
{
return
Object
.
assign
({},
item
,
{
course_status
:
2
});
}
return
item
;
}),
}
this
.
setState
({
...
obj
});
}
else
{
Toast
.
info
(
msg
,
2
,
null
,
false
);
}
this
.
setState
({
...
obj
});
}
else
{
Toast
.
info
(
msg
,
2
,
null
,
false
);
}
});
});
}
else
{
toLogin
();
}
}
...
...
src/components/blessingPreheat/index.js
View file @
c9f13cb3
...
...
@@ -46,6 +46,12 @@ class BlessingPreheat extends Component {
}
fetchUserBlessing
()
{
// 判断登录未登录 根据this.state.userInfo.isLogin
if
(
getParam
(
'version'
))
{
// app 平台
}
else
{
// H5
}
const
{
userInfo
}
=
this
.
state
;
http
.
get
(
`
${
API
.
home
}
/sys/user/blessing`
).
then
(
res
=>
{
const
{
code
,
data
}
=
res
.
data
;
...
...
@@ -91,7 +97,7 @@ class BlessingPreheat extends Component {
handleToShow
=
(
key
,
isLogin
=
false
)
=>
{
const
{
history
}
=
this
.
props
;
if
(
isLogin
)
{
history
.
push
(
'/passport'
)
this
.
toLogin
();
}
else
{
let
obj
=
{};
obj
[
key
]
=
true
;
...
...
@@ -102,20 +108,25 @@ class BlessingPreheat extends Component {
}
handleToShowInvite
=
()
=>
{
QRCode
.
toDataURL
(
'http://m.julyedu.com/invite'
,
{
width
:
120
,
height
:
120
,
margin
:
1
})
.
then
(
url
=>
{
this
.
setState
({
inviteUrl
:
url
,
inviteVisible
:
true
const
{
userInfo
}
=
this
.
state
;
if
(
userInfo
.
isLogin
)
{
QRCode
.
toDataURL
(
'http://m.julyedu.com/invite'
,
{
width
:
120
,
height
:
120
,
margin
:
1
})
.
then
(
url
=>
{
this
.
setState
({
inviteUrl
:
url
,
inviteVisible
:
true
});
})
.
catch
(
err
=>
{
console
.
error
(
err
)
});
})
.
catch
(
err
=>
{
console
.
error
(
err
)
});
}
else
{
this
.
toLogin
();
}
}
handleToShowNotice
=
()
=>
{
...
...
@@ -137,15 +148,14 @@ class BlessingPreheat extends Component {
console
.
error
(
err
)
});
}
else
if
(
errno
===
4030
||
errno
===
4040
)
{
location
.
href
=
`http://passport.julyedu.com/login?redirect=
${
encodeURI
(
document
.
URL
)}
`
;
this
.
toLogin
()
;
}
});
}
toLogin
=
()
=>
{
let
plat
=
getParam
(
'version'
);
const
{
history
}
=
this
.
props
;
if
(
!
plat
)
{
if
(
!
getParam
(
'version'
)
)
{
history
.
push
(
'/passport'
);
}
else
{
SendMessageToApp
(
"toLogin"
);
...
...
@@ -190,7 +200,7 @@ class BlessingPreheat extends Component {
{
/* 精品课程特惠专区 */
}
<
ListHeader
id
=
{
'best-courses'
}
text
=
"精品课程特惠专区"
styles
=
{{
margin
:
'30px 0 15px'
}}
/
>
<
CourseList
isFormal
=
{
isFormal
}
/
>
<
CourseList
isFormal
=
{
isFormal
}
isLogin
=
{
userInfo
.
isLogin
}
toLogin
=
{
this
.
toLogin
}
/
>
{
isRule
&&
...
...
@@ -254,7 +264,7 @@ class BlessingPreheat extends Component {
<
div
className
=
"test__record"
onClick
=
{()
=>
this
.
handleToShow
(
'showRecordList'
,
true
)}
>
测试记录
>
<
/div
>
<
LevelTest
><
/LevelTest
>
<
LevelTest
isLogin
=
{
userInfo
.
isLogin
}
toLogin
=
{
this
.
toLogin
}
><
/LevelTest
>
<
RankList
><
/RankList
>
...
...
src/components/blessingPreheat/levelTest/index.js
View file @
c9f13cb3
import
React
,
{
Component
}
from
'react'
import
'./index.scss'
import
listFrame
from
'./../listFrame/index'
;
import
{
http
}
from
"@/utils"
import
{
http
,
SendMessageToApp
}
from
"@/utils"
class
LevelTest
extends
Component
{
constructor
(
props
)
{
...
...
@@ -35,19 +35,28 @@ class LevelTest extends Component {
}
componentDidMount
()
{
http
.
get
(
`
${
API
.
home
}
/sys/ai_test/get_user_testinfo`
).
then
(
res
=>
{
let
{
code
,
data
:
{
user_test_total
,
user_residue_number
}}
=
res
.
data
;
if
(
code
===
200
)
{
this
.
setState
({
testNumber
:
user_test_total
,
number
:
user_residue_number
})
}
});
const
{
isLogin
}
=
this
.
props
;
if
(
isLogin
)
{
http
.
get
(
`
${
API
.
home
}
/sys/ai_test/get_user_testinfo`
).
then
(
res
=>
{
let
{
code
,
data
:
{
user_test_total
,
user_residue_number
}}
=
res
.
data
;
if
(
code
===
200
)
{
this
.
setState
({
testNumber
:
user_test_total
,
number
:
user_residue_number
})
}
});
}
}
startTest
=
()
=>
{
console
.
log
(
'startTest'
);
const
{
history
,
isLogin
,
toLogin
}
=
this
.
props
;
if
(
isLogin
)
{
history
.
push
(
'/levelTest/testing'
);
}
else
{
toLogin
();
}
}
render
()
{
...
...
@@ -56,6 +65,7 @@ class LevelTest extends Component {
number
,
prizeListUrl
,
}
=
this
.
state
;
const
{
isLogin
}
=
this
.
props
;
return
(
<>
<
div
className
=
"level__test_module"
>
...
...
@@ -63,7 +73,11 @@ class LevelTest extends Component {
<
img
src
=
"https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/m/test_icon.png"
/>
<
div
className
=
"button__text"
>
<
p
>
点击测试
<
/p
>
<
span
>
(剩余
{
number
}
次)
<
/span
>
{
isLogin
&&
(
<
span
>
(剩余
{
number
}
次)
<
/span
>
)
}
<
/div
>
<
/div
>
<
div
className
=
'test__number'
>
...
...
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