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 {http, getParam, SendMessageToApp} from '@/utils'
import {http, getParam, browser} from '@/utils'
import PythonDes from './pythomDes'
import PythonStudy from './pythonStudy'
import {connect} from "react-redux"
......@@ -19,7 +19,8 @@ class Python extends Component {
this.state = {
isPay: '',
userInfoList: [],
isAppUpdate: false
isAppUpdate: false,
backwardVersion: false, // 默认是新版本
}
}
......@@ -89,19 +90,41 @@ class Python extends Component {
http.get(`${API.home}/m/course/detail/${id}`).then((res) => {
const {data, code} = res.data
if (code === 200) {
this.setState({
isPay: data.course_info.is_pay
})
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({
isPay: data.course_info.is_pay
})
}
}
}
})
}
render() {
const {isPay, isAppUpdate} = this.state
const {isPay, isAppUpdate, backwardVersion} = this.state;
// 旧版本 无论购买未购买 都跳转到 未购买的详情页; 如果是已购买就提示更新APP
return (
<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}/>
......
......@@ -121,6 +121,7 @@ class PythonDes extends Component {
}
toLearn = () => {
const {backwardVersion, isPay} = this.props;
http.post(`${API['home']}/m/it/user/trialCourse`, {course_id: getParam('id')}).then((res) => {
const {code, msg} = res.data
if (code == 200) {
......@@ -129,7 +130,11 @@ class PythonDes extends Component {
toApp: true
})
} else { // APP
SendMessageToApp("toLearn")
if(backwardVersion) {
Toast.info('当前版本不支持该课程模式,请升级到最新版本或前往PC端体验', 2)
} else {
SendMessageToApp("toLearn")
}
}
} else {
Toast.info(msg, 2)
......@@ -144,6 +149,7 @@ class PythonDes extends Component {
}
toDetail = () => {
const {backwardVersion, isPay} = this.props;
const id = getParam('id')
if (!getParam('version')) { // H5
http.get(`${API['base-api']}/m/cart/addtopreorder/[${id}]`).then((res) => {
......@@ -154,7 +160,16 @@ class PythonDes extends Component {
}
})
} 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 {
componentDidMount() {
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