Authored by 叶弯弯

Merge branch 'develop' of git.yoho.cn:mobile/yh_vendor into develop

{
"images" : [
{
"orientation" : "portrait",
"idiom" : "iphone",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"minimum-system-version" : "7.0",
"subtype" : "retina4",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
... ... @@ -12,6 +12,8 @@
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundleDisplayName</key>
<string>潮店宝</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
... ...
... ... @@ -6,6 +6,7 @@ import {
StyleSheet,
View,
Text,
Platform,
} from 'react-native';
export default class ChartView extends Component {
... ... @@ -15,13 +16,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);
... ... @@ -46,6 +50,8 @@ export default class ChartView extends Component {
}
}
const chartHeight = (Platform.OS === 'android') ? 250 : 175;
const styles = StyleSheet.create({
container: {
backgroundColor: 'white',
... ... @@ -57,22 +63,24 @@ const styles = StyleSheet.create({
marginLeft: 15,
},
chartStyle: {
height: 175,
height: chartHeight,
marginLeft: -45,
marginRight: -45,
marginBottom: 15,
},
});
const fontSize = (Platform.OS === 'android') ? 14 : 24;
function getHTMLString(xData,yData) {
const HTML = `
<!DOCTYPE html>
<html style="height: 100%">
<html style="height: 100%; margin: 0px;">
<head>
<meta charset="utf-8">
</head>
<body style="height: 100%; margin: 0">
<div id="container" style="height: 100%"></div>
<body style="height: 100%; margin: 0px;">
<div id="container" style="height: 100%; margin: 0px; min-height: 250px;"></div>
<script type="text/javascript" src="http://cdn.bootcss.com/echarts/3.0.0/echarts.min.js"></script>
<script type="text/javascript">
var dom = document.getElementById("container");
... ... @@ -100,7 +108,7 @@ function getHTMLString(xData,yData) {
axisLabel: {
textStyle: {
color: '#b1b1b1',
fontSize: 24,
fontSize: ` + fontSize + `,
},
},
splitLine: {
... ... @@ -132,7 +140,7 @@ function getHTMLString(xData,yData) {
backgroundColor: 'orange',
formatter: '{c}',
textStyle: {
fontSize: 24,
fontSize: ` + fontSize + `,
},
axisPointer: {
type: 'line',
... ...
... ... @@ -103,10 +103,6 @@ export default class SaleStatistics extends Component {
render() {
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];
return (
<ScrollView contentContainerStyle={{flex: 1}}>
<CalendarTrigger date={this.state.selectdDate} toogleSelector={this.toogleSelector} />
... ... @@ -116,8 +112,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}
... ...
... ... @@ -29,5 +29,10 @@ module.exports = {
deliveryStats: 'deliveryStats',
requestStats: 'requestStats',
accountSettlement: 'accountSettlement',
},
dateFilterKey: {
date: 1,//天
week: 2,
month: 3,
}
}
... ...
... ... @@ -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>
... ...
... ... @@ -31,10 +31,9 @@ const {
} = require('../../constants/actionTypes').default;
export function overviewRequest(brandId) {
export function overviewRequest() {
return {
type: HOME_OVERVIEW_REQUEST,
payload: brandId
};
}
... ... @@ -52,10 +51,9 @@ export function overviewFailure(error) {
};
}
export function brandRankRequest(brandId) {
export function brandRankRequest() {
return {
type: HOME_BRABDRANK_REQUEST,
payload: brandId
};
}
... ... @@ -76,7 +74,7 @@ export function brandRankFailure(error) {
export function overview(brandId) {
return dispatch => {
dispatch(overviewRequest(brandId));
dispatch(overviewRequest());
return new HomeService().overview(brandId)
.then(json => {
dispatch(overviewSuccess(json));
... ... @@ -90,7 +88,7 @@ export function overview(brandId) {
export function brandRank(brandId) {
return dispatch => {
dispatch(brandRankRequest(brandId));
dispatch(brandRankRequest());
return new HomeService().brandRank(brandId)
.then(json => {
dispatch(brandRankSuccess(json));
... ...
... ... @@ -53,8 +53,7 @@ export default function userReducer(state = initialState, action) {
case HOME_OVERVIEW_REQUEST:
case HOME_BRABDRANK_REQUEST: {
let nextState = state.set('isFetching', true)
.set('error', null)
.set('brandId', action.payload);
.set('error', null);
return nextState;
}
... ...
... ... @@ -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,11 +39,11 @@ 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 => {
dispatch(saleStatsSuccess(json));
})
... ...
... ... @@ -12,6 +12,7 @@
import InitialState from './saleStatisticsInitialState';
import Immutable, {List, Record} from 'immutable';
import moment from 'moment';
const {
... ... @@ -44,18 +45,21 @@ export default function saleStatisticsReducer(state = initialState, action) {
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);
}
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;
... ...
... ... @@ -7,7 +7,6 @@
'use strict';
import {Actions} from 'react-native-router-flux';
import AppAuthToken from '../../services/AppAuthToken';
import UserService from '../../services/UserService';
import {Alert, Linking} from 'react-native';
... ... @@ -152,7 +151,7 @@ export function pwdDisplay(ishow) {
}
export function logout() {
new AppAuthToken().deleteSessionToken();
new UserService().deleteUserInfo();
Actions.pop();
Actions.Login();
return {
... ...
... ... @@ -57,14 +57,13 @@ export default class UserService {
})
}
async saleStats() {
async saleStats(params) {
return await this.api.get({
url:'/gateway',
body: {
method: 'app.shops.sales',
shopsId: 6666,
type: 1,
reqTime: 20160525,
...params,
}
})
.then((json) => {
... ...