Commit c9f13cb3 by wangshuo

与APP交互

parent ee07b94a
......@@ -40,7 +40,7 @@ class Banner extends Component {
}
componentWillUnmount() {
window.removeEventListener('scroll', throttle(this.calcNavActive, 100))
}
......@@ -57,6 +57,7 @@ class Banner extends Component {
}
let el = document.querySelector(`#${navs[_index].id}`)
let nav = document.querySelector('#main-nav')
if(el) {
let top = el.offsetTop
if (y <= this.navTop) {
......@@ -81,6 +82,8 @@ class Banner extends Component {
this.prevY = y
}
}
toSection = (i, e) => {
e.preventDefault()
let top = document.querySelector(`#${this.state.navs[i].id}`).offsetTop
......
......@@ -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 &&
......
......@@ -221,6 +221,8 @@ class CourseList extends Component {
}
toReceiveCoupon(id, key = '') {
const {isLogin, toLogin} = this.props;
if(isLogin) {
http.post(`${API.home}/sys/activity/coupon/receive`, {
course_id: id
}).then(res => {
......@@ -254,6 +256,10 @@ class CourseList extends Component {
Toast.info(msg, 2, null, false);
}
});
}else{
toLogin();
}
}
......
......@@ -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,6 +108,8 @@ class BlessingPreheat extends Component {
}
handleToShowInvite = () => {
const { userInfo } = this.state;
if(userInfo.isLogin) {
QRCode.toDataURL('http://m.julyedu.com/invite', {
width: 120,
height: 120,
......@@ -116,6 +124,9 @@ class BlessingPreheat extends Component {
.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>
......
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,6 +35,8 @@ class LevelTest extends Component {
}
componentDidMount() {
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) {
......@@ -45,9 +47,16 @@ class LevelTest extends Component {
}
});
}
}
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>
{
isLogin && (
<span>(剩余{number}次)</span>
)
}
</div>
</div>
<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