Commit b6418da3 by wangshuo

返场

parent fa58a508
...@@ -148,7 +148,7 @@ class BlessingPreheat extends Component { ...@@ -148,7 +148,7 @@ class BlessingPreheat extends Component {
// // 这里有获取ID的步骤,由于运营过多的调整,导致顺序不定,所以包含ID的title必须要放到判断中(防止出现多个title),设置定时器是因为如果返回较慢 获取不到ID导致报错 // // 这里有获取ID的步骤,由于运营过多的调整,导致顺序不定,所以包含ID的title必须要放到判断中(防止出现多个title),设置定时器是因为如果返回较慢 获取不到ID导致报错
// _this.setInitialNavActiveStatus() // _this.setInitialNavActiveStatus()
// }, 50); // }, 50);
window.addEventListener('scroll', throttle(this.calcNavActive, 100)) // window.addEventListener('scroll', throttle(this.calcNavActive, 100))
if (is_weixin()) { if (is_weixin()) {
wxShare({ wxShare({
title: 'AI充电节,积福气享1折秒课,超10万元奖品来就送!!', title: 'AI充电节,积福气享1折秒课,超10万元奖品来就送!!',
...@@ -264,6 +264,9 @@ class BlessingPreheat extends Component { ...@@ -264,6 +264,9 @@ class BlessingPreheat extends Component {
return findIndex(navs, item => item.id === str) return findIndex(navs, item => item.id === str)
} }
componentWillUnmount () {
window.removeEventListener('scroll', this.calcNavActive);
}
setInitialNavActiveStatus = () => { setInitialNavActiveStatus = () => {
const observer = new MutationObserver(debounce((list, observer) => { const observer = new MutationObserver(debounce((list, observer) => {
...@@ -285,13 +288,22 @@ class BlessingPreheat extends Component { ...@@ -285,13 +288,22 @@ class BlessingPreheat extends Component {
if (isFormal) { if (isFormal) {
if(onlyShow) { if(onlyShow) {
this.setState({ this.setState({
navs: encoreNavs navs: encoreNavs
}, () => {
this.setInitialNavActiveStatus()
window.addEventListener('scroll', throttle(this.calcNavActive, 100))
}) })
} else { } else {
this.setState({ this.setState({
navs: formalNavs navs: formalNavs
}, () => {
this.setInitialNavActiveStatus()
window.addEventListener('scroll', throttle(this.calcNavActive, 100))
}) })
} }
} }
} }
...@@ -325,7 +337,6 @@ class BlessingPreheat extends Component { ...@@ -325,7 +337,6 @@ class BlessingPreheat extends Component {
inviteBlessing: (data.types_total_blessing_value && data.types_total_blessing_value.invite) ? data.types_total_blessing_value.invite : 0, inviteBlessing: (data.types_total_blessing_value && data.types_total_blessing_value.invite) ? data.types_total_blessing_value.invite : 0,
}) })
})); }));
this.setInitialNavActiveStatus()
if (data.is_login === 1) { if (data.is_login === 1) {
this.handleToSign() this.handleToSign()
} }
...@@ -454,14 +465,23 @@ class BlessingPreheat extends Component { ...@@ -454,14 +465,23 @@ class BlessingPreheat extends Component {
calcNavActive = () => { calcNavActive = () => {
const {navs, index} = this.state const {navs, index} = this.state
const y = window.scrollY const y = window.scrollY
let swipeDirection = y > this.prevY ? 'up' : 'down' let swipeDirection = y > this.prevY ? 'up' : 'down'
let _index let _index
if (swipeDirection === 'up') { if (swipeDirection === 'up') {
_index = (index + 1) >= navs.length ? index : index + 1 if(Number.isInteger(index)){
_index = (index + 1) >= navs.length ? index : index + 1
}else {
_index = 0
}
} else { } else {
_index = (index - 1) <= 0 ? 0 : index - 1 if(Number.isInteger(index)){
_index = (index - 1) <= 0 ? 0 : index - 1
}else {
_index = 0
}
} }
let el = document.querySelector(`#${navs[_index].id}`) let el = document.querySelector(`#${navs[_index].id}`)
let nav = document.querySelector('#main-nav') let nav = document.querySelector('#main-nav')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment