Authored by 盖剑秋

Add real data to account settlement. Reviewer: Yu Liang.

... ... @@ -69,11 +69,22 @@ export default class AccountSettlement extends Component {
);
case 'SECTION_CONTENT':
return (
let statusStr = '';
switch (Data.status) {
case 1:
statusStr = '已出账单';
break;
case 2:
statusStr = '已付款';
break;
default:
}
<View style={styles.cellContainer}>
<Text style={[styles.inCellText,{flex:0.9}]}>{Data.brand}</Text>
<Text style={[styles.inCellText,{flex:1.0}]}>{Data.date}</Text>
<Text style={[styles.inCellText,{flex:0.8}]}>{Data.status}</Text>
<Text style={[styles.inCellText,{flex:1.3}]}>{Data.bill}</Text>
<Text style={[styles.inCellText,{flex:0.9}]}>{Data.brandId}</Text>
<Text style={[styles.inCellText,{flex:1.0}]}>{Data.dateId}</Text>
<Text style={[styles.inCellText,{flex:0.8}]}>{statusStr}</Text>
<Text style={[styles.inCellText,{flex:1.3}]}>{Data.orderAmount}</Text>
</View>
);
}
... ... @@ -83,7 +94,11 @@ export default class AccountSettlement extends Component {
render() {
let isFetching = this.props.isFetching;
let loadText = isFetching?'加载中':'上拉加载更多';
let loadText = 'All data loaded';
if (!this.props.reachEnd) {
loadText = isFetching?'加载中':'上拉加载更多';
}
return (
<View>
... ...
... ... @@ -25,7 +25,6 @@ const actions = [
accountSettlementActions,
];
function mapStateToProps(state) {
return {
...state
... ... @@ -53,24 +52,33 @@ export default class AccountSettlementContainer extends Component {
}
componentDidMount() {
this.props.actions.nextPageOfDataRequest();
fetchNextPage();
}
fetchNextPage(){
this.props.actions.nextPageOfDataRequest();
let params = {
page: this.props.actStmt.currentPage+1,
size: 20,
brandId: this.props.home.get('brandId'),
}
this.props.actions.nextPageOfDataRequest(params);
}
render() {
let dataBlob = {
'SECTION_HEADER':[{title:'累计结算金额(元)',content:'12567.00'}],
'SECTION_HEADER':[{title:'累计结算金额(元)',content:`${this.props.actStmt.sum}`}],
'SECTION_SEPORATOR':[{}],
'SECTION_TITLE':[{}],
'SECTION_CONTENT':this.props.actStmt.jsonData,
};
let mapBlob = Immutable.fromJS(dataBlob);
let end = this.props.actStmt.currentPage>=this.props.actStmt.pageCount;
return (
<AccountSettlement
dataBlob={mapBlob}
fetchNextPage={this.fetchNextPage}
isFetching={this.props.actStmt.isFetching}
reachEnd={end}
/>
);
... ...
... ... @@ -40,12 +40,18 @@ export function nextPageOfDataFailure(error) {
* @method nextPageOfDataRequest
* @return {JS Objecrt}
*/
export function nextPageOfDataRequest() {
export function nextPageOfDataRequest(params) {
return (dispatch,getState) => {
const {actStmt} = getState();
if (actStmt.currentPage>=actStmt.pageCount) {//Last page reached....
return;
}
return dispatch => {
dispatch(requestNextPage());
return new HomeService().accountSettlementData()
return new HomeService().accountSettlementData(params)
.then(json => {
dispatch(nextPageOfDataSuccess(json));
})
... ...
... ... @@ -5,7 +5,8 @@ import {List, Record} from 'immutable';
let InitialState = Record({
error: null,
isFetching: false,
pageCount: 0,
pageCount: 1,
currentPage:0,
sum:'0.00',
jsonData:List(),
});
... ...
... ... @@ -25,8 +25,12 @@ export default function messageReducer(state = initialState, action) {
case ACCOUNT_LIST_SUCCESS:{
const {jsonData} = state;
let origin = jsonData.toJS();
let data = [...origin, ...action.payload];
let nextState = state.set('isFetching',false).set('jsonData', List(data));
let data = [...origin, ...action.payload.list];
let nextState = state.set('isFetching',false)
.set('pageCount', action.payload.totalPage)
.set('currentPage',action.payload.page)
.set('sum',action.payload.additionInfo.allAmountRate)
.set('jsonData', Immutable.fromJS(data));
return nextState;
}
break;
... ...
... ... @@ -45,12 +45,16 @@ export default class UserService {
});
}
async accountSettlementData() {
async accountSettlementData(params) {
return await this.api.get({
url:'/operations/api/v6/category/getCategory'
url:'/gateway',
body: {
method: 'app.shops.balance',
...params,
}
})
.then((json) => {
return testData;
return json;
})
.catch((error) => {
throw(error);
... ... @@ -128,87 +132,3 @@ export default class UserService {
})
}
}
let testData = [
{
brand:'vans',
date: '2016-01-23',
status: '已出账单',
bill:'923.00'
},
{
brand:'vans',
date: '2016-01-23',
status: '已出账单',
bill:'923.00'
},
{
brand:'vans',
date: '2016-01-23',
status: '已出账单',
bill:'923.00'
},
{
brand:'vans',
date: '2016-01-23',
status: '已出账单',
bill:'923.00'
},
{
brand:'vans',
date: '2016-01-23',
status: '已出账单',
bill:'923.00'
},
{
brand:'vans',
date: '2016-01-23',
status: '已出账单',
bill:'923.00'
},
{
brand:'vans',
date: '2016-01-23',
status: '已出账单',
bill:'923.00'
},
{
brand:'vans',
date: '2016-01-23',
status: '已出账单',
bill:'923.00'
},
{
brand:'vans',
date: '2016-01-23',
status: '已出账单',
bill:'923.00'
},
{
brand:'vans',
date: '2016-01-23',
status: '已出账单',
bill:'923.00'
},
{
brand:'vans',
date: '2016-01-23',
status: '已出账单',
bill:'923.00'
},
{
brand:'vans',
date: '2016-01-23',
status: '已出账单',
bill:'923.00'
},
{
brand:'vans',
date: '2016-01-23',
status: '已出账单',
bill:'923.00'
},
];
... ...