Authored by chenl

增加了订单付款详情业务逻辑。review by 张丽霞。

@@ -97,8 +97,8 @@ export default class ConfirmPay extends React.Component { @@ -97,8 +97,8 @@ export default class ConfirmPay extends React.Component {
97 onChange={this._codeValueChange} 97 onChange={this._codeValueChange}
98 onFocus={this._codeInputOnFocus} 98 onFocus={this._codeInputOnFocus}
99 style={styles.textInput} 99 style={styles.textInput}
100 - maxLength={4}  
101 keyboardType='numeric' 100 keyboardType='numeric'
  101 + underlineColorAndroid="transparent"
102 /> 102 />
103 </View> 103 </View>
104 <TouchableOpacity onPress={() => {this._reSendConfirmPaySnsCode()}} > 104 <TouchableOpacity onPress={() => {this._reSendConfirmPaySnsCode()}} >
@@ -198,6 +198,7 @@ let styles = StyleSheet.create({ @@ -198,6 +198,7 @@ let styles = StyleSheet.create({
198 height: 44 * DEVICE_WIDTH_RATIO, 198 height: 44 * DEVICE_WIDTH_RATIO,
199 fontSize: 12 * DEVICE_WIDTH_RATIO, 199 fontSize: 12 * DEVICE_WIDTH_RATIO,
200 marginTop: 1 * DEVICE_WIDTH_RATIO, 200 marginTop: 1 * DEVICE_WIDTH_RATIO,
  201 + padding: 0,
201 }, 202 },
202 reSendSnsCode: { 203 reSendSnsCode: {
203 width: 78 * DEVICE_WIDTH_RATIO, 204 width: 78 * DEVICE_WIDTH_RATIO,
@@ -19,6 +19,8 @@ import SlicedImage from '../../../common/components/SlicedImage'; @@ -19,6 +19,8 @@ import SlicedImage from '../../../common/components/SlicedImage';
19 import LoadingIndicator from '../../../common/components/LoadingIndicator'; 19 import LoadingIndicator from '../../../common/components/LoadingIndicator';
20 import BankSafePay from '../installment/BankSafePay'; 20 import BankSafePay from '../installment/BankSafePay';
21 import ConfirmPay from '../installment/ConfirmPay'; 21 import ConfirmPay from '../installment/ConfirmPay';
  22 +import Prompt from '../../../coupon/components/coupon/Prompt';
  23 +
22 24
23 export default class MyOrderDetail extends React.Component { 25 export default class MyOrderDetail extends React.Component {
24 constructor(props) { 26 constructor(props) {
@@ -35,13 +37,15 @@ export default class MyOrderDetail extends React.Component { @@ -35,13 +37,15 @@ export default class MyOrderDetail extends React.Component {
35 return ( 37 return (
36 <MyOrderDetailPayListCell 38 <MyOrderDetailPayListCell
37 data={rowData} 39 data={rowData}
  40 + rowIndex={rowID}
  41 + onPressCheckboxCell={this.props.onPressCheckboxCell}
38 /> 42 />
39 ); 43 );
40 } 44 }
41 45
42 render() { 46 render() {
43 47
44 - let {isFetching, orderInfo, showBankSafePayView, showConfirmPayView, payCard, formateData} = this.props.myOrderDetail; 48 + let {isFetching, orderInfo, showBankSafePayView, showConfirmPayView, payCard, formateData, tipMessage} = this.props.myOrderDetail;
45 49
46 if(!orderInfo) 50 if(!orderInfo)
47 return null; 51 return null;
@@ -64,7 +68,7 @@ export default class MyOrderDetail extends React.Component { @@ -64,7 +68,7 @@ export default class MyOrderDetail extends React.Component {
64 //分期列表 68 //分期列表
65 let package_list = orderInfo.get("package_list") ? orderInfo.get("package_list").toArray() : []; 69 let package_list = orderInfo.get("package_list") ? orderInfo.get("package_list").toArray() : [];
66 70
67 - let checked = this.props.isChecked; 71 + let checked = formateData.get("isAllChecked");
68 let checkboxIcon = require('../../image/uncheck_icon.png'); 72 let checkboxIcon = require('../../image/uncheck_icon.png');
69 if (checked) { 73 if (checked) {
70 checkboxIcon = require('../../image/check_icon.png'); 74 checkboxIcon = require('../../image/check_icon.png');
@@ -107,14 +111,15 @@ export default class MyOrderDetail extends React.Component { @@ -107,14 +111,15 @@ export default class MyOrderDetail extends React.Component {
107 /> 111 />
108 <View style={styles.splitLine}></View> 112 <View style={styles.splitLine}></View>
109 <View style={styles.bottomContainer}> 113 <View style={styles.bottomContainer}>
110 - <View style={styles.checkboxContainer}> 114 + <TouchableOpacity style={styles.checkboxContainer} activeOpacity={1} onPress={() => {
  115 + this.props.onPressCheckboxAll && this.props.onPressCheckboxAll()}}>
111 <Image style={styles.checkboxIcon} source={checkboxIcon}/> 116 <Image style={styles.checkboxIcon} source={checkboxIcon}/>
112 - </View> 117 + </TouchableOpacity>
113 <View style={styles.payMoneyContainer}> 118 <View style={styles.payMoneyContainer}>
114 <Text style={styles.payTitle} numberOfLines={1}>待支付</Text> 119 <Text style={styles.payTitle} numberOfLines={1}>待支付</Text>
115 - <Text style={styles.payAmount} numberOfLines={1}>{"¥ 555"}</Text> 120 + <Text style={styles.payAmount} numberOfLines={1}> ¥{formateData.get("currAmtCount")?formateData.get("currAmtCount"):'0.00'}</Text>
116 </View> 121 </View>
117 - <Text style={styles.payDesc} numberOfLines={1}>{"含服务费¥5.00"}</Text> 122 + <Text style={styles.payDesc} numberOfLines={1}>含服务费¥{formateData.get("currFeeCount")?formateData.get("currFeeCount"):'0.00'}</Text>
118 123
119 <TouchableOpacity style={styles.payButtonContainer} activeOpacity={1} onPress={() => { 124 <TouchableOpacity style={styles.payButtonContainer} activeOpacity={1} onPress={() => {
120 this.props.onPressPayNow && this.props.onPressPayNow()}}> 125 this.props.onPressPayNow && this.props.onPressPayNow()}}>
@@ -129,8 +134,8 @@ export default class MyOrderDetail extends React.Component { @@ -129,8 +134,8 @@ export default class MyOrderDetail extends React.Component {
129 134
130 {showBankSafePayView? 135 {showBankSafePayView?
131 <BankSafePay 136 <BankSafePay
132 - payCard={payCard}  
133 - formateData={formateData} 137 + payCard={payCard.toJS()}
  138 + formateData={formateData.toJS()}
134 closeBankSafePay={this.props.closeBankSafePay} 139 closeBankSafePay={this.props.closeBankSafePay}
135 bankSafePayNow={this.props.bankSafePayNow} 140 bankSafePayNow={this.props.bankSafePayNow}
136 changeBankCard={this.props.changeBankCard} 141 changeBankCard={this.props.changeBankCard}
@@ -146,6 +151,12 @@ export default class MyOrderDetail extends React.Component { @@ -146,6 +151,12 @@ export default class MyOrderDetail extends React.Component {
146 /> 151 />
147 :null 152 :null
148 } 153 }
  154 +
  155 + {tipMessage !== '' ? <Prompt
  156 + text={tipMessage}
  157 + duration={800}
  158 + onPromptHidden={this.props.clearTipMessage}
  159 + /> : null}
149 160
150 161
151 </View> 162 </View>
@@ -45,26 +45,27 @@ export default class MyOrderDetailPayListCell extends React.Component { @@ -45,26 +45,27 @@ export default class MyOrderDetailPayListCell extends React.Component {
45 45
46 46
47 return( 47 return(
48 - <TouchableOpacity activeOpacity={1} onPress={() => this.props.onPressOrder && this.props.onPressOrder()}>  
49 - <View style={styles.container} >  
50 - <View style={styles.sortContainer}>  
51 - {  
52 - isPayable ? <Image style={styles.checkboxIcon} source={checkboxIcon}/>  
53 - : <Text style={styles.sortText} numberOfLines={1}>{sort}</Text>  
54 - }  
55 - </View>  
56 - <Text style={styles.totalAmount} numberOfLines={1}>{currentTotalAmount}</Text>  
57 - <View style={styles.amountDetailContainer}>  
58 - <Text style={styles.amountText}>{currentDate}</Text>  
59 - <Text style={styles.amountText}>{"本金:" + currentPAmount}</Text>  
60 - <Text style={styles.amountText}>{"服务费:" + currentFee}</Text>  
61 - {  
62 - isDelay ? <Text style={styles.amountText}>{"逾期服务费:" + currentDelayFee}</Text> : null  
63 - }  
64 - </View>  
65 - <Text style={[styles.desc,colorStyle]} numberOfLines={1}>{desc}</Text> 48 + <View style={styles.container} >
  49 + <View style={styles.sortContainer}>
  50 + {
  51 + isPayable ?
  52 + <TouchableOpacity activeOpacity={1} onPress={() => this.props.onPressCheckboxCell && this.props.onPressCheckboxCell(this.props.rowIndex)}>
  53 + <Image style={styles.checkboxIcon} source={checkboxIcon}/>
  54 + </TouchableOpacity>
  55 + : <Text style={styles.sortText} numberOfLines={1}>{sort}</Text>
  56 + }
66 </View> 57 </View>
67 - </TouchableOpacity> 58 + <Text style={styles.totalAmount} numberOfLines={1}>{currentTotalAmount}</Text>
  59 + <View style={styles.amountDetailContainer}>
  60 + <Text style={styles.amountText}>{currentDate}</Text>
  61 + <Text style={styles.amountText}>{"本金:" + currentPAmount}</Text>
  62 + <Text style={styles.amountText}>{"服务费:" + currentFee}</Text>
  63 + {
  64 + isDelay ? <Text style={styles.amountText}>{"逾期服务费:" + currentDelayFee}</Text> : null
  65 + }
  66 + </View>
  67 + <Text style={[styles.desc,colorStyle]} numberOfLines={1}>{desc}</Text>
  68 + </View>
68 ); 69 );
69 } 70 }
70 71
@@ -90,4 +90,6 @@ export default keyMirror({ @@ -90,4 +90,6 @@ export default keyMirror({
90 GET_ORDER_DETAIL_REQUEST: null, 90 GET_ORDER_DETAIL_REQUEST: null,
91 GET_ORDER_DETAIL_FAILURE: null, 91 GET_ORDER_DETAIL_FAILURE: null,
92 GET_ORDER_DETAIL_SUCCESS: null, 92 GET_ORDER_DETAIL_SUCCESS: null,
  93 +
  94 + UPDATE_ORDER_INFO_AND_FORMATE_DATA: null,
93 }); 95 });
@@ -47,19 +47,30 @@ class InstallmentMyOrderDetailContainer extends Component { @@ -47,19 +47,30 @@ class InstallmentMyOrderDetailContainer extends Component {
47 constructor(props) { 47 constructor(props) {
48 super(props); 48 super(props);
49 this._reloadPage = this._reloadPage.bind(this); 49 this._reloadPage = this._reloadPage.bind(this);
50 - // this._onPressCheckAll = this._onPressCheckAll.bind(this); 50 + this._onPressCheckboxCell = this._onPressCheckboxCell.bind(this);
  51 + this._onPressCheckboxAll = this._onPressCheckboxAll.bind(this);
51 this._onPressPayNow = this._onPressPayNow.bind(this); 52 this._onPressPayNow = this._onPressPayNow.bind(this);
52 this._closeBankSafePay = this._closeBankSafePay.bind(this); 53 this._closeBankSafePay = this._closeBankSafePay.bind(this);
53 this._bankSafePayNow = this._bankSafePayNow.bind(this); 54 this._bankSafePayNow = this._bankSafePayNow.bind(this);
54 this._cancelPayInConfirm = this._cancelPayInConfirm.bind(this); 55 this._cancelPayInConfirm = this._cancelPayInConfirm.bind(this);
55 this._reSendConfirmPaySnsCode = this._reSendConfirmPaySnsCode.bind(this); 56 this._reSendConfirmPaySnsCode = this._reSendConfirmPaySnsCode.bind(this);
56 this._confirmPayAction = this._confirmPayAction.bind(this); 57 this._confirmPayAction = this._confirmPayAction.bind(this);
  58 + this._clearTipMessage = this._clearTipMessage.bind(this);
57 } 59 }
58 60
59 _reloadPage() { 61 _reloadPage() {
  62 + this.props.actions.getBankCards();
60 this.props.actions.getOrderDetail(); 63 this.props.actions.getOrderDetail();
61 } 64 }
62 65
  66 + _onPressCheckboxCell(cellInfo) {
  67 + this.props.actions.onPressCheckboxCell(cellInfo);
  68 + }
  69 +
  70 + _onPressCheckboxAll() {
  71 + this.props.actions.onPressCheckboxAll();
  72 + }
  73 +
63 _onPressPayNow() { 74 _onPressPayNow() {
64 this.props.actions.onPressPayNow(); 75 this.props.actions.onPressPayNow();
65 } 76 }
@@ -84,8 +95,13 @@ class InstallmentMyOrderDetailContainer extends Component { @@ -84,8 +95,13 @@ class InstallmentMyOrderDetailContainer extends Component {
84 this.props.actions.confirmPayAction(snsCode); 95 this.props.actions.confirmPayAction(snsCode);
85 } 96 }
86 97
  98 + _clearTipMessage() {
  99 + this.props.actions.setTipMessage('');
  100 + }
  101 +
87 102
88 componentDidMount() { 103 componentDidMount() {
  104 + this.props.actions.getBankCards();
89 this.props.actions.getOrderDetail(); 105 this.props.actions.getOrderDetail();
90 } 106 }
91 107
@@ -104,14 +120,15 @@ class InstallmentMyOrderDetailContainer extends Component { @@ -104,14 +120,15 @@ class InstallmentMyOrderDetailContainer extends Component {
104 <MyOrderDetail 120 <MyOrderDetail
105 style={styles.container} 121 style={styles.container}
106 myOrderDetail={this.props.myOrderDetail} 122 myOrderDetail={this.props.myOrderDetail}
107 - // onPressRepaylistCellCheckbox={this._onPressRepaylistCellCheckbox}  
108 - // onPressCheckAll={this._onPressCheckAll} 123 + onPressCheckboxCell={this._onPressCheckboxCell}
  124 + onPressCheckboxAll={this._onPressCheckboxAll}
109 onPressPayNow={this._onPressPayNow} 125 onPressPayNow={this._onPressPayNow}
110 closeBankSafePay={this._closeBankSafePay} 126 closeBankSafePay={this._closeBankSafePay}
111 bankSafePayNow={this._bankSafePayNow} 127 bankSafePayNow={this._bankSafePayNow}
112 cancelPayInConfirm={this._cancelPayInConfirm} 128 cancelPayInConfirm={this._cancelPayInConfirm}
113 reSendConfirmPaySnsCode={this._reSendConfirmPaySnsCode} 129 reSendConfirmPaySnsCode={this._reSendConfirmPaySnsCode}
114 confirmPayAction={this._confirmPayAction} 130 confirmPayAction={this._confirmPayAction}
  131 + clearTipMessage={this._clearTipMessage}
115 132
116 /> 133 />
117 ); 134 );
@@ -2,6 +2,8 @@ @@ -2,6 +2,8 @@
2 2
3 import ReactNative from 'react-native'; 3 import ReactNative from 'react-native';
4 import InstallmentService from '../../services/InstallmentService'; 4 import InstallmentService from '../../services/InstallmentService';
  5 +import * as _ from 'lodash';
  6 +
5 7
6 const { 8 const {
7 9
@@ -15,6 +17,11 @@ GET_ORDER_DETAIL_FAILURE, @@ -15,6 +17,11 @@ GET_ORDER_DETAIL_FAILURE,
15 GET_ORDER_DETAIL_SUCCESS, 17 GET_ORDER_DETAIL_SUCCESS,
16 18
17 SET_BANK_SAFE_PAY_VIEW_STATUS, 19 SET_BANK_SAFE_PAY_VIEW_STATUS,
  20 +SET_SHOW_CONFIRM_PAY_VIEW_STATUS,
  21 +UPDATE_ORDER_INFO_AND_FORMATE_DATA,
  22 +SET_BANK_CARDS_LIST_AND_PAY_CARD,
  23 +UPDATE_REPAY_TERM_LIST,
  24 +UPDATE_PREPAY_SUCCESS_PARAM,
18 25
19 } = require('../../constants/actionTypes').default; 26 } = require('../../constants/actionTypes').default;
20 27
@@ -48,7 +55,7 @@ export function getOrderDetailSuccess(json){ @@ -48,7 +55,7 @@ export function getOrderDetailSuccess(json){
48 55
49 56
50 57
51 -export function getOrderDetail(orderCode) { 58 +export function getOrderDetail() {
52 return (dispatch, getState) => { 59 return (dispatch, getState) => {
53 60
54 let {app, myOrderDetail} = getState(); 61 let {app, myOrderDetail} = getState();
@@ -96,6 +103,167 @@ export function setTipMessage(message){ @@ -96,6 +103,167 @@ export function setTipMessage(message){
96 } 103 }
97 } 104 }
98 105
  106 +export function setBankCardslistAndPayCard(list){
  107 + return {
  108 + type: SET_BANK_CARDS_LIST_AND_PAY_CARD,
  109 + payload: list,
  110 + }
  111 +}
  112 +
  113 +
  114 +function processBankCardsInfo(list) {
  115 + if (list && list.length > 0) {
  116 + _.forEach(list, (data) => {
  117 + let cardNo = data.cardNo;
  118 + data.outBankNameNumb = data.bankName +'(' + cardNo.substring(cardNo.length - 4) +')';
  119 + data.outMobile = data.mobile.substring(data.mobile.length - 6);
  120 + });
  121 + return list;
  122 + }
  123 + return [];
  124 +}
  125 +
  126 +export function getBankCards() {
  127 + return (dispatch, getState) => {
  128 + let {app} = getState();
  129 + let queryBankCards = (uid) => {
  130 + return new InstallmentService(app.host).getBankCards(uid)
  131 + .then(json => {
  132 + let bankCardsInfo = processBankCardsInfo(json);
  133 + dispatch(setBankCardslistAndPayCard(bankCardsInfo));
  134 + })
  135 + .catch(error => {
  136 + dispatch(setTipMessage(error.message || '暂未获取到数据'));
  137 + });
  138 + };
  139 + ReactNative.NativeModules.YH_CommonHelper.uid()
  140 + .then(uid => {
  141 + queryBankCards(uid);
  142 + })
  143 + .catch(error => {
  144 + ReactNative.NativeModules.YH_CommonHelper.login()
  145 + .then(uid => {
  146 + queryBankCards(uid);
  147 + })
  148 + .catch(error => {
  149 +
  150 + });
  151 + });
  152 + };
  153 +}
  154 +
  155 +
  156 +//计算金额和费用
  157 +function amtAndFeeCount(list) {
  158 + let formateData = {
  159 + currAmtCount: 0,
  160 + currFeeCount: 0
  161 + };
  162 + let checkAbleCount = 0;
  163 + let checkedCount = 0
  164 + if (list) {
  165 + _.forEach(list, (data) => {
  166 + if (data.isChecked) {
  167 + checkedCount++;
  168 + formateData.currAmtCount = formateData.currAmtCount + parseFloat(data.curr_amt);
  169 + formateData.currFeeCount += formateData.currFeeCount + parseFloat(data.curr_fee_amt);
  170 + }
  171 +
  172 + if(data.status == 1 || data.status == 3){
  173 + checkAbleCount++;
  174 + }
  175 + });
  176 + if (checkedCount == checkAbleCount) {
  177 + formateData.isAllChecked = true;
  178 + }else{
  179 + formateData.isAllChecked = false;
  180 + }
  181 + if (formateData.currFeeCount > 0) {
  182 + formateData.isCurrFee = true;
  183 + } else {
  184 + formateData.isCurrFee = false;
  185 + }
  186 + return formateData;
  187 + }else {
  188 + return null;
  189 + }
  190 +}
  191 +
  192 +
  193 +
  194 +// onPressRepaylistCell
  195 +export function onPressCheckboxCell(curIndex) {
  196 + return (dispatch, getState) => {
  197 + let {app, myOrderDetail} = getState();
  198 + let {orderInfo} = myOrderDetail;
  199 + let package_list = orderInfo.get("package_list") ? orderInfo.get("package_list").toJS() : [];
  200 + let formateData;
  201 + let tipMessage = '';
  202 +
  203 + curIndex = parseInt(curIndex);
  204 + if (curIndex == 0) {
  205 + if (package_list[curIndex+1].isChecked) {
  206 + tipMessage = '同一个分期订单不能跨期还款,请按时间顺序还款';
  207 + dispatch(setTipMessage(tipMessage));
  208 + }else {
  209 + package_list[curIndex].isChecked = !package_list[curIndex].isChecked;
  210 + formateData = amtAndFeeCount(package_list);
  211 + dispatch(updatOrderInfoAndFormateData({package_list,formateData}));
  212 + }
  213 + }else if (curIndex == package_list.length - 1) {
  214 + if (!package_list[curIndex-1].isChecked && (package_list[curIndex-1].status == 1 || package_list[curIndex-1].status == 3)) {
  215 + tipMessage = '同一个分期订单不能跨期还款,请按时间顺序还款';
  216 + dispatch(setTipMessage(tipMessage));
  217 + }else {
  218 + package_list[curIndex].isChecked = !package_list[curIndex].isChecked;
  219 + formateData = amtAndFeeCount(package_list);
  220 + dispatch(updatOrderInfoAndFormateData({package_list,formateData}));
  221 + }
  222 + }else {
  223 + let preCell = package_list[curIndex - 1];
  224 + let nextCell = package_list[curIndex + 1];
  225 +
  226 + //上一个应付款未选中或者下一个已选中
  227 + if(((preCell.status == 1 || preCell.status == 3) && !preCell.isChecked) || (nextCell && nextCell.isChecked)){
  228 + tipMessage = '同一个分期订单不能跨期还款,请按时间顺序还款';
  229 + dispatch(setTipMessage(tipMessage));
  230 + }else {
  231 + package_list[curIndex].isChecked = !package_list[curIndex].isChecked;
  232 + formateData = amtAndFeeCount(package_list);
  233 + dispatch(updatOrderInfoAndFormateData({package_list,formateData}));
  234 + }
  235 + }
  236 +
  237 + };
  238 +}
  239 +
  240 +
  241 +export function onPressCheckboxAll() {
  242 + return (dispatch, getState) => {
  243 + let {app, myOrderDetail} = getState();
  244 + let {orderInfo,formateData} = myOrderDetail;
  245 + let package_list = orderInfo.get("package_list") ? orderInfo.get("package_list").toJS() : [];
  246 +
  247 + formateData = formateData.toJS();
  248 + formateData.isAllChecked = !formateData.isAllChecked;
  249 + _.forEach(package_list, (data) => {
  250 + data.isChecked = formateData.isAllChecked;
  251 + });
  252 + formateData = amtAndFeeCount(package_list);
  253 + dispatch(updatOrderInfoAndFormateData({package_list,formateData}));
  254 +
  255 +
  256 + };
  257 +}
  258 +
  259 +
  260 +export function updatOrderInfoAndFormateData(object){
  261 + return {
  262 + type: UPDATE_ORDER_INFO_AND_FORMATE_DATA,
  263 + payload: object,
  264 + }
  265 +}
  266 +
99 267
100 268
101 export function setBankSafePayViewStatus(status){ 269 export function setBankSafePayViewStatus(status){
@@ -105,28 +273,177 @@ export function setBankSafePayViewStatus(status){ @@ -105,28 +273,177 @@ export function setBankSafePayViewStatus(status){
105 } 273 }
106 } 274 }
107 275
  276 +export function setShowConfirmPayViewStatus(status) {
  277 + return {
  278 + type: SET_SHOW_CONFIRM_PAY_VIEW_STATUS,
  279 + payload: status,
  280 + }
  281 +}
  282 +
108 283
109 // onPressPayNow 284 // onPressPayNow
110 export function onPressPayNow() { 285 export function onPressPayNow() {
111 return (dispatch, getState) => { 286 return (dispatch, getState) => {
112 - // dispatch(getBankCards()); 287 + dispatch(getBankCards());
113 dispatch(setBankSafePayViewStatus(true)); 288 dispatch(setBankSafePayViewStatus(true));
114 - // let {app, repayList} = getState();  
115 - // let {repaymentList,queryDays,formateData} = repayList;  
116 - // repaymentList = repaymentList.toJS();  
117 - // formateData = formateData.toJS();  
118 - // let termsList = [];  
119 - // _.forEach(repaymentList, (data) => {  
120 - // if (data.isChecked) {  
121 - // termsList.push({  
122 - // index: data.key,  
123 - // orderCode: data.billNo,  
124 - // termNo: data.currTerm  
125 - // });  
126 - // }  
127 - // });  
128 - // dispatch(updateRepayTermList(termsList)); 289 + let {app, myOrderDetail} = getState();
  290 + let {orderInfo, formateData} = myOrderDetail;
  291 + let package_list = orderInfo.get("package_list") ? orderInfo.get("package_list").toJS() : [];
  292 + let orderCode = orderInfo.get("order_code");
  293 +
  294 + formateData = formateData.toJS();
  295 + let termsList = [];
  296 + _.forEach(package_list, (data) => {
  297 + if (data.isChecked) {
  298 + termsList.push({
  299 + index: data.sort_id,
  300 + orderCode: orderCode,
  301 + termNo: data.sort_id
  302 + });
  303 + }
  304 + });
  305 + dispatch(updateRepayTermList(termsList));
  306 + }
  307 +}
  308 +
  309 +export function bankSafePayNow() {
  310 + return (dispatch, getState) => {
  311 +
  312 + let bankSafePayNowAction = (uid) => {
  313 + let {app, myOrderDetail} = getState();
  314 + let {formateData,repayTermList,payCard} = myOrderDetail;
  315 + formateData = formateData.toJS();
  316 + repayTermList = repayTermList.toJS();
  317 + payCard = payCard.toJS();
  318 + let params = {
  319 + uid,
  320 + repay_amount: formateData.currAmtCount,
  321 + repayTermList:JSON.stringify(repayTermList),
  322 + bankcard_IdNo: payCard.cardIdNo,
  323 + terminal_type: 'mobile',
  324 + user_ip: '',
  325 + terminal_info: '',
  326 + card_id: payCard.cardIdNo,
  327 + }
  328 + return new InstallmentService(app.host).getPrerePay(params)
  329 + .then(json => {
  330 + if (json && json.isRepaySuccess == 'Y') {
  331 + dispatch(updatePrepaySuccessParam(json));
  332 + } else {
  333 + let tipMessage = json.message || '暂未获取到数据';
  334 + dispatch(setTipMessage(tipMessage));
  335 + }
  336 + })
  337 + .catch(error => {
  338 + dispatch(setTipMessage(error.message || '暂未获取到数据'));
  339 + });
  340 + };
  341 + ReactNative.NativeModules.YH_CommonHelper.uid()
  342 + .then(uid => {
  343 + bankSafePayNowAction(uid);
  344 + })
  345 + .catch(error => {
  346 + ReactNative.NativeModules.YH_CommonHelper.login()
  347 + .then(uid => {
  348 + bankSafePayNowAction(uid);
  349 + })
  350 + .catch(error => {
  351 +
  352 + });
  353 + });
  354 + };
  355 +}
  356 +
  357 +export function updatePrepaySuccessParam(param) {
  358 + return {
  359 + type: UPDATE_PREPAY_SUCCESS_PARAM,
  360 + payload: param,
  361 + }
  362 +}
  363 +
  364 +
  365 +
  366 +export function updateRepayTermList(list) {
  367 + return {
  368 + type: UPDATE_REPAY_TERM_LIST,
  369 + payload: list,
129 } 370 }
130 } 371 }
131 372
132 373
  374 +//
  375 +export function reSendConfirmPaySnsCode() {
  376 + return (dispatch, getState) => {
  377 + let {app, myOrderDetail} = getState();
  378 + let resendSnsCode = (uid) => {
  379 + let {prePaySuccessParam} = myOrderDetail;
  380 + prePaySuccessParam = prePaySuccessParam.toJS();
  381 + let params = {
  382 + uid,
  383 + orderNo: prePaySuccessParam.crfRepayOrderNo,
  384 + prepayNo: prePaySuccessParam.repayOrderCode,
  385 + }
  386 + return new InstallmentService(app.host).reSendConfirmPaySnsCode(params)
  387 + .then(json => {
  388 + if (json && json.code && json.code !== 200) {
  389 + let tipMessage = json.message || '暂未获取到数据';
  390 + dispatch(setTipMessage(tipMessage));
  391 + }
  392 + })
  393 + .catch(error => {
  394 + dispatch(setTipMessage(error.message || '暂未获取到数据'));
  395 + });
  396 +
  397 + }
  398 +
  399 + ReactNative.NativeModules.YH_CommonHelper.uid()
  400 + .then(uid => {
  401 + resendSnsCode(uid);
  402 + })
  403 + .catch(error => {
  404 + ReactNative.NativeModules.YH_CommonHelper.login()
  405 + .then(uid => {
  406 + resendSnsCode(uid);
  407 + })
  408 + .catch(error => {
  409 +
  410 + });
  411 + });
  412 + };
  413 +}
  414 +
  415 +//
  416 +export function confirmPayAction(snsCode) {
  417 + return (dispatch, getState) => {
  418 + let {app, myOrderDetail} = getState();
  419 + let {payCard,repayTermList,formateData,prePaySuccessParam} = myOrderDetail;
  420 + payCard = payCard.toJS();
  421 + repayTermList = repayTermList.toJS();
  422 + formateData = formateData.toJS();
  423 + prePaySuccessParam = prePaySuccessParam.toJS();
  424 + let params = prePaySuccessParam;
  425 + delete params.isRepaySuccess;
  426 + params.phoneNumber = payCard.mobile;
  427 + params.smsCode = snsCode;
  428 + params.repayTermList = JSON.stringify(repayTermList);
  429 + params.terminal_type = 'mobile';
  430 +
  431 + return new InstallmentService(app.host).confirmRepay(params)
  432 + .then(json => {
  433 + if (json.isPaySuccess == 'Y') {
  434 + //刷新页面数据
  435 + dispatch(setShowConfirmPayViewStatus(false));
  436 + dispatch(setBankSafePayViewStatus(false));
  437 + dispatch(getOrderDetail());
  438 + }else {
  439 + dispatch(setTipMessage(json.message || '暂未获取到数据'));
  440 + }
  441 + })
  442 + .catch(error => {
  443 + dispatch(setTipMessage(error.message || '暂未获取到数据'));
  444 + });
  445 + };
  446 +}
  447 +
  448 +
  449 +
@@ -11,9 +11,13 @@ let InitialState = Record({ @@ -11,9 +11,13 @@ let InitialState = Record({
11 orderInfo: Map(), 11 orderInfo: Map(),
12 12
13 formateData: Map(), 13 formateData: Map(),
  14 + bankCardsList: List(),
14 payCard: Map(), 15 payCard: Map(),
15 showBankSafePayView: false, 16 showBankSafePayView: false,
16 showConfirmPayView: false, 17 showConfirmPayView: false,
  18 + repayTermList:List(),
  19 + prePaySuccessParam: Map(),
  20 +
17 21
18 }); 22 });
19 23
@@ -14,6 +14,10 @@ const { @@ -14,6 +14,10 @@ const {
14 14
15 SET_BANK_SAFE_PAY_VIEW_STATUS, 15 SET_BANK_SAFE_PAY_VIEW_STATUS,
16 SET_SHOW_CONFIRM_PAY_VIEW_STATUS, 16 SET_SHOW_CONFIRM_PAY_VIEW_STATUS,
  17 + UPDATE_ORDER_INFO_AND_FORMATE_DATA,
  18 + SET_BANK_CARDS_LIST_AND_PAY_CARD,
  19 + UPDATE_REPAY_TERM_LIST,
  20 + UPDATE_PREPAY_SUCCESS_PARAM,
17 21
18 } = require('../../constants/actionTypes').default; 22 } = require('../../constants/actionTypes').default;
19 23
@@ -42,7 +46,18 @@ export default function appReducer(state = initialState, action) { @@ -42,7 +46,18 @@ export default function appReducer(state = initialState, action) {
42 case SET_BANK_SAFE_PAY_VIEW_STATUS: 46 case SET_BANK_SAFE_PAY_VIEW_STATUS:
43 return state.set('showBankSafePayView',action.payload); 47 return state.set('showBankSafePayView',action.payload);
44 case SET_SHOW_CONFIRM_PAY_VIEW_STATUS: 48 case SET_SHOW_CONFIRM_PAY_VIEW_STATUS:
45 - return state.set('showConfirmPayView', action.payload); 49 + return state.set('showConfirmPayView', action.payload);
  50 + case UPDATE_ORDER_INFO_AND_FORMATE_DATA:
  51 + return state.setIn(['orderInfo', 'package_list'], Immutable.fromJS(action.payload.package_list))
  52 + .set('formateData', Immutable.fromJS(action.payload.formateData));
  53 + case SET_BANK_CARDS_LIST_AND_PAY_CARD:
  54 + return state.set('bankCardsList', Immutable.fromJS(action.payload))
  55 + .set('payCard', Immutable.fromJS(action.payload[0]));
  56 + case UPDATE_REPAY_TERM_LIST:
  57 + return state.set('repayTermList', Immutable.fromJS(action.payload));
  58 + case UPDATE_PREPAY_SUCCESS_PARAM:
  59 + return state.set('prePaySuccessParam',Immutable.fromJS(action.payload))
  60 + .set('showConfirmPayView', true);
46 } 61 }
47 62
48 return state; 63 return state;