Commit d07c2bc6 by zhanghaozhe

search-result

parent 8cf60829
......@@ -3,6 +3,7 @@ import SearchHead from './searchHead'
import Tag from '@common/Tag/index.js'
import { http, api } from '@/utils'
import './index.scss';
import { Link } from 'react-router-dom'
class Search extends PureComponent {
......@@ -10,14 +11,22 @@ class Search extends PureComponent {
super(props);
this.state = {
history: JSON.parse(localStorage.getItem('history')) || [],
searchHot: ['rec', '电脑', '照片扫描仪', '智能手表', '功夫茶杯', '广角镜头手机'],
hot_words: [],
searchList: []
}
}
async componentDidMount() {
const data = await http.get(`${api['search-api']}/search_hot_word`)
console.log(data)
const res = await http.get(`${api['search-api']}/search_hot_word`)
if (res.data.errno === 0) {
this.setState({
hot_words: res.data.data.info.hot_words
})
}
}
search = text => {
}
render() {
......@@ -47,9 +56,13 @@ class Search extends PureComponent {
</label>
<div className="search-tag">
{
this.state.searchHot.length > 0 ?
this.state.searchHot.map((v, i) => {
return (<Tag key={i}>{v}</Tag>)
this.state['hot_words'].length > 0 ?
this.state['hot_words'].map((v, i) => {
return (
<Link key={i} to={`/search-result?word=${v}`}>
<Tag>{v}</Tag>
</Link>
)
})
: <div style={{textAlign: 'center', padding: '20px'}}>暂无热门</div>
}
......
import React, { PureComponent } from 'react';
import SearchHeader from './searchHead'
class SearchResult extends PureComponent {
componentDidMount(){
}
render() {
return (
<div className='search-result'>
<SearchHeader/>
</div>
);
}
}
export default SearchResult;
\ No newline at end of file
.search-result {
}
\ No newline at end of file
export const CHANGEVAL = 'CHANGEVAL'
\ No newline at end of file
import reducer from './reducer';
import * as constants from './constants';
export { reducer, constants };
\ No newline at end of file
const initState = {
}
export default (state = initState, actions) => {
switch (actions.type) {
default:
return state
}
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ import CourseList from '@/components/classify/courselist';
import Order from '@/components/order/index';
import Preferential from '@/components/preferential/index';
import Search from '@/components/search/index'
import SearchResult from '@/components/search/search-result'
import Detail from '@/components/detail/index'
import Examination from '@/components/examination'
import ExchangeCoupons from '@/components/coupons/exchange-coupons'
......@@ -43,9 +44,14 @@ export default [
},
{
path: '/search',
exact: true,
component: Search
},
{
path: '/search-result',
component: SearchResult
},
{
path: '/order',
component: Order
},
......
import { combineReducers } from 'redux';
import searchReducer from '@/components/search/store/reducer';
import myCourses from '@/components/study/myCourses/reducers'
const reducer = combineReducers({
searchReducer,
myCourses
});
......
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