Commit df76033c by xuzhenghua

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

parents 295d9eb6 8cf60829
import React, { Component } from 'react'
import React, { PureComponent } from 'react'
import './tag.scss'
export default class Tag extends Component {
export default class Tag extends PureComponent {
render() {
return (
<span className="tag" {...this.props}>
......
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import SearchHead from './searchHead'
import Tag from '@common/Tag/index.js'
import { http, api } from '@/utils'
import './index.scss';
class Search extends Component {
class Search extends PureComponent {
constructor(props) {
super(props);
this.state = {
......@@ -14,51 +14,50 @@ class Search extends Component {
searchList: []
}
}
async componentDidMount() {
const data = await http.get(`${api['search-api']}/search_hot_word`)
console.log(data)
}
render() {
let querystring = this.props.location.query ? this.props.location.query.s : '';
return (
<div className="search-page">
<SearchHead value={querystring} returnbtn={true} ></SearchHead>
<SearchHead value={querystring} returnbtn={true}/>
<div className="search-main">
<div className="search-land search-history">
<label>
<span>最近搜索</span>
<i className="iconfont iconiconfront-56" onClick={() => {
this.removeHistory()
}} >
</i>
<i className="iconfont iconiconfront-56"/>
</label>
<div className="search-tag">
{
this.state.history.length > 0 ?
this.state.history.map((v, i) => {
return (<Tag key={i} onClick={() => {
this.gotoList(v)
}}>{v}</Tag>)
return (<Tag key={i}>{v}</Tag>)
})
: <div style={{ textAlign: 'center', padding: '20px' }}>暂无历史</div>
: <div style={{textAlign: 'center', padding: '20px'}}>暂无历史</div>
}
</div>
</div>
<div className="search-land search-hot">
<label>
<span>热门搜索</span>
</label>
<div className="search-tag">
{
this.state.searchHot.length>0?
this.state.searchHot.map((v,i)=>{
return (<Tag key={i} onClick={()=>{
this.gotoList(v)
}}>{v}</Tag>)
})
:<div style={{textAlign:'center',padding:'20px'}}>暂无热门</div>
}
</div>
<label>
<span>热门搜索</span>
</label>
<div className="search-tag">
{
this.state.searchHot.length > 0 ?
this.state.searchHot.map((v, i) => {
return (<Tag key={i}>{v}</Tag>)
})
: <div style={{textAlign: 'center', padding: '20px'}}>暂无热门</div>
}
</div>
</div>
</div>
</div>
</div>
</div>
)
}
......
import React, { Component } from 'react'
//引入redux
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import * as searchAction from './store'
//引入antd-mobile组件
import React, { PureComponent } from 'react'
import { SearchBar } from 'antd-mobile'
//引入路由跳转装饰器
import { withRouter } from 'react-router-dom'
import './search_header.scss'
class SearchHead extends Component {
//默认参数
static defaultProps = {
returnbtn: false
}
// 构造函数
class SearchHead extends PureComponent {
constructor(props) {
super(props);
this.state = {
......@@ -24,30 +12,28 @@ class SearchHead extends Component {
val: this.props.value || ''
}
}
// 返回某个页面
returnPage() {
console.log(111);
console.log(111);
}
//组件装载完毕
componentDidMount() {
this.refs.search.focus();
}
render() {
return (
<div className="search-head">
{
this.props.returnbtn
?
<div className="left" onClick={() => {
// 返回某个页面
this.returnPage()
}}>
{/* <img src={require("@common/images/return.png")} alt="return" /> */}
<i className="iconfont iconiconfront-68"></i>
</div>
: null
}
<div className="left" onClick={() => {
// 返回某个页面
this.returnPage()
}}>
<i className="iconfont iconiconfront-68"/>
</div>
<div className="center">
<SearchBar
value={this.state.val}
......@@ -55,30 +41,21 @@ class SearchHead extends Component {
cancelText={" "}
ref="search"
focus={true}
onChange={(val) => {
this.setState({ val })
this.setState({val})
this.props.search.changeVal(val)
}}
placeholder="搜索课程"></SearchBar>
placeholder="搜索课程"/>
</div>
<div className="right right-btn">
<div className="submit-btn"
>搜索</div>
<div className="submit-btn"
>搜索
</div>
</div>
</div>
)
}
}
export default connect(
({ searchReducer }) => {
return {
searchVal: searchReducer.val
}
},
(dispatch) => {
return {
search: bindActionCreators(searchAction, dispatch)
}
}
)(withRouter(SearchHead))
\ No newline at end of file
export default SearchHead
\ No newline at end of file
......@@ -42,7 +42,7 @@ class FreeCourse extends PureComponent {
}
getFreeCourses = () => {
return api.get(`/m/free_course/${this.state.page}/${this.state.num}`)
return api.get(`/api/m/free_course/${this.state.page}/${this.state.num}`)
}
getFreeLive = () => {
......
const config = require('./utils/proxy-config')
const proxy = require('http-proxy-middleware')
const target = 'http://fast-test.julyedu.com'
module.exports = function (app) {
app.use(proxy(
'/api',
{
target,
changeOrigin: true,
pathRewrite: {
'^/api': ''
Object.keys(config).forEach(item => {
app.use(proxy(
config[item]['development'], {
target: config[item]['test'],
changeOrigin: true,
pathRewrite: {
[`^${config[item]['development']}`]: ''
},
...item['proxy']
}
})
)
};
))
})
};
\ No newline at end of file
import axios from "axios";
import qs from 'qs'
import config from './proxy-config'
export const BASE_URL = process.env.NODE_ENV === 'development' ? '/api' : 'https://api.julyedu.com'
let api = {}
const instance = axios.create({
baseURL: BASE_URL,
transformRequest: [
(data) => qs.stringify(data)
],
headers: {
HTTP_PLAT_FORM: 5,
HTTP_PLAT: 5
Object.keys(config).forEach(item => {
if(item !== 'proxy'){
api[item] = config[item][process.env.NODE_ENV]
}
})
export default instance
\ No newline at end of file
export default api
\ No newline at end of file
import axios from "axios";
import qs from 'qs'
const instance = axios.create({
transformRequest: [
(data) => qs.stringify(data)
],
headers: {
HTTP_PLAT_FORM: 5,
HTTP_PLAT: 5
}
})
export default instance
\ No newline at end of file
export { default as http } from './http'
export { default as api } from './api'
// 计算时间相差fn(过去距离当前时间)
export const computingTime = (pastTime) => {
var currentTime = (new Date()).getTime(),
......
const config = {
home: {
development: '/api',
test: 'http://fast-test.julyedu.com',
production: 'https://m.julyedu.com',
proxy: {}
},
'search-api': {
development: '/search-api',
test: 'https://search.julyedu.com',
production: 'https://search.julyedu.com',
proxy: {}
},
}
module.exports = config
\ No newline at end of file
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