Authored by 张丽霞

分期付款,review by redding

... ... @@ -21,12 +21,20 @@ export function urlAddParamOfType(url, type='0') {
dataString = strs[1];
}
}
var obj = JSON.parse(dataString); //由JSON字符串转换为JSON对象
obj.params.type = type + ''; // params增加type参数
let totalUrlWithType = "yohobuy=" + JSON.stringify(obj);
if (strs.length > 1) {
totalUrlWithType = strs[0] + totalUrlWithType;
try {
var obj = {};
if (dataString.length > 1) {
obj = JSON.parse(dataString); //由JSON字符串转换为JSON对象
}
obj.params.type = type + ''; // params增加type参数
let totalUrlWithType = "yohobuy=" + JSON.stringify(obj);
if (strs.length > 1) {
totalUrlWithType = strs[0] + totalUrlWithType;
}
return totalUrlWithType;
} catch (e) {
}
return totalUrlWithType;
}
\ No newline at end of file
}
... ...
... ... @@ -12,15 +12,41 @@ import ReactNative, {
} from 'react-native';
import Immutable, {Map} from 'immutable';
import LoadingIndicator from '../../../common/components/LoadingIndicator';
import RepayListCell from './RepayListCell'
import Prompt from '../../../coupon/components/coupon/Prompt';
export default class AlreadyOpened extends React.Component {
export default class RepayList extends React.Component {
constructor(props) {
super(props);
super(props);
this._renderRow = this._renderRow.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
}
_renderRow(rowData, sectionID, rowID, highlightRow) {
return (
<RepayListCell
key={'row' + rowID}
rowID={rowID}
dataSource={rowData}
onPressRepaylistCellCheckbox={this.props.onPressRepaylistCellCheckbox}
onPressRepaylistCellDetail={this.props.onPressRepaylistCellDetail}
/>
);
}
render() {
let{repaymentList}=this.props;
if (!repaymentList || repaymentList.size == 0) {
let{isFetching,repaymentList,formateData,tipMessage}=this.props;
repaymentList = repaymentList.toArray();
formateData = formateData.toJS();
let checked = formateData.isAllChecked;
let checkboxIcon = require('../../image/check_icon.png');
if (!checked) {
checkboxIcon = require('../../image/fenqi_3_ic.png');
}
if (repaymentList.size == 0 && !isFetching) {
return (
<View style={styles.container}>
<Image
... ... @@ -38,18 +64,62 @@ export default class AlreadyOpened extends React.Component {
去逛逛
</Text>
</View>
</TouchableOpacity>
</TouchableOpacity>
<LoadingIndicator
isVisible={isFetching}
/>
</View>
);
}else {
return(
<View style={styles.container}>
{repaymentList.length>0?
<ListView
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRows(repaymentList)}
renderRow={this._renderRow}
/>
:null
}
<View style={styles.bottomContainer}>
<View style={styles.repaymentTotalContainer}>
<TouchableOpacity onPress={() => {this.props.onPressCheckAll &&this.props.onPressCheckAll()}} >
<Image style={styles.checkboxIcon} source={checkboxIcon}/>
</TouchableOpacity>
<View style={styles.repaymentTotal}>
<Text style={{fontSize:14*DEVICE_WIDTH_RATIO}}>待支付:
<Text style={{color:'#d2000d'}}>¥{formateData.currAmtCount?formateData.currAmtCount:''}</Text>
</Text>
{formateData.isCurrFee?
<Text>含逾期服务费¥{formateData.currFeeCount}</Text>
:null
}
</View>
</View>
<TouchableOpacity onPress={() => {this.props.onPressPayNow &&this.props.onPressPayNow()}} >
<View style={styles.repaymentBtn}>
<Text style={{color:'white',fontSize:17,lineHeight:29*DEVICE_WIDTH_RATIO}}>立即还款</Text>
</View>
</TouchableOpacity>
</View>
<LoadingIndicator
isVisible={isFetching}
/>
{tipMessage !== '' ? <Prompt
text={tipMessage}
duration={800}
onPromptHidden={this.props.clearTipMessage}
/> : null}
<Text>
RepayList page
</Text>
</View>
);
}
... ... @@ -62,8 +132,9 @@ const DEVICE_WIDTH_RATIO = width / 320;
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
backgroundColor: '#e5e5e5',
alignItems: 'center',
position: 'relative',
},
emptyIcon: {
width: 110 * DEVICE_WIDTH_RATIO,
... ... @@ -86,4 +157,41 @@ let styles = StyleSheet.create({
backgroundColor: 'transparent',
lineHeight: 29 * DEVICE_WIDTH_RATIO,
},
contentContainer:{
backgroundColor: 'white',
},
bottomContainer: {
width: width,
height: 57.5 * DEVICE_WIDTH_RATIO,
position: 'absolute',
bottom: 0,
backgroundColor: 'white',
flexDirection: 'row',
justifyContent: 'space-between',
},
repaymentTotalContainer: {
width: 190 * DEVICE_WIDTH_RATIO,
height: 60 * DEVICE_WIDTH_RATIO,
flexDirection: 'row',
},
repaymentTotal: {
marginLeft: 30 * DEVICE_WIDTH_RATIO,
marginTop: 10 * DEVICE_WIDTH_RATIO,
},
repaymentBtn: {
marginTop: 6.5 * DEVICE_WIDTH_RATIO,
marginRight: 15 * DEVICE_WIDTH_RATIO,
width: 85 * DEVICE_WIDTH_RATIO,
height: 44 * DEVICE_WIDTH_RATIO,
backgroundColor: '#d2000d',
borderRadius: 5,
alignItems: 'center',
},
checkboxIcon: {
width: 15 * DEVICE_WIDTH_RATIO,
height: 15 * DEVICE_WIDTH_RATIO,
marginLeft: 15 * DEVICE_WIDTH_RATIO,
marginTop: 18 * 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 RepayList extends React.Component {
constructor(props) {
super(props);
}
render() {
let{dataSource}=this.props;
dataSource = dataSource.toJS();
let checked = dataSource.isChecked;
let checkboxIcon = require('../../image/check_icon.png');
if (!checked) {
checkboxIcon = require('../../image/fenqi_3_ic.png');
}
return(
<View style={styles.container}>
<View style={styles.cellContainer}>
<View style={styles.cellLeftContainer}>
<TouchableOpacity onPress={() => {this.props.onPressRepaylistCellCheckbox &&this.props.onPressRepaylistCellCheckbox(dataSource)}} >
<Image style={styles.checkboxIcon} source={checkboxIcon}/>
</TouchableOpacity>
<View style={styles.priceContainer}>
<Text style={{marginLeft:5*DEVICE_WIDTH_RATIO}}>¥{dataSource.currAmt}</Text>
<Text numberOfLines={1}>【全{dataSource.stage}期】{dataSource.billInfo}</Text>
</View>
</View>
<TouchableOpacity onPress={() => {this.props.onPressRepaylistCellDetail &&this.props.onPressRepaylistCellDetail(dataSource)}} >
{dataSource.isOverdue?
<View style={styles.cellRightContainer}>
<Text style={{color:'#d0021b',fontSize:12*DEVICE_WIDTH_RATIO,marginRight:5*DEVICE_WIDTH_RATIO}}>逾期{dataSource.day}</Text>
<Image style={{width:12*DEVICE_WIDTH_RATIO,height:12*DEVICE_WIDTH_RATIO,marginRight:5*DEVICE_WIDTH_RATIO}} source={require("../../image/fenqi_3_ic.png")}/>
<Image style={{marginRight:5*DEVICE_WIDTH_RATIO}} source={require("../../image/category_b_arrow.png")}/>
</View>
:<View style={styles.cellRightContainer}>
<Text style={{color:'#b0b0b0',fontSize:12*DEVICE_WIDTH_RATIO,marginRight:5*DEVICE_WIDTH_RATIO}}>剩余{dataSource.day}</Text>
<Image style={{marginRight:5*DEVICE_WIDTH_RATIO}} source={require("../../image/category_b_arrow.png")}/>
</View>
}
</TouchableOpacity>
</View>
<View style={{
width: width,
height: 0.5 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
</View>
);
}
};
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
alignItems: 'center',
width: width,
height: 61 * DEVICE_WIDTH_RATIO,
},
cellContainer: {
width: width,
height: 60.5 * DEVICE_WIDTH_RATIO,
flexDirection: 'row',
justifyContent: 'space-between',
},
checkboxIcon: {
width: 15 * DEVICE_WIDTH_RATIO,
height: 15 * DEVICE_WIDTH_RATIO,
marginLeft: 15 * DEVICE_WIDTH_RATIO,
},
cellLeftContainer: {
flexDirection: 'row',
width: 190 * DEVICE_WIDTH_RATIO,
alignItems: 'center',
},
priceContainer: {
width: 160 * DEVICE_WIDTH_RATIO,
height: 40 * DEVICE_WIDTH_RATIO,
marginTop: 10 * DEVICE_WIDTH_RATIO,
},
cellRightContainer: {
marginRight: 15 * DEVICE_WIDTH_RATIO,
height: 60 * DEVICE_WIDTH_RATIO,
alignItems: 'center',
flexDirection: 'row',
}
});
... ...
... ... @@ -35,7 +35,14 @@ export default keyMirror({
SET_ALREADY_PAGE_AMT_INFO: null,
SET_ALREADY_PAGE_OVERDUE_STATUS: null,
SET_ALREADY_PAGE_CREDIT_INFO: null,
SET_ALREADY_PAGE_REPAY_STATUS_INFO: null,
SET_QUERY_DAYS: null,
SET_REPAYMENT_LIST: null,
QUERY_REPAYMENT_LIST_REQUEST: null,
QUERY_REPAYMENT_LIST_FAILURE: null,
QUERY_REPAYMENT_LIST_SUCCESS: null,
SET_FORMATE_DATA: null,
UPDATE_REPAYMENT_LIST: null,
SET_TIP_MESSAGE: null,
UPDATE_REPAYMENT_LIST_AND_FORMATE_DATA: null,
});
... ...
... ... @@ -17,6 +17,7 @@ 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,
];
... ... @@ -41,6 +42,11 @@ class RepayListContainer extends Component {
constructor(props) {
super(props);
this._onPressGoNew = this._onPressGoNew.bind(this);
this._onPressRepaylistCellCheckbox = this._onPressRepaylistCellCheckbox.bind(this);
this._onPressRepaylistCellDetail = this._onPressRepaylistCellDetail.bind(this);
this._clearTipMessage = this._clearTipMessage.bind(this);
this._onPressCheckAll = this._onPressCheckAll.bind(this);
this._onPressPayNow = this._onPressPayNow.bind(this);
}
componentDidMount() {
this.props.actions.getQueryAmtList("0");
... ... @@ -50,12 +56,40 @@ class RepayListContainer extends Component {
this.props.actions.getoNewArrival();
}
_onPressRepaylistCellCheckbox(cellInfo) {
this.props.actions.onPressRepaylistCellCheckbox(cellInfo);
}
_clearTipMessage() {
this.props.actions.setTipMessage('');
}
_onPressCheckAll() {
this.props.actions.onPressCheckAll();
}
_onPressRepaylistCellDetail(cellInfo) {
this.props.actions.onPressRepaylistCellDetail(cellInfo);
}
_onPressPayNow() {
this.props.actions.onPressPayNow();
}
render() {
let {queryDays,repaymentList} = this.props.repayList;
let {isFetching,queryDays,repaymentList,formateData,tipMessage} = this.props.repayList;
return (
<RepayList
repaymentList={repaymentList}
formateData={formateData}
isFetching={isFetching}
tipMessage={tipMessage}
onPressGoNew={this._onPressGoNew}
onPressRepaylistCellCheckbox={this._onPressRepaylistCellCheckbox}
onPressRepaylistCellDetail={this._onPressRepaylistCellDetail}
clearTipMessage={this._clearTipMessage}
onPressCheckAll={this._onPressCheckAll}
onPressPayNow={this._onPressPayNow}
/>
);
}
... ...
... ... @@ -26,6 +26,7 @@ SET_ALREADY_PAGE_NOTICE,
SET_ALREADY_PAGE_AMT_INFO,
SET_ALREADY_PAGE_OVERDUE_STATUS,
SET_ALREADY_PAGE_CREDIT_INFO,
SET_ALREADY_PAGE_REPAY_STATUS_INFO,
} = require('../../../constants/actionTypes').default;
const codeContent = {
... ... @@ -144,6 +145,12 @@ export function setAlreadPageCreditInfo(creditInfo) {
}
}
export function setAlreadPageRepayStatusInfo(statusInfo) {
return {
type: SET_ALREADY_PAGE_REPAY_STATUS_INFO,
payload: statusInfo,
}
}
export function productListForInstallment() {
return (dispatch, getState) => {
... ... @@ -406,7 +413,9 @@ function getAlreadPageAmtInfo(uid) {
let {app, installment} = getState();
return new InstallmentService(app.host).getAmtInfo(uid)
.then(json => {
console.log('---还款信息');
json.dayAmt = json.s_7daysAmt;
console.log(json);
dispatch(setAlreadPageAmtInfo(json))
})
.catch(error => {
... ... @@ -417,9 +426,21 @@ function getAlreadPageAmtInfo(uid) {
function getAlreadPageCreditInfo(uid) {
return (dispatch, getState) => {
let {app, installment} = getState();
let repayStatusInfo={
isOverdue: false,
repayStatus: '正常',
}
return new InstallmentService(app.host).getQueryCreditInfo(uid)
.then(json => {
// status: 1 正常 2 逾期 3 不可用 4 未开通
if (json.status == '2') {
repayStatusInfo.replayStatus = '逾期';
repayStatusInfo.isOverdue = true;
} else if (json.status == '3') {
repayStatusInfo.replayStatus = '不可用';
}
dispatch(setAlreadPageCreditInfo(json))
dispatch(setAlreadPageRepayStatusInfo(repayStatusInfo));
})
.catch(error => {
});
... ...
... ... @@ -22,6 +22,7 @@ let InitialState = Record({
tabFocusIndex: 1,
goods: List(),
isOverdue: false,
repayStatus: '',
content: Map(),
notice: Map(),
installmentInfo:Map(),
... ...
... ... @@ -25,6 +25,7 @@ const {
SET_ALREADY_PAGE_AMT_INFO,
SET_ALREADY_PAGE_OVERDUE_STATUS,
SET_ALREADY_PAGE_CREDIT_INFO,
SET_ALREADY_PAGE_REPAY_STATUS_INFO,
} = require('../../../constants/actionTypes').default;
... ... @@ -78,6 +79,9 @@ export default function appReducer(state = initialState, action) {
return state.setIn(['alreadyOpenedPageInfo', 'isOverdue'], Immutable.fromJS(action.payload));
case SET_ALREADY_PAGE_CREDIT_INFO:
return state.setIn(['alreadyOpenedPageInfo', 'creditInfo'], Immutable.fromJS(action.payload));
case SET_ALREADY_PAGE_REPAY_STATUS_INFO:
return state.setIn(['alreadyOpenedPageInfo', 'isOverdue'], action.payload.isOverdue)
.setIn(['alreadyOpenedPageInfo', 'repayStatus'], action.payload.repayStatus);
}
return state;
... ...
... ... @@ -2,12 +2,18 @@
import ReactNative from 'react-native';
import InstallmentService from '../../../services/InstallmentService';
import * as _ from 'lodash';
const {
SET_PLATFORM,
SET_QUERY_DAYS,
SET_REPAYMENT_LIST,
SET_FORMATE_DATA,
QUERY_REPAYMENT_LIST_REQUEST,
QUERY_REPAYMENT_LIST_FAILURE,
QUERY_REPAYMENT_LIST_SUCCESS,
UPDATE_REPAYMENT_LIST_AND_FORMATE_DATA,
SET_TIP_MESSAGE,
} = require('../../../constants/actionTypes').default;
... ... @@ -18,21 +24,166 @@ export function setQueryDays(days){
}
}
// SET_REPAYMENT_LIST
export function setRepaymentList(list){
// QUERY_REPAYMENT_LIST_SUCCESS
export function queryRepaymentListRequest(){
return {
type: SET_REPAYMENT_LIST,
type: QUERY_REPAYMENT_LIST_REQUEST,
}
}
export function queryRepaymentListFailure(error){
return {
type: QUERY_REPAYMENT_LIST_FAILURE,
payload: error,
}
}
export function queryRepaymentListSuccess(list){
return {
type: QUERY_REPAYMENT_LIST_SUCCESS,
payload: list,
}
}
export function setFormateData(data){
return {
type: SET_FORMATE_DATA,
payload: data,
}
}
export function setTipMessage(message){
return {
type: SET_TIP_MESSAGE,
payload: message,
}
}
export function updatRepaymentListAndFormateData(object){
return {
type: UPDATE_REPAYMENT_LIST_AND_FORMATE_DATA,
payload: object,
}
}
function processAmtList(list, queryDays) {
let overduecount = 0;
let formateData = {
currAmtCount: 0,
currFeeCount: 0
};
if (list) {
_.forEach(list, (data, key) => {
// 第一条选中
if (key == 0) {
data.isChecked = true;
}
// 组装分期的显示格式
if (data.terms == 1) {
data.stage = data.terms;
} else {
data.stage = data.currTerm + '/' + data.terms;
}
// 判断是否逾期
if (data.unExpireDays < 0) {
data.isOverdue = true;
overduecount++;
}
data.day = Math.abs(data.unExpireDays);
data.url = `/home/installment/order/${data.billNo}`;
data.key = key;
});
if (overduecount == 0) {
if (queryDays == 0) { // 待还总金额
list[0].isChecked = true;
formateData.currAmtCount = (+list[0].currAmt);
formateData.currFeeCount = (+list[0].currFee);
if (list.length == 1) {
formateData.isAllChecked = true;
}
} else if (queryDays == 7 || queryDays == 30) { // 近7日待还金额和本月待还金额
_.forEach(list, (data) => {
data.isChecked = true;
formateData.currAmtCount += (+data.currAmt);
formateData.currFeeCount += (+data.currFee);
});
formateData.isAllChecked = true;
}
} else { // 只要有逾期的记录,走这里
_.forEach(list, (data) => {
if (data.unExpireDays < 0) {
data.isChecked = true;
formateData.currAmtCount += (+data.currAmt);
formateData.currFeeCount += (+data.currFee);
}
});
if (overduecount == list.length) {
formateData.isAllChecked = true;
}
}
// 逾期未还款金额
if (queryDays == -1) {
formateData.isAllChecked = true;
}
if (formateData.currFeeCount > 0) {
formateData.isCurrFee = true;
} else {
formateData.isCurrFee = false;
}
return {
repaymentList: list,
formateData,};
}else {
return null;
}
}
function amtAndFeeCount(list) {
let formateData = {
currAmtCount: 0,
currFeeCount: 0
};
let cellLength = list.length;
let count = 0
if (list) {
_.forEach(list, (data) => {
if (data.isChecked) {
count++;
formateData.currAmtCount += (+data.currAmt);
formateData.currFeeCount += (+data.currFee);
}
});
if (count == cellLength) {
formateData.isAllChecked = true;
}
if (formateData.currFeeCount > 0) {
formateData.isCurrFee = true;
} else {
formateData.isCurrFee = false;
}
return formateData;
}else {
return null;
}
}
export function getQueryAmtList(days) {
return (dispatch, getState) => {
let {app, rePayList} = getState();
let {app, repayList} = getState();
dispatch(queryRepaymentListRequest());
return new InstallmentService(app.host).getQueryAmtList(days)
.then(json => {
if (json && json.length > 0) {
dispatch(setRepaymentList(json));
if (json && json.amtList.length > 0) {
let result = processAmtList(json.amtList, days);
dispatch(queryRepaymentListSuccess(result.repaymentList));
dispatch(setFormateData(result.formateData));
}
})
.catch(error => {
... ... @@ -42,9 +193,103 @@ export function getQueryAmtList(days) {
export function getoNewArrival() {
return (dispatch, getState) => {
let {app, rePayList} = 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);
};
}
// onPressRepaylistCell
export function onPressRepaylistCellCheckbox(cellInfo) {
return (dispatch, getState) => {
let {app, repayList} = getState();
let {repaymentList,queryDays} = repayList;
repaymentList = repaymentList.toJS();
let formateData;
let curIndex = cellInfo.key;
let tipMessage = '';
if (curIndex == 0) {
if (repaymentList[curIndex+1].isChecked) {
tipMessage = '同一个分期订单不能跨期还款,请按时间顺序还款';
dispatch(setTipMessage(tipMessage));
}else {
repaymentList[curIndex].isChecked = !repaymentList[curIndex].isChecked;
formateData = amtAndFeeCount(repaymentList);
dispatch(updatRepaymentListAndFormateData({repaymentList,formateData}));
}
}else if (curIndex == repaymentList.length - 1) {
if (!repaymentList[curIndex-1].isChecked) {
tipMessage = '同一个分期订单不能跨期还款,请按时间顺序还款';
dispatch(setTipMessage(tipMessage));
}else {
repaymentList[curIndex].isChecked = !repaymentList[curIndex].isChecked;
formateData = amtAndFeeCount(repaymentList);
dispatch(updatRepaymentListAndFormateData({repaymentList,formateData}));
}
}else {
if (!repaymentList[curIndex-1].isChecked || repaymentList[curIndex + 1].isChecked) {
tipMessage = '同一个分期订单不能跨期还款,请按时间顺序还款';
dispatch(setTipMessage(tipMessage));
}else {
repaymentList[curIndex].isChecked = !repaymentList[curIndex].isChecked;
formateData = amtAndFeeCount(repaymentList);
dispatch(updatRepaymentListAndFormateData({repaymentList,formateData}));
}
}
};
}
export function onPressCheckAll(cellInfo) {
return (dispatch, getState) => {
let {app, repayList} = getState();
let {repaymentList,queryDays,formateData} = repayList;
repaymentList = repaymentList.toJS();
formateData = formateData.toJS();
formateData.isAllChecked = !formateData.isAllChecked;
_.forEach(repaymentList, (data) => {
data.isChecked = formateData.isAllChecked;
});
formateData = amtAndFeeCount(repaymentList);
dispatch(updatRepaymentListAndFormateData({repaymentList,formateData}));
};
}
// onPressPayNow
export function onPressPayNow() {
return (dispatch, getState) => {
let {app, repayList} = getState();
let {repaymentList,queryDays,formateData} = repayList;
formateData = formateData.toJS();
repaymentList = repaymentList.toJS();
let checkedCellList=[];
_.forEach(repaymentList, (data) => {
if (data.isChecked) {
checkedCellList.push({
index: data.key,
orderCode: data.billNo,
termNo: data.currTerm,
});
}
});
console.log('checkedCellList');
console.log(checkedCellList);
let url = {
action: "go.instalmentRepayment",
params:{
list: checkedCellList,
amount: formateData.currAmtCount,
},
};
url = JSON.stringify(url);
let jumpUrl = `http://m.yohobuy.com/home/installment/repay/total?openby:yohobuy=${url}`;
// let jumpUrl = `http://m.yohobuy.com/product/new/?openby:yohobuy={"action":"go.new","params":{"title":"新品到着"}}`;
console.log('jumpUrl');
console.log(jumpUrl);
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(jumpUrl);
};
}
... ...
... ... @@ -3,9 +3,13 @@
import Immutable,{Record, List, Map} from 'immutable';
let InitialState = Record({
isFetching:false,
isFetching: false,
queryDays: '',
repaymentList: List(),
formateData: Map(),
error: null,
showBottom: true,
tipMessage: '',
});
export default InitialState;
... ...
... ... @@ -5,7 +5,13 @@ import Immutable, {Map} from 'immutable';
const {
SET_QUERY_DAYS,
SET_REPAYMENT_LIST,
QUERY_REPAYMENT_LIST_REQUEST,
QUERY_REPAYMENT_LIST_FAILURE,
QUERY_REPAYMENT_LIST_SUCCESS,
SET_FORMATE_DATA,
SET_TIP_MESSAGE,
UPDATE_REPAYMENT_LIST_AND_FORMATE_DATA,
} = require('../../../constants/actionTypes').default;
... ... @@ -18,8 +24,28 @@ export default function appReducer(state = initialState, action) {
case SET_QUERY_DAYS:{
return state.set('queryDays', action.payload);
}
case SET_REPAYMENT_LIST: {
return state.set('repaymentList', Immutable.from(action.payload));
case QUERY_REPAYMENT_LIST_REQUEST: {
return state.set('isFetching', true)
.set('error', null);
}
case QUERY_REPAYMENT_LIST_FAILURE: {
return state.set('isFetching', false)
.set('error',action.payload);
}
case UPDATE_REPAYMENT_LIST_AND_FORMATE_DATA: {
return state.set('repaymentList', Immutable.fromJS(action.payload.repaymentList))
.set('formateData', Immutable.fromJS(action.payload.formateData));
}
case QUERY_REPAYMENT_LIST_SUCCESS: {
console.log('---3333');
return state.set('repaymentList', Immutable.fromJS(action.payload))
.set('isFetching', false);
}
case SET_FORMATE_DATA: {
return state.set('formateData', Immutable.fromJS(action.payload));
}
case SET_TIP_MESSAGE: {
return state.set('tipMessage', action.payload);
}
}
... ...
... ... @@ -13,6 +13,7 @@ const {
SWITCH_GENDER,
JUMP_WITH_URL,
} = require('../../constants/actionTypes').default;
import {urlAddParamOfType} from '../../../common/utils/urlHandler';
export function setSegment(segment) {
return {
... ... @@ -157,37 +158,11 @@ export function jumpWithUrl(url) {
return;
}
//拼接type
url = urlAddParamOfType(url);
url = urlAddParamOfType(url, '7')
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
return {
type: JUMP_WITH_URL,
payload: url
};
}
function urlAddParamOfType(url) {
let strs= new Array();
let dataString = '';
if (url.indexOf('yohobuy=') !== -1) {
strs = url.split("yohobuy=");
if (strs.length == 1) {
dataString = strs[0];
} else {
dataString = strs[1];
}
} else {
strs = url.split("yohobuy=");
if (strs.length == 1) {
dataString = strs[0];
} else {
dataString = strs[1];
}
}
var obj = JSON.parse(dataString); //由JSON字符串转换为JSON对象
obj.params.type = '7';
let totalUrlWithType = "yohobuy=" + JSON.stringify(obj);
if (strs.length > 1) {
totalUrlWithType = strs[0] + totalUrlWithType;
}
return totalUrlWithType;
}
... ...