Commit dd8a08bb by FE

Merge branch 'pythonForApp' of gitlab.julyedu.com:baiguangyao/mr-julyedu into pythonForApp

parents 6ae12cdc 676571b4
import React, {Component} from 'react' import React, {Component} from 'react'
import {http, getParam, SendMessageToApp} from '@/utils' import {http, getParam, browser} from '@/utils'
import PythonDes from './pythomDes' import PythonDes from './pythomDes'
import PythonStudy from './pythonStudy' import PythonStudy from './pythonStudy'
import {connect} from "react-redux" import {connect} from "react-redux"
...@@ -19,7 +19,8 @@ class Python extends Component { ...@@ -19,7 +19,8 @@ class Python extends Component {
this.state = { this.state = {
isPay: '', isPay: '',
userInfoList: [], userInfoList: [],
isAppUpdate: false isAppUpdate: false,
backwardVersion: false, // 默认是新版本
} }
} }
...@@ -61,6 +62,7 @@ class Python extends Component { ...@@ -61,6 +62,7 @@ class Python extends Component {
isAppUpdate: true isAppUpdate: true
}) })
} }
alert(`uid = ${cookie.get("uid")}`);
this.props.setCurrentUser(this.transformUser(this.state.userInfoList)) this.props.setCurrentUser(this.transformUser(this.state.userInfoList))
} }
...@@ -89,19 +91,52 @@ class Python extends Component { ...@@ -89,19 +91,52 @@ class Python extends Component {
http.get(`${API.home}/m/course/detail/${id}`).then((res) => { http.get(`${API.home}/m/course/detail/${id}`).then((res) => {
const {data, code} = res.data const {data, code} = res.data
if (code === 200) { if (code === 200) {
this.setState({ let version = getParam('version')
isPay: data.course_info.is_pay if(version) {
}) version = version.replace(/\./g, '').slice(0, 3)
alert(version);
if(browser.isAndroidApp && version < 453) { // 安卓的低版本
alert('低版本');
this.setState({
backwardVersion: true,
isPay: 0,
})
}else{
alert('高版本');
this.setState({
backwardVersion: false,
isPay: data.course_info.is_pay
})
}
if(browser.isIOSApp && version < 380) { // ISO的低版本
this.setState({
backwardVersion: true,
isPay: 0,
})
}else{
this.setState({
backwardVersion: false,
isPay: data.course_info.is_pay
})
}
} else {
this.setState({
backwardVersion: false,
isPay: data.course_info.is_pay
})
}
} }
}) })
} }
render() { render() {
const {isPay, isAppUpdate} = this.state const {isPay, isAppUpdate, backwardVersion} = this.state;
// 旧版本 无论购买未购买 都跳转到 未购买的详情页; 如果是已购买就提示更新APP
return ( return (
<div> <div>
{ {
isPay === 0 && <PythonDes history={this.props.history} isAppUpdate={isAppUpdate}></PythonDes> // isPay === 0 && <PythonDes history={this.props.history} isAppUpdate={isAppUpdate} backwardVersion={backwardVersion} isPay={isPay}></PythonDes>
isPay === 0 && <div>为什么需要这么做</div>
} }
{ {
(isPay === 1 && !getParam('version')) && <PythonStudy isAppUpdate={isAppUpdate}/> (isPay === 1 && !getParam('version')) && <PythonStudy isAppUpdate={isAppUpdate}/>
......
...@@ -96,7 +96,7 @@ class PythonDes extends Component { ...@@ -96,7 +96,7 @@ class PythonDes extends Component {
}, },
], ],
payMoney: 0, payMoney: 0,
isOnline: false, //课程是否上架 isOnline: true, //课程是否上架
} }
} }
...@@ -121,6 +121,7 @@ class PythonDes extends Component { ...@@ -121,6 +121,7 @@ class PythonDes extends Component {
} }
toLearn = () => { toLearn = () => {
const {backwardVersion, isPay} = this.props;
http.post(`${API['home']}/m/it/user/trialCourse`, {course_id: getParam('id')}).then((res) => { http.post(`${API['home']}/m/it/user/trialCourse`, {course_id: getParam('id')}).then((res) => {
const {code, msg} = res.data const {code, msg} = res.data
if (code == 200) { if (code == 200) {
...@@ -129,7 +130,11 @@ class PythonDes extends Component { ...@@ -129,7 +130,11 @@ class PythonDes extends Component {
toApp: true toApp: true
}) })
} else { // APP } else { // APP
SendMessageToApp("toLearn") if(backwardVersion) {
Toast.info('当前版本不支持该课程模式,请升级到最新版本或前往PC端体验', 2)
} else {
SendMessageToApp("toLearn")
}
} }
} else { } else {
Toast.info(msg, 2) Toast.info(msg, 2)
...@@ -144,6 +149,7 @@ class PythonDes extends Component { ...@@ -144,6 +149,7 @@ class PythonDes extends Component {
} }
toDetail = () => { toDetail = () => {
const {backwardVersion, isPay} = this.props;
const id = getParam('id') const id = getParam('id')
if (!getParam('version')) { // H5 if (!getParam('version')) { // H5
http.get(`${API['base-api']}/m/cart/addtopreorder/[${id}]`).then((res) => { http.get(`${API['base-api']}/m/cart/addtopreorder/[${id}]`).then((res) => {
...@@ -154,7 +160,16 @@ class PythonDes extends Component { ...@@ -154,7 +160,16 @@ class PythonDes extends Component {
} }
}) })
} else { // APP } else { // APP
SendMessageToApp('toPay', id) if(backwardVersion) {
Toast.info('当前版本不支持该课程模式,请升级到最新版本或前往PC端购买', 2);
let onlyoneUse = setTimeout(() => {
clearTimeout(onlyoneUse);
onlyoneUse = null;
SendMessageToApp('toPay', id)
}, 2000);
} else {
SendMessageToApp('toPay', id)
}
} }
} }
...@@ -214,6 +229,11 @@ class PythonDes extends Component { ...@@ -214,6 +229,11 @@ class PythonDes extends Component {
componentDidMount() { componentDidMount() {
this.getStatus() this.getStatus()
const {backwardVersion, isPay} = this.props;
if(backwardVersion && isPay === 1) {
Toast.info('当前版本不支持该课程模式,请升级到最新版本或前往PC端学习', 2);
}
} }
...@@ -240,6 +260,7 @@ class PythonDes extends Component { ...@@ -240,6 +260,7 @@ class PythonDes extends Component {
} = this.state } = this.state
return ( return (
<div className={'python__des'}> <div className={'python__des'}>
<div>测试显示不显示</div>
<div className={'des__start'}></div> <div className={'des__start'}></div>
<div className={'python__define'}> <div className={'python__define'}>
<img className={'left__decorate'} <img className={'left__decorate'}
......
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