Commit 13e92cea by zhanghaozhe

智能选课

parent 9e0b8956
...@@ -31,10 +31,7 @@ class IntelligentRecommend extends Component { ...@@ -31,10 +31,7 @@ class IntelligentRecommend extends Component {
} }
componentDidMount() { componentDidMount() {
const {user, intelligentRecommend, history, reselect} = this.props const {intelligentRecommend, reselect} = this.props
if (user.hasError) {
return history.push('/passport')
}
if (isEmpty(intelligentRecommend.result)) { if (isEmpty(intelligentRecommend.result)) {
reselect() reselect()
this.getMessage() this.getMessage()
...@@ -100,6 +97,12 @@ class IntelligentRecommend extends Component { ...@@ -100,6 +97,12 @@ class IntelligentRecommend extends Component {
}) })
} }
displayPrice = (price) => {
let _price = price.toString()
let decimal = _price.split('.')
return parseInt(decimal[1]) === 0 ? decimal[0] : price
}
goBack = () => { goBack = () => {
const {state} = this.props.location const {state} = this.props.location
if (browser.isWeixin && getParam('code') && getParam('state')) { if (browser.isWeixin && getParam('code') && getParam('state')) {
...@@ -208,8 +211,8 @@ class IntelligentRecommend extends Component { ...@@ -208,8 +211,8 @@ class IntelligentRecommend extends Component {
{ {
item.c_type === 1 && <React.Fragment key={item.course_id}> item.c_type === 1 && <React.Fragment key={item.course_id}>
<div className="prices"> <div className="prices">
<span className={'price'}>{item.price_sale}</span> <span className={'price'}>{this.displayPrice(item.price_sale)}</span>
<span className={'old-price'}>{item.price_original}</span> <span className={'old-price'}>{this.displayPrice(item.price_original)}</span>
</div> </div>
<Link className={'register'} to={`/detail?id=${item.course_id}`}>{item.second_btn}</Link> <Link className={'register'} to={`/detail?id=${item.course_id}`}>{item.second_btn}</Link>
</React.Fragment> </React.Fragment>
......
...@@ -216,6 +216,7 @@ ...@@ -216,6 +216,7 @@
font-size: 18px; font-size: 18px;
line-height: 36px; line-height: 36px;
font-weight: 600; font-weight: 600;
white-space: pre-line;
&.project { &.project {
font-size: 14px; font-size: 14px;
......
...@@ -11,6 +11,7 @@ const PrivateRoute = ({component: Component, path, user, ...rest}) => { ...@@ -11,6 +11,7 @@ const PrivateRoute = ({component: Component, path, user, ...rest}) => {
const [authenticated, setAuthorization] = useState(false) const [authenticated, setAuthorization] = useState(false)
useEffect(() => { useEffect(() => {
console.log(user.hasError)
let _auth = !user.hasError && user.code != 4040 let _auth = !user.hasError && user.code != 4040
typeof _auth !== 'undefined' && (setAuthorization(_auth) , setLoadingState(false)) typeof _auth !== 'undefined' && (setAuthorization(_auth) , setLoadingState(false))
}, [user.hasError]) }, [user.hasError])
......
...@@ -19,7 +19,6 @@ function RouteMiddlePage(props) { ...@@ -19,7 +19,6 @@ function RouteMiddlePage(props) {
} else { } else {
let {data} = user || {data: {}} let {data} = user || {data: {}}
if (data && Object.values(data).every(item => !!item)) { if (data && Object.values(data).every(item => !!item)) {
history.push(location.pathname)
setLoadingState(false) setLoadingState(false)
} else { } else {
history.push('/passport', {from: location}) history.push('/passport', {from: location})
......
...@@ -338,6 +338,7 @@ export default [ ...@@ -338,6 +338,7 @@ export default [
//智能选课 //智能选课
{ {
path: '/intelligent-recommend', path: '/intelligent-recommend',
isPrivate: true,
component: loadable(() => import(/* webpackChunkName: 'intelligent-recommend' */'@/components/intelligent-recommend')), component: loadable(() => import(/* webpackChunkName: 'intelligent-recommend' */'@/components/intelligent-recommend')),
}, },
] ]
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