Toggle navigation
Toggle navigation
This project
Loading...
Sign in
mobile
/
yh_vendor
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
盖剑秋
9 years ago
Commit
c3d8090ac618dd610c545bf7140e2aed85f3712c
1 parent
b2bc002f
调接口。 Reviewer: Yu Liang.
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
96 additions
and
28 deletions
js/components/LineChart/ChartView.js
js/components/SaleStatistics.js
js/constants/config.js
js/containers/SaleStatisticsContainer.js
js/reducers/saleStatistics/saleStatisticsActions.js
js/reducers/saleStatistics/saleStatisticsReducer.js
js/services/HomeService.js
js/components/LineChart/ChartView.js
View file @
c3d8090
...
...
@@ -15,13 +15,16 @@ export default class ChartView extends Component {
render
()
{
let
xString
=
''
;
if
(
this
.
props
.
xData
.
length
!==
0
)
{
xString
=
this
.
props
.
xData
.
reduce
((
previous
,
current
,
index
,
array
)
=>
{
if
(
index
==
1
)
{
previous
=
`\
'` + previous + `\'`;
}
return previous + '
,
'+ `\'` + current+ `\'`;
});
}
let
xString
=
this
.
props
.
xData
.
reduce
((
previous
,
current
,
index
,
array
)
=>
{
if
(
index
==
1
)
{
previous
=
`\
'` + previous + `\'`;
}
return previous + '
,
'+ `\'` + current+ `\'`;
});
// xString = '
\
''
+
xString
;
console
.
log
(
xString
);
...
...
js/components/SaleStatistics.js
View file @
c3d8090
...
...
@@ -106,6 +106,8 @@ export default class SaleStatistics extends Component {
let
months
=
[
'5.01'
,
'5.02'
,
'5.03'
,
'5.04'
,
'5.05'
,
'5.06'
,
'5.07'
];
let
data
=
[
100
,
122
,
80
,
110
,
140
,
77
,
151
];
console
.
log
(
this
.
props
.
sevenDays
);
console
.
log
(
this
.
props
.
trendInSevenDays
);
return
(
<
ScrollView
contentContainerStyle
=
{{
flex
:
1
}}
>
...
...
@@ -116,8 +118,8 @@ export default class SaleStatistics extends Component {
<
Placeholder
/>
<
ChartView
chartTitle
=
{
'近7天交易趋势'
}
xData
=
{
months
}
yData
=
{
data
}
xData
=
{
this
.
props
.
sevenDays
}
yData
=
{
this
.
props
.
trendInSevenDays
}
/
>
{
this
.
state
.
showPicker
?
<
CalendarPicker
calendarModes
=
{
this
.
calendarModes
}
selectMode
=
{
this
.
state
.
selectMode
}
selected
=
{
this
.
state
.
selected
}
onCancel
=
{
this
.
onCancel
}
onOK
=
{
this
.
onOK
}
/> : null
}
...
...
js/constants/config.js
View file @
c3d8090
...
...
@@ -29,5 +29,10 @@ module.exports = {
deliveryStats
:
'deliveryStats'
,
requestStats
:
'requestStats'
,
accountSettlement
:
'accountSettlement'
,
},
dateFilterKey
:
{
date
:
1
,
//天
week
:
2
,
month
:
3
,
}
}
...
...
js/containers/SaleStatisticsContainer.js
View file @
c3d8090
...
...
@@ -14,6 +14,9 @@ import {Map} from 'immutable';
import
SaleStatistics
from
'../components/SaleStatistics'
;
import
*
as
saleStatisticsActions
from
'../reducers/saleStatistics/saleStatisticsActions'
;
import
moment
from
'moment'
;
import
Immutable
,
{
List
,
Record
}
from
'immutable'
;
import
config
from
'../constants/config'
;
let
{
Component
,
...
...
@@ -56,11 +59,56 @@ class SalestisticsContainer extends Component {
}
componentDidMount
()
{
this
.
props
.
actions
.
saleStats
(
111
);
let
params
=
{
type
:
config
.
dateFilterKey
.
date
,
reqTime
:
moment
().
subtract
(
1
,
'days'
).
format
(
'YYYYMMDD'
),
brandId
:
this
.
props
.
home
.
get
(
'brandId'
),
}
this
.
props
.
actions
.
saleStats
(
params
);
}
onChangeDate
(
selected
)
{
this
.
props
.
actions
.
saleStats
(
111
);
let
params
=
{};
switch
(
selected
.
selectMode
)
{
case
'day'
:
let
wrapper
=
moment
(
selected
.
day
);
let
dateStr
=
wrapper
.
format
(
'YYYYMMDD'
);
params
=
{
type
:
config
.
dateFilterKey
.
date
,
reqTime
:
dateStr
,
brandId
:
this
.
props
.
home
.
get
(
'brandId'
),
}
break
;
case
'week'
:
params
=
{
type
:
config
.
dateFilterKey
.
week
,
beginTime
:
moment
(
selected
.
from
).
format
(
'YYYYMMDD'
),
endTime
:
moment
(
selected
.
to
).
format
(
'YYYYMMDD'
),
brandId
:
this
.
props
.
home
.
get
(
'brandId'
),
}
break
;
case
'month'
:
let
monthStr
=
''
;
if
(
selected
.
month
>
9
)
{
monthStr
=
`
$
{
selected
.
year
}
`
+
`
$
{
selected
.
month
}
`
}
else
{
monthStr
=
`
$
{
selected
.
year
}
`
+
'0'
+
`
$
{
selected
.
month
}
`
}
params
=
{
type
:
config
.
dateFilterKey
.
month
,
reqTime
:
monthStr
,
brandId
:
this
.
props
.
home
.
get
(
'brandId'
),
}
break
;
default
:
}
this
.
props
.
actions
.
saleStats
(
params
);
}
render
()
{
...
...
@@ -94,8 +142,8 @@ class SalestisticsContainer extends Component {
<
SaleStatistics
section1
=
{
section1
}
section2
=
{
section2
}
sevenDays
=
{
this
.
props
.
saleStats
.
sevenDays
}
trendInSevenDays
=
{
this
.
props
.
saleStats
.
trendInSevenDays
}
sevenDays
=
{
this
.
props
.
saleStats
.
sevenDays
.
toJS
()}
trendInSevenDays
=
{
this
.
props
.
saleStats
.
trendInSevenDays
.
toJS
()}
onChangeDate
=
{
this
.
onChangeDate
}
/
>
<
/View
>
...
...
js/reducers/saleStatistics/saleStatisticsActions.js
View file @
c3d8090
...
...
@@ -18,10 +18,10 @@ const {
}
=
require
(
'../../constants/actionTypes'
).
default
;
export
function
saleStatsRequest
(
shopId
)
{
export
function
saleStatsRequest
(
params
)
{
return
{
type
:
SALE_STATS_REQUEST
,
payload
:
shopId
payload
:
params
};
}
...
...
@@ -39,12 +39,13 @@ export function saleStatsFailure(error) {
};
}
export
function
saleStats
(
shopId
)
{
export
function
saleStats
(
params
)
{
return
dispatch
=>
{
dispatch
(
saleStatsRequest
(
shopId
));
return
new
HomeService
().
saleStats
(
shopId
)
dispatch
(
saleStatsRequest
(
params
));
return
new
HomeService
().
saleStats
(
params
)
.
then
(
json
=>
{
console
.
log
(
json
);
dispatch
(
saleStatsSuccess
(
json
));
})
.
catch
(
error
=>
{
...
...
js/reducers/saleStatistics/saleStatisticsReducer.js
View file @
c3d8090
...
...
@@ -12,6 +12,7 @@
import
InitialState
from
'./saleStatisticsInitialState'
;
import
Immutable
,
{
List
,
Record
}
from
'immutable'
;
import
moment
from
'moment'
;
const
{
...
...
@@ -40,22 +41,30 @@ export default function saleStatisticsReducer(state = initialState, action) {
}
case
SALE_STATS_SUCCESS
:
{
console
.
log
(
action
.
payload
);
let
sevenDays
=
[];
let
trendInSevenDays
=
[];
for
(
var
i
=
0
;
i
<
action
.
payload
.
list
.
length
;
i
++
)
{
let
item
=
action
.
payload
.
list
[
i
];
sevenDays
.
push
(
item
.
dateId
);
sevenDays
.
push
(
moment
(
item
.
dateId
).
format
(
'MM.DD'
)
);
trendInSevenDays
.
push
(
item
.
allNums
);
}
console
.
log
(
sevenDays
);
console
.
log
(
trendInSevenDays
);
let
amountRate
=
Math
.
abs
(
action
.
payload
.
additionInfo
.
allAmountRate
)
let
countRate
=
Math
.
abs
(
action
.
payload
.
additionInfo
.
allNumberRate
);
let
nextState
=
state
.
set
(
'isFetching'
,
false
)
.
set
(
'error'
,
null
)
.
set
(
'goodsAmount'
,
action
.
payload
.
addtionInfo
.
allAmount
)
.
set
(
'amountRise'
,
action
.
payload
.
addtionInfo
.
allAmountRate
>=
0
)
.
set
(
'amountRisePercent'
,
action
.
payload
.
addtionInfo
.
allAmountRate
)
.
set
(
'goodsCount'
,
action
.
payload
.
addtionInfo
.
allNumber
)
.
set
(
'countRise'
,
action
.
payload
.
addtionInfo
.
allNumberRate
>=
0
)
.
set
(
'countRisePercent'
,
action
.
payload
.
addtionInfo
.
allNumberRate
)
.
set
(
'goodsAmount'
,
action
.
payload
.
additionInfo
.
allAmount
)
.
set
(
'amountRise'
,
action
.
payload
.
additionInfo
.
allAmountRate
>=
0
)
.
set
(
'amountRisePercent'
,
amountRate
)
.
set
(
'goodsCount'
,
action
.
payload
.
additionInfo
.
allNumber
)
.
set
(
'countRise'
,
action
.
payload
.
additionInfo
.
allNumberRate
>=
0
)
.
set
(
'countRisePercent'
,
countRate
)
.
set
(
'sevenDays'
,
Immutable
.
fromJS
(
sevenDays
))
.
set
(
'trendInSevenDays'
,
Immutable
.
fromJS
(
trendInSevenDays
));
return
nextState
;
...
...
js/services/HomeService.js
View file @
c3d8090
...
...
@@ -57,14 +57,14 @@ export default class UserService {
})
}
async
saleStats
()
{
async
saleStats
(
params
)
{
console
.
log
(
params
);
return
await
this
.
api
.
get
({
url
:
'/gateway'
,
body
:
{
method
:
'app.shops.sales'
,
shopsId
:
6666
,
type
:
1
,
reqTime
:
20160525
,
...
params
,
}
})
.
then
((
json
)
=>
{
...
...
Please
register
or
login
to post a comment