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
df76033c
Commit
df76033c
authored
Jun 04, 2019
by
xuzhenghua
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.julyedu.com:baiguangyao/mr-julyedu into detail
parents
295d9eb6
8cf60829
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
108 additions
and
103 deletions
+108
-103
src/common/Tag/index.js
+2
-2
src/components/search/index.js
+28
-29
src/components/search/searchHead.js
+23
-46
src/components/study/freeCourses/index.js
+1
-1
src/setupProxy.js
+14
-11
src/utils/api.js
+7
-13
src/utils/http.js
+15
-0
src/utils/index.js
+1
-1
src/utils/proxy-config.js
+17
-0
No files found.
src/common/Tag/index.js
View file @
df76033c
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 @
df76033c
import
React
,
{
Component
}
from
'react'
;
import
React
,
{
Pure
Component
}
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
Pure
Component
{
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
>
)
}
...
...
src/components/search/searchHead.js
View file @
df76033c
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/components/study/freeCourses/index.js
View file @
df76033c
...
...
@@ -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
=
()
=>
{
...
...
src/setupProxy.js
View file @
df76033c
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
src/utils/api.js
View file @
df76033c
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
src/utils/http.js
0 → 100644
View file @
df76033c
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
src/utils/index.js
View file @
df76033c
export
{
default
as
http
}
from
'./http'
export
{
default
as
api
}
from
'./api'
// 计算时间相差fn(过去距离当前时间)
export
const
computingTime
=
(
pastTime
)
=>
{
var
currentTime
=
(
new
Date
()).
getTime
(),
...
...
src/utils/proxy-config.js
0 → 100644
View file @
df76033c
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
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