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
685cdb40
Commit
685cdb40
authored
Oct 31, 2019
by
wangshuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
APP 邀请好友注册
parent
620392c2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
128 additions
and
88 deletions
+128
-88
src/components/blessingPreheat/banner/index.js
+52
-52
src/components/blessingPreheat/coursePopup/index.js
+30
-4
src/components/blessingPreheat/index.js
+46
-32
No files found.
src/components/blessingPreheat/banner/index.js
View file @
685cdb40
...
...
@@ -34,66 +34,66 @@ class Banner extends Component {
index
:
0
,
}
componentDidMount
()
{
window
.
addEventListener
(
'scroll'
,
throttle
(
this
.
calcNavActive
,
100
))
}
//
componentDidMount() {
//
window.addEventListener('scroll', throttle(this.calcNavActive, 100))
//
}
componentWillUnmount
()
{
window
.
removeEventListener
(
'scroll'
,
throttle
(
this
.
calcNavActive
,
100
))
}
//
componentWillUnmount() {
//
window.removeEventListener('scroll', throttle(this.calcNavActive, 100))
//
}
calcNavActive
=
()
=>
{
const
{
navs
,
index
}
=
this
.
state
const
y
=
window
.
scrollY
let
swipeDirection
=
y
>
this
.
prevY
?
'up'
:
'down'
let
_index
if
(
swipeDirection
===
'up'
)
{
_index
=
(
index
+
1
)
>=
navs
.
length
?
index
:
index
+
1
//
calcNavActive = () => {
//
const {navs, index} = this.state
//
const y = window.scrollY
//
let swipeDirection = y > this.prevY ? 'up' : 'down'
//
let _index
//
if (swipeDirection === 'up') {
//
_index = (index + 1) >= navs.length ? index : index + 1
}
else
{
_index
=
(
index
-
1
)
<=
0
?
0
:
index
-
1
}
let
el
=
document
.
querySelector
(
`#
${
navs
[
_index
].
id
}
`
)
let
nav
=
document
.
querySelector
(
'#main-nav'
)
if
(
el
)
{
let
top
=
el
.
offsetTop
//
} else {
//
_index = (index - 1) <= 0 ? 0 : index - 1
//
}
//
let el = document.querySelector(`#${navs[_index].id}`)
//
let nav = document.querySelector('#main-nav')
//
if(el) {
//
let top = el.offsetTop
if
(
y
<=
this
.
navTop
)
{
nav
.
classList
.
remove
(
'fixed'
)
}
else
{
!
nav
.
classList
.
contains
(
'fixed'
)
&&
nav
.
classList
.
add
(
'fixed'
)
}
//
if (y <= this.navTop) {
//
nav.classList.remove('fixed')
//
} else {
//
!nav.classList.contains('fixed') && nav.classList.add('fixed')
//
}
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
}
//
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
//
}
}
//
}
toSection
=
(
i
,
e
)
=>
{
e
.
preventDefault
()
let
top
=
document
.
querySelector
(
`#
${
this
.
state
.
navs
[
i
].
id
}
`
).
offsetTop
this
.
setState
({
index
:
i
})
window
.
scrollTo
({
top
:
top
-
60
,
left
:
0
})
}
//
toSection = (i, e) => {
//
e.preventDefault()
//
let top = document.querySelector(`#${this.state.navs[i].id}`).offsetTop
//
this.setState({
//
index: i
//
})
//
window.scrollTo({
//
top: top - 60,
//
left: 0
//
})
//
}
render
()
{
...
...
src/components/blessingPreheat/coursePopup/index.js
View file @
685cdb40
import
React
,
{
Component
}
from
'react'
;
import
{
http
}
from
"@/utils"
;
import
{
http
,
SendMessageToApp
}
from
"@/utils"
;
import
{
Link
}
from
'react-router-dom'
;
import
'./index.scss'
;
import
{
getParam
}
from
'../../../utils'
;
class
CoursePopup
extends
Component
{
constructor
(
props
)
{
...
...
@@ -37,6 +38,31 @@ class CoursePopup extends Component {
});
}
toCourseDetail
=
(
item
)
=>
{
console
.
log
(
this
.
props
);
const
{
isLogin
,
history
,
toLogin
}
=
this
.
props
;
// to={`/detail?id=${item.course_id}&ac=11`}
if
(
isLogin
)
{
if
(
!
getParam
(
'version'
))
{
history
.
push
(
`/detail?id=
${
item
.
course_id
}
&ac=11`
);
}
else
{
let
type
=
0
;
if
(
item
.
blessing
)
{
type
=
2
;
}
else
{
type
=
1
;
}
let
data
=
{
courseId
:
courseId
,
type
:
type
// 正常跳课程详情页type:0,积福气浏览课程详情页-没有浏览过type:1 已浏览过type:2
}
SendMessageToApp
(
"toCourse"
,
data
);
}
}
else
{
toLogin
();
}
}
render
()
{
const
{
courseList
}
=
this
.
state
;
const
{
handleToHide
}
=
this
.
props
;
...
...
@@ -47,17 +73,17 @@ class CoursePopup extends Component {
<
div
className
=
"course-popup__list"
>
{
courseList
.
map
(
item
=>
(
<
Link
to
=
{
`/detail?id=
${
item
.
course_id
}
&ac=11`
}
<
span
className
=
"course-popup__item"
key
=
{
item
.
course_id
}
onClick
=
{
this
.
toCourseDetail
}
>
<
span
className
=
"course-popup__name"
>
{
item
.
course_title
}
<
/span
>
{
item
.
blessing
&&
<
span
>+
2
点
<
/span
>
}
<
/
Link
>
<
/
span
>
))
}
<
/div
>
...
...
src/components/blessingPreheat/index.js
View file @
685cdb40
...
...
@@ -154,23 +154,34 @@ class BlessingPreheat extends Component {
}
}
// 邀请好友注册
handleToShowInvite
=
()
=>
{
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
if
(
!
getParam
(
'version'
))
{
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
{
let
data
=
{
title
:
'11.11-11.13 AI充电节,预热来袭!重磅好课1折秒,超10万元奖品来就送-七月在线'
,
// 标题
desc
:
'11.11-11.13 AI充电节,预热来袭!重磅好课1折秒,超10万元奖品来就送-七月在线'
,
// 描述
imgUrl
:
'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_717/m/717/shareimg.png'
,
// 图片地址
link
:
'https://m.julyedu.com/blessingPreheat'
// url
}
SendMessageToApp
(
"toShare"
,
data
)
}
}
else
{
this
.
toLogin
();
}
...
...
@@ -239,28 +250,30 @@ class BlessingPreheat 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
}
render
()
{
...
...
@@ -279,6 +292,7 @@ class BlessingPreheat extends Component {
shareMark
,
index
}
=
this
.
state
;
const
{
history
}
=
this
.
props
;
return
(
<
div
id
=
{
'blessing-preheat'
}
>
<
Banner
...
...
@@ -329,7 +343,7 @@ class BlessingPreheat extends Component {
}
{
isCourse
&&
<
CoursePopup
handleToHide
=
{()
=>
this
.
handleToHide
(
'isCourse'
)}
/
>
<
CoursePopup
toLogin
=
{
this
.
toLogin
}
history
=
{
history
}
isLogin
=
{
userInfo
.
isLogin
}
handleToHide
=
{()
=>
this
.
handleToHide
(
'isCourse'
)}
/
>
}
{
showRecordList
&&
...
...
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