Authored by 张丽霞

分期已开通页面,review by redding

'use strict';
import React from 'react';
import ReactNative, {
View,
Text,
Image,
StyleSheet,
Dimensions,
PixelRatio,
TouchableOpacity,
ListView,
} from 'react-native';
import Immutable, {Map} from 'immutable';
import AlreadyOpenedHeader from './AlreadyOpenedHeader';
import AlreadyOpenedFooter from './AlreadyOpenedFooter';
import ProductListCell from '../../../common/components/ListCell/ProductListCell';
export default class AlreadyOpened extends React.Component {
constructor(props) {
super(props);
this._renderRow = this._renderRow.bind(this);
this._renderHeader = this._renderHeader.bind(this);
this._renderFooter = this._renderFooter.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
}
componentDidMount() {
this.props.getAlreadyPageInfo();
}
_renderRow(rowData, sectionID, rowID, highlightRow) {
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
let customStyle = rowID == 0 || rowID == 1 ? {paddingLeft} : {paddingLeft};
return (
<ProductListCell
style={[styles.listContainer, customStyle]}
key={'row' + rowID}
rowID={rowID}
data={rowData}
onPressProduct={this.props.onPressProductListProduct}
/>
);
}
_renderHeader() {
let {alreadyOpenedPageInfo} = this.props;
return (
<AlreadyOpenedHeader
alreadyOpenedPageInfo={alreadyOpenedPageInfo}
onPressTabBtn={this.props.onPressTabBtn}
onPressMoreProducts={this.props.onPressMoreProducts}
onPressProtocol={this.props.onPressProtocol}
/>
)
}
_renderFooter() {
let {alreadyOpenedPageInfo} = this.props;
return (
<AlreadyOpenedFooter
alreadyOpenedPageInfo={alreadyOpenedPageInfo}
onPressMoreProducts={this.props.onPressMoreProducts}
/>
)
}
render() {
let {alreadyOpenedPageInfo} = this.props;
let {tabFocusIndex,goods} = alreadyOpenedPageInfo;
let dataSource=[];
if (tabFocusIndex == 2) {
dataSource = alreadyOpenedPageInfo.goods.toArray();
}
return(
<View style={styles.container}>
<ListView
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRows(dataSource)}
renderRow={this._renderRow}
renderHeader={this._renderHeader}
renderFooter={this._renderFooter}
onEndReached={() => {
if (goods && goods.size > 0) {
this.props.onEndReached && this.props.onEndReached();
}
}}
/>
</View>
);
}
};
let {width, height} = Dimensions.get('window');
let rowWidth = Math.ceil(137.5 * width / 320);
let rowHeight = Math.ceil(254 * width / 320);
let rowMarginTop = Math.ceil(10 * width / 320);
let rowMarginHorizontal = (width - rowWidth * 2) / 3;
const DEVICE_WIDTH_RATIO = width / 320;
let tabBtnWidth = (width - 30) / 2;
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
},
contentContainer:{
flexDirection: 'row',
flexWrap: 'wrap',
},
tabBarContainer: {
width: width,
height: 44 * DEVICE_WIDTH_RATIO,
backgroundColor: 'black',
flexDirection: 'row',
},
tabBtnFocus: {
textAlign: 'center',
width: tabBtnWidth,
height: 44 * DEVICE_WIDTH_RATIO,
fontSize: 17 * DEVICE_WIDTH_RATIO,
lineHeight: 31 * DEVICE_WIDTH_RATIO,
backgroundColor: 'transparent',
color: 'white',
},
tabBtnUnfocus: {
textAlign: 'center',
width: tabBtnWidth,
height: 44 * DEVICE_WIDTH_RATIO,
fontSize: 17 * DEVICE_WIDTH_RATIO,
lineHeight: 31 * DEVICE_WIDTH_RATIO,
backgroundColor: 'transparent',
color: '#b0b0b0',
},
listContainer: {
width: width / 2,
},
});
... ...
'use strict';
import React from 'react';
import ReactNative, {
View,
Text,
Image,
StyleSheet,
Dimensions,
PixelRatio,
TouchableOpacity,
ListView,
Platform,
DeviceInfo,
} from 'react-native';
import Immutable, {Map} from 'immutable';
export default class AlreadyOpenedFooter extends React.Component {
constructor(props) {
super(props);
}
render() {
let {tabFocusIndex,creditInfo,goods,installmentInfo} = this.props.alreadyOpenedPageInfo;
return(
<View style={styles.container}>
{tabFocusIndex==1?
<View style={styles.bottomCellsContainer}>
<View style={{
width: width,
height: 15 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.monthRepay && this.props.monthRepay();
}}>
<View style={styles.cellContainer}>
<Text style={styles.cellTitle}>本月待还金额:</Text>
<View style={styles.cellLeftContainer}>
<Text style={styles.cellPrice}>¥{installmentInfo.get('monthAmt')}</Text>
<Image source={require("../../image/category_b_arrow.png")}/>
</View>
</View>
</TouchableOpacity>
<View style={{
marginLeft: 15 * DEVICE_WIDTH_RATIO,
width: width,
height: 0.5 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.totalRepayCell && this.props.totalRepayCell();
}}>
<View style={styles.cellContainer}>
<Text style={styles.cellTitle}>待还总金额:</Text>
<View style={styles.cellLeftContainer}>
<Text style={styles.cellPrice}>¥{installmentInfo.get('totalAmt')}</Text>
<Image source={require("../../image/category_b_arrow.png")}/>
</View>
</View>
</TouchableOpacity>
<View style={{
marginLeft: 15 * DEVICE_WIDTH_RATIO,
width: width,
height: 0.5 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.repayRecordCell && this.props.repayRecordCell();
}}>
<View style={styles.cellContainer}>
<Text style={styles.cellTitle}>还款记录:</Text>
<View style={styles.cellLeftContainer}>
<Image source={require("../../image/category_b_arrow.png")}/>
</View>
</View>
</TouchableOpacity>
<View style={{
marginLeft: 15 * DEVICE_WIDTH_RATIO,
width: width,
height: 0.5 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.installmentOrderCell && this.props.installmentOrderCell();
}}>
<View style={styles.cellContainer}>
<Text style={styles.cellTitle}>分期订单:</Text>
<View style={styles.cellLeftContainer}>
<Image source={require("../../image/category_b_arrow.png")}/>
</View>
</View>
</TouchableOpacity>
<View style={{
width: width,
height: 15 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.installmentAccountCell && this.props.installmentAccountCell();
}}>
<View style={styles.cellContainer}>
<Text style={styles.cellTitle}>账户管理:</Text>
<View style={styles.cellLeftContainer}>
<Image source={require("../../image/category_b_arrow.png")}/>
</View>
</View>
</TouchableOpacity>
</View>
:<TouchableOpacity activeOpacity={0.5} onPress={() => {
this.props.onPressMoreProducts && this.props.onPressMoreProducts(this.props.moreUrl);
}}>
<View style={styles.moreBtnContainer}>
<Text style={styles.moreProductBtn}>
查看更多可分期商品
</Text>
</View>
</TouchableOpacity>
}
</View>
);
}
};
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let containerHeight = 74 * DEVICE_WIDTH_RATIO;
let styles = StyleSheet.create({
container: {
flex: 1,
width: width,
backgroundColor: '#e5e5e5',
},
bottomCellsContainer: {
backgroundColor: 'white',
},
moreBtnContainer: {
borderRadius: 5,
margin: 15 * DEVICE_WIDTH_RATIO,
height: 44 * DEVICE_WIDTH_RATIO,
alignItems: 'center',
backgroundColor: '#444444',
},
moreProductBtn: {
width: width,
fontSize: 13 * DEVICE_WIDTH_RATIO,
textAlign: 'center',
height: 44 * DEVICE_WIDTH_RATIO,
lineHeight: 29 * DEVICE_WIDTH_RATIO,
backgroundColor: 'transparent',
color: 'white',
},
cellContainer: {
width: width,
flexDirection: 'row',
justifyContent: 'space-between',
height: 40 * DEVICE_WIDTH_RATIO,
},
cellTitle: {
marginLeft: 15 * DEVICE_WIDTH_RATIO,
fontSize: 12 * DEVICE_WIDTH_RATIO,
lineHeight: 26 * DEVICE_WIDTH_RATIO,
},
cellPrice: {
color: '#b0b0b0',
marginRight: 5 * DEVICE_WIDTH_RATIO,
},
cellLeftContainer: {
marginRight: 15 * DEVICE_WIDTH_RATIO,
flexDirection: 'row',
alignItems: 'center',
}
});
... ...
'use strict';
import React from 'react';
import ReactNative, {
View,
Text,
Image,
StyleSheet,
Dimensions,
PixelRatio,
TouchableOpacity,
ListView,
Platform,
DeviceInfo,
} from 'react-native';
import Immutable, {Map} from 'immutable';
export default class AlreadyOpenedHeader extends React.Component {
constructor(props) {
super(props);
}
render() {
let {tabFocusIndex,creditInfo,goods,installmentInfo,isOverdue} = this.props.alreadyOpenedPageInfo;
if (tabFocusIndex == 2 && goods && goods.size > 0) {
containerHeight = (44 + 175 + 15 + 42 + 0.5) * DEVICE_WIDTH_RATIO;
}else {
containerHeight = (44 + 175) * DEVICE_WIDTH_RATIO;
}
return(
<View style={[styles.container,{height: containerHeight}]}>
<View style={styles.tabBarContainer}>
<TouchableOpacity activeOpacity={1} onPress={() => {this.props.onPressTabBtn &&this.props.onPressTabBtn(1)}} >
{tabFocusIndex==1?
<Text style={styles.tabBtnFocus}>
待还款金额
</Text>
:<Text style={styles.tabBtnUnfocus}>
待还款金额
</Text>
}
</TouchableOpacity>
<View style={{width: 0.5,height:23*DEVICE_WIDTH_RATIO,marginTop:10*DEVICE_WIDTH_RATIO,backgroundColor:'white'}} />
<TouchableOpacity activeOpacity={1} onPress={() => {this.props.onPressTabBtn &&this.props.onPressTabBtn(2)}} >
{tabFocusIndex==1?
<Text style={styles.tabBtnUnfocus}>
可用额度
</Text>
:<Text style={styles.tabBtnFocus}>
可用额度
</Text>
}
</TouchableOpacity>
</View>
{tabFocusIndex==1?
<View style={styles.imageContainer}>
<Image style={styles.bgImage} source={require("../../image/header_bg.png")}/>
<Text style={[styles.imageText,styles.text1]}>近七日待还款</Text>
<Text style={[styles.imageText,{fontSize:12*DEVICE_WIDTH_RATIO,marginTop:5*DEVICE_WIDTH_RATIO,marginBottom:5*DEVICE_WIDTH_RATIO}]}>¥
<Text style={[styles.imageText,styles.text2]}>
{installmentInfo.get('dayAmt')}
</Text>
</Text>
{isOverdue?
<Text style={[styles.imageText,{fontSize:12*DEVICE_WIDTH_RATIO,marginBottom:15*DEVICE_WIDTH_RATIO}]}>您有¥{creditInfo.get('initCreditLimit')}已逾期,点击
<TouchableOpacity activeOpacity={0.5} onPress={() => {
this.props.onPressOverdue && this.props.onPressOverdue();
}}>
<View style={{borderColor:'white',borderBottomWidth:0.5*DEVICE_WIDTH_RATIO}}>
<Text style={[styles.imageText]}>查看详情</Text>
</View>
</TouchableOpacity>
</Text>
:null
}
<TouchableOpacity activeOpacity={0.5} onPress={() => {
this.props.onPressProtocol && this.props.onPressProtocol();
}}>
<View style={{width:95*DEVICE_WIDTH_RATIO,height:30*DEVICE_WIDTH_RATIO,borderRadius:15*DEVICE_WIDTH_RATIO,alignItems:'center',backgroundColor:'rgba(69, 74, 76, 0.5)',marginTop:15*DEVICE_WIDTH_RATIO}}>
<Text style={[styles.imageText,{lineHeight:20*DEVICE_WIDTH_RATIO}]}>明细</Text>
</View>
</TouchableOpacity>
</View>
:<View style={styles.imageContainer}>
<Image style={styles.bgImage} source={require("../../image/header_bg.png")}/>
<Text style={[styles.imageText,styles.text1]}>可用额度</Text>
<Text style={[styles.imageText,{fontSize:12*DEVICE_WIDTH_RATIO,marginTop:5*DEVICE_WIDTH_RATIO,marginBottom:5*DEVICE_WIDTH_RATIO}]}>¥
<Text style={[styles.imageText,styles.text2]}>
{creditInfo.get('currCreditLimit')}
</Text>
</Text>
<Text style={[styles.imageText,{fontSize:12*DEVICE_WIDTH_RATIO,marginBottom:15*DEVICE_WIDTH_RATIO}]}>总额度:¥{creditInfo.get('initCreditLimit')}</Text>
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.onPressProtocol && this.props.onPressProtocol();
}}>
<View style={{borderColor:'white',borderBottomWidth:0.5*DEVICE_WIDTH_RATIO}}>
<Text style={[styles.imageText]}>服务条款</Text>
</View>
</TouchableOpacity>
</View>
}
{tabFocusIndex==2&&goods&&goods.size>0?
<View style={styles.installmentOnlyHeader}>
<View style={{
width: width,
height: 15 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
<View style={styles.titleContainer}>
<Text style={styles.productText}>分期专享</Text>
<TouchableOpacity activeOpacity={0.5} onPress={() => {
this.props.onPressMoreProducts && this.props.onPressMoreProducts(this.props.moreUrl);
}}>
<Image
source={require('../../image/btn_more_p.png')}
style={{width: 22*DEVICE_WIDTH_RATIO, height: 4*DEVICE_WIDTH_RATIO,backgroundColor:'white',marginRight:15*DEVICE_WIDTH_RATIO,marginTop:21*DEVICE_WIDTH_RATIO,}}
resizeMode={'contain'}
/>
</TouchableOpacity>
</View>
<View style={{
width: width,
height: 0.5 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
</View>
:null
}
</View>
);
}
};
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let tabBtnWidth = (width - 30) / 2;
let imageContainerWidth = width - 52 * DEVICE_WIDTH_RATIO;
let containerHeight = (44 + 175) * DEVICE_WIDTH_RATIO;
let styles = StyleSheet.create({
container: {
flex: 1,
width:width,
height: containerHeight,
backgroundColor: 'white',
},
tabBarContainer: {
width: width,
height: 44 * DEVICE_WIDTH_RATIO,
backgroundColor: 'black',
flexDirection: 'row',
},
tabBtnFocus: {
textAlign: 'center',
width: tabBtnWidth,
height: 44 * DEVICE_WIDTH_RATIO,
fontSize: 17 * DEVICE_WIDTH_RATIO,
lineHeight: 31 * DEVICE_WIDTH_RATIO,
backgroundColor: 'transparent',
color: 'white',
},
tabBtnUnfocus: {
textAlign: 'center',
width: tabBtnWidth,
height: 44 * DEVICE_WIDTH_RATIO,
fontSize: 17 * DEVICE_WIDTH_RATIO,
lineHeight: 31 * DEVICE_WIDTH_RATIO,
backgroundColor: 'transparent',
color: '#b0b0b0',
},
imageContainer: {
width: width,
height: 175 * DEVICE_WIDTH_RATIO,
position: 'relative',
alignItems: 'center',
},
bgImage: {
position: 'absolute',
width: width,
height: 175 * DEVICE_WIDTH_RATIO,
resizeMode: 'cover',
},
imageText: {
backgroundColor: 'transparent',
color: 'white',
},
text1: {
marginTop: 25 * DEVICE_WIDTH_RATIO,
fontSize: 12 *DEVICE_WIDTH_RATIO,
},
text2: {
marginTop: 15 * DEVICE_WIDTH_RATIO,
fontSize: 24 * DEVICE_WIDTH_RATIO,
marginBottom: 5 * DEVICE_WIDTH_RATIO,
},
titleContainer: {
width: width,
flexDirection: 'row',
justifyContent: 'space-between',
height: 42 * DEVICE_WIDTH_RATIO,
},
productText:{
width: imageContainerWidth,
marginLeft: 15 * DEVICE_WIDTH_RATIO,
alignItems: 'center',
justifyContent: 'center',
height: 42 * DEVICE_WIDTH_RATIO,
fontSize: 16 * DEVICE_WIDTH_RATIO,
lineHeight: 29 * DEVICE_WIDTH_RATIO,
textAlign:'center',
textAlignVertical:'center',
backgroundColor: 'white',
},
});
... ...
... ... @@ -25,6 +25,10 @@ export default class Installment extends React.Component {
});
}
componentDidMount() {
this.props.getNewUserPageInfo();
}
_renderRow(rowData, sectionID, rowID, highlightRow) {
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
let customStyle = rowID == 0 || rowID == 1 ? {paddingLeft} : {paddingLeft};
... ... @@ -88,8 +92,8 @@ let styles = StyleSheet.create({
contentContainer:{
flexDirection: 'row',
flexWrap: 'wrap',
},
},
listContainer: {
width: width / 2,
},
});
\ No newline at end of file
},
});
... ...
... ... @@ -25,4 +25,13 @@ export default keyMirror({
SET_INSTALLMENT_STATUS_PAGE_ORIGINAL_INFO: null,
SET_INSTALLMENT_STATUS_PAGE_GOODS: null,
SET_STATUS_PAGE_ADVERTISEMENT: null,
SET_ALREADY_PAGE_TAB_FOCUS_INDEX: null,
SET_ALREADY_PAGE_GOODS: null,
SET_ALREADY_PAGE_CONTENT: null,
SET_ALREADY_PAGE_NOTICE: null,
SET_ALREADY_PAGE_AMT_INFO: null,
SET_ALREADY_PAGE_OVERDUE_STATUS: null,
SET_ALREADY_PAGE_CREDIT_INFO: null,
});
... ...
... ... @@ -16,6 +16,9 @@ import {connect} from 'react-redux';
import {Map} from 'immutable';
import * as installmentActions from '../reducers/installment/installmentActions';
import Installment from '../components/installment/Installment';
import AlreadyOpened from '../components/installment/AlreadyOpened';
import InstallmentStatus from '../components/installment/InstallmentStatus';
const actions = [
installmentActions,
];
... ... @@ -41,11 +44,24 @@ class InstallmentContainer extends Component {
super(props);
this._onPressOpenInstallment = this._onPressOpenInstallment.bind(this);
this._onPressMoreProducts = this._onPressMoreProducts.bind(this);
this._onPressTabBtn = this._onPressTabBtn.bind(this);
this._getAlreadyPageInfo = this._getAlreadyPageInfo.bind(this);
this._getNewUserPageInfo = this._getNewUserPageInfo.bind(this);
this._onPressMoreProducts = this._onPressMoreProducts.bind(this);
this._onPressProtocol = this._onPressProtocol.bind(this);
}
componentDidMount() {
this.props.actions.getInstallmentStatus();
}
_getNewUserPageInfo() {
this.props.actions.productListForInstallment();
}
_getAlreadyPageInfo() {
this.props.actions.getAlreadyPageInfo();
}
_onPressOpenInstallment() {
this.props.actions.onPressOpenInstallment();
}
... ... @@ -54,17 +70,50 @@ class InstallmentContainer extends Component {
this.props.actions.onPressMoreProducts();
}
_onPressTabBtn(index) {
this.props.actions.setAlreadyPageTabFocusIndex(index);
}
_onPressProtocol() {
this.props.actions.onPressTabBtn();
}
render() {
let {isFetching,open,installmentStatus} = this.props.installment;
return (
<Installment
isFetching={open.isFetching}
productListForInstallment={open.productListForInstallment}
installmentInfo={open.installmentInfo}
onPressOpenInstallment={this._onPressOpenInstallment}
onPressMoreProducts={this._onPressMoreProducts}
/>
);
let {isFetching,open,alreadyOpenedPageInfo,installmentStatus,installmentStausPageInfo} = this.props.installment;
let {status} = installmentStatus;
if (status == 'New') {
return (
<Installment
getNewUserPageInfo={this._getNewUserPageInfo}
isFetching={open.isFetching}
productListForInstallment={open.productListForInstallment}
installmentInfo={open.installmentInfo}
onPressOpenInstallment={this._onPressOpenInstallment}
onPressMoreProducts={this._onPressMoreProducts}
/>
);
} else if (status == 'AlreadyOpned') {
return (
<AlreadyOpened
alreadyOpenedPageInfo={alreadyOpenedPageInfo}
onPressTabBtn={this._onPressTabBtn}
getAlreadyPageInfo={this._getAlreadyPageInfo}
onPressMoreProducts={this._onPressMoreProducts}
onPressProtocol={this._onPressProtocol}
/>
);
} else if (status == 'OpenStatus') {
let status = '5';
let failReason = '您的授信未通过,在有货更多的消费,增加信用度,会大大提升审核通过率奥。';
let uid = '5448919';
this.props.actions.setInstallmentStausPageParams(status,failReason,uid);
return (
<InstallmentStatus/>
)
} else {
return null;
}
}
}
let styles = StyleSheet.create({
... ...
... ... @@ -28,6 +28,15 @@ NEXT_BTN_PROCESSING_FAILURE,
SET_INSTALLMENT_STATUS_PAGE_ORIGINAL_INFO,
SET_INSTALLMENT_STATUS_PAGE_GOODS,
SET_STATUS_PAGE_ADVERTISEMENT,
SET_ALREADY_PAGE_TAB_FOCUS_INDEX,
SET_ALREADY_PAGE_GOODS,
SET_ALREADY_PAGE_CONTENT,
SET_ALREADY_PAGE_NOTICE,
SET_ALREADY_PAGE_AMT_INFO,
SET_ALREADY_PAGE_OVERDUE_STATUS,
SET_ALREADY_PAGE_CREDIT_INFO,
} = require('../../constants/actionTypes').default;
const codeContent = {
... ... @@ -60,9 +69,10 @@ export function productListForInstallmentFailure(){
}
}
export function featchInstallmentStatusRequest() {
export function featchInstallmentStatusRequest(uid) {
return {
type: GET_INSTALLMENT_STATUS_REQUEST,
payload: uid
}
}
... ... @@ -159,6 +169,62 @@ export function setInstallmentStatusPageGoods(goods) {
}
}
export function setStatusPageAdvertisement(advertisement) {
return {
type: SET_STATUS_PAGE_ADVERTISEMENT,
payload: advertisement
}
}
export function setAlreadyPageTabFocusIndex(index) {
return {
type: SET_ALREADY_PAGE_TAB_FOCUS_INDEX,
payload: index
}
}
export function setAlreadPageGoods(goods) {
return {
type: SET_ALREADY_PAGE_GOODS,
payload: goods
}
}
export function setAlreadPageContent(content) {
return {
type: SET_ALREADY_PAGE_CONTENT,
payload: content
}
}
export function setAlreadPageNotices(notice) {
return {
type: SET_ALREADY_PAGE_NOTICE,
payload: notice
}
}
export function setAlreadPageAmtInfo(info) {
return {
type: SET_ALREADY_PAGE_AMT_INFO,
payload: info
}
}//
export function setAlreadPageOverdueStatus(status) {
return {
type: SET_ALREADY_PAGE_OVERDUE_STATUS,
payload: status
}
}
export function setAlreadPageCreditInfo(creditInfo) {
return {
type: SET_ALREADY_PAGE_CREDIT_INFO,
payload: creditInfo,
}
}
export function productListForInstallment() {
return (dispatch, getState) => {
let {app, installment} = getState();
... ... @@ -217,14 +283,26 @@ export function getInstallmentStatus() {
let installmentStatus = (uid) => {
let {app, installment} = getState();
dispatch(featchInstallmentStatusRequest());
dispatch(featchInstallmentStatusRequest(uid));
return new InstallmentService(app.host).getStauts(uid)
.then(json => {
let status = 0;
if (json.status) {
status = json.status;
let status = 'New';
switch (json.status) {
case '0':
status = 'New';
break;
case '2':
status = 'AlreadyOpned';
break;
case '1':
case '3':
case '4':
case '5':
status = 'OpenStatus';
break;
default:
}
dispatch(productListForInstallment());
dispatch(featchInstallmentStatusSuccess(status));
})
.catch(error => {
dispatch(featchInstallmentStatusFailure(error));
... ... @@ -261,10 +339,10 @@ export function onPressOpenNext() {
let {nextBtnEnable,cellList,nextProcessing} = installment.openPageInfo;
let activateParams = {};
let newCellList = cellList;
if (!nextBtnEnable) {
return;
}
// ReactNative.NativeModules.YH_InstallmentHelper.gotoInstallmentStatusView('5', '您的授信未通过,在有货更多的消费,增加信用度,会大大提升审核通过率奥。');
// if (!nextBtnEnable) {
// return;
// }
ReactNative.NativeModules.YH_InstallmentHelper.gotoInstallmentStatusView('2', '您的授信未通过,在有货更多的消费,增加信用度,会大大提升审核通过率奥。');
return;
cellList.map((item, i) => {
if (item.get('inputKey') != 'BankIcon') {
... ... @@ -273,11 +351,9 @@ export function onPressOpenNext() {
});
let activateService = (uid) => {
dispatch(nextBtnProcessingRequest());
console.log('----0000');
return new InstallmentService(app.host).checkVerifyCode(uid, activateParams.mobile, activateParams.snsCheckCode)
.then(json => {
if (json.result === '1') {
return new InstallmentService(app.host).activateService(activateParams)
}else {
newCellList.map((item, i) => {
... ... @@ -515,7 +591,7 @@ export function onPressCheckCode() {
if (snsCheckCodeEnable && snsCheckCodeText == '获取验证码') {
return new InstallmentService(app.host).sendVerifyCode('17705176933')
.then(json => {
let status = 0;
let snsText = '';
new Timer().startCountdown(function() {
... ... @@ -547,8 +623,6 @@ export function setInstallmentStausPageParams(statusCode, failReason, uid) {
//请求用户信用额度
return new InstallmentService(app.host).getQueryCreditInfo('5448919')
.then(json => {
console.log('---额度');
console.log(json);
status = 'success',
statusInfo = {
message: '可用额度',
... ... @@ -627,11 +701,17 @@ export function setInstallmentStausPageParams(statusCode, failReason, uid) {
export function getInstallmentProductAndAdvertisement(page) {
return (dispatch, getState) => {
let {app, installment} = getState();
return new InstallmentService(app.host).getSearchIntallment(page)
return new InstallmentService(app.host).fetchInstallmentProductList(page)
.then(json => {
dispatch(setInstallmentStatusPageGoods(json.product_list))
console.log('goods');
console.log(json);
let content_code = codeContent['advertisement'];
return new InstallmentService(app.serviceHost).getResources(content_code)
})
.then(json => {
let advertisement = false;
if (json && json.length > 1) {
advertisement = json[0].data[0];
}
})
.catch(error => {
});
... ... @@ -650,3 +730,83 @@ export function onPressStatusPageBtn(page) {
}
};
}
function getAlreadPageGoods() {
return (dispatch, getState) => {
let {app, installment} = getState();
return new InstallmentService(app.host).fetchInstallmentProductList(1)
.then(json => {
dispatch(setAlreadPageGoods(json.product_list))
})
.catch(error => {
});
};
}
function getAlreadPageResources() {
return (dispatch, getState) => {
let {app, installment} = getState();
let content_code = codeContent['openY'];
return new InstallmentService(app.serviceHost).getResources(content_code)
.then(json => {
dispatch(setAlreadPageContent(json))
})
.catch(error => {
});
};
}
function getAlreadPageNotices() {
return (dispatch, getState) => {
let {app, installment} = getState();
return new InstallmentService(app.host).getNotices()
.then(json => {
dispatch(setAlreadPageNotices(json))
})
.catch(error => {
});
};
}
function getAlreadPageAmtInfo(uid) {
return (dispatch, getState) => {
let {app, installment} = getState();
return new InstallmentService(app.host).getAmtInfo(uid)
.then(json => {
json.dayAmt = json.s_7daysAmt;
dispatch(setAlreadPageAmtInfo(json))
})
.catch(error => {
});
};
}
function getAlreadPageCreditInfo(uid) {
return (dispatch, getState) => {
let {app, installment} = getState();
return new InstallmentService(app.host).getQueryCreditInfo(uid)
.then(json => {
dispatch(setAlreadPageCreditInfo(json))
})
.catch(error => {
});
};
}
export function getAlreadyPageInfo() {
return (dispatch, getState) => {
let {app, installment} = getState();
let {uid} = installment;
dispatch(getAlreadPageGoods());
dispatch(getAlreadPageResources());
dispatch(getAlreadPageNotices());
dispatch(getAlreadPageAmtInfo(uid));
dispatch(getAlreadPageCreditInfo(uid));
};
}
export function onPressTabBtn() {
return (dispatch, getState) => {
ReactNative.NativeModules.YH_InstallmentHelper.helpAction();
};
}
... ...
... ... @@ -44,9 +44,10 @@ let banks = ['农业银行', '中国银行', '工商银行', '建设银行', '
let InitialState = Record({
isFetching:false,
uid: '',
installmentStatus:new (Record({
isFetching:false,
status: 0,
status: '',
error: null,
})),
open:new (Record({
... ... @@ -57,6 +58,15 @@ let InitialState = Record({
})),
installmentInfo:'',
})),
alreadyOpenedPageInfo:new (Record({
tabFocusIndex: 1,
goods: List(),
isOverdue: false,
content: Map(),
notice: Map(),
installmentInfo:Map(),
creditInfo: Map(),
})),
openPageInfo:new (Record({ //开通有货分期页面数据
cellList: Immutable.fromJS(openPageParams),
agreeProtocol: true,
... ... @@ -76,6 +86,7 @@ let InitialState = Record({
jumpUrl: '',
statusInfo:Map(),
goods: List(),
advertisement: false,
})),
});
... ...
... ... @@ -28,6 +28,15 @@ const {
SET_INSTALLMENT_STATUS_PAGE_ORIGINAL_INFO,
SET_INSTALLMENT_STATUS_PAGE_GOODS,
SET_STATUS_PAGE_ADVERTISEMENT,
SET_ALREADY_PAGE_TAB_FOCUS_INDEX,
SET_ALREADY_PAGE_GOODS,
SET_ALREADY_PAGE_CONTENT,
SET_ALREADY_PAGE_NOTICE,
SET_ALREADY_PAGE_AMT_INFO,
SET_ALREADY_PAGE_OVERDUE_STATUS,
SET_ALREADY_PAGE_CREDIT_INFO,
} = require('../../constants/actionTypes').default;
... ... @@ -50,7 +59,8 @@ export default function appReducer(state = initialState, action) {
return state.setIn(['open', 'productListForInstallment'], productListForInstallment);
}
case GET_INSTALLMENT_STATUS_REQUEST:
return state.setIn(['installmentStatus', 'isFetching'], true);
return state.setIn(['installmentStatus', 'isFetching'], true)
.set('uid',action.payload);
case GET_INSTALLMENT_STATUS_SUCCESS:
return state.setIn(['installmentStatus', 'isFetching'], false)
.setIn(['installmentStatus', 'status'], action.payload);
... ... @@ -87,6 +97,22 @@ export default function appReducer(state = initialState, action) {
.setIn(['installmentStausPageInfo', 'statusInfo'], Immutable.fromJS(action.payload.statusInfo));
case SET_INSTALLMENT_STATUS_PAGE_GOODS:
return state.setIn(['installmentStausPageInfo', 'goods'], Immutable.fromJS(action.payload));
case SET_STATUS_PAGE_ADVERTISEMENT:
return state.setIn(['installmentStausPageInfo', 'advertisement'], action.payload);
case SET_ALREADY_PAGE_TAB_FOCUS_INDEX:
return state.setIn(['alreadyOpenedPageInfo', 'tabFocusIndex'], action.payload);
case SET_ALREADY_PAGE_GOODS:
return state.setIn(['alreadyOpenedPageInfo', 'goods'], Immutable.fromJS(action.payload));
case SET_ALREADY_PAGE_CONTENT:
return state.setIn(['alreadyOpenedPageInfo', 'content'], Immutable.fromJS(action.payload));
case SET_ALREADY_PAGE_NOTICE:
return state.setIn(['alreadyOpenedPageInfo', 'notice'], Immutable.fromJS(action.payload));
case SET_ALREADY_PAGE_AMT_INFO:
return state.setIn(['alreadyOpenedPageInfo', 'installmentInfo'], Immutable.fromJS(action.payload));
case SET_ALREADY_PAGE_OVERDUE_STATUS:
return state.setIn(['alreadyOpenedPageInfo', 'isOverdue'], Immutable.fromJS(action.payload));
case SET_ALREADY_PAGE_CREDIT_INFO:
return state.setIn(['alreadyOpenedPageInfo', 'creditInfo'], Immutable.fromJS(action.payload));
}
return state;
... ...
... ... @@ -10,6 +10,8 @@ export default class InstallmentService {
}
this.api = new Request(baseURL);
}
// 分期专享推荐商品
async fetchInstallmentProductList(page=1) {
return await this.api.get({
url: '',
... ... @@ -28,6 +30,7 @@ export default class InstallmentService {
});
}
// 获取分期开通状态
async getStauts(uid) {
return await this.api.get({
url: '',
... ... @@ -44,6 +47,7 @@ export default class InstallmentService {
});
}
// 获取短信验证码
async sendVerifyCode(mobile) {
return await this.api.get({
url: '',
... ... @@ -62,6 +66,7 @@ export default class InstallmentService {
});
}
// 获取银行信息
async fentchBankInfo(cardNo,uid) {
return await this.api.get({
url: '',
... ... @@ -130,14 +135,13 @@ export default class InstallmentService {
});
}
async getSearchIntallment(page) {
// 获取用户可用额度信息
async getQueryCreditInfo(uid) {
return await this.api.get({
url: '',
body: {
method: 'app.search.instalment',
limit: '50',
order: 's_t_desc',
page: page
method: 'user.instalment.queryCreditLimit',
uid,
}
})
.then((json) => {
... ... @@ -148,11 +152,32 @@ export default class InstallmentService {
});
}
async getQueryCreditInfo(uid) {
/**
* 获取资源位数据
* @return {[array]}
*/
async getResources(content_code) {
return await this.api.get({
url: '/operations/api/v5/resource/get',
body: {
content_code,
platform: 'iphone'
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
// 获取用户待还款金额
async getAmtInfo(uid) {
return await this.api.get({
url: '',
body: {
method: 'user.instalment.queryCreditLimit',
method: 'app.order.queryAmtInfo',
uid,
}
})
... ... @@ -164,12 +189,14 @@ export default class InstallmentService {
});
}
async getResources(content_code) {
return await this.serviceAPI.get({
url: '/operations/api/v5/resource/get',
// 公告
async getNotices() {
return await this.api.get({
url: '',
body: {
content_code,
platform: 'iphone'
method: 'app.resources.getNotices',
position: 8,
client_type: 'iphone'
}
})
.then((json) => {
... ...