Authored by 孙凯

Merge branch '5.4.1' of http://git.yoho.cn/mobile/YH_RNComponent into 5.4.1

'use strict';
import React, {Component} from 'react';
import ReactNative, {
View,
TouchableOpacity,
StyleSheet,
Dimensions,
} from 'react-native';
import Immutable, {Map} from 'immutable';
import TimerMixin from 'react-timer-mixin';
import SlicedImage from '../../../common/components/SlicedImage';
import YH_Image from '../../../common/components/YH_Image';
import HeadTitleCell from '../cell/HeadTitleCell';
import ImageSlider from '../cell/ImageSlider';
/**
* 首页 sale 楼层,
* 这个楼层是标题、banner、左带倒计时大图,右四小图
**/
export default class Sale1T1L4R extends Component{
constructor(props) {
super(props);
this.state = {
remainTime : "",
};
}
componentWillUnmount() {
this.timer && TimerMixin.clearTimeout(this.timer);
}
render(){
let data = this.props.data;
let banner = data.get("banner");
let title = data.get("title");
let imglst = data.get("list");
//初始化时间,待测
let leftBigImageUrl = SlicedImage.getSlicedUrl(imglst.get(0).get("src"), leftBigImageWidth, leftBigImageHeight, 2);
let rightTopBigImageUrl = SlicedImage.getSlicedUrl(imglst.get(1).get("src"), rightBigImageWidth, rightBigImageHeight, 2);
let rightTopSmallImageUrl = SlicedImage.getSlicedUrl(imglst.get(2).get("src"), rightSmallImageWidth, rightSmallImageHeight, 2);
let rightBottomBigImageUrl = SlicedImage.getSlicedUrl(imglst.get(3).get("src"), rightBigImageWidth, rightBigImageHeight, 2);
let rightBottomSmallImageUrl = SlicedImage.getSlicedUrl(imglst.get(4).get("src"), rightSmallImageWidth, rightSmallImageHeight, 2);
return(
<View style={styles.container}>
<HeadTitleCell title={title.get('title')} moreUrl={title.get('more_url')} />
<ImageSlider
resource={banner}
sliderWidth={width}
sliderHeight={bannerHeight}
onPressSlideItem={this.props.onPressSlideItem}
/>
<View style={styles.imageContainer}>
<TouchableOpacity style={styles.leftBigImageContainer} activeOpacity={1}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(0).toJS())}>
<YH_Image style={styles.leftBigImage} url={leftBigImageUrl}/>
<Image style={styles.timerImage} source={require("../../images/ic_limit_times.png")}/>
<Text style={styles.timerText}>{remainTime}</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.rightTopBigImageContainer} activeOpacity={1}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(1).toJS())}>
<YH_Image style={styles.rightTopBigImage} url={rightTopBigImageUrl}/>
</TouchableOpacity>
<TouchableOpacity style={styles.rightTopSmallImageContainer} activeOpacity={1}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(2).toJS())}>
<YH_Image style={styles.rightTopSmallImage} url={rightTopSmallImageUrl}/>
</TouchableOpacity>
<TouchableOpacity style={styles.rightBottomBigImageContainer} activeOpacity={1}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(3).toJS())}>
<YH_Image style={styles.rightBottomBigImage} url={rightBottomBigImageUrl}/>
</TouchableOpacity>
<TouchableOpacity style={styles.rightBottomSmallImageContainer} activeOpacity={1}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(4).toJS())}>
<YH_Image style={styles.rightBottomSmallImage} url={rightBottomSmallImageUrl}/>
</TouchableOpacity>
</View>
</View>
);
}
};
let {width} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let bannerHeight = Math.floor(width / 3);
let leftBigImageWidth = width * 310 / 740;
let leftBigImageHeight = leftBigImageWidth * 422 / 310;
let rightBigImageWidth = width * 330 / 740;
let rightBigImageHeight = rightBigImageWidth * 210 / 330;
let rightSmallImageWidth = width * 100 / 740;
let rightSmallImageHeight = rightSmallImageWidth * 210 / 100;
let styles = StyleSheet.create({
container: {
width: width,
backgroundColor: "#e5e5e5",
},
imageContainer: {
width: width,
height: 422 * DEVICE_WIDTH_RATIO,
},
leftBigImageContainer: {
position: 'absolute',
top: 0,
left: 0,
width: leftBigImageWidth,
height: leftBigImageHeight,
},
leftBigImage: {
width: leftBigImageWidth,
height: leftBigImageHeight,
},
timerImage:{
position: 'absolute',
top: 20,
},
timerText:{
position: 'absolute',
top: 50,
textAlign: 'center',
},
rightTopBigImageContainer: {
position: 'absolute',
top: 0,
left: leftBigImageWidth,
width: rightBigImageWidth,
height: rightBigImageHeight,
},
rightTopBigImage: {
width: rightBigImageWidth,
height: rightBigImageHeight,
},
rightTopSmallImageContainer: {
position: 'absolute',
top: 0,
left: leftBigImageWidth,
width: rightSmallImageWidth,
height: rightSmallImageHeight,
},
rightTopSmallImage: {
width: rightSmallImageWidth,
height: rightSmallImageHeight,
},
rightBottomBigImageContainer: {
position: 'absolute',
top: rightBigImageHeight,
left: leftBigImageWidth,
width: rightBigImageWidth,
height: rightBigImageHeight,
marginTop: 2,
},
rightBottomBigImage: {
width: rightBigImageWidth,
height: rightBigImageHeight,
},
rightBottomSmallImageContainer: {
position: 'absolute',
top: rightBigImageHeight,
left: leftBigImageWidth + rightBigImageWidth,
width: rightSmallImageWidth,
height: rightSmallImageHeight,
marginTop: 2,
},
rightBottomBigImage: {
width: rightSmallImageWidth,
height: rightSmallImageHeight,
},
});
... ...
... ... @@ -20,12 +20,17 @@ import installmentInitialState from './reducers/installment/installmentInitialSt
import InstallmentContainer from './containers/InstallmentContainer';
import OpenContainer from './containers/OpenContainer';
import InstallmentStatusContainer from './containers/InstallmentStatusContainer';
import {
setPlatform,
setChannel,
} from './reducers/app/appActions';
import {
setInstallmentStausPageParams,
} from './reducers/installment/installmentActions';
function getInitialState() {
const _initState = {
app: (new appInitialState()),
... ... @@ -56,6 +61,16 @@ export default function native(platform) {
<OpenContainer />
</Provider>
);
} else if (type == 'installStatus') {
let status = this.props.status;
let failReason = this.props.failReason;
let uid = this.props.uid;
store.dispatch(setInstallmentStausPageParams(status,failReason,uid));
return (
<Provider store={store}>
<InstallmentStatusContainer />
</Provider>
)
}
}
... ...
'use strict';
import React from 'react';
import ReactNative, {
View,
Text,
Image,
StyleSheet,
Dimensions,
PixelRatio,
TouchableOpacity,
Platform,
ListView,
} from 'react-native';
import Immutable, {Map} from 'immutable';
import ProductListCell from '../../../common/components/ListCell/ProductListCell';
export default class InstallmentStatus extends React.Component {
constructor(props) {
super(props);
this._renderRow = this._renderRow.bind(this);
this._renderHeader=this._renderHeader.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
}
_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 {failReason,status,jumpUrl,statusInfo,goods} = this.props.installmentStausPageInfo;
let resultImg;
if (status == 'review') {
resultImg = require('../../image/review-img-1.png');
} else if (status == 'error') {
resultImg = require('../../image/review-img-2.png');
} else if (status == 'success') {
resultImg = require('../../image/review-img-4.png');
} else if (status == 'cancel') {
resultImg = require('../../image/review-img-5.png');
} else if (status == 'refresh') {
resultImg = require('../../image/review-img-6.png');
}
if (goods && goods.size > 0) {
headerContainerHeight = (235 + 27 + 20 + 79 + 84.5) * DEVICE_WIDTH_RATIO;
}
if (status == 'cancel') {
headerContainerHeight = (235 + 27 + 20 + 79 + 40) * DEVICE_WIDTH_RATIO;
}
return (
<View style={[styles.headerContainer,{height:headerContainerHeight}]}>
<Image
style={styles.statusIcon}
source={resultImg}
resizeMode={'contain'}
/>
<Text style={styles.message}>
{statusInfo.get('message')}
</Text>
{status=='success'?
<View>
<Text style={{fontSize:12}}>
¥
<Text style={{fontSize: 24}}>
{statusInfo.get('reason')}
</Text>
</Text>
</View>
:<View>
<Text style={styles.reason}>
{statusInfo.get('reason')}
</Text>
{statusInfo.get('reasonTwo') ?
<Text style={styles.reason}>
{statusInfo.get('reasonTwo')}
</Text>
:null
}
{statusInfo.get('reasonThird') ?
<Text style={styles.reason}>
{statusInfo.get('reasonThird')}
</Text>
:null
}
</View>
}
<TouchableOpacity onPress={() => {this.props.onPressStatusPageBtn && this.props.onPressStatusPageBtn()}} >
<View style={styles.buttonContainer}>
<Text style={styles.button}>
{statusInfo.get('btnText')}
</Text>
</View>
</TouchableOpacity>
{goods&&goods.size>0 ?
<View>
<View style={{
marginTop: 30 * DEVICE_WIDTH_RATIO,
width: width,
height: 10 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
<Text style={{
width: width,
height: 44 * DEVICE_WIDTH_RATIO,
textAlign: 'center',
lineHeight: 29 *DEVICE_WIDTH_RATIO,
}}>
分期专享
</Text>
<View style={{
width: width,
height: 0.5 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
</View>
:null
}
</View>
)
}
render() {
let {failReason,status,jumpUrl,statusInfo,goods} = this.props.installmentStausPageInfo;
let dataSource = goods.toArray();
return(
<View style={styles.container}>
<ListView
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRows(dataSource)}
renderRow={this._renderRow}
renderHeader={this._renderHeader}
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 headerContainerHeight = (235 + 27 + 20 + 79) * DEVICE_WIDTH_RATIO;
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
},
headerContainer: {
width: width,
alignItems: 'center',
height: headerContainerHeight,
},
contentContainer:{
flexDirection: 'row',
flexWrap: 'wrap',
},
listContainer: {
width: width / 2,
},
statusIcon: {
width: 110 * DEVICE_WIDTH_RATIO,
height: 110 * DEVICE_WIDTH_RATIO,
marginTop: 100 * DEVICE_WIDTH_RATIO,
marginBottom: 25 * DEVICE_WIDTH_RATIO,
},
message: {
fontSize: 12 * DEVICE_WIDTH_RATIO,
color: '#444444',
marginBottom: 15 * DEVICE_WIDTH_RATIO,
},
reason: {
width: 260 * DEVICE_WIDTH_RATIO,
fontSize: 12 * DEVICE_WIDTH_RATIO,
color: '#b0b0b0',
textAlign: 'center',
lineHeight: 20 * 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,
},
});
... ...
... ... @@ -14,6 +14,7 @@ import ReactNative, {
import Immutable, {Map} from 'immutable';
import OpenPageInputCell from './OpenPageInputCell';
import Prompt from '../../../coupon/components/coupon/Prompt';
export default class Open extends React.Component {
constructor(props) {
... ... @@ -30,16 +31,54 @@ export default class Open extends React.Component {
if (!rowData) {
return null
}
return (
<OpenPageInputCell
cellParams={rowData}
snsCheckCodeEnable={this.props.openPageInfo.snsCheckCodeEnable}
snsCheckCodeText={this.props.openPageInfo.snsCheckCodeText}
onPressCardNoQuestion={this.props.onPressCardNoQuestion}
updateOpenPageCellInfo={this.props.updateOpenPageCellInfo}
onPressCheckCode={this.props.onPressCheckCode}
/>
);
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>
</View>
<View style={{
width: width,
height: 0.5,
backgroundColor: '#e5e5e5',
}}/>
</View>
);
}else {
return null;
}
} else {
return (
<OpenPageInputCell
cellParams={rowData}
snsCheckCodeEnable={this.props.openPageInfo.snsCheckCodeEnable}
snsCheckCodeText={this.props.openPageInfo.snsCheckCodeText}
onPressCardNoQuestion={this.props.onPressCardNoQuestion}
updateOpenPageCellInfo={this.props.updateOpenPageCellInfo}
onPressCheckCode={this.props.onPressCheckCode}
/>
);
}
}
_renderHeader() {
... ... @@ -99,7 +138,7 @@ export default class Open extends React.Component {
render() {
let {openPageInfo} = this.props;
let {cellList, agreeProtocol,nextBtnEnable} = openPageInfo;
let {cellList, agreeProtocol,nextBtnEnable,tipMessage} = openPageInfo;
if (cellList && cellList.size) {
cellList = cellList.toArray();
}else {
... ... @@ -115,6 +154,11 @@ export default class Open extends React.Component {
renderHeader={this._renderHeader}
renderFooter={this._renderFooter}
/>
{tipMessage !== '' ? <Prompt
text={tipMessage}
duration={800}
onPromptHidden={this.props.tipMessageRemove}
/> : null}
</View>
);
}
... ... @@ -182,4 +226,19 @@ let styles = StyleSheet.create({
fontSize: 14 * DEVICE_WIDTH_RATIO,
lineHeight: 26 * DEVICE_WIDTH_RATIO,
},
bankCellContainer: {
width: width,
height: 44.5 * DEVICE_WIDTH_RATIO,
backgroundColor: 'white',
alignItems: 'flex-start',
flexDirection: 'column',
},
bankIconContainer: {
flexDirection: 'row',
height: 44 * DEVICE_WIDTH_RATIO,
marginLeft: 50 * DEVICE_WIDTH_RATIO,
},
bankIcon: {
marginTop: 12 * DEVICE_WIDTH_RATIO,
},
});
... ...
... ... @@ -35,7 +35,7 @@ export default class OpenPageInputCell extends React.Component {
checkCodeColor = '#84c990';
}
let inputBoxWidth = 211 * DEVICE_WIDTH_RATIO;
if (cellParams.inputKey == "sns-check-code") {
if (cellParams.inputKey == "snsCheckCode") {
inputBoxWidth = 120 * DEVICE_WIDTH_RATIO;
}
return(
... ... @@ -48,7 +48,7 @@ export default class OpenPageInputCell extends React.Component {
<TextInput
autoCapitalize="none"
placeholder={cellParams.placeholder}
text={cellParams.text}
value={cellParams.text}
onChange={this._updateCellParams}
style={[styles.textInput,{width:inputBoxWidth}]}
maxLength={cellParams.maxLength}
... ... @@ -63,7 +63,7 @@ export default class OpenPageInputCell extends React.Component {
: null
}
{cellParams.inputKey == "sns-check-code" ?
{cellParams.inputKey == "snsCheckCode" ?
<TouchableOpacity onPress={() => {
this.props.onPressCheckCode && this.props.onPressCheckCode();
}}>
... ...
... ... @@ -17,6 +17,12 @@ export default keyMirror({
UPDATE_SNS_CHECK_CODE_ENABLE_STATUS: null,
UPDATE_CELL_LIST: null,
UPDATE_NEXT_BTN_ENABLE_STATUS: null,
UPDATE_NEXT_BTN_TEXT: null,
UPDATE_SNS_CHECK_CODE_TEXT: null,
UPDATE_TIP_MESSAGE: null,
NEXT_BTN_PROCESSING_REQUEST: null,
NEXT_BTN_PROCESSING_SUCCESS: null,
NEXT_BTN_PROCESSING_FAILURE: null,
SET_INSTALLMENT_STATUS_PAGE_ORIGINAL_INFO: null,
SET_INSTALLMENT_STATUS_PAGE_GOODS: null,
});
... ...
'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 installmentActions from '../reducers/installment/installmentActions';
import InstallmentStatus from '../components/installment/InstallmentStatus';
const actions = [
installmentActions,
];
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 InstallmentStatusContainer extends Component {
constructor(props) {
super(props);
this._onPressStatusPageBtn = this._onPressStatusPageBtn.bind(this);
}
componentDidMount() {
}
_onPressStatusPageBtn() {
this.props.actions.onPressStatusPageBtn();
}
render() {
let {installmentStausPageInfo} = this.props.installment;
return (
<InstallmentStatus
installmentStausPageInfo={installmentStausPageInfo}
onPressStatusPageBtn={this._onPressStatusPageBtn}
/>
);
}
}
let styles = StyleSheet.create({
container: {
flex: 1,
},
});
export default connect(mapStateToProps, mapDispatchToProps)(InstallmentStatusContainer);
... ...
... ... @@ -46,6 +46,7 @@ class OpenContainer extends Component {
this._onPressCardNoQuestion = this._onPressCardNoQuestion.bind(this);
this._updateOpenPageCellInfo = this._updateOpenPageCellInfo.bind(this);
this._onPressCheckCode = this._onPressCheckCode.bind(this);
this._tipMessageRemove = this._tipMessageRemove.bind(this);
}
componentDidMount() {
}
... ... @@ -55,7 +56,6 @@ class OpenContainer extends Component {
}
_onPressOpenNext() {
this.props.actions.updateNextBtnText('处理中...')
this.props.actions.onPressOpenNext();
}
... ... @@ -75,6 +75,10 @@ class OpenContainer extends Component {
this.props.actions.onPressCheckCode();
}
_tipMessageRemove() {
this.props.actions.updateTipMessage('');
}
render() {
let {openPageInfo} = this.props.installment;
return (
... ... @@ -87,6 +91,7 @@ class OpenContainer extends Component {
updateOpenPageCellInfo={this._updateOpenPageCellInfo}
onPressCheckCode={this._onPressCheckCode}
onPressOpenNext={this._onPressOpenNext}
tipMessageRemove={this._tipMessageRemove}
/>
);
}
... ...
... ... @@ -20,8 +20,14 @@ 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,
} = require('../../constants/actionTypes').default;
const codeContent = {
... ... @@ -109,17 +115,47 @@ export function updateNextBtnEnableStatus(status) {
}
}
export function updateNextBtnText(text) {
export function updateSnsCheckCodeText(text) {
return {
type: UPDATE_NEXT_BTN_TEXT,
type: UPDATE_SNS_CHECK_CODE_TEXT,
payload: text
}
}
export function updateSnsCheckCodeText(text) {
export function updateTipMessage(message) {
return {
type: UPDATE_SNS_CHECK_CODE_TEXT,
payload: text
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,
payload: params
}
}
export function setInstallmentStatusPageGoods(goods) {
return {
type: SET_INSTALLMENT_STATUS_PAGE_GOODS,
payload: goods
}
}
... ... @@ -222,10 +258,67 @@ export function onPressProtocol() {
export function onPressOpenNext() {
return (dispatch, getState) => {
let {app, installment} = getState();
let {nextBtnEnable} = installment.openPageInfo;
if (!nextBtnEnable) {
return;
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());
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) => {
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 => {
});
});
};
}
... ... @@ -247,6 +340,62 @@ export function onPressCardNoQuestion() {
};
}
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();
... ... @@ -256,14 +405,37 @@ export function updateOpenPageCellInfo(cellInfo) {
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 >=13) {
if (item.inputKey == 'cardNo' && item.text.length >=16 && cellInfo.inputKey != 'cardNo') {
cardNoValid = true;
} else if (item.inputKey == 'mobile' && item.text.length ==11) {
} else if (item.inputKey == 'mobile' && item.text.length ==11 && cellInfo.inputKey != 'mobile') {
mobileValid = true;
}
if (item.inputKey == cellInfo.inputKey) {
item.text = cellInfo.text;
item = cellInfo;
}
if (item.text == '') {
nextBtnEnable = false;
... ... @@ -275,6 +447,8 @@ export function updateOpenPageCellInfo(cellInfo) {
}else {
snsCheckCodeEnable = false;
}
console.log('cellInfo');
console.log(cellInfo);
dispatch(updateCellList(cellList));
dispatch(updateSnsCheckCodeEnableStatus(snsCheckCodeEnable));
dispatch(updateNextBtnEnableStatus(nextBtnEnable));
... ... @@ -362,3 +536,112 @@ export function onPressCheckCode() {
};
}
export function setInstallmentStausPageParams(statusCode, failReason, uid) {
return (dispatch, getState) => {
let {app, installment} = getState();
let status ='';
let jumpUrl = '';
let statusInfo = {};
if (statusCode == '2') {//成功
//请求用户信用额度
return new InstallmentService(app.host).getQueryCreditInfo('5448919')
.then(json => {
console.log('---额度');
console.log(json);
status = 'success',
statusInfo = {
message: '可用额度',
reason: json.currCreditLimit,
btnText: '去逛逛',
}
jumpUrl = `http://m.yohobuy.com/home/installment/index?uid=${uid}?openby:yohobuy={"action":"go.instalmentlist","params":{"title":"分期专享"}}`;
let params = {
statusCode,
status,
jumpUrl,
statusInfo,
};
dispatch(setInstallmentStatusPageOriginalInfo(params));
dispatch(getInstallmentProductAndAdvertisement(1));
})
.catch(error => {
});
}else {
switch (statusCode) {
case '1':{
status = 'review',
statusInfo = {
message: '审核中',
reason: '审核结果会在5分钟内短信通知您',
btnText: '先去逛逛',
}
}
break;
case '3':{
status = 'error',
statusInfo = {
message: '审核未通过暂时无法授信',
reason: failReason,
btnText: '重新申请',
}
}
break;
case '4':{
status = 'cancel',
statusInfo = {
message: '账户已注销',
reason: '您的有货分期账户经本人确认已注销,',
reasonTwo: '如有疑问,请联系客服。',
reasonThird: '提示:已注销用户不可再开通',
btnText: '先去逛逛',
}
}
break;
case '5':{
status = 'error',
statusInfo = {
message: '审核未通过暂时无法授信',
reason: '您的授信未通过,在有货更多的消费,增加信用度,会大大提升审核通过率奥。',
btnText: '重新申请',
}
}
break;
default:
}
}
console.log('---1111');
let params = {
statusCode,
status,
jumpUrl,
statusInfo,
};
dispatch(setInstallmentStatusPageOriginalInfo(params));
};
}
export function getInstallmentProductAndAdvertisement(page) {
return (dispatch, getState) => {
let {app, installment} = getState();
return new InstallmentService(app.host).getSearchIntallment(page)
.then(json => {
dispatch(setInstallmentStatusPageGoods(json.product_list))
console.log('goods');
console.log(json);
})
.catch(error => {
});
};
}
// onPressStatusPageBtn
export function onPressStatusPageBtn(page) {
return (dispatch, getState) => {
let {app, installment} = getState();
let {jumpUrl} = installment.installmentStausPageInfo;
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(jumpUrl);
};
}
... ...
... ... @@ -18,7 +18,14 @@ let openPageParams=[{
title: '卡号:',
placeholder: '银行卡号',
text: '',
maxLength: 19,
maxLength: 23,
showBankIcon: false,
},{
inputKey: 'BankIcon',
bankCode: '',
bankName: '',
bankText: '',
show: false,
},{
inputKey: 'mobile',
title: '手机号:',
... ... @@ -26,7 +33,7 @@ let openPageParams=[{
text: '',
maxLength: 11,
},{
inputKey: 'sns-check-code',
inputKey: 'snsCheckCode',
title: '验证码:',
placeholder: '请输入验证码',
text: '',
... ... @@ -55,11 +62,20 @@ let InitialState = Record({
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(),
})),
});
... ...
... ... @@ -21,6 +21,13 @@ const {
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,
} = require('../../constants/actionTypes').default;
... ... @@ -60,10 +67,26 @@ export default function appReducer(state = initialState, action) {
return state.setIn(['openPageInfo', 'cellList'], Immutable.fromJS(action.payload));
case UPDATE_NEXT_BTN_ENABLE_STATUS:
return state.setIn(['openPageInfo', 'nextBtnEnable'], action.payload);
case UPDATE_NEXT_BTN_TEXT:
return state.setIn(['openPageInfo', 'nextBtnText'], 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)
.setIn(['installmentStausPageInfo', 'jumpUrl'], action.payload.jumpUrl)
.setIn(['installmentStausPageInfo', 'statusInfo'], Immutable.fromJS(action.payload.statusInfo));
case SET_INSTALLMENT_STATUS_PAGE_GOODS:
return state.setIn(['installmentStausPageInfo', 'goods'], Immutable.fromJS(action.payload));
}
return state;
... ...
... ... @@ -61,4 +61,122 @@ export default class InstallmentService {
throw(error);
});
}
async fentchBankInfo(cardNo,uid) {
return await this.api.get({
url: '',
body: {
method: 'user.instalment.getBankInfoByCardNo',
cardNo,
uid,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
async checkVerifyCode(uid, mobile, snsCheckCode) {
console.log('snsCheckCode');
console.log(snsCheckCode);
return await this.api.get({
url: '',
body: {
method: 'user.instalment.validateSnsCheckCode',
uid,
mobile,
snsCheckCode,
codeType: 1, // 授信
}
})
.then((json) => {
console.log('---json');
console.log(json);
return json;
})
.catch((error) => {
throw(error);
});
}
/**
* 开通服务
*
* @param 参数
* uid 用户id
* userName 姓名
* identityCardNo 身份证号码
* cardNo 银行卡号码
* mobile 手机号码
* snsCheckCode 验证码
* @returns {*}
*/
async activateService(params) {
return await this.api.get({
url: '',
body: {
method: 'user.instalment.activate',
...params,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
async getSearchIntallment(page) {
return await this.api.get({
url: '',
body: {
method: 'app.search.instalment',
limit: '50',
order: 's_t_desc',
page: page
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
async getQueryCreditInfo(uid) {
return await this.api.get({
url: '',
body: {
method: 'user.instalment.queryCreditLimit',
uid,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
async getResources(content_code) {
return await this.serviceAPI.get({
url: '/operations/api/v5/resource/get',
body: {
content_code,
platform: 'iphone'
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
}
... ...