Commit 4c2dba18 by zhanghaozhe

智能选课

parent b8089100
import React, { Component } from 'react';
import './index.scss'
import { Link } from "react-router-dom";
import { http } from "@/utils"
import { browser, getParam, http } from "@/utils"
import { Toast } from "antd-mobile";
import { connect } from "react-redux";
import { WithFullSize } from "@/HOCs"
......@@ -31,7 +31,11 @@ class IntelligentRecommend extends Component {
}
componentDidMount() {
if (!this.props.intelligentRecommend.processing.length) {
const {user, intelligentRecommend, history} = this.props
if (user.hasError) {
return history.push('/passport')
}
if (!intelligentRecommend.processing.length) {
this.getMessage()
}
}
......@@ -63,7 +67,7 @@ class IntelligentRecommend extends Component {
setTimeout(() => {
this.setState({showAnalyzing: false})
this.props.addResult({...data})
}, Math.random() * 1000 + 2000)
}, Math.random() * 500 + 1000)
})
} else {
const message = {
......@@ -95,6 +99,21 @@ class IntelligentRecommend extends Component {
})
}
goBack = () => {
const {state} = this.props.location
if (browser.isWeixin && getParam('code') && getParam('state')) {
window.history.go(-2)
}
if (state.records && state.records.length > 1) {
window.history.go(-1);
} else if (state.from && state.from.pathname) {
location.replace(`${state.from.pathname}${state.from.search}`)
} else {
window.location.href = window.location.origin
}
}
render() {
const {showAnalyzing, systemAvatar, options} = this.state
const {user, intelligentRecommend: {result, processing}, reselect} = this.props
......@@ -169,7 +188,13 @@ class IntelligentRecommend extends Component {
{
!!recommends.courses.length && recommends.courses.map(item => {
return <li className={'course'} key={item.course_id} onClick={(e) => {
e.target.nodeName.toLowerCase() !== 'a' && this.props.history.push(`/detail?id=${item.course_id}`)
if (e.target.nodeName.toLowerCase() !== 'a') {
if (item.course_id) {
this.props.history.push(`/detail?id=${item.course_id}`)
} else {
this.props.history.push(`/play?id=${item.v_course_id}`)
}
}
}}>
<div className="cover">
<img src={item.img_url}
......@@ -211,6 +236,7 @@ class IntelligentRecommend extends Component {
</div>
);
}
}
function Message({text, avatar, identity}) {
......
......@@ -79,7 +79,6 @@
img {
width: 30px;
height: 30px;
border: 1px solid rgba(0, 153, 255, 1);
border-radius: 50%;
}
}
......@@ -268,6 +267,10 @@
}
.title {
width: 97%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-bottom: 8px;
font-size: 16px;
line-height: 16px;
......
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