Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
taroMeeting
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
fengzhaoyu
taroMeeting
Commits
19710804
Commit
19710804
authored
Sep 25, 2018
by
王树冬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
4c85e978
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
28 deletions
+52
-28
project.config.json
project.config.json
+1
-1
counter.js
src/actions/counter.js
+5
-1
index.js
src/pages/index/index.js
+36
-23
counter.js
src/reducers/counter.js
+7
-2
api.js
src/service/api.js
+3
-1
No files found.
project.config.json
View file @
19710804
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
"description"
:
"demo"
,
"description"
:
"demo"
,
"appid"
:
"wx8566afef50e5f76b"
,
"appid"
:
"wx8566afef50e5f76b"
,
"setting"
:
{
"setting"
:
{
"urlCheck"
:
fals
e
,
"urlCheck"
:
tru
e
,
"es6"
:
false
,
"es6"
:
false
,
"postcss"
:
false
,
"postcss"
:
false
,
"minified"
:
false
,
"minified"
:
false
,
...
...
src/actions/counter.js
View file @
19710804
...
@@ -79,7 +79,11 @@ export function asyncAdd() {
...
@@ -79,7 +79,11 @@ export function asyncAdd() {
// 'content-type': 'application/json'
// 'content-type': 'application/json'
// }
// }
// }))
// }))
export
const
list
=
createApiAction
(
LIST
,
params
=>
api
.
get
(
'news/list'
,
params
))
// export const list = createApiAction(LIST, params => api.get('news/list', params))
export
const
list
=
createApiAction
(
LIST
,
params
=>
{
console
.
log
(
'list'
,
params
);
return
api
.
get
(
'news/list'
,
params
)
})
export
default
bindActionCreators
({
export
default
bindActionCreators
({
list
,
list
,
...
...
src/pages/index/index.js
View file @
19710804
...
@@ -27,14 +27,11 @@ import './index.styl'
...
@@ -27,14 +27,11 @@ import './index.styl'
state
=>
({
state
=>
({
list
:
state
.
counter
.
list
,
list
:
state
.
counter
.
list
,
}),
}),
(
dispatch
)
=>
{
(
dispatch
)
=>
({
console
.
log
(
'dispatch'
,
dispatch
);
getList
(
params
)
{
return
{
dispatch
(
list
(
params
))
list
()
{
dispatch
(
list
())
}
}
}
}
,
}
)
)
)
class
Index
extends
Component
{
class
Index
extends
Component
{
...
@@ -45,33 +42,51 @@ class Index extends Component {
...
@@ -45,33 +42,51 @@ class Index extends Component {
super
(
props
)
super
(
props
)
console
.
log
(
'props'
,
props
);
console
.
log
(
'props'
,
props
);
// this.state = { date: new Date() }
// this.state = { date: new Date() }
props
.
list
()
// let params = {
// page: 2, perPage: 2
// }
this
.
state
=
{
page
:
1
,
perPage
:
10
}
props
.
getList
(
this
.
state
)
}
}
componentWillReceiveProps
(
nextProps
)
{
componentWillReceiveProps
(
nextProps
)
{
console
.
log
(
this
.
props
,
nextProps
)
console
.
log
(
this
.
props
,
nextProps
)
}
}
componentWillMount
()
{
this
.
props
.
getList
(
this
.
state
)
}
componentWillUnmount
()
{
componentWillUnmount
()
{
}
}
componentDidShow
()
{
}
componentDidShow
()
{
}
componentDidHide
()
{
}
componentDidHide
()
{
}
render
()
{
onShareAppMessage
()
{
return
{
title
:
'蜂窝煤'
,
path
:
'/pages/index/index'
,
imageUrl
:
'../../common/image/share.png'
}
}
onReachBottom
()
{
console
.
log
(
'触发到底部了'
)
this
.
setState
({
page
:
this
.
state
.
page
+
1
})
const
{
page
,
perPage
}
=
this
.
state
let
params
=
{
page
:
this
.
state
.
page
+
1
,
perPage
:
perPage
}
console
.
log
(
this
.
props
,
'onReachBottom'
)
this
.
props
.
getList
(
params
)
}
render
()
{
return
(
return
(
<
View
className
=
'index'
>
<
View
className
=
'index'
>
<
View
className
=
'news'
>
<
View
className
=
'news'
>
<
View
className
=
'item'
>
<
View
className
=
'desc'
>
<
View
className
=
'title'
><
/View
>
<
View
className
=
'info'
><
/View
>
<
/View
>
<
View
className
=
'rightImage'
>
<
/View
>
<
/View
>
<
View
>
{
{
this
.
props
.
list
.
map
((
item
,
index
)
=>
{
this
.
props
.
list
.
map
((
item
,
index
)
=>
{
return
<
View
className
=
'item'
key
=
{
index
}
>
return
<
View
className
=
'item'
key
=
{
index
}
>
...
@@ -87,11 +102,9 @@ class Index extends Component {
...
@@ -87,11 +102,9 @@ class Index extends Component {
})
})
}
}
<
/View
>
<
/View
>
<
/View
>
<
/View
>
<
/View
>
)
)
}
}
}
}
export
default
Index
export
default
Index
src/reducers/counter.js
View file @
19710804
...
@@ -2,7 +2,7 @@ import { ADD, MINUS, LIST } from '../constants/counter'
...
@@ -2,7 +2,7 @@ import { ADD, MINUS, LIST } from '../constants/counter'
const
INITIAL_STATE
=
{
const
INITIAL_STATE
=
{
num
:
0
,
num
:
0
,
list
:
''
list
:
[]
}
}
export
default
function
counter
(
state
=
INITIAL_STATE
,
action
)
{
export
default
function
counter
(
state
=
INITIAL_STATE
,
action
)
{
...
@@ -19,9 +19,14 @@ export default function counter (state = INITIAL_STATE, action) {
...
@@ -19,9 +19,14 @@ export default function counter (state = INITIAL_STATE, action) {
num
:
state
.
num
-
1
num
:
state
.
num
-
1
}
}
case
LIST
:
case
LIST
:
let
data
=
state
.
list
.
concat
(
action
.
payload
.
data
.
news
)
// Object.assign(state.list, action.payload.data.news)
console
.
log
(
'data'
,
data
)
console
.
log
(
'state'
,
state
)
return
{
return
{
...
state
,
...
state
,
list
:
action
.
payload
.
data
.
news
// list: action.payload.data.news
list
:
data
}
}
default
:
default
:
return
state
return
state
...
...
src/service/api.js
View file @
19710804
...
@@ -3,7 +3,7 @@ import { HTTP_STATUS, COMMON_STATUS, RESULT_STATUS } from '../const/status.js'
...
@@ -3,7 +3,7 @@ import { HTTP_STATUS, COMMON_STATUS, RESULT_STATUS } from '../const/status.js'
// import config from '../config/index.js'
// import config from '../config/index.js'
import
{
logError
}
from
'../utils'
import
{
logError
}
from
'../utils'
const
baseURL
=
"http
://beeapi.
shudong.wang/v1/"
const
baseURL
=
"http
s://
shudong.wang/v1/"
// Taro.request({
// Taro.request({
// url: baseURL + '',
// url: baseURL + '',
// data: {
// data: {
...
@@ -21,6 +21,7 @@ export default {
...
@@ -21,6 +21,7 @@ export default {
let
{
url
,
data
}
=
params
let
{
url
,
data
}
=
params
// let token = getApp().globalData.token
// let token = getApp().globalData.token
// if (!token) login()
// if (!token) login()
console
.
log
(
'params'
,
params
)
let
contentType
=
'application/x-www-form-urlencoded'
let
contentType
=
'application/x-www-form-urlencoded'
contentType
=
params
.
contentType
||
contentType
contentType
=
params
.
contentType
||
contentType
const
option
=
{
const
option
=
{
...
@@ -41,6 +42,7 @@ export default {
...
@@ -41,6 +42,7 @@ export default {
},
},
get
(
url
,
data
=
''
)
{
get
(
url
,
data
=
''
)
{
let
option
=
{
url
,
data
}
let
option
=
{
url
,
data
}
console
.
log
(
'data'
,
data
)
return
this
.
baseOptions
(
option
)
return
this
.
baseOptions
(
option
)
},
},
post
:
function
(
url
,
data
,
contentType
)
{
post
:
function
(
url
,
data
,
contentType
)
{
...
...
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