Authored by 张丽霞

还款页面,review by redding

Showing 22 changed files with 866 additions and 493 deletions
... ... @@ -16,11 +16,14 @@ import configureStore from './store/configureStore';
import {Record, List, Map} from 'immutable';
import appInitialState from './reducers/app/appInitialState';
import installmentInitialState from './reducers/installment/installmentInitialState';
import installmentInitialState from './reducers/installment/installment/installmentInitialState';
import newRegisterInitialState from './reducers/installment/newRegister/newRegisterInitialState';
import repayListInitialState from './reducers/installment/repayList/repayListInitialState';
import InstallmentContainer from './containers/InstallmentContainer';
import OpenContainer from './containers/OpenContainer';
import InstallmentStatusContainer from './containers/InstallmentStatusContainer';
import RepayListContainer from './containers/RepayListContainer';
import {
setPlatform,
... ... @@ -29,12 +32,14 @@ import {
import {
setInstallmentStausPageParams,
} from './reducers/installment/installmentActions';
} from './reducers/installment/installment/installmentActions';
function getInitialState() {
const _initState = {
app: (new appInitialState()),
installment: (new installmentInitialState()),
newRegister: (new newRegisterInitialState()),
repayList: (new repayListInitialState()),
};
return _initState;
}
... ... @@ -71,6 +76,12 @@ export default function native(platform) {
<InstallmentStatusContainer />
</Provider>
)
} else if (type == 'repayList') {
return (
<Provider store={store}>
<RepayListContainer />
</Provider>
);
}
}
... ...
... ... @@ -52,6 +52,7 @@ export default class AlreadyOpened extends React.Component {
onPressTabBtn={this.props.onPressTabBtn}
onPressMoreProducts={this.props.onPressMoreProducts}
onPressProtocol={this.props.onPressProtocol}
gotoRepayListPageWithDays={this.props.gotoRepayListPageWithDays}
/>
)
}
... ... @@ -62,6 +63,10 @@ export default class AlreadyOpened extends React.Component {
<AlreadyOpenedFooter
alreadyOpenedPageInfo={alreadyOpenedPageInfo}
onPressMoreProducts={this.props.onPressMoreProducts}
gotoRepayListPageWithDays={this.props.gotoRepayListPageWithDays}
repayRecordCell={this.props.repayRecordCell}
installmentOrderCell={this.props.installmentOrderCell}
installmentAccountCell={this.props.installmentAccountCell}
/>
)
}
... ...
... ... @@ -34,7 +34,7 @@ export default class AlreadyOpenedFooter extends React.Component {
}}/>
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.monthRepay && this.props.monthRepay();
this.props.gotoRepayListPageWithDays && this.props.gotoRepayListPageWithDays('30');
}}>
<View style={styles.cellContainer}>
<Text style={styles.cellTitle}>本月待还金额:</Text>
... ... @@ -52,7 +52,7 @@ export default class AlreadyOpenedFooter extends React.Component {
}}/>
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.totalRepayCell && this.props.totalRepayCell();
this.props.gotoRepayListPageWithDays && this.props.gotoRepayListPageWithDays('0');
}}>
<View style={styles.cellContainer}>
<Text style={styles.cellTitle}>待还总金额:</Text>
... ...
... ... @@ -66,7 +66,7 @@ export default class AlreadyOpenedHeader extends React.Component {
{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();
this.props.gotoRepayListPageWithDays && this.props.gotoRepayListPageWithDays('-1');
}}>
<View style={{borderColor:'white',borderBottomWidth:0.5*DEVICE_WIDTH_RATIO}}>
<Text style={[styles.imageText]}>查看详情</Text>
... ... @@ -75,9 +75,7 @@ export default class AlreadyOpenedHeader extends React.Component {
</Text>
:null
}
<TouchableOpacity activeOpacity={0.5} onPress={() => {
this.props.onPressProtocol && this.props.onPressProtocol();
}}>
<TouchableOpacity activeOpacity={0.5} onPress={() => {this.props.gotoRepayListPageWithDays &&this.props.gotoRepayListPageWithDays('7')}} >
<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>
... ...
... ... @@ -15,6 +15,7 @@ import ReactNative, {
import Immutable, {Map} from 'immutable';
import OpenPageInputCell from './OpenPageInputCell';
import Prompt from '../../../coupon/components/coupon/Prompt';
import SlicedImage from '../../../common/components/SlicedImage';
export default class Open extends React.Component {
constructor(props) {
... ... @@ -28,44 +29,40 @@ export default class Open extends React.Component {
}
_renderRow(rowData, sectionID, rowID, highlightRow) {
let {bankInfo} = this.props.openPageInfo;
if (!rowData) {
return null
}
if (rowData.get('inputKey') == 'BankIcon') {
rowData = rowData.toJS();
if ( rowData.show == true) {
let imageUrl = '';
if (rowData.bankCode != '') {
let imageName = rowData.bankCode +'';
// imageUrl = require('../../image/' + imageName + '.png');
imageUrl = require('../../image/check_icon.png');
}
return(
<View style={styles.bankCellContainer}>
<View style={styles.bankIconContainer}>
{rowData.bankCode !='' ?
<Image
style={styles.bankIcon}
source={imageUrl}
resizeMode={'contain'}
/>
:null}
<Text style={{marginTop: 15*DEVICE_WIDTH_RATIO,marginLeft:5*DEVICE_WIDTH_RATIO,}}>{rowData.bankName?rowData.bankName:rowData.bankText}</Text>
if (bankInfo) {
bankInfo = bankInfo.toJS();
if (bankInfo.show == true) {
return(
<View style={styles.bankCellContainer}>
<View style={styles.bankIconContainer}>
{bankInfo.bankCode !='' ?
<SlicedImage source={{uri: bankInfo.bankLogo}} style={{width:16,height:16}}/>
:null}
<Text style={{marginLeft:5*DEVICE_WIDTH_RATIO,}}>{bankInfo.bankName?bankInfo.bankName:bankInfo.bankText}</Text>
</View>
<View style={{
width: width,
height: 0.5,
backgroundColor: '#e5e5e5',
}}/>
</View>
<View style={{
width: width,
height: 0.5,
backgroundColor: '#e5e5e5',
}}/>
</View>
);
);
}else {
return null;
}
}else {
return null;
}
} else {
return (
<OpenPageInputCell
... ... @@ -237,6 +234,7 @@ let styles = StyleSheet.create({
flexDirection: 'row',
height: 44 * DEVICE_WIDTH_RATIO,
marginLeft: 50 * DEVICE_WIDTH_RATIO,
alignItems: 'center',
},
bankIcon: {
marginTop: 12 * DEVICE_WIDTH_RATIO,
... ...
'use strict';
import React from 'react';
import ReactNative, {
View,
Text,
Image,
StyleSheet,
Dimensions,
PixelRatio,
TouchableOpacity,
ListView,
} from 'react-native';
import Immutable, {Map} from 'immutable';
export default class AlreadyOpened extends React.Component {
constructor(props) {
super(props);
}
render() {
let{repaymentList}=this.props;
if (!repaymentList || repaymentList.size == 0) {
return (
<View style={styles.container}>
<Image
style={styles.emptyIcon}
source={require('../../image/review-img-3.png')}
resizeMode={'contain'}
/>
<Text>
暂无待还款订单
</Text>
<TouchableOpacity onPress={() => {this.props.onPressGoNew && this.props.onPressGoNew()}} >
<View style={styles.buttonContainer}>
<Text style={styles.button}>
去逛逛
</Text>
</View>
</TouchableOpacity>
</View>
);
}else {
return(
<View style={styles.container}>
<Text>
RepayList page
</Text>
</View>
);
}
}
};
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
alignItems: 'center',
},
emptyIcon: {
width: 110 * DEVICE_WIDTH_RATIO,
height: 110 * DEVICE_WIDTH_RATIO,
marginTop: 100 * DEVICE_WIDTH_RATIO,
marginBottom: 25 * DEVICE_WIDTH_RATIO,
},
buttonContainer: {
marginTop: 35 * DEVICE_WIDTH_RATIO,
width: 235 * DEVICE_WIDTH_RATIO,
height: 44 * DEVICE_WIDTH_RATIO,
backgroundColor: '#222222',
borderRadius: 5 * DEVICE_WIDTH_RATIO,
},
button: {
color: 'white',
textAlign: 'center',
fontSize: 14 * DEVICE_WIDTH_RATIO,
backgroundColor: 'transparent',
lineHeight: 29 * DEVICE_WIDTH_RATIO,
},
});
... ...
... ... @@ -19,6 +19,7 @@ export default keyMirror({
UPDATE_NEXT_BTN_ENABLE_STATUS: null,
UPDATE_SNS_CHECK_CODE_TEXT: null,
UPDATE_TIP_MESSAGE: null,
UPDATE_BANK_INFO: null,
NEXT_BTN_PROCESSING_REQUEST: null,
NEXT_BTN_PROCESSING_SUCCESS: null,
NEXT_BTN_PROCESSING_FAILURE: null,
... ... @@ -34,4 +35,7 @@ export default keyMirror({
SET_ALREADY_PAGE_AMT_INFO: null,
SET_ALREADY_PAGE_OVERDUE_STATUS: null,
SET_ALREADY_PAGE_CREDIT_INFO: null,
SET_QUERY_DAYS: null,
SET_REPAYMENT_LIST: null,
});
... ...
... ... @@ -14,7 +14,7 @@ import {
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Map} from 'immutable';
import * as installmentActions from '../reducers/installment/installmentActions';
import * as installmentActions from '../reducers/installment/installment/installmentActions';
import Installment from '../components/installment/Installment';
import AlreadyOpened from '../components/installment/AlreadyOpened';
import InstallmentStatus from '../components/installment/InstallmentStatus';
... ... @@ -49,6 +49,10 @@ class InstallmentContainer extends Component {
this._getNewUserPageInfo = this._getNewUserPageInfo.bind(this);
this._onPressMoreProducts = this._onPressMoreProducts.bind(this);
this._onPressProtocol = this._onPressProtocol.bind(this);
this._gotoRepayListPageWithDays = this._gotoRepayListPageWithDays.bind(this);
this._repayRecordCell = this._repayRecordCell.bind(this);
this._installmentOrderCell = this._installmentOrderCell.bind(this);
this._installmentAccountCell = this._installmentAccountCell.bind(this);
}
componentDidMount() {
this.props.actions.getInstallmentStatus();
... ... @@ -78,6 +82,23 @@ class InstallmentContainer extends Component {
this.props.actions.onPressTabBtn();
}
_gotoRepayListPageWithDays(days) {
console.log('------12112');
this.props.actions.gotoRepayListPageWithDays(days);
}
_repayRecordCell() {//还款记录
}
_installmentOrderCell() {//分期订单:
}
_installmentAccountCell() {//账户管理:
}
render() {
let {isFetching,open,alreadyOpenedPageInfo,installmentStatus,installmentStausPageInfo} = this.props.installment;
let {status} = installmentStatus;
... ... @@ -100,6 +121,10 @@ class InstallmentContainer extends Component {
getAlreadyPageInfo={this._getAlreadyPageInfo}
onPressMoreProducts={this._onPressMoreProducts}
onPressProtocol={this._onPressProtocol}
gotoRepayListPageWithDays={this._gotoRepayListPageWithDays}
repayRecordCell={this._repayRecordCell}
installmentOrderCell={this._installmentOrderCell}
installmentAccountCell={this._installmentAccountCell}
/>
);
} else if (status == 'OpenStatus') {
... ...
... ... @@ -15,7 +15,7 @@ import {
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Map} from 'immutable';
import * as installmentActions from '../reducers/installment/installmentActions';
import * as installmentActions from '../reducers/installment/installment/installmentActions';
import InstallmentStatus from '../components/installment/InstallmentStatus';
const actions = [
... ...
... ... @@ -15,10 +15,10 @@ import {
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Map} from 'immutable';
import * as installmentActions from '../reducers/installment/installmentActions';
import * as newRegisterActions from '../reducers/installment/newRegister/newRegisterActions';
import Open from '../components/installment/Open';
const actions = [
installmentActions,
newRegisterActions,
];
function mapStateToProps(state) {
return {
... ... @@ -80,10 +80,10 @@ class OpenContainer extends Component {
}
render() {
let {openPageInfo} = this.props.installment;
let {newRegister} = this.props;
return (
<Open
openPageInfo={openPageInfo}
openPageInfo={newRegister}
onPressProtocol={this._onPressProtocol}
onPressOpenInstallment={this._onPressOpenInstallment}
onPressCheckbox={this._onPressCheckbox}
... ...
'use strict'
import React, {Component} from 'react';
import {
StyleSheet,
Dimensions,
Platform,
View,
NativeModules,
InteractionManager,
NativeAppEventEmitter,
Text,
} from 'react-native'
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Map} from 'immutable';
import * as newRegisterActions from '../reducers/installment/repayList/repayListActions';
import RepayList from '../components/installment/RepayList';
const actions = [
newRegisterActions,
];
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 RepayListContainer extends Component {
constructor(props) {
super(props);
this._onPressGoNew = this._onPressGoNew.bind(this);
}
componentDidMount() {
this.props.actions.getQueryAmtList("0");
}
_onPressGoNew() {
this.props.actions.getoNewArrival();
}
render() {
let {queryDays,repaymentList} = this.props.repayList;
return (
<RepayList
repaymentList={repaymentList}
onPressGoNew={this._onPressGoNew}
/>
);
}
}
let styles = StyleSheet.create({
container: {
flex: 1,
},
});
export default connect(mapStateToProps, mapDispatchToProps)(RepayListContainer);
... ...
import {combineReducers} from 'redux';
import app from './app/appReducer';
import installment from './installment/installmentReducer';
import installment from './installment/installment/installmentReducer';
import newRegister from './installment/newRegister/newRegisterReducer';
import repayList from './installment/repayList/repayListReducer';
const rootReducer = combineReducers({
app,
installment,
newRegister,
repayList,
});
export default rootReducer;
... ...
'use strict';
import ReactNative from 'react-native';
import InstallmentService from '../../services/InstallmentService';
import InstallmentService from '../../../services/InstallmentService';
const {
... ... @@ -15,17 +15,6 @@ GET_INSTALLMENT_STATUS_REQUEST,
GET_INSTALLMENT_STATUS_SUCCESS,
GET_INSTALLMENT_STATUS_FAILURE,
UPDATE_SHOW_BANK_ALERT_STATUS,
UPDATE_AGREE_PROTOCOL_STATUS,
UPDATE_SNS_CHECK_CODE_ENABLE_STATUS,
UPDATE_CELL_LIST,
UPDATE_NEXT_BTN_ENABLE_STATUS,
UPDATE_SNS_CHECK_CODE_TEXT,
UPDATE_TIP_MESSAGE,
NEXT_BTN_PROCESSING_REQUEST,
NEXT_BTN_PROCESSING_SUCCESS,
NEXT_BTN_PROCESSING_FAILURE,
SET_INSTALLMENT_STATUS_PAGE_ORIGINAL_INFO,
SET_INSTALLMENT_STATUS_PAGE_GOODS,
SET_STATUS_PAGE_ADVERTISEMENT,
... ... @@ -38,18 +27,13 @@ SET_ALREADY_PAGE_AMT_INFO,
SET_ALREADY_PAGE_OVERDUE_STATUS,
SET_ALREADY_PAGE_CREDIT_INFO,
} = require('../../constants/actionTypes').default;
} = require('../../../constants/actionTypes').default;
const codeContent = {
openN: '0876085ff46bed27f1a1eb6ee8b68987',
openY: 'c233ad4ca91fef45ed7d0b26d9953e61',
advertisement: 'f3fe0793a7d59479542a14b15359c47d'
};
var Timer = function() {
this.counter = 0;
this.countdownTimer = null;
};
export function productListForInstallmentRequest(){
return {
type: INSTALLMENT_PRODUCT_REQUEST,
... ... @@ -90,71 +74,6 @@ export function featchInstallmentStatusFailure(error) {
}
}
export function updateShowBankAlertStatus(status) {
return {
type: UPDATE_SHOW_BANK_ALERT_STATUS,
payload: status
}
}
export function updateAgreeProtocolStatus(status) {
return {
type: UPDATE_AGREE_PROTOCOL_STATUS,
payload: status
}
}
export function updateSnsCheckCodeEnableStatus(status) {
return {
type: UPDATE_SNS_CHECK_CODE_ENABLE_STATUS,
payload: status
}
}
export function updateCellList(cellList) {
return {
type: UPDATE_CELL_LIST,
payload: cellList
}
}
export function updateNextBtnEnableStatus(status) {
return {
type: UPDATE_NEXT_BTN_ENABLE_STATUS,
payload: status
}
}
export function updateSnsCheckCodeText(text) {
return {
type: UPDATE_SNS_CHECK_CODE_TEXT,
payload: text
}
}
export function updateTipMessage(message) {
return {
type: UPDATE_TIP_MESSAGE,
payload: message
}
}
export function nextBtnProcessingRequest() {
return {
type: NEXT_BTN_PROCESSING_REQUEST,
}
}
export function nextBtnProcessingFailure() {
return {
type: NEXT_BTN_PROCESSING_FAILURE
}
}
export function nextBtnProcessingSuccess() {
return {
type: NEXT_BTN_PROCESSING_SUCCESS
}
}
export function setInstallmentStatusPageOriginalInfo(params) {
return {
type: SET_INSTALLMENT_STATUS_PAGE_ORIGINAL_INFO,
... ... @@ -225,6 +144,7 @@ export function setAlreadPageCreditInfo(creditInfo) {
}
}
export function productListForInstallment() {
return (dispatch, getState) => {
let {app, installment} = getState();
... ... @@ -325,293 +245,6 @@ export function getInstallmentStatus() {
}
}
export function onPressProtocol() {
return (dispatch, getState) => {
//跳转原生静态页面
let url = `://m.yohobuy.com/home/installment/agreement?openby:yohobuy={"action":"go.h5","params":{"url":"http://m.yohobuy.com/home/installment/agreement"}}`;
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
};
}
export function onPressOpenNext() {
return (dispatch, getState) => {
let {app, installment} = getState();
let {nextBtnEnable,cellList,nextProcessing} = installment.openPageInfo;
let activateParams = {};
let newCellList = cellList;
// if (!nextBtnEnable) {
// return;
// }
ReactNative.NativeModules.YH_InstallmentHelper.gotoInstallmentStatusView('2', '您的授信未通过,在有货更多的消费,增加信用度,会大大提升审核通过率奥。');
return;
cellList.map((item, i) => {
if (item.get('inputKey') != 'BankIcon') {
activateParams[item.get('inputKey')]= item.get('text');
}
});
let activateService = (uid) => {
dispatch(nextBtnProcessingRequest());
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) => {
if (item.inputKey == 'snsCheckCode') {
item.text = '';
}
cellList[i] = item;
});
dispatch(updateTipMessage(json.message))
dispatch(updateCellList(cellList));
dispatch(nextBtnProcessingFailure());
}
})
.then(json => {
dispatch(nextBtnProcessingSuccess());
console.log('2222222');
console.log(json);
let tipMessage = '';
if (json.status == '3') {
json.failReason = json.failReason || '姓名、身份证、银行卡不匹配';
}
ReactNative.NativeModules.YH_InstallmentHelper.gotoInstallmentStatusView(json.status, json.failReason);
})
.catch(error => {
});
}
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
activateService(uid);
})
.catch(error => {
ReactNative.NativeModules.YH_CommonHelper.login()
.then(uid => {
activateService(uid);
})
.catch(error => {
});
});
};
}
export function onPressCheckbox() {
return (dispatch, getState) => {
let {app, installment} = getState();
let {agreeProtocol} = installment.openPageInfo;
agreeProtocol = !agreeProtocol;
dispatch(updateAgreeProtocolStatus(agreeProtocol));
};
}
export function onPressCardNoQuestion() {
return (dispatch, getState) => {
let {app, installment} = getState();
let {showBankAlert} = installment.openPageInfo;
showBankAlert = !showBankAlert;
dispatch(updateShowBankAlertStatus(showBankAlert));
};
}
export function getBankInfo(cellInfo,cardNo) {
return (dispatch, getState) => {
let bankInfo = (uid) => {
let {app, installment} = getState();
let {cellList,snsCheckCodeEnable} = installment.openPageInfo;
cellList = cellList.toJS();
let newCellList = cellList;
let nextBtnEnable = true;
return new InstallmentService(app.host).fentchBankInfo(cardNo,uid)
.then(json => {
let bankIconInfo = {
inputKey: 'BankIcon',
bankCode: '',
bankName: '',
bankText: '',
show: true,
};
if (json.bankCode) {
bankIconInfo.bankCode = json.bankCode;
bankIconInfo.bankName = json.bankName;
}
if (json.businessSupport === '1') {
bankIconInfo.bankCode = '';
bankIconInfo.bankName = '';
bankIconInfo.bankText = '暂不支持此银行卡';
}
newCellList.map((item, i) => {
if (item.inputKey == 'BankIcon') {
item = bankIconInfo;
}
cellList[i] = item;
});
dispatch(updateCellList(cellList));
})
.catch(error => {
});
}
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
bankInfo(uid);
})
.catch(error => {
ReactNative.NativeModules.YH_CommonHelper.login()
.then(uid => {
bankInfo(uid);
})
.catch(error => {
});
});
}
}
export function updateOpenPageCellInfo(cellInfo) {
return (dispatch, getState) => {
let {app, installment} = getState();
let {cellList,snsCheckCodeEnable} = installment.openPageInfo;
cellList = cellList.toJS();
let newCellList = cellList;
let cardNoValid = false;
let mobileValid = false;
let nextBtnEnable = true;
if (cellInfo.inputKey == "cardNo") {
let value = cellInfo.text;
console.log('value');
console.log(value);
let cardNo = value.replace(/\s/g, '');
let newCardNo = value.replace(/[^\d]/g, '').replace(/(\d{4})(?=\d)/g, '$1 ');
console.log('newCardNo');
console.log(newCardNo);
cellInfo.text = newCardNo;
if (cardNo && cardNo.length >= 16) {
cardNoValid = true;
dispatch(getBankInfo(cellInfo,value));
}else {
cardNoValid = false;
cellInfo.showBankIcon = false;
}
}else if (cellInfo.inputKey == "mobile" && cellInfo.text.length ==11) {
mobileValid = true;
}
newCellList.map((item, i) => {
if (item.inputKey == 'cardNo' && item.text.length >=16 && cellInfo.inputKey != 'cardNo') {
cardNoValid = true;
} else if (item.inputKey == 'mobile' && item.text.length ==11 && cellInfo.inputKey != 'mobile') {
mobileValid = true;
}
if (item.inputKey == cellInfo.inputKey) {
item = cellInfo;
}
if (item.text == '') {
nextBtnEnable = false;
}
cellList[i] = item;
});
if (cardNoValid && mobileValid) {
snsCheckCodeEnable = true;
}else {
snsCheckCodeEnable = false;
}
console.log('cellInfo');
console.log(cellInfo);
dispatch(updateCellList(cellList));
dispatch(updateSnsCheckCodeEnableStatus(snsCheckCodeEnable));
dispatch(updateNextBtnEnableStatus(nextBtnEnable));
};
}
/**
* 倒计时
*
* @param start 启动回调
* @param tick 进度回调
* @param complete 完成回调
*/
Timer.prototype.startCountdown = function(start, tick, complete) {
var self = this;
if (this.counter > 0 || this.countdownTimer) {
return;
} else {
this.counter = 59;
}
// 启动回调
if (start) {
start.call(this);
}
if (tick) {
tick.call(this, this.counter);
}
this.complete = complete;
// 开始计时器
this.countdownTimer = setInterval(function() {
self.counter--;
if (self.counter <= 0) {
if (complete) {
clearInterval(self.countdownTimer);
// 重置计时器
self.counter = 0;
self.countdownTimer = null;
complete.call(self);
}
}
// 完成回调
if (tick && self.counter > 0) {
tick.call(self, self.counter);
}
}, 1000);
return this;
};
export function onPressCheckCode() {
return (dispatch, getState) => {
let {app, installment} = getState();
let {cellList,snsCheckCodeEnable,snsCheckCodeText} = installment.openPageInfo;
if (snsCheckCodeEnable && snsCheckCodeText == '获取验证码') {
return new InstallmentService(app.host).sendVerifyCode('17705176933')
.then(json => {
let status = 0;
let snsText = '';
new Timer().startCountdown(function() {
}, function(counter) {
// 进度回调
snsText = counter + 's';
dispatch(updateSnsCheckCodeText(snsText));
}, function() {
// 倒计时结束后再次显示 "获取验证码"
snsText = '获取验证码';
dispatch(updateSnsCheckCodeText(snsText));
});
dispatch(updateSnsCheckCodeText(snsText));
})
.catch(error => {
});
}
};
}
export function setInstallmentStausPageParams(statusCode, failReason, uid) {
return (dispatch, getState) => {
... ... @@ -810,3 +443,11 @@ export function onPressTabBtn() {
ReactNative.NativeModules.YH_InstallmentHelper.helpAction();
};
}
export function gotoRepayListPageWithDays(days) {
return (dispatch, getState) => {
let {app, installment} = getState();
ReactNative.NativeModules.YH_InstallmentHelper.gotoRepayListPage(days);
};
}
... ...
'use strict';
import Immutable,{Record, List, Map} from 'immutable';
let InitialState = Record({
isFetching:false,
uid: '',
installmentStatus:new (Record({
isFetching:false,
status: '',
error: null,
})),
open:new (Record({
productListForInstallment:new (Record({
list:List(),
page:1,
totalPage:1,
})),
installmentInfo:'',
})),
alreadyOpenedPageInfo:new (Record({
tabFocusIndex: 1,
goods: List(),
isOverdue: false,
content: Map(),
notice: Map(),
installmentInfo:Map(),
creditInfo: Map(),
})),
installmentStausPageInfo:new (Record({
statusCode: '',
status: 'success',
jumpUrl: '',
statusInfo:Map(),
goods: List(),
advertisement: false,
})),
});
export default InitialState;
... ...
... ... @@ -14,18 +14,6 @@ const {
GET_INSTALLMENT_STATUS_SUCCESS,
GET_INSTALLMENT_STATUS_FAILURE,
UPDATE_SHOW_BANK_ALERT_STATUS,
UPDATE_AGREE_PROTOCOL_STATUS,
UPDATE_SNS_CHECK_CODE_ENABLE_STATUS,
UPDATE_CELL_LIST,
UPDATE_NEXT_BTN_ENABLE_STATUS,
UPDATE_NEXT_BTN_TEXT,
UPDATE_SNS_CHECK_CODE_TEXT,
UPDATE_TIP_MESSAGE,
NEXT_BTN_PROCESSING_REQUEST,
NEXT_BTN_PROCESSING_SUCCESS,
NEXT_BTN_PROCESSING_FAILURE,
SET_INSTALLMENT_STATUS_PAGE_ORIGINAL_INFO,
SET_INSTALLMENT_STATUS_PAGE_GOODS,
SET_STATUS_PAGE_ADVERTISEMENT,
... ... @@ -38,7 +26,7 @@ const {
SET_ALREADY_PAGE_OVERDUE_STATUS,
SET_ALREADY_PAGE_CREDIT_INFO,
} = require('../../constants/actionTypes').default;
} = require('../../../constants/actionTypes').default;
const initialState = new InitialState;
... ... @@ -67,29 +55,6 @@ export default function appReducer(state = initialState, action) {
case GET_INSTALLMENT_STATUS_FAILURE:
return state.setIn(['installmentStatus', 'isFetching'], false)
.setIn(['installmentStatus', 'error'], action.payload);
case UPDATE_SHOW_BANK_ALERT_STATUS:
return state.setIn(['openPageInfo', 'showBankAlert'], action.payload);
case UPDATE_AGREE_PROTOCOL_STATUS:
return state.setIn(['openPageInfo', 'agreeProtocol'], action.payload);
case UPDATE_SNS_CHECK_CODE_ENABLE_STATUS:
return state.setIn(['openPageInfo', 'snsCheckCodeEnable'], action.payload);
case UPDATE_CELL_LIST:
return state.setIn(['openPageInfo', 'cellList'], Immutable.fromJS(action.payload));
case UPDATE_NEXT_BTN_ENABLE_STATUS:
return state.setIn(['openPageInfo', 'nextBtnEnable'], action.payload);
case UPDATE_SNS_CHECK_CODE_TEXT:
return state.setIn(['openPageInfo', 'snsCheckCodeText'], action.payload);
case UPDATE_TIP_MESSAGE:
return state.setIn(['openPageInfo', 'tipMessage'], action.payload);
case NEXT_BTN_PROCESSING_REQUEST:
return state.setIn(['openPageInfo', 'nextBtnText'], '处理中...')
.setIn(['openPageInfo', 'nextProcessing'], true);
case NEXT_BTN_PROCESSING_SUCCESS:
return state.setIn(['openPageInfo', 'nextBtnText'], '下一步')
.setIn(['openPageInfo', 'nextProcessing'], false);
case NEXT_BTN_PROCESSING_FAILURE:
return state.setIn(['openPageInfo', 'nextBtnText'], '下一步')
.setIn(['openPageInfo', 'nextProcessing'], false);
case SET_INSTALLMENT_STATUS_PAGE_ORIGINAL_INFO:
return state.setIn(['installmentStausPageInfo', 'statusCode'],action.payload.status)
.setIn(['installmentStausPageInfo', 'status'], action.payload.status)
... ...
'use strict';
import ReactNative from 'react-native';
import InstallmentService from '../../../services/InstallmentService';
const {
SET_PLATFORM,
UPDATE_SHOW_BANK_ALERT_STATUS,
UPDATE_AGREE_PROTOCOL_STATUS,
UPDATE_SNS_CHECK_CODE_ENABLE_STATUS,
UPDATE_CELL_LIST,
UPDATE_NEXT_BTN_ENABLE_STATUS,
UPDATE_SNS_CHECK_CODE_TEXT,
UPDATE_TIP_MESSAGE,
UPDATE_BANK_INFO,
NEXT_BTN_PROCESSING_REQUEST,
NEXT_BTN_PROCESSING_SUCCESS,
NEXT_BTN_PROCESSING_FAILURE,
} = require('../../../constants/actionTypes').default;
var Timer = function() {
this.counter = 0;
this.countdownTimer = null;
};
export function updateShowBankAlertStatus(status) {
return {
type: UPDATE_SHOW_BANK_ALERT_STATUS,
payload: status
}
}
export function updateAgreeProtocolStatus(status) {
return {
type: UPDATE_AGREE_PROTOCOL_STATUS,
payload: status
}
}
export function updateSnsCheckCodeEnableStatus(status) {
return {
type: UPDATE_SNS_CHECK_CODE_ENABLE_STATUS,
payload: status
}
}
export function updateCellList(cellList) {
return {
type: UPDATE_CELL_LIST,
payload: cellList
}
}
export function updateNextBtnEnableStatus(status) {
return {
type: UPDATE_NEXT_BTN_ENABLE_STATUS,
payload: status
}
}
export function updateSnsCheckCodeText(text) {
return {
type: UPDATE_SNS_CHECK_CODE_TEXT,
payload: text
}
}
export function updateTipMessage(message) {
return {
type: UPDATE_TIP_MESSAGE,
payload: message
}
}
// updateBankInfo
export function updateBankInfo(bankInfo) {
return {
type: UPDATE_BANK_INFO,
payload: bankInfo,
}
}
export function nextBtnProcessingRequest() {
return {
type: NEXT_BTN_PROCESSING_REQUEST,
}
}
export function nextBtnProcessingFailure() {
return {
type: NEXT_BTN_PROCESSING_FAILURE
}
}
export function nextBtnProcessingSuccess() {
return {
type: NEXT_BTN_PROCESSING_SUCCESS
}
}
export function onPressProtocol() {
return (dispatch, getState) => {
//跳转原生静态页面
let url = `://m.yohobuy.com/home/installment/agreement?openby:yohobuy={"action":"go.h5","params":{"url":"http://m.yohobuy.com/home/installment/agreement"}}`;
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
};
}
export function onPressOpenNext() {
return (dispatch, getState) => {
let {app, newRegister} = getState();
let {nextBtnEnable,cellList,nextProcessing} = newRegister;
let activateParams = {};
let newCellList = cellList;
// if (!nextBtnEnable) {
// return;
// }
ReactNative.NativeModules.YH_InstallmentHelper.gotoInstallmentStatusView('2', '您的授信未通过,在有货更多的消费,增加信用度,会大大提升审核通过率奥。');
return;
cellList.map((item, i) => {
if (item.get('inputKey') != 'BankIcon') {
activateParams[item.get('inputKey')]= item.get('text');
}
});
let activateService = (uid) => {
dispatch(nextBtnProcessingRequest());
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) => {
if (item.inputKey == 'snsCheckCode') {
item.text = '';
}
cellList[i] = item;
});
dispatch(updateTipMessage(json.message))
dispatch(updateCellList(cellList));
dispatch(nextBtnProcessingFailure());
}
})
.then(json => {
dispatch(nextBtnProcessingSuccess());
console.log('2222222');
console.log(json);
let tipMessage = '';
if (json.status == '3') {
json.failReason = json.failReason || '姓名、身份证、银行卡不匹配';
}
ReactNative.NativeModules.YH_InstallmentHelper.gotoInstallmentStatusView(json.status, json.failReason);
})
.catch(error => {
});
}
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
activateService(uid);
})
.catch(error => {
ReactNative.NativeModules.YH_CommonHelper.login()
.then(uid => {
activateService(uid);
})
.catch(error => {
});
});
};
}
export function onPressCheckbox() {
return (dispatch, getState) => {
let {app, newRegister} = getState();
let {agreeProtocol} = newRegister;
agreeProtocol = !agreeProtocol;
dispatch(updateAgreeProtocolStatus(agreeProtocol));
};
}
export function onPressCardNoQuestion() {
return (dispatch, getState) => {
let {app, newRegister} = getState();
let {showBankAlert} = newRegister;
showBankAlert = !showBankAlert;
dispatch(updateShowBankAlertStatus(showBankAlert));
};
}
export function getBankInfo(cellInfo,cardNo) {
return (dispatch, getState) => {
let bankInfo = (uid) => {
let {app, newRegister} = getState();
let {snsCheckCodeEnable} = newRegister;
let bankInfo = {
bankCode: '',
bankName: '',
bankText: '',
bankLogo: '',
show: false,
};
let nextBtnEnable = true;
return new InstallmentService('http://api-test2.yohops.com:9999/').fentchBankInfo(cardNo,uid)
.then(json => {
console.log('--1');
console.log(json);
if (json.businessSupport == '0' && json.bankCode && json.bankCode != '') {
bankInfo.bankCode = json.bankCode;
bankInfo.bankName = json.bankName;
bankInfo.bankLogo = json.bankLogo;
bankInfo.show = true;
}else {
bankInfo.bankCode = '';
bankInfo.bankName = '';
bankInfo.bankText = '暂不支持此银行卡';
bankInfo.show = true;
}
console.log('-----bankInfo 1');
console.log(bankInfo);
dispatch(updateBankInfo(bankInfo));
})
.catch(error => {
});
}
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
bankInfo(uid);
})
.catch(error => {
ReactNative.NativeModules.YH_CommonHelper.login()
.then(uid => {
bankInfo(uid);
})
.catch(error => {
});
});
}
}
export function updateOpenPageCellInfo(cellInfo) {
return (dispatch, getState) => {
let {app, newRegister} = getState();
let {cellList,snsCheckCodeEnable} = newRegister;
cellList = cellList.toJS();
let newCellList = cellList;
let cardNoValid = false;
let mobileValid = false;
let nextBtnEnable = true;
if (cellInfo.inputKey == "cardNo") {
let value = cellInfo.text;
console.log('value');
console.log(value);
let cardNo = value.replace(/\s/g, '');
let newCardNo = value.replace(/[^\d]/g, '').replace(/(\d{4})(?=\d)/g, '$1 ');
console.log('newCardNo');
console.log(newCardNo);
cellInfo.text = newCardNo;
if (cardNo && cardNo.length >= 16) {
cardNoValid = true;
dispatch(getBankInfo(cellInfo,value));
}else {
cardNoValid = false;
cellInfo.showBankIcon = false;
dispatch(updateBankInfo({
show: false,
}));
}
}else if (cellInfo.inputKey == "mobile" && cellInfo.text.length ==11) {
mobileValid = true;
}
newCellList.map((item, i) => {
if (item.inputKey == 'cardNo' && item.text.length >=16 && cellInfo.inputKey != 'cardNo') {
cardNoValid = true;
} else if (item.inputKey == 'mobile' && item.text.length ==11 && cellInfo.inputKey != 'mobile') {
mobileValid = true;
}
if (item.inputKey == cellInfo.inputKey) {
item = cellInfo;
}
if (item.text == '') {
nextBtnEnable = false;
}
cellList[i] = item;
});
if (cardNoValid && mobileValid) {
snsCheckCodeEnable = true;
}else {
snsCheckCodeEnable = false;
}
console.log('cellInfo');
console.log(cellInfo);
dispatch(updateCellList(cellList));
dispatch(updateSnsCheckCodeEnableStatus(snsCheckCodeEnable));
dispatch(updateNextBtnEnableStatus(nextBtnEnable));
};
}
/**
* 倒计时
*
* @param start 启动回调
* @param tick 进度回调
* @param complete 完成回调
*/
Timer.prototype.startCountdown = function(start, tick, complete) {
var self = this;
if (this.counter > 0 || this.countdownTimer) {
return;
} else {
this.counter = 59;
}
// 启动回调
if (start) {
start.call(this);
}
if (tick) {
tick.call(this, this.counter);
}
this.complete = complete;
// 开始计时器
this.countdownTimer = setInterval(function() {
self.counter--;
if (self.counter <= 0) {
if (complete) {
clearInterval(self.countdownTimer);
// 重置计时器
self.counter = 0;
self.countdownTimer = null;
complete.call(self);
}
}
// 完成回调
if (tick && self.counter > 0) {
tick.call(self, self.counter);
}
}, 1000);
return this;
};
export function onPressCheckCode() {
return (dispatch, getState) => {
let {app, newRegister} = getState();
let {cellList,snsCheckCodeEnable,snsCheckCodeText} = newRegister;
if (snsCheckCodeEnable && snsCheckCodeText == '获取验证码') {
return new InstallmentService(app.host).sendVerifyCode('17705176933')
.then(json => {
let status = 0;
let snsText = '';
new Timer().startCountdown(function() {
}, function(counter) {
// 进度回调
snsText = counter + 's';
dispatch(updateSnsCheckCodeText(snsText));
}, function() {
// 倒计时结束后再次显示 "获取验证码"
snsText = '获取验证码';
dispatch(updateSnsCheckCodeText(snsText));
});
dispatch(updateSnsCheckCodeText(snsText));
})
.catch(error => {
});
}
};
}
... ...
... ... @@ -45,49 +45,18 @@ let banks = ['农业银行', '中国银行', '工商银行', '建设银行', '
let InitialState = Record({
isFetching:false,
uid: '',
installmentStatus:new (Record({
isFetching:false,
status: '',
error: null,
})),
open:new (Record({
productListForInstallment:new (Record({
list:List(),
page:1,
totalPage:1,
})),
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,
nextBtnEnable: false,
nextBtnText: '下一步',
nextProcessing: false,
snsCheckCodeEnable: false,
snsCheckCodeText: '获取验证码',
banks: banks.join('、'),
showBankAlert: false,
bankList: Immutable.fromJS(banks),
tipMessage: '',
})),
installmentStausPageInfo:new (Record({
statusCode: '',
status: 'success',
jumpUrl: '',
statusInfo:Map(),
goods: List(),
advertisement: false,
})),
cellList: Immutable.fromJS(openPageParams),
agreeProtocol: true,
nextBtnEnable: false,
nextBtnText: '下一步',
nextProcessing: false,
snsCheckCodeEnable: false,
snsCheckCodeText: '获取验证码',
banks: banks.join('、'),
showBankAlert: false,
bankList: Immutable.fromJS(banks),
tipMessage: '',
bankInfo: Immutable.fromJS(),
});
export default InitialState;
... ...
'use strict';
import InitialState from './newRegisterInitialState';
import Immutable, {Map} from 'immutable';
const {
SET_PLATFORM,
UPDATE_SHOW_BANK_ALERT_STATUS,
UPDATE_AGREE_PROTOCOL_STATUS,
UPDATE_SNS_CHECK_CODE_ENABLE_STATUS,
UPDATE_CELL_LIST,
UPDATE_NEXT_BTN_ENABLE_STATUS,
UPDATE_NEXT_BTN_TEXT,
UPDATE_SNS_CHECK_CODE_TEXT,
UPDATE_TIP_MESSAGE,
UPDATE_BANK_INFO,
NEXT_BTN_PROCESSING_REQUEST,
NEXT_BTN_PROCESSING_SUCCESS,
NEXT_BTN_PROCESSING_FAILURE,
} = require('../../../constants/actionTypes').default;
const initialState = new InitialState;
export default function appReducer(state = initialState, action) {
if (!(state instanceof InitialState)) return initialState.merge(state);
switch (action.type) {
case UPDATE_SHOW_BANK_ALERT_STATUS:
return state.set('showBankAlert', action.payload);
case UPDATE_AGREE_PROTOCOL_STATUS:
return state.set('agreeProtocol', action.payload);
case UPDATE_SNS_CHECK_CODE_ENABLE_STATUS:
return state.set('snsCheckCodeEnable', action.payload);
case UPDATE_CELL_LIST:
return state.set('cellList', Immutable.fromJS(action.payload));
case UPDATE_NEXT_BTN_ENABLE_STATUS:
return state.set('nextBtnEnable', action.payload);
case UPDATE_SNS_CHECK_CODE_TEXT:
return state.set('snsCheckCodeText', action.payload);
case UPDATE_TIP_MESSAGE:
return state.set('tipMessage', action.payload);
case UPDATE_BANK_INFO:
return state.set('bankInfo', Immutable.fromJS(action.payload));
case NEXT_BTN_PROCESSING_REQUEST:
return state.set('nextBtnText', '处理中...')
.set('nextProcessing', true);
case NEXT_BTN_PROCESSING_SUCCESS:
return state.set('nextBtnText', '下一步')
.set('nextProcessing', false);
case NEXT_BTN_PROCESSING_FAILURE:
return state.set('nextBtnText', '下一步')
.set('nextProcessing', false);
}
return state;
}
... ...
'use strict';
import ReactNative from 'react-native';
import InstallmentService from '../../../services/InstallmentService';
const {
SET_PLATFORM,
SET_QUERY_DAYS,
SET_REPAYMENT_LIST,
} = require('../../../constants/actionTypes').default;
export function setQueryDays(days){
return {
type: SET_QUERY_DAYS,
payload: days,
}
}
// SET_REPAYMENT_LIST
export function setRepaymentList(list){
return {
type: SET_REPAYMENT_LIST,
payload: list,
}
}
export function getQueryAmtList(days) {
return (dispatch, getState) => {
let {app, rePayList} = getState();
return new InstallmentService(app.host).getQueryAmtList(days)
.then(json => {
if (json && json.length > 0) {
dispatch(setRepaymentList(json));
}
})
.catch(error => {
});
};
}
export function getoNewArrival() {
return (dispatch, getState) => {
let {app, rePayList} = getState();
let jumpUrl = `http://m.yohobuy.com/product/new/?openby:yohobuy={"action":"go.new","params":{"title":"新品到着"}}`;
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(jumpUrl);
};
}
... ...
'use strict';
import Immutable,{Record, List, Map} from 'immutable';
let InitialState = Record({
isFetching:false,
queryDays: '',
repaymentList: List(),
});
export default InitialState;
... ...
'use strict';
import InitialState from './repayListInitialState';
import Immutable, {Map} from 'immutable';
const {
SET_QUERY_DAYS,
SET_REPAYMENT_LIST,
} = require('../../../constants/actionTypes').default;
const initialState = new InitialState;
export default function appReducer(state = initialState, action) {
if (!(state instanceof InitialState)) return initialState.merge(state);
switch (action.type) {
case SET_QUERY_DAYS:{
return state.set('queryDays', action.payload);
}
case SET_REPAYMENT_LIST: {
return state.set('repaymentList', Immutable.from(action.payload));
}
}
return state;
}
... ...
... ... @@ -206,4 +206,23 @@ export default class InstallmentService {
throw(error);
});
}
// 获取用户待还列表信息 queryDays -1:逾期待还;0:全部待还;7:七日待还;30:本月待还
async getQueryAmtList(queryDays) {
return await this.api.get({
url: '',
body: {
method: 'app.order.queryAmtList',
pageSize: '20',
queryDays,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
}
... ...