Commit 1d61b1de by FE

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

parents 6331f0e3 d5c097cf
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, // 默认是新版本
} }
} }
...@@ -89,19 +90,41 @@ class Python extends Component { ...@@ -89,19 +90,41 @@ 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) {
let version = getParam('version')
if(version) {
version = version.replace(/\./g, '').slice(0, 3)
if(browser.isAndroidApp && version < 453) { // 安卓的低版本
this.setState({
backwardVersion: true,
isPay: 0,
})
}else{
this.setState({
isPay: data.course_info.is_pay
})
}
if(browser.isIOSApp && version < 380) { // ISO的低版本
this.setState({
backwardVersion: true,
isPay: 0,
})
}else{
this.setState({ this.setState({
isPay: data.course_info.is_pay 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 === 1 && !getParam('version')) && <PythonStudy isAppUpdate={isAppUpdate}/> (isPay === 1 && !getParam('version')) && <PythonStudy isAppUpdate={isAppUpdate}/>
......
...@@ -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,8 +130,12 @@ class PythonDes extends Component { ...@@ -129,8 +130,12 @@ class PythonDes extends Component {
toApp: true toApp: true
}) })
} else { // APP } else { // APP
if(backwardVersion) {
Toast.info('当前版本不支持该课程模式,请升级到最新版本或前往PC端体验', 2)
} else {
SendMessageToApp("toLearn") 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,9 +160,18 @@ class PythonDes extends Component { ...@@ -154,9 +160,18 @@ class PythonDes extends Component {
} }
}) })
} else { // APP } else { // APP
if(backwardVersion) {
Toast.info('当前版本不支持该课程模式,请升级到最新版本或前往PC端购买', 2);
let onlyoneUse = setTimeout(() => {
clearTimeout(onlyoneUse);
onlyoneUse = null;
SendMessageToApp('toPay', id)
}, 2000);
} else {
SendMessageToApp('toPay', id) SendMessageToApp('toPay', id)
} }
} }
}
toLogin = () => { toLogin = () => {
if (!getParam('version')) { // H5 if (!getParam('version')) { // H5
...@@ -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);
}
} }
......
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