Commit 685cdb40 by wangshuo

APP 邀请好友注册

parent 620392c2
...@@ -34,66 +34,66 @@ class Banner extends Component { ...@@ -34,66 +34,66 @@ class Banner extends Component {
index: 0, index: 0,
} }
componentDidMount() { // componentDidMount() {
window.addEventListener('scroll', throttle(this.calcNavActive, 100)) // window.addEventListener('scroll', throttle(this.calcNavActive, 100))
} // }
componentWillUnmount() { // componentWillUnmount() {
window.removeEventListener('scroll', throttle(this.calcNavActive, 100)) // window.removeEventListener('scroll', throttle(this.calcNavActive, 100))
} // }
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 // _index = (index + 1) >= navs.length ? index : index + 1
} else { // } else {
_index = (index - 1) <= 0 ? 0 : index - 1 // _index = (index - 1) <= 0 ? 0 : index - 1
} // }
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')
if(el) { // if(el) {
let top = el.offsetTop // let top = el.offsetTop
if (y <= this.navTop) { // if (y <= this.navTop) {
nav.classList.remove('fixed') // nav.classList.remove('fixed')
} else { // } else {
!nav.classList.contains('fixed') && nav.classList.add('fixed') // !nav.classList.contains('fixed') && nav.classList.add('fixed')
} // }
if (swipeDirection === 'up') { // if (swipeDirection === 'up') {
if (y + 30 + 30 >= top) { // if (y + 30 + 30 >= top) {
this.setState({ // this.setState({
index: _index // index: _index
}) // })
} // }
} else { // } else {
if (y + 30 + 20 <= top) { // if (y + 30 + 20 <= top) {
this.setState({ // this.setState({
index: _index // index: _index
}) // })
} // }
} // }
this.prevY = y // this.prevY = y
} // }
} // }
toSection = (i, e) => { // toSection = (i, e) => {
e.preventDefault() // e.preventDefault()
let top = document.querySelector(`#${this.state.navs[i].id}`).offsetTop // let top = document.querySelector(`#${this.state.navs[i].id}`).offsetTop
this.setState({ // this.setState({
index: i // index: i
}) // })
window.scrollTo({ // window.scrollTo({
top: top - 60, // top: top - 60,
left: 0 // left: 0
}) // })
} // }
render() { render() {
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { http } from "@/utils"; import { http, SendMessageToApp } from "@/utils";
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import './index.scss'; import './index.scss';
import { getParam } from '../../../utils';
class CoursePopup extends Component { class CoursePopup extends Component {
constructor(props) { constructor(props) {
...@@ -37,6 +38,31 @@ class CoursePopup extends Component { ...@@ -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() { render() {
const { courseList } = this.state; const { courseList } = this.state;
const { handleToHide } = this.props; const { handleToHide } = this.props;
...@@ -47,17 +73,17 @@ class CoursePopup extends Component { ...@@ -47,17 +73,17 @@ class CoursePopup extends Component {
<div className="course-popup__list"> <div className="course-popup__list">
{ {
courseList.map(item => ( courseList.map(item => (
<Link <span
to={`/detail?id=${item.course_id}&ac=11`}
className="course-popup__item" className="course-popup__item"
key={item.course_id} key={item.course_id}
onClick={this.toCourseDetail}
> >
<span className="course-popup__name">{item.course_title}</span> <span className="course-popup__name">{item.course_title}</span>
{ {
item.blessing && item.blessing &&
<span>+2</span> <span>+2</span>
} }
</Link> </span>
)) ))
} }
</div> </div>
......
...@@ -154,23 +154,34 @@ class BlessingPreheat extends Component { ...@@ -154,23 +154,34 @@ class BlessingPreheat extends Component {
} }
} }
// 邀请好友注册
handleToShowInvite = () => { handleToShowInvite = () => {
const { userInfo } = this.state; const { userInfo } = this.state;
if(userInfo.isLogin) { if(userInfo.isLogin) {
QRCode.toDataURL('http://m.julyedu.com/invite', { if(!getParam('version')) {
width: 120, QRCode.toDataURL('http://m.julyedu.com/invite', {
height: 120, width: 120,
margin: 1 height: 120,
}) margin: 1
.then(url => { })
this.setState({ .then(url => {
inviteUrl: url, this.setState({
inviteVisible: true inviteUrl: url,
inviteVisible: true
});
})
.catch(err => {
console.error(err)
}); });
}) }else{
.catch(err => { let data = {
console.error(err) 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 { } else {
this.toLogin(); this.toLogin();
} }
...@@ -239,28 +250,30 @@ class BlessingPreheat extends Component { ...@@ -239,28 +250,30 @@ class BlessingPreheat extends Component {
} }
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')
let top = el.offsetTop if(el) {
let top = el.offsetTop
if (y <= this.navTop) {
nav.classList.remove('fixed')
} else {
!nav.classList.contains('fixed') && nav.classList.add('fixed')
}
if (swipeDirection === 'up') { if (y <= this.navTop) {
if (y + 30 + 30 >= top) { nav.classList.remove('fixed')
this.setState({ } else {
index: _index !nav.classList.contains('fixed') && nav.classList.add('fixed')
})
} }
} else {
if (y + 30 + 20 <= top) { if (swipeDirection === 'up') {
this.setState({ if (y + 30 + 30 >= top) {
index: _index this.setState({
}) index: _index
})
}
} else {
if (y + 30 + 20 <= top) {
this.setState({
index: _index
})
}
} }
this.prevY = y
} }
this.prevY = y
} }
render() { render() {
...@@ -279,6 +292,7 @@ class BlessingPreheat extends Component { ...@@ -279,6 +292,7 @@ class BlessingPreheat extends Component {
shareMark, shareMark,
index index
} = this.state; } = this.state;
const {history} = this.props;
return ( return (
<div id={'blessing-preheat'}> <div id={'blessing-preheat'}>
<Banner <Banner
...@@ -329,7 +343,7 @@ class BlessingPreheat extends Component { ...@@ -329,7 +343,7 @@ class BlessingPreheat extends Component {
} }
{ {
isCourse && isCourse &&
<CoursePopup handleToHide={() => this.handleToHide('isCourse')}/> <CoursePopup toLogin={this.toLogin} history={history} isLogin={userInfo.isLogin} handleToHide={() => this.handleToHide('isCourse')}/>
} }
{ {
showRecordList && showRecordList &&
......
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