Commit 3688b959 by zhanghaozhe

Merge branch 'intelligent-recommend' into dev

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