Commit 5f544961 by zhanghaozhe

temp

parent 475890b6
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 { api } from '@/utils'
import {config} from '@/utils'
console.log(config)
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,29 +16,29 @@ class Search extends Component { ...@@ -14,29 +16,29 @@ class Search extends Component {
searchList: [] searchList: []
} }
} }
async componentDidMount() {
const data = await api.get(`/m/live/free_list`)
}
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>
...@@ -46,13 +48,11 @@ class Search extends Component { ...@@ -46,13 +48,11 @@ class Search extends Component {
</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>
......
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,10 +12,12 @@ class SearchHead extends Component { ...@@ -24,10 +12,12 @@ 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();
...@@ -36,18 +26,14 @@ class SearchHead extends Component { ...@@ -36,18 +26,14 @@ class SearchHead extends Component {
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()
}}> }}>
{/* <img src={require("@common/images/return.png")} alt="return" /> */} <i className="iconfont iconiconfront-68"/>
<i className="iconfont iconiconfront-68"></i>
</div> </div>
: null
}
<div className="center"> <div className="center">
<SearchBar <SearchBar
value={this.state.val} value={this.state.val}
...@@ -57,28 +43,19 @@ class SearchHead extends Component { ...@@ -57,28 +43,19 @@ class SearchHead extends Component {
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
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' const target = 'http://fast-test.julyedu.com'
module.exports = function (app) { module.exports = function (app) {
app.use(proxy( app.use(proxy(
'/api', '/api',
{ {
target, target: 'http://fast-test.julyedu.com',
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
'^/api': '' '^/api': ''
} }
}) })
) )
/*app.use(proxy(
config.home.development,
{
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']
}
))
})
*/
}; };
function generateProxyConfig(config) {
}
import config from './proxy-config'
let apiConfig = {}
Object.keys(config).forEach(item => {
if(item !== 'proxy'){
apiConfig[item] = config[item][process.env.NODE_ENV]
}
})
export default apiConfig
\ No newline at end of file
import axios from "axios"; import axios from "axios";
import qs from 'qs' import qs from 'qs'
export const BASE_URL = process.env.NODE_ENV === 'development' ? '/api' : 'https://api.julyedu.com' // export const BASE_URL = process.env.NODE_ENV === 'development' ? '/api' : 'https://api.julyedu.com'
const instance = axios.create({ const instance = axios.create({
baseURL: BASE_URL, // baseURL: BASE_URL,
transformRequest: [ transformRequest: [
(data) => qs.stringify(data) (data) => qs.stringify(data)
], ],
......
export { default as api } from './api' export { default as api } from './api'
export {default as config} from './api-config'
// 计算时间相差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: {
development: '/s',
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