Authored by 张文文

佣金页面添加粉丝数和好友数

&邀请好友列表页面
... ... @@ -24,6 +24,7 @@ import BankListContainer from './containers/BankListContainer';
import RecommendContainer from './containers/RecommendContainer';
import TalentRankContainer from './containers/TalentRankContainer';
import ShareDetailContainer from './containers/ShareDetailContainer';
import InvitedFriendsContainer from './containers/InvitedFriendsContainer';
import {setChannel, setHost, setPlatform, setServiceHost, setproductPool, setSkns} from './reducers/app/appActions';
import {setOrderCode, setActivityId, setSrc, setJumpUrl} from './reducers/alliance/allianceActions';
... ... @@ -124,6 +125,12 @@ export default function native(platform) {
<RecommendContainer/>
</Provider>
);
} else if (type === 'invitedFriends') {
return (
<Provider store={store}>
<InvitedFriendsContainer/>
</Provider>
);
} else {
return (
<Provider store={store}>
... ...
... ... @@ -52,8 +52,16 @@ export default class Data extends Component {
let settlementAmount = this.props.settlementInfo.settlementInfoData.settlementAmount;
settlementAmount = settlementAmount ? settlementAmount : '0';
//当前粉丝数空值判断
let fansAmount = this.props.shareTotalInfo.shareTotalInfoData.fans;
fansAmount = fansAmount ? fansAmount : '0';
//邀请好友数空值判断
let invitesAmount = this.props.shareTotalInfo.shareTotalInfoData.inviteNum;
invitesAmount = invitesAmount ? invitesAmount : '0';
return (
<ScrollView style={styles.container} scrollEnabled = {scrollEnabled}>
<ScrollView style={styles.container} scrollEnabled = {true}>
<TipsAlert
tips={this.props.tips}
isShow={isShowTipsAlert}
... ... @@ -136,6 +144,21 @@ export default class Data extends Component {
<Statistics statisticsInfo={statisticsInfo} jumpWithUrl={this.props.jumpWithUrl}/>
<Statistics statisticsInfo={statisticsInfo} jumpWithUrl={this.props.jumpWithUrl}/>
</ScrollableTabView>
<View style={{height: 10, backgroundColor: '#f0f0f0'}}/>
<View style={styles.statisticsView}>
<View style={styles.attentionView}>
<Text style={[styles.hasWithDrawText,{marginLeft: 10}]}>当前粉丝数</Text>
<Text style={[styles.hasWithDrawText, {marginRight: 10}]}>{fansAmount}</Text>
</View>
<View style={styles.spaceView}/>
<TouchableOpacity activeOpacity={1} style={styles.attentionView} onPress={() => {
this.props.jumpWithUrl && this.props.jumpWithUrl('邀请好友', 'invitedFriends');
}}>
<Text style={[styles.hasWithDrawText],{marginLeft: 10}}>邀请好友数</Text>
<Text style={[styles.hasWithDrawText],{marginRight: 10}}>{invitesAmount}</Text>
</TouchableOpacity>
</View>
</ScrollView>
);
}
... ... @@ -248,5 +271,25 @@ let styles = StyleSheet.create({
height: 0.5,
backgroundColor: '#e0e0e0'
},
statisticsView: {
width: width,
height: 50,
backgroundColor: 'white',
flexDirection: 'row',
alignItems: 'center',
},
attentionView: {
width: width/2,
height: 50,
backgroundColor: 'white',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between'
},
spaceView: {
width: 0.5,
height: 50,
backgroundColor: '#e0e0e0'
},
})
;
... ...
'use strict';
import React, { Component } from 'react';
import { Dimensions, Image, ListView, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import { Immutable } from 'immutable';
const DEVICE_WIDTH_RATIO = Dimensions.get('window').width / 375;
const { width } = Dimensions.get('window');
export default class InvitedFriends extends Component {
constructor(props) {
super(props);
this._renderRow = this._renderRow.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
}
_renderRow(rowData, sectionID, rowID) {
return (
<View>
<View style={styles.rowView}>
<View style={styles.rowItemStyle}>
<Text style={styles.nameStyle}>{rowData.get("name")}</Text>
</View>
<View style={styles.rowItemStyle}>
<Text style={styles.rowTextStyle}>{rowData.get("dateStr")}</Text>
</View>
<View style={styles.rowItemStyle}>
<Text style={styles.rowTextStyle}>{rowData.get("orderNum")}</Text>
</View>
<View style={styles.rowItemStyle}>
<Text style={styles.rowTextStyle}>{rowData.get("orderAmountStr")}</Text>
</View>
</View>
</View>
);
}
render() {
let {
invitedFriendsList,
} = this.props;
let invitersList = invitedFriendsList.list ? invitedFriendsList.list.toArray() : [];
return (
<View style={styles.container}>
<View style={styles.topImageView}>
<Image style={styles.topImageView} source={{uri:'https://img.alicdn.com/tps/TB1OvT9NVXXXXXdaFXXXXXXXXXX-520-280.jpg'}}/>
</View>
<View style={styles.spaceView}/>
<View style={styles.middleView}>
<View style={styles.textItemStyle}>
<Text style={styles.textsStyle}>我邀请的好友</Text>
</View>
<View style={styles.textItemStyle}>
<Text style={styles.textsStyle}>申请时间</Text>
</View>
<View style={styles.textItemStyle}>
<Text style={styles.textsStyle}>7天订单数</Text>
</View>
<View style={styles.textItemStyle}>
<Text style={styles.textsStyle}>7天订单金额</Text>
</View>
</View>
<ListView
ref={(c) => {
this.listView = c;
}}
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRows(invitersList)}
renderRow={this._renderRow}
onEndReached={() => {
if (invitersList.size !== 0) {
this.props.onEndReached && this.props.onEndReached();
}
}}/>
<TouchableOpacity activeOpacity={1} style={styles.touchableStyle} onPress={() => {
//有货有赚调原生
}}>
<Text style={styles.buttonStyle}>邀请好友加入有货有赚</Text>
</TouchableOpacity>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
contentContainer: {
width: width,
backgroundColor: 'white',
paddingBottom: 55 * DEVICE_WIDTH_RATIO,
},
topImageView: {
width: width,
height: 120 * DEVICE_WIDTH_RATIO,
},
middleView: {
height: 50 * DEVICE_WIDTH_RATIO,
flexDirection: 'row',
alignItems: 'center',
},
textItemStyle: {
width: width / 4,
alignItems: 'center',
paddingVertical: 18,
},
textsStyle: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 12,
color: 'black',
},
rowView: {
height: 44 * DEVICE_WIDTH_RATIO,
flexDirection: 'row',
alignItems: 'center',
},
rowItemStyle: {
width: width / 4,
alignItems: 'center',
paddingVertical: 15,
},
rowTextStyle: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 10,
color: '#323232',
},
nameStyle: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 10,
color: 'black',
},
buttonStyle: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 16,
fontWeight: 'bold',
color: '#FFFFFF',
textAlign: 'center',
},
touchableStyle: {
position: 'absolute',
width: width,
height: 55,
bottom: 0,
borderRadius: 2,
backgroundColor: '#D0021B',
justifyContent: 'center'
},
spaceView: {
height: 10 * DEVICE_WIDTH_RATIO,
backgroundColor: '#F0F0F0'
},
});
... ...
... ... @@ -145,4 +145,12 @@ export default keyMirror({
SHARE_CODE_INFO_REQUEST: null,
SHARE_CODE_INFO_SUCCESS: null,
SHARE_CODE_INFO_FAILURE: null,
INVITED_FRIENDS_REQUEST: null,
INVITED_FRIENDS_SUCCESS: null,
INVITED_FRIENDS_FAILURE: null,
SHARETOTAL_REQUEST: null,
SHARETOTAL_SUCCESS: null,
SHARETOTAL_FAILURE: null,
});
... ...
... ... @@ -60,6 +60,7 @@ class DataContainer extends Component {
componentDidMount() {
this.props.actions.getSettlementInfo();
this.props.actions.getStatisticsInfo(1);
this.props.actions.getShareTotalInfo();
}
componentWillUnmount() {
... ... @@ -136,6 +137,7 @@ class DataContainer extends Component {
settlementInfo,
addSettlement,
statisticsInfo,
shareTotalInfo,
} = this.props.alliance;
let tip = this.state.tips;
let isFetching = settlementInfo.isFetching;
... ... @@ -149,6 +151,7 @@ class DataContainer extends Component {
settlementInfo={settlementInfo}
addSettlement={addSettlement}
statisticsInfo={statisticsInfo}
shareTotalInfo={shareTotalInfo}
tips={tip}
showTipsAlertDialog={this._showTipsAlertDialog}
hiddenTipsAlertDialog={this._hiddenTipsAlertDialog}
... ...
'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 LoadingIndicator from '../../common/components/LoadingIndicator';
import * as allianceActions from '../reducers/alliance/allianceActions';
import InvitedFriends from '../components/InvitedFriends';
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 InvitedFriendsContainer extends Component {
constructor(props) {
super(props);
this._onEndReached = this._onEndReached.bind(this);
}
componentDidMount() {
this.props.actions.getInvitedFriends();
}
componentWillUnmount() {
}
_onEndReached() {
this.props.actions.getInvitedFriends();
}
render() {
let {invitedFriendsList} = this.props.alliance;
let isFetching = invitedFriendsList.isFetching;
return (
<View style={styles.container}>
<InvitedFriends
invitedFriendsList={invitedFriendsList}
onEndReached={this._onEndReached}/>
<LoadingIndicator isVisible={isFetching}/>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
}
})
export default connect(mapStateToProps, mapDispatchToProps)(InvitedFriendsContainer);
... ...
... ... @@ -95,6 +95,14 @@ const {
GET_MINEUSERINFO_SUCCESS,
GET_MINEUSERINFO_FAILURE,
SHARETOTAL_REQUEST,
SHARETOTAL_SUCCESS,
SHARETOTAL_FAILURE,
INVITED_FRIENDS_REQUEST,
INVITED_FRIENDS_SUCCESS,
INVITED_FRIENDS_FAILURE,
} = require('../../constants/actionTypes').default;
export function showTipsAlertDialog() {
... ... @@ -506,6 +514,26 @@ export function getStatisticsInfoFailure() {
}
}
export function getShareTotalInfoRequest() {
return {
type: SHARETOTAL_REQUEST,
};
}
export function getShareTotalInfoSuccess(json) {
return {
type: SHARETOTAL_SUCCESS,
payload: json,
}
}
export function getShareTotalInfoFailure() {
return {
type: SHARETOTAL_FAILURE,
payload: error
}
}
export function getMineUserInfoSuccess(json) {
return {
type: GET_MINEUSERINFO_SUCCESS,
... ... @@ -527,6 +555,26 @@ export function getMineUserInfoRequest() {
}
export function invitedFriendsRequest() {
return {
type: INVITED_FRIENDS_REQUEST
}
}
export function invitedFriendsSuccess(json) {
return {
type: INVITED_FRIENDS_SUCCESS,
payload: json
}
}
export function invitedFriendsFailue(error) {
return {
type: INVITED_FRIENDS_FAILURE,
payload: error
}
}
export function getSettlementInfo() {
return (dispatch, getState) => {
let {app} = getState();
... ... @@ -771,6 +819,55 @@ export function getSettlementRecord() {
};
}
export function getInvitedFriends() {
return (dispatch, getState) => {
let {app, alliance} = getState();
let list = alliance.invitedFriendsList;
/**
* page: 0, //当前页面
* page_size: 20, //每页显示的数量
* total: 0, //总共多少条
* totalPage: 0, //总共多少页
* endReached: false, //到达底部
*/
if (list.isFetching || list.endReached || list.error || (!list.endReached && list.totalPage === 1)) {
return;
}
let page = list.page + 1;
let pageSize = list.page_size;
let fetchInvitedFriends = (uid) => {
dispatch(invitedFriendsRequest());
return new AllianceService(app.host).fetchInvitedFriends(uid, 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(invitedFriendsSuccess(payload));
})
.catch(error => {
dispatch(invitedFriendsFailue(error));
});
};
let uid = 0;
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
fetchInvitedFriends(uid)
})
.catch(error => {
fetchInvitedFriends(uid)
});
};
}
export function getOrderList(orderType, orderStatus, isChanged) {
return (dispatch, getState) => {
let {app, alliance} = getState();
... ... @@ -1000,6 +1097,31 @@ export function getStatisticsInfo(queryTimeType) {
}
}
export function getShareTotalInfo() {
return (dispatch, getState) => {
let {app} = getState();
let fetchShareTotalInfo = (uid) => {
dispatch(getShareTotalInfoRequest());
return new AllianceService(app.host).fetchShareTotalInfo(uid)
.then(json => {
dispatch(getShareTotalInfoSuccess(json));
})
.catch(error => {
dispatch(getShareTotalInfoFailure());
});
};
let uid = 0;
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
fetchShareTotalInfo(uid)
})
.catch(error => {
fetchShareTotalInfo(uid)
});
}
}
export function getMineUserInfo() {
return (dispatch, getState) => {
let {app} = getState();
... ...
... ... @@ -19,6 +19,12 @@ let InitialState = Record({
settlementInfoData: Map(),
})),
shareTotalInfo: new (Record({
isFetching: false,
error: null,
shareTotalInfoData: Map(),
})),
addSettlement: new (Record({
isFetching: false,
error: null,
... ... @@ -105,6 +111,17 @@ let InitialState = Record({
list: List(),
})),
invitedFriendsList: new (Record({
isFetching: false,
error: null,
page: 0, //当前页面
page_size: 20, //每页显示的数量
total: 0, //总共多少条
totalPage: 0, //总共多少页
endReached: false, //到达底部
list: List(),
})),
topList: new (Record({
isFetching: false,
error: null,
... ...
... ... @@ -93,6 +93,14 @@ const {
GET_MINEUSERINFO_SUCCESS,
GET_MINEUSERINFO_FAILURE,
SHARETOTAL_REQUEST,
SHARETOTAL_SUCCESS,
SHARETOTAL_FAILURE,
INVITED_FRIENDS_REQUEST,
INVITED_FRIENDS_SUCCESS,
INVITED_FRIENDS_FAILURE,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
... ... @@ -344,6 +352,31 @@ export default function couponReducer(state = initialState, action) {
.setIn(['settlementRecordList', 'error'], action.payload);
}
case INVITED_FRIENDS_REQUEST: {
return state.setIn(['invitedFriendsList', 'isFetching'], true)
.setIn(['invitedFriendsList', 'error'], null);
}
case INVITED_FRIENDS_SUCCESS: {
let {
page,
totalPage,
endReached,
list,
} = action.payload;
return state.setIn(['invitedFriendsList', 'isFetching'], false)
.setIn(['invitedFriendsList', 'page'], page)
.setIn(['invitedFriendsList', 'totalPage'], totalPage)
.setIn(['invitedFriendsList', 'endReached'], endReached)
.setIn(['invitedFriendsList', 'list'], Immutable.fromJS(list))
.setIn(['invitedFriendsList', 'error'], null);
}
case INVITED_FRIENDS_FAILURE: {
return state.setIn(['invitedFriendsList', 'isFetching'], false)
.setIn(['invitedFriendsList', 'error'], action.payload);
}
case ORDER_LIST_REQUEST: {
return state.setIn(['orderList', 'isFetching'], true)
.setIn(['orderList', 'error'], null);
... ... @@ -521,6 +554,23 @@ export default function couponReducer(state = initialState, action) {
return state.setIn(['profile', 'isFetching'], false)
.setIn(['profile', 'error'], null);
case SHARETOTAL_REQUEST: {
return state.setIn(['shareTotalInfo', 'isFetching'], true)
.setIn(['shareTotalInfo', 'error'], null);
}
case SHARETOTAL_SUCCESS: {
return state.setIn(['shareTotalInfo', 'isFetching'], false)
.setIn(['shareTotalInfo', 'shareTotalInfoData'], action.payload)
.setIn(['shareTotalInfo', 'error'], null);
}
case SHARETOTAL_FAILURE: {
return state.setIn(['shareTotalInfo', 'isFetching'], false)
.setIn(['shareTotalInfo', 'error'], action.payload);
}
}
return state;
... ...
... ... @@ -156,6 +156,25 @@ export default class AllianceService {
});
}
//(邀请好友列表)
async fetchInvitedFriends(uid, page, size) {
return await this.api.get({
url: '',
body: {
uid,
page,
size,
method: 'app.union.shareOrder.queryInviteList',
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
//(订单列表)
/**
*
... ... @@ -347,5 +366,21 @@ export default class AllianceService {
});
}
//获取分享数量统计
async fetchShareTotalInfo(uid) {
return await this.api.get({
url: '',
body: {
uid,
method: 'app.union.shareOrder.queryShareTotal',
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
}
... ...
... ... @@ -44,16 +44,20 @@ class TipsAlert extends React.Component {
}
_renderChildren(children) {
return children.map((element, index) => {
return (
<React.Fragment key={index}>
{element}
if (index !== children.length) {
<View style={{ width: 0.5, height: '100%', backgroundColor: '#e0e0e0' }}></View>
}
</React.Fragment>
)
});
if('[object Array]' == Object.prototype.toString.call(children)){
return children.map((element, index) => {
if (index === children.length) return element
return (
<React.Fragment>
{element}
<View style={{width: 0.5, height: '100%', backgroundColor: '#e0e0e0'}}></View>
</React.Fragment>
)
});
}else {
return children
}
}
render() {
... ... @@ -137,4 +141,10 @@ let styles = StyleSheet.create({
letterSpacing: -0.41,
fontWeight: 'bold'
},
common: {
fontSize: 17,
color: 'black',
letterSpacing: -0.41,
fontFamily: 'PingFang-SC-Regular'
},
});
... ...