Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mr-julyedu
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
baiguangyao
mr-julyedu
Commits
5f544961
Commit
5f544961
authored
Jun 03, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temp
parent
475890b6
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
120 additions
and
81 deletions
+120
-81
src/common/Tag/index.js
+2
-2
src/components/search/index.js
+29
-29
src/components/search/searchHead.js
+23
-46
src/setupProxy.js
+34
-1
src/utils/api-config.js
+12
-0
src/utils/api.js
+2
-2
src/utils/index.js
+1
-1
src/utils/proxy-config.js
+17
-0
No files found.
src/common/Tag/index.js
View file @
5f544961
import
React
,
{
Component
}
from
'react'
import
React
,
{
Pure
Component
}
from
'react'
import
'./tag.scss'
export
default
class
Tag
extends
Component
{
export
default
class
Tag
extends
Pure
Component
{
render
()
{
return
(
<
span
className
=
"tag"
{...
this
.
props
}
>
...
...
src/components/search/index.js
View file @
5f544961
import
React
,
{
Component
}
from
'react'
;
import
React
,
{
Pure
Component
}
from
'react'
;
import
SearchHead
from
'./searchHead'
import
Tag
from
'@common/Tag/index.js'
import
{
api
}
from
'@/utils'
import
{
config
}
from
'@/utils'
console
.
log
(
config
)
import
'./index.scss'
;
class
Search
extends
Component
{
class
Search
extends
Pure
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
...
...
@@ -14,51 +16,49 @@ class Search extends Component {
searchList
:
[]
}
}
async
componentDidMount
()
{
const
data
=
await
api
.
get
(
`/m/live/free_list`
)
}
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
>
)
}
...
...
src/components/search/searchHead.js
View file @
5f544961
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
src/setupProxy.js
View file @
5f544961
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
,
target
:
'http://fast-test.julyedu.com'
,
changeOrigin
:
true
,
pathRewrite
:
{
'^/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
)
{
}
src/utils/api-config.js
0 → 100644
View file @
5f544961
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
src/utils/api.js
View file @
5f544961
import
axios
from
"axios"
;
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
({
baseURL
:
BASE_URL
,
//
baseURL: BASE_URL,
transformRequest
:
[
(
data
)
=>
qs
.
stringify
(
data
)
],
...
...
src/utils/index.js
View file @
5f544961
export
{
default
as
api
}
from
'./api'
export
{
default
as
config
}
from
'./api-config'
// 计算时间相差fn(过去距离当前时间)
export
const
computingTime
=
(
pastTime
)
=>
{
var
currentTime
=
(
new
Date
()).
getTime
(),
...
...
src/utils/proxy-config.js
0 → 100644
View file @
5f544961
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment