Authored by 张文文

添加跳转预估佣金页面及接口调试

... ... @@ -25,6 +25,7 @@ import RecommendContainer from './containers/RecommendContainer';
import TalentRankContainer from './containers/TalentRankContainer';
import ShareDetailContainer from './containers/ShareDetailContainer';
import InvitedFriendsContainer from './containers/InvitedFriendsContainer';
import EstimateDetailContainer from './containers/EstimateDetailContainer';
import {setChannel, setHost, setPlatform, setServiceHost, setproductPool, setSkns} from './reducers/app/appActions';
import {setOrderCode, setActivityId, setSrc, setJumpUrl} from './reducers/alliance/allianceActions';
... ... @@ -131,6 +132,14 @@ export default function native(platform) {
<InvitedFriendsContainer/>
</Provider>
);
} else if (type === 'estimateDetails') {
return (
<Provider store={store}>
<EstimateDetailContainer
time_type={this.props.time_type}
tab_type={this.props.tab_type}/>
</Provider>
);
} else {
return (
<Provider store={store}>
... ...
... ... @@ -140,9 +140,9 @@ export default class Data extends Component {
renderTabBar={() => <TabStatistics tabNames={tabTitles}/>}
onChangeTab={(obj) => {this.props.changeTab && this.props.changeTab(obj.i + 1);}}
>
<Statistics statisticsInfo={statisticsInfo} jumpWithUrl={this.props.jumpWithUrl}/>
<Statistics statisticsInfo={statisticsInfo} jumpWithUrl={this.props.jumpWithUrl}/>
<Statistics statisticsInfo={statisticsInfo} jumpWithUrl={this.props.jumpWithUrl}/>
<Statistics statisticsInfo={statisticsInfo} currentTab = {1} resourceJumpWithUrl={this.props.resourceJumpWithUrl}/>
<Statistics statisticsInfo={statisticsInfo} currentTab = {2} resourceJumpWithUrl={this.props.resourceJumpWithUrl}/>
<Statistics statisticsInfo={statisticsInfo} currentTab = {3} resourceJumpWithUrl={this.props.resourceJumpWithUrl}/>
</ScrollableTabView>
<View style={{height: 10, backgroundColor: '#f0f0f0'}}/>
... ...
'use strict';
import React, {Component} from 'react';
import {Dimensions, ListView, StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import {Immutable} from 'immutable';
export default class EstimateIncome extends Component {
constructor(props) {
super(props);
this.state = {
tabType: this.props.tabType,
timeType: this.props.timeType,
};
this._renderRow = this._renderRow.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
}
_renderRow(rowData, sectionID, rowID) {
let status = rowData.get('status') === '10' ? '待结算' : '';
return (
<View>
<TouchableOpacity activeOpacity={1} onPress={() => {
this.props.jumpWithUrl && (this.state.tabType === 1 ? this.props.jumpWithUrl('订单详情', 'orderDetail', rowData.get('orderCode')) : this.props.jumpWithUrl('佣金详情', 'activityOrderDetail', rowData.get('id')) );
}}>
<View style={styles.rowView}>
<View style={{height: 70, paddingTop: 12, paddingBottom: 12}}>
{ this.state.tabType === 1 ? <Text style={styles.numberText}>订单金额:{rowData.get('lastOrderAmountStr')}</Text> : <Text style={styles.numberText}>活动名称:{rowData.get('activityName')}</Text>}
<View style={{flexDirection: 'row', marginTop: 6}}>
<Text style={styles.timeText}>{rowData.get('orderTimeStr')}</Text>
{rowData.get('isNew') === 1 && this.state.tabType === 1 ?
<View style={styles.statusTextContainer}>
<Text style={styles.statusText}>新客订单</Text>
</View>: null}
</View>
</View>
<View>
<Text style={styles.priceText}>{rowData.get('amountStr')}</Text>
<Text style={[styles.timeText, {fontSize:12, textAlign:'right'}]}>{status}</Text>
</View>
</View>
<View style={styles.lineView}/>
</TouchableOpacity>
</View>
);
}
render() {
let {estimateList} = this.props;
let estimateLists = estimateList.list ? estimateList.list.toArray() : [];
return (
<View style={styles.container}>
<ListView
ref={(c) => {
this.listView = c;
}}
// yh_viewVisible={true}
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRows(estimateLists)}
renderRow={this._renderRow}
onEndReached={() => {
if (estimateLists.size !== 0) {
this.props.onEndReached && this.props.onEndReached();
}
}}/>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f0f0f0',
alignItems: 'center'
},
contentContainer: {
width: width,
backgroundColor: 'white'
},
rowView: {
width: width,
height: 70,
flexDirection: 'row',
paddingLeft: 15,
paddingRight: 15,
alignItems: 'center',
justifyContent: 'space-between'
},
underLine: {
width: 56,
height: 2,
backgroundColor: '#444444',
},
lineView: {
width: width,
height: 0.5,
backgroundColor: '#e0e0e0'
},
numberText: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 14,
color: '#444444',
letterSpacing: -0.19,
},
priceText: {
fontFamily: 'PingFang-SC-Medium',
fontSize: 16,
color: '#444444',
letterSpacing: -0.21,
fontWeight: 'bold'
},
timeText: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 14,
color: '#B0B0B0',
letterSpacing: -0.19,
},
statusTextContainer: {
width: 48,
height: 18,
marginLeft: 10,
borderWidth: 1,
borderColor: '#D0021B',
borderRadius: 2,
alignItems: 'center',
justifyContent: 'center',
},
statusText: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 10,
color: '#D0021B',
letterSpacing: -0.24,
textAlign: 'center',
},
});
\ No newline at end of file
... ...
... ... @@ -20,23 +20,46 @@ export default class Statistics extends Component {
render() {
let {statisticsInfo} = this.props;
let currentTab = this.props.currentTab;
return (
<TouchableOpacity activeOpacity={1} style={styles.container} onPress={() => {
this.props.jumpWithUrl && this.props.jumpWithUrl('全部佣金', 'orderIncome');
}} >
<View style={styles.container}>
<View style={styles.statisticsView}>
<TouchableOpacity activeOpacity={1} style={styles.container} onPress={() => {
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.minealliance","params":{"title":"预估佣金","type":"estimateDetails","time_type":${currentTab}, "tab_type":"1"}}`;
this.props.resourceJumpWithUrl && this.props.resourceJumpWithUrl(url);
}} >
<View style={{width: width / 2, paddingLeft: 30, marginTop: -10}}>
<Text style={styles.numberText}>¥{statisticsInfo.orderAmountSum}</Text>
<Text style={styles.tipsText}>预估订单佣金</Text>
</View>
</TouchableOpacity>
<View style={styles.spaceView}/>
<TouchableOpacity activeOpacity={1} style={styles.container} onPress={() => {
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.minealliance","params":{"title":"预估佣金","type":"estimateDetails","time_type":${currentTab}, "tab_type":"2"}}`;
this.props.resourceJumpWithUrl && this.props.resourceJumpWithUrl(url);
}} >
<View style={{width: width / 2, paddingLeft: 30, marginTop: -10}}>
<Text style={styles.numberText}>¥{statisticsInfo.extraAmountSum}</Text>
<Text style={styles.tipsText}>预估其他佣金</Text>
</View>
</TouchableOpacity>
</View>
<View style={styles.lineView}/>
<TouchableOpacity activeOpacity={1} style={styles.container} onPress={() => {
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.minealliance","params":{"title":"全部佣金","type":"orderIncome"}}`;
this.props.resourceJumpWithUrl && this.props.resourceJumpWithUrl(url);
}} >
<View style={styles.statisticsView}>
<View style={{width: width / 2, paddingLeft: 30, marginTop: -10}}>
<Text style={styles.numberText}>{statisticsInfo.orderNum}</Text>
... ... @@ -48,9 +71,12 @@ export default class Statistics extends Component {
<Text style={styles.tipsText}>点击数</Text>
</View>
</View>
</TouchableOpacity>
<View style={styles.lineView}/>
</View>
</TouchableOpacity>
);
}
... ...
... ... @@ -69,6 +69,10 @@ export default keyMirror({
ORDER_LIST_SUCCESS: null,
ORDER_LIST_FAILURE: null,
ESTIMATE_LIST_REQUEST: null,
ESTIMATE_LIST_SUCCESS: null,
ESTIMATE_LIST_FAILURE: null,
TOP_LIST_REQUEST: null,
TOP_LIST_SUCCESS: null,
TOP_LIST_FAILURE: null,
... ...
'use strict';
import React, {Component} from 'react';
import {StyleSheet, View} from 'react-native';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Map} from 'immutable';
import * as allianceActions from '../reducers/alliance/allianceActions';
import EstimateIncome from "../components/EstimateIncome";
import LoadingIndicator from '../../common/components/LoadingIndicator';
import ReactNative from "react-native";
const actions = [
allianceActions,
];
function mapStateToProps(state) {
return {
...state
};
}
function mapDispatchToProps(dispatch) {
const creators = Map()
.merge(...actions)
.filter(value => typeof value === 'function')
.toObject();
return {
actions: bindActionCreators(creators, dispatch),
dispatch
};
}
class EstimateDetailContainer extends Component {
constructor(props) {
super(props);
this.state = {
tabType: this.props.tab_type, //1 订单收入,2活动收入
timeType: this.props.time_type, //1 昨日 2 本月 3 上月
};
this._jumpWithUrl = this._jumpWithUrl.bind(this);
this._onEndReached = this._onEndReached.bind(this);
}
componentDidMount() {
this.props.actions.getEstimateList(this.state.tabType, this.state.timeType, true);
}
componentWillUnmount() {
}
_jumpWithUrl(title='', type='', orderCode='') {
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.minealliance","params":{"title":"${title}","type":"${type}","order_code":"${orderCode}"}}`;
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
_onEndReached() {
this.props.actions.getEstimateList(this.state.tabType, this.state.timeType, true);
}
render() {
let {estimateList} = this.props.alliance;
let isFetching = estimateList.isFetching;
return (
<View style={styles.container}>
<EstimateIncome
estimateList={estimateList}
jumpWithUrl={this._jumpWithUrl}
onEndReached={this._onEndReached}
/>
<LoadingIndicator isVisible={isFetching}/>
</View>
)
}
}
let styles = StyleSheet.create({
container: {
flex: 1,
},
});
export default connect(mapStateToProps, mapDispatchToProps)(EstimateDetailContainer);
\ No newline at end of file
... ...
... ... @@ -67,6 +67,10 @@ const {
ORDER_LIST_SUCCESS,
ORDER_LIST_FAILURE,
ESTIMATE_LIST_REQUEST,
ESTIMATE_LIST_SUCCESS,
ESTIMATE_LIST_FAILURE,
TOP_LIST_REQUEST,
TOP_LIST_SUCCESS,
TOP_LIST_FAILURE,
... ... @@ -394,6 +398,26 @@ export function orderListFailure(error) {
};
}
export function estimateListRequest() {
return {
type: ESTIMATE_LIST_REQUEST,
};
}
export function estimateListSuccess(json) {
return {
type: ESTIMATE_LIST_SUCCESS,
payload: json
};
}
export function estimateListFailure(error) {
return {
type: ESTIMATE_LIST_FAILURE,
payload: error
};
}
export function topListRequest() {
return {
type: TOP_LIST_REQUEST,
... ... @@ -917,6 +941,55 @@ export function getOrderList(orderType, orderStatus, isChanged) {
};
}
export function getEstimateList(tabType, timeType, isChanged) {
return (dispatch, getState) => {
let {app, alliance} = getState();
let list = alliance.estimateList;
/**
* page: 0, //当前页面
* page_size: 20, //每页显示的数量
* total: 0, //总共多少条
* totalPage: 0, //总共多少页
* endReached: false, //到达底部
*/
if (!isChanged && (list.isFetching || list.endReached || list.error || (!list.endReached && list.totalPage === 1))) {
return;
}
let page = isChanged ? 1 : list.page + 1;
let pageSize = list.page_size;
let fetchEstimateList = (uid) => {
dispatch(estimateListRequest());
return new AllianceService(app.host).fetchEstimateList(uid, tabType, timeType, page, pageSize)
.then(json => {
let payload = json;
payload.endReached = (payload.page === payload.totalPage) && (payload.totalPage !== 1);
if (payload.page > 1) {
let oldList = list.list.toJS();
let newList = [...oldList, ...payload.list];
payload.list = newList;
}
dispatch(estimateListSuccess(payload));
})
.catch(error => {
dispatch(estimateListFailure(error));
});
};
let uid = 0;
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
fetchEstimateList(uid)
})
.catch(error => {
fetchEstimateList(uid)
});
};
}
export function getTop100List() {
return (dispatch, getState) => {
let {app, alliance} = getState();
... ...
... ... @@ -100,6 +100,17 @@ let InitialState = Record({
list: List(),
})),
estimateList: new (Record({
isFetching: false,
error: null,
page: 0, //当前页面
page_size: 20, //每页显示的数量
total: 0, //总共多少条
totalPage: 0, //总共多少页
endReached: false, //到达底部
list: List(),
})),
settlementRecordList: new (Record({
isFetching: false,
error: null,
... ...
... ... @@ -65,6 +65,10 @@ const {
ORDER_LIST_SUCCESS,
ORDER_LIST_FAILURE,
ESTIMATE_LIST_REQUEST,
ESTIMATE_LIST_SUCCESS,
ESTIMATE_LIST_FAILURE,
TOP_LIST_REQUEST,
TOP_LIST_SUCCESS,
TOP_LIST_FAILURE,
... ... @@ -403,6 +407,32 @@ export default function couponReducer(state = initialState, action) {
.setIn(['orderList', 'error'], action.payload);
}
case ESTIMATE_LIST_REQUEST: {
return state.setIn(['estimateList', 'isFetching'], true)
.setIn(['estimateList', 'error'], null);
}
case ESTIMATE_LIST_SUCCESS: {
let {
page,
totalPage,
endReached,
list,
} = action.payload;
return state.setIn(['estimateList', 'isFetching'], false)
.setIn(['estimateList', 'page'], page)
.setIn(['estimateList', 'totalPage'], totalPage)
.setIn(['estimateList', 'endReached'], endReached)
.setIn(['estimateList', 'list'], Immutable.fromJS(list))
.setIn(['estimateList', 'error'], null);
}
case ESTIMATE_LIST_FAILURE: {
return state.setIn(['estimateList', 'isFetching'], false)
.setIn(['estimateList', 'error'], action.payload);
}
case TOP_LIST_REQUEST: {
return state.setIn(['topList', 'isFetching'], true)
.setIn(['topList', 'error'], null);
... ...
... ... @@ -230,6 +230,40 @@ export default class AllianceService {
});
}
//(预估收入详细列表)
/**
* @param uid
* @param type 1-订单收入,2-其他收入
* @param time_type 1-昨日,2-本月,3-上月
* @param page
* @param size
* @returns {Promise<T>}
*/
async fetchEstimateList(uid, tab_type, time_type, page, size) {
let converted_tab_type, converted_time_type;
let customBody = {
uid,
type: tab_type,
time_type: time_type,
page,
size,
method: 'app.union.shareOrder.queryEstimateDetails',
}
return await this.api.get({
url: '',
body: customBody
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
//获取热卖Top100列表
async fetchTop100List(uid, page, limit) {
let fromPage = Platform.OS === 'android' ? 'aFP_Alliance' : 'iFP_Alliance';
... ...