Commit c9f13cb3 by wangshuo

与APP交互

parent ee07b94a
...@@ -40,7 +40,7 @@ class Banner extends Component { ...@@ -40,7 +40,7 @@ class Banner extends Component {
} }
componentWillUnmount() { componentWillUnmount() {
window.removeEventListener('scroll', throttle(this.calcNavActive, 100))
} }
...@@ -57,6 +57,7 @@ class Banner extends Component { ...@@ -57,6 +57,7 @@ class Banner 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')
if(el) {
let top = el.offsetTop let top = el.offsetTop
if (y <= this.navTop) { if (y <= this.navTop) {
...@@ -81,6 +82,8 @@ class Banner extends Component { ...@@ -81,6 +82,8 @@ class Banner extends Component {
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
......
...@@ -114,9 +114,9 @@ class CollectBlessing extends Component { ...@@ -114,9 +114,9 @@ class CollectBlessing extends Component {
} }
{ {
index === 0 && (!isLogin || !isSign) && index === 0 && (!isLogin || !isSign) &&
<Link to='/passport' className="collect-blessing__content"> <span onClick={toLogin} className="collect-blessing__content">
点击<br/>签到 点击<br/>签到
</Link> </span>
} }
{ {
index === 1 && index === 1 &&
......
...@@ -221,6 +221,8 @@ class CourseList extends Component { ...@@ -221,6 +221,8 @@ class CourseList extends Component {
} }
toReceiveCoupon(id, key = '') { toReceiveCoupon(id, key = '') {
const {isLogin, toLogin} = this.props;
if(isLogin) {
http.post(`${API.home}/sys/activity/coupon/receive`, { http.post(`${API.home}/sys/activity/coupon/receive`, {
course_id: id course_id: id
}).then(res => { }).then(res => {
...@@ -254,6 +256,10 @@ class CourseList extends Component { ...@@ -254,6 +256,10 @@ class CourseList extends Component {
Toast.info(msg, 2, null, false); Toast.info(msg, 2, null, false);
} }
}); });
}else{
toLogin();
}
} }
......
...@@ -46,6 +46,12 @@ class BlessingPreheat extends Component { ...@@ -46,6 +46,12 @@ class BlessingPreheat extends Component {
} }
fetchUserBlessing() { fetchUserBlessing() {
// 判断登录未登录 根据this.state.userInfo.isLogin
if(getParam('version')) {
// app 平台
}else{
// H5
}
const { userInfo } = this.state; const { userInfo } = this.state;
http.get(`${API.home}/sys/user/blessing`).then(res => { http.get(`${API.home}/sys/user/blessing`).then(res => {
const { code, data } = res.data; const { code, data } = res.data;
...@@ -91,7 +97,7 @@ class BlessingPreheat extends Component { ...@@ -91,7 +97,7 @@ class BlessingPreheat extends Component {
handleToShow = (key, isLogin = false) => { handleToShow = (key, isLogin = false) => {
const { history } = this.props; const { history } = this.props;
if(isLogin) { if(isLogin) {
history.push('/passport') this.toLogin();
}else { }else {
let obj = {}; let obj = {};
obj[key] = true; obj[key] = true;
...@@ -102,6 +108,8 @@ class BlessingPreheat extends Component { ...@@ -102,6 +108,8 @@ class BlessingPreheat extends Component {
} }
handleToShowInvite = () => { handleToShowInvite = () => {
const { userInfo } = this.state;
if(userInfo.isLogin) {
QRCode.toDataURL('http://m.julyedu.com/invite', { QRCode.toDataURL('http://m.julyedu.com/invite', {
width: 120, width: 120,
height: 120, height: 120,
...@@ -116,6 +124,9 @@ class BlessingPreheat extends Component { ...@@ -116,6 +124,9 @@ class BlessingPreheat extends Component {
.catch(err => { .catch(err => {
console.error(err) console.error(err)
}); });
} else {
this.toLogin();
}
} }
handleToShowNotice = () => { handleToShowNotice = () => {
...@@ -137,15 +148,14 @@ class BlessingPreheat extends Component { ...@@ -137,15 +148,14 @@ class BlessingPreheat extends Component {
console.error(err) console.error(err)
}); });
}else if(errno === 4030 || errno === 4040) { }else if(errno === 4030 || errno === 4040) {
location.href = `http://passport.julyedu.com/login?redirect=${encodeURI(document.URL)}`; this.toLogin();
} }
}); });
} }
toLogin = () => { toLogin = () => {
let plat = getParam('version');
const { history } = this.props; const { history } = this.props;
if(!plat) { if(!getParam('version')) {
history.push('/passport'); history.push('/passport');
}else{ }else{
SendMessageToApp("toLogin"); SendMessageToApp("toLogin");
...@@ -190,7 +200,7 @@ class BlessingPreheat extends Component { ...@@ -190,7 +200,7 @@ class BlessingPreheat extends Component {
{/* 精品课程特惠专区 */} {/* 精品课程特惠专区 */}
<ListHeader id={'best-courses'} text="精品课程特惠专区" styles={{margin: '30px 0 15px'}} /> <ListHeader id={'best-courses'} text="精品课程特惠专区" styles={{margin: '30px 0 15px'}} />
<CourseList isFormal={isFormal} /> <CourseList isFormal={isFormal} isLogin={userInfo.isLogin} toLogin={this.toLogin}/>
{ {
isRule && isRule &&
...@@ -254,7 +264,7 @@ class BlessingPreheat extends Component { ...@@ -254,7 +264,7 @@ class BlessingPreheat extends Component {
<div className="test__record" onClick={() => this.handleToShow('showRecordList', true)}> <div className="test__record" onClick={() => this.handleToShow('showRecordList', true)}>
测试记录> 测试记录>
</div> </div>
<LevelTest></LevelTest> <LevelTest isLogin={userInfo.isLogin} toLogin={this.toLogin}></LevelTest>
<RankList></RankList> <RankList></RankList>
......
import React, { Component } from 'react' import React, { Component } from 'react'
import './index.scss' import './index.scss'
import listFrame from './../listFrame/index'; import listFrame from './../listFrame/index';
import { http} from "@/utils" import { http, SendMessageToApp} from "@/utils"
class LevelTest extends Component { class LevelTest extends Component {
constructor(props) { constructor(props) {
...@@ -35,6 +35,8 @@ class LevelTest extends Component { ...@@ -35,6 +35,8 @@ class LevelTest extends Component {
} }
componentDidMount() { componentDidMount() {
const {isLogin} = this.props;
if(isLogin) {
http.get(`${API.home}/sys/ai_test/get_user_testinfo`).then(res => { http.get(`${API.home}/sys/ai_test/get_user_testinfo`).then(res => {
let {code, data: {user_test_total, user_residue_number}} = res.data; let {code, data: {user_test_total, user_residue_number}} = res.data;
if(code === 200) { if(code === 200) {
...@@ -45,9 +47,16 @@ class LevelTest extends Component { ...@@ -45,9 +47,16 @@ class LevelTest extends Component {
} }
}); });
} }
}
startTest = () => { startTest = () => {
console.log('startTest'); const {history, isLogin, toLogin} = this.props;
if(isLogin) {
history.push('/levelTest/testing');
}else{
toLogin();
}
} }
render() { render() {
...@@ -56,6 +65,7 @@ class LevelTest extends Component { ...@@ -56,6 +65,7 @@ class LevelTest extends Component {
number, number,
prizeListUrl, prizeListUrl,
} = this.state; } = this.state;
const {isLogin} = this.props;
return ( return (
<> <>
<div className="level__test_module"> <div className="level__test_module">
...@@ -63,7 +73,11 @@ class LevelTest extends Component { ...@@ -63,7 +73,11 @@ class LevelTest extends Component {
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/m/test_icon.png" /> <img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/m/test_icon.png" />
<div className="button__text"> <div className="button__text">
<p>点击测试</p> <p>点击测试</p>
{
isLogin && (
<span>(剩余{number}次)</span> <span>(剩余{number}次)</span>
)
}
</div> </div>
</div> </div>
<div className='test__number'> <div className='test__number'>
......
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