Authored by 王海元

我的联盟新增二次确认和资源位展示 --review by 戴强

... ... @@ -6,8 +6,10 @@ import {Dimensions, Image, ListView, StyleSheet, Text, TouchableOpacity, View, N
import {Immutable} from 'immutable';
import ProductListCell from '../../common/components/ListCell/ProductListCell';
import HelpTipsModal from "./HelpTipsModal";
import SureModal from "./SureModal";
import WithdrawModal from "./WithdrawModal";
import GuideModal from "./GuideModal";
import BannerSwiper from './BannerSwiper';
export default class Alliance extends Component {
constructor(props) {
... ... @@ -30,7 +32,7 @@ export default class Alliance extends Component {
<View style={styles.helpView}>
<Text style={styles.canWithDrawText}>可提现金额</Text>
<TouchableOpacity activeOpacity={1} onPress={() => {
this.props.showHelpDialog && this.props.showHelpDialog('仅计算当天凌晨4点前产生的有效订单结算后的可提现金额,具体说明请参见规则说明');
this.props.showHelpDialog && this.props.showHelpDialog('仅计算当天12点前产生的有效订单结算后的可提现金额,具体说明请参见规则说明');
}}>
<Image style={styles.helpImage} source={require('../images/help.png')}/>
</TouchableOpacity>
... ... @@ -47,7 +49,7 @@ export default class Alliance extends Component {
return
}
if (this.props.settlementInfo.settlementInfoData.canSettlement) {
!this.props.addSettlement.isFetching && this.props.showWithdrawalDialog && this.props.showWithdrawalDialog();
!this.props.addSettlement.isFetching && this.props.showSureDialog && this.props.showSureDialog();
} else {
this.props.showHelpDialog && this.props.showHelpDialog('您有正在处理中的提现,请耐心等待完成后再做新的提现操作');
}
... ... @@ -67,25 +69,39 @@ export default class Alliance extends Component {
</View>
</TouchableOpacity>
<View style={{height: 10, backgroundColor: '#f0f0f0'}}/>
<View style={styles.withdrawView}>
</View>
)
}
_renderRow(rowData, sectionID, rowID) {
let paddingLeft = rowID % 2 === 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
let customStyle = rowID === 0 || rowID === 1 ? {paddingLeft} : {paddingLeft};
let hasOrder = this.props.recentlyOrder.recentlyOrder_list.toArray().length > 0;
switch (sectionID) {
case 'resourceList': {
return(
<View>
<BannerSwiper resource={rowData} row_ID={rowID} resourceJumpWithUrl={this.props.resourceJumpWithUrl}/>
<View style={{height: 10, backgroundColor: '#f0f0f0'}}/>
</View>
);
}
case 'orderListHeader': {
return (
<View>
<View style={styles.orderView}>
<Text style={[styles.hasWithDrawText, {fontWeight: 'bold'}]}>最近订单</Text>
<Text style={styles.orderTipsText}>当天订单第二天显示</Text>
</View>
<View style={styles.titleBottomLine}/>
{this.props.recentlyOrder.recentlyOrder_list.toArray().length > 0 ? null :
<View style={styles.emptyOrderView}>
<Text style={[styles.hasWithDrawText, {color: '#B0B0B0', justifyContent: 'center', width: 98}]}>您暂时没有订单</Text>
<Text style={[styles.hasWithDrawText, {color: '#B0B0B0', justifyContent: 'center'}]}>您暂时没有订单</Text>
</View>
}
</View>
)
}
_renderRow(rowData, sectionID, rowID) {
let paddingLeft = rowID % 2 === 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
let customStyle = rowID === 0 || rowID === 1 ? {paddingLeft} : {paddingLeft};
let hasOrder = this.props.recentlyOrder.recentlyOrder_list.toArray().length > 0;
switch (sectionID) {
case 'orderList': {
let status = rowData.get('status') === '10' ? '待确认' : '';
return (
... ... @@ -157,12 +173,16 @@ export default class Alliance extends Component {
render() {
let {
isShowHelp,
isShowSure,
isShowWithdrawal,
resourceInfo,
recentlyOrder,
topList,
} = this.props;
let dataSource = {
resourceList: resourceInfo.resourceList ? resourceInfo.resourceList.toArray() : [],
orderListHeader: ['最近订单'],
orderList: recentlyOrder.recentlyOrder_list ? recentlyOrder.recentlyOrder_list.toArray() : [],
orderListFooter: ['查看全部'],
productListTitle: ['推荐商品'],
... ... @@ -178,6 +198,10 @@ export default class Alliance extends Component {
tips={this.props.tips}
isShowHelp={isShowHelp}
hiddenHelpDialog={this.props.hiddenHelpDialog}/>
<SureModal
isShow={isShowSure}
hiddenSureDialog={this.props.hiddenSureDialog}
showWithdrawalDialog={this.props.showWithdrawalDialog}/>
<WithdrawModal
isShowWithdrawal={isShowWithdrawal}
hiddenWithDrawDialog={this.props.hiddenWithDrawDialog}/>
... ... @@ -285,11 +309,26 @@ let styles = StyleSheet.create({
alignItems: 'center',
justifyContent: 'space-between'
},
orderView: {
width: width,
height: 44,
backgroundColor: '#FFFFFF',
flexDirection: 'row',
paddingLeft: 15,
alignItems: 'center',
},
hasWithDrawText: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 14,
color: '#444444',
},
orderTipsText: {
marginLeft: 4,
fontFamily: 'PingFang-SC-Regular',
fontSize: 12,
color: '#B0B0B0',
letterSpacing: -0.16,
},
arrowImage: {
width: 16,
height: 16,
... ...
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import YH_Swiper from '../../common/components/YH_Swiper';
import YH_Image from '../../common/components/YH_Image';
import {getSlicedUrl} from '../../classify/utils/Utils';
const {
View,
TouchableOpacity,
StyleSheet,
Dimensions,
Platform,
} = ReactNative;
import Immutable, {Map} from 'immutable';
export default class BannerSwiper extends React.Component {
constructor(props) {
super (props);
}
shouldComponentUpdate(nextProps){
if (Immutable.is(nextProps.resource, this.props.resource)) {
return false;
} else {
return true;
}
}
render() {
let {resource ,row_ID} = this.props;
if (!resource) {
return null;
}
let template_name = resource?resource.get('template_name'):'';
let template_id = resource?resource.get('template_id'):0;
let data = resource.get('data').toJS();
if (data.length == 1) {
let newSrc = getSlicedUrl(data[0].src, width, swiperHeight);
return (
<View style={styles.container}>
<TouchableOpacity
activeOpacity={1}
style={{width: width, height: swiperHeight}}
onPress={() => {
this.props.resourceJumpWithUrl && this.props.resourceJumpWithUrl(data[0].url)
}}
>
<YH_Image
url={newSrc}
style={{ width: width, height: swiperHeight}}
/>
</TouchableOpacity>
</View>
);
} else {
return (
<View style={styles.container}>
<YH_Swiper
style={styles.banner}
showsButtons={false}
loop={true}
autoplay={true}
autoplayTimeout={2}
paginationStyle={{bottom: 8}}
width={width}
height={swiperHeight}
>
{data.map((item, i) => {
let newSrc = getSlicedUrl(item.src, width, swiperHeight);
return (
<TouchableOpacity
key={i}
activeOpacity={1}
onPress={() => {
this.props.resourceJumpWithUrl && this.props.resourceJumpWithUrl(item.url)
}}
>
<YH_Image
url={newSrc}
style={{width: width, height: swiperHeight}}
/>
</TouchableOpacity>
);
})}
</YH_Swiper>
</View>
);
}
}
}
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 375;
let swiperHeight = Math.ceil(118 * DEVICE_WIDTH_RATIO);
let styles = StyleSheet.create({
container: {
width: width,
height: swiperHeight,
backgroundColor: 'white',
},
});
... ...
'use strict';
import React from 'react';
import ReactNative from 'react-native';
const {
AppRegistry,
StyleSheet,
Text,
View,
Dimensions,
TouchableOpacity,
Modal,
} = ReactNative;
export default class SureModal extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<Modal
visible={this.props.isShow}
animationType={'none'}
transparent={true}
onRequestClose={() => {
}}>
<View style={styles.modalContainer}>
<View style={styles.modalView}>
<View style={styles.confirmTitleContainer}>
<Text style={styles.confirmTitle}>申请提现后不能取消,确定要提现吗?</Text>
</View>
<View style={{width: '100%', height: 0.5, backgroundColor: '#e0e0e0'}}/>
<View style={styles.confirmBtnContainer}>
<TouchableOpacity
style={{width: '49%', alignItems: 'center', justifyContent: 'center', height: 45.5}}
onPress={() => {
this.props.hiddenSureDialog && this.props.hiddenSureDialog();
}}>
<Text style={{fontSize: 17, color: '#444444', letterSpacing: -0.41}}>取消</Text>
</TouchableOpacity>
<View style={{width: 0.5, height: 45, backgroundColor: '#e0e0e0'}}/>
<TouchableOpacity
style={{width: '49%', alignItems: 'center', justifyContent: 'center', height: 45.5}}
onPress={() => {
this.props.hiddenSureDialog && this.props.hiddenSureDialog();
this.props.showWithdrawalDialog && this.props.showWithdrawalDialog();
}}>
<Text style={{
fontSize: 17,
color: '#d0021b',
letterSpacing: -0.41,
fontWeight: '500'
}}>确定</Text>
</TouchableOpacity>
</View>
</View>
</View>
</Modal>
);
}
};
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
modalContainer: {
flex: 1,
width: width,
height: height,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'rgba(0, 0, 0, 0.4)',
},
modalView: {
width: 270,
borderRadius: 5,
alignItems: 'center',
backgroundColor: '#ffffff',
},
confirmBtnContainer: {
width: '100%',
height: 44.5,
flexDirection: 'row',
},
confirmTitleContainer: {
alignItems: 'center'
},
confirmTitle: {
paddingTop: 20,
paddingLeft: 30,
paddingRight: 30,
paddingBottom: 20,
color: '#444444',
fontSize: 14,
lineHeight: 24,
textAlign: 'center',
letterSpacing: -0.09,
fontFamily: 'PingFang-SC-Regular',
},
confirmContent: {
marginLeft: 30,
marginRight: 30,
marginBottom: 20,
color: '#444444',
fontSize: 14,
lineHeight: 24,
textAlign: 'center',
letterSpacing: -0.09,
fontFamily: 'PingFang-SC-Regular',
includeFontPadding: false,
},
click: {
width: '100%',
alignItems: 'center',
justifyContent: 'center'
},
sure: {
fontSize: 17,
color: '#D0021B',
letterSpacing: -0.41,
fontWeight: 'bold'
},
});
... ...
... ... @@ -10,6 +10,9 @@ export default keyMirror({
SHOW_HELP_DIALOG: null,
DISMISS_HELP_DIALOG: null,
SHOW_SURE_DIALOG: null,
DISMISS_SURE_DIALOG: null,
SET_ORDER_CODE: null,
SHOW_WITHDRAW_DIALOG: null,
... ... @@ -23,6 +26,10 @@ export default keyMirror({
ADD_SETTLEMENT_SUCCESS: null,
ADD_SETTLEMENT_FAILURE: null,
RESOURCE_INFO_REQUEST: null,
RESOURCE_INFO_SUCCESS: null,
RESOURCE_INFO_FAILURE: null,
RECENTLY_ORDER_REQUEST: null,
RECENTLY_ORDER_SUCCESS: null,
RECENTLY_ORDER_FAILURE: null,
... ...
... ... @@ -47,10 +47,13 @@ class AllianceContainer extends Component {
this._hiddenGuideDialog = this._hiddenGuideDialog.bind(this);
this._showHelpDialog = this._showHelpDialog.bind(this);
this._hiddenHelpDialog = this._hiddenHelpDialog.bind(this);
this._showSureDialog = this._showSureDialog.bind(this);
this._hiddenSureDialog = this._hiddenSureDialog.bind(this);
this._showWithDrawDialog = this._showWithDrawDialog.bind(this);
this._hiddenWithDrawDialog = this._hiddenWithDrawDialog.bind(this);
this._jumpWithUrl = this._jumpWithUrl.bind(this);
this._onPressProduct = this._onPressProduct.bind(this);
this._resourceJumpWithUrl = this._resourceJumpWithUrl.bind(this);
this._onEndReached = this._onEndReached.bind(this);
AsyncStorage.getItem(AsyncStorageKey, (error, value) => {
... ... @@ -76,6 +79,7 @@ class AllianceContainer extends Component {
componentDidMount() {
this.props.actions.getSettlementInfo();
this.props.actions.getResourceInfo();
this.props.actions.getRecentlyOrderLimitTen();
this.props.actions.getTop100List();
}
... ... @@ -104,6 +108,14 @@ class AllianceContainer extends Component {
this.props.actions.hiddenHelpDialog();
}
_showSureDialog() {
this.props.actions.showSureDialog();
}
_hiddenSureDialog() {
this.props.actions.hiddenSureDialog();
}
_showWithDrawDialog() {
this.props.actions.getAddSettlement();
}
... ... @@ -120,6 +132,10 @@ class AllianceContainer extends Component {
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
_resourceJumpWithUrl(url) {
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
_onPressProduct(product) {
let productSkn = product && product.get('product_skn', 0);
let is_global = product && product.get('is_global', 'N');
... ... @@ -149,9 +165,11 @@ class AllianceContainer extends Component {
render() {
let {
showHelpDialog,
showSureDialog,
showWithdrawalDialog,
settlementInfo,
addSettlement,
resourceInfo,
recentlyOrder,
topList
} = this.props.alliance;
... ... @@ -163,18 +181,23 @@ class AllianceContainer extends Component {
<Alliance
isShowGuide={isShowGuide}
isShowHelp={showHelpDialog}
isShowSure={showSureDialog}
isShowWithdrawal={showWithdrawalDialog}
settlementInfo={settlementInfo}
addSettlement={addSettlement}
resourceInfo={resourceInfo}
recentlyOrder={recentlyOrder}
topList={topList}
tips={tip}
hiddenGuideDialog={this._hiddenGuideDialog}
showHelpDialog={this._showHelpDialog}
hiddenHelpDialog={this._hiddenHelpDialog}
showSureDialog={this._showSureDialog}
hiddenSureDialog={this._hiddenSureDialog}
showWithdrawalDialog={this._showWithDrawDialog}
hiddenWithDrawDialog={this._hiddenWithDrawDialog}
jumpWithUrl={this._jumpWithUrl}
resourceJumpWithUrl={this._resourceJumpWithUrl}
onPressProduct={this._onPressProduct}
onEndReached={this._onEndReached}
/>
... ...
... ... @@ -9,6 +9,9 @@ const {
SHOW_HELP_DIALOG,
DISMISS_HELP_DIALOG,
SHOW_SURE_DIALOG,
DISMISS_SURE_DIALOG,
SHOW_WITHDRAW_DIALOG,
DISMISS_WITHDRAW_DIALOG,
... ... @@ -22,6 +25,10 @@ const {
ADD_SETTLEMENT_SUCCESS,
ADD_SETTLEMENT_FAILURE,
RESOURCE_INFO_REQUEST,
RESOURCE_INFO_SUCCESS,
RESOURCE_INFO_FAILURE,
RECENTLY_ORDER_REQUEST,
RECENTLY_ORDER_SUCCESS,
RECENTLY_ORDER_FAILURE,
... ... @@ -56,6 +63,18 @@ export function hiddenHelpDialog() {
}
}
export function showSureDialog() {
return {
type: SHOW_SURE_DIALOG,
}
}
export function hiddenSureDialog() {
return {
type: DISMISS_SURE_DIALOG,
}
}
export function showWithDrawDialog() {
return {
type: SHOW_WITHDRAW_DIALOG,
... ... @@ -115,6 +134,26 @@ export function addSettlementFailure(error) {
};
}
export function getResourceRequest() {
return {
type: RESOURCE_INFO_REQUEST,
};
}
export function getResourceSuccess(json) {
return {
type: RESOURCE_INFO_SUCCESS,
payload: json
};
}
export function getResourceFailure(error) {
return {
type: RESOURCE_INFO_FAILURE,
payload: error
};
}
export function recentlyOrderRequest() {
return {
type: RECENTLY_ORDER_REQUEST,
... ... @@ -268,6 +307,20 @@ export function getAddSettlement() {
};
}
export function getResourceInfo() {
return (dispatch, getState) => {
let {app} = getState();
dispatch(getResourceRequest());
return new AllianceService(app.host).fetchResourceInfo()
.then(json => {
dispatch(getResourceSuccess(json));
})
.catch(error => {
dispatch(getResourceFailure(error));
});
};
}
export function getRecentlyOrderLimitTen() {
return (dispatch, getState) => {
let {app} = getState();
... ...
... ... @@ -6,6 +6,7 @@ import {List, Map, Record} from 'immutable';
let InitialState = Record({
orderCode: 0,
showHelpDialog: false,
showSureDialog: false,
showWithdrawalDialog: false,
settlementInfo: new (Record({
... ... @@ -20,6 +21,12 @@ let InitialState = Record({
data: List(),
})),
resourceInfo: new (Record({
isFetching: false,
error: null,
resourceList: List(),
})),
recentlyOrder: new (Record({
isFetching: false,
error: null,
... ...
... ... @@ -7,6 +7,9 @@ const {
SHOW_HELP_DIALOG,
DISMISS_HELP_DIALOG,
SHOW_SURE_DIALOG,
DISMISS_SURE_DIALOG,
SHOW_WITHDRAW_DIALOG,
DISMISS_WITHDRAW_DIALOG,
... ... @@ -20,6 +23,10 @@ const {
ADD_SETTLEMENT_SUCCESS,
ADD_SETTLEMENT_FAILURE,
RESOURCE_INFO_REQUEST,
RESOURCE_INFO_SUCCESS,
RESOURCE_INFO_FAILURE,
RECENTLY_ORDER_REQUEST,
RECENTLY_ORDER_SUCCESS,
RECENTLY_ORDER_FAILURE,
... ... @@ -56,6 +63,14 @@ export default function couponReducer(state = initialState, action) {
case DISMISS_HELP_DIALOG: {
return state.set('showHelpDialog', false);
}
case SHOW_SURE_DIALOG: {
return state.set('showSureDialog', true);
}
case DISMISS_SURE_DIALOG: {
return state.set('showSureDialog', false);
}
case SHOW_WITHDRAW_DIALOG: {
return state.set('showWithdrawalDialog', true);
}
... ... @@ -90,15 +105,31 @@ export default function couponReducer(state = initialState, action) {
case ADD_SETTLEMENT_SUCCESS: {
return state.setIn(['addSettlement', 'isFetching'], true)
.set('showWithdrawalDialog', action.payload.isShow)
.setIn(['addSettlement', 'error'], null);
}
case ADD_SETTLEMENT_FAILURE: {
return state.setIn(['addSettlement', 'isFetching'], false)
.set('showWithdrawalDialog', action.payload.isShow)
.setIn(['addSettlement', 'error'], null);
}
case RESOURCE_INFO_REQUEST: {
return state.setIn(['resourceInfo', 'isFetching'], true)
.setIn(['resourceInfo', 'error'], action.payload);
}
case RESOURCE_INFO_SUCCESS: {
return state.setIn(['resourceInfo', 'isFetching'], false)
.setIn(['resourceInfo', 'resourceList'], Immutable.fromJS(action.payload))
.setIn(['resourceInfo', 'error'], null);
}
case RESOURCE_INFO_FAILURE: {
return state.setIn(['resourceInfo', 'isFetching'], false)
.setIn(['resourceInfo', 'error'], null);
}
case RECENTLY_ORDER_REQUEST: {
return state.setIn(['recentlyOrder', 'isFetching'], true)
.setIn(['recentlyOrder', 'error'], null);
... ...
... ... @@ -47,6 +47,24 @@ export default class AllianceService {
});
}
//获取资源位
async fetchResourceInfo() {
let fromPage = Platform.OS === 'android' ? 'aFP_Alliance' : 'iFP_Alliance';
return await this.api.get({
url: '/operations/api/v5/resource/get',
body: {
content_code: 'c2802b9fb47c148dff37ece842bf190e',
fromPage
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
//(用户前台获取个人推广近期订单(10个))
async fetchRecentlyOrderLimitTen(uid) {
return await this.api.get({
... ...