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