Authored by hongyong.zhao

城市选择

... ... @@ -4,6 +4,7 @@ import React, {Component} from 'react';
import {DeviceEventEmitter, Dimensions, Image, StyleSheet, Text, TextInput, TouchableOpacity, View, Linking, Platform} from 'react-native';
import SureBankCardModal from "./SureBankCardModal";
import BankBranchModal from "./BankBranchModal";
import CityPicker from './common/CityPicker'
export default class BankCard extends Component {
... ... @@ -21,6 +22,9 @@ export default class BankCard extends Component {
bankCode: '',
cardNo: '',
bankBranch: '',
bankCityId: '',
bankLocationStr: '',
isShowLocationAlert: false,
}
}
... ... @@ -77,12 +81,20 @@ export default class BankCard extends Component {
return
}
let bankCityId = this.state.bankCityId
if (!bankCityId) {
this.setState({messageTips: '请输入开户城市'});
return
}
this.setState({messageTips: '', isUpdate: true});
this.props.checkBankCard && this.props.checkBankCard(this.state.name, this.state.number, this.state.bankCode, this.state.cardNo,bankBranch);
this.props.checkBankCard && this.props.checkBankCard(this.state.name, this.state.number, this.state.bankCode, this.state.cardNo,bankBranch, bankCityId);
}
renderUnBind() {
let checkMessage = this.state.messageTips || this.props.checkBankCardResult.message;
if (this.state.isShow) {
return (
<View>
... ... @@ -126,6 +138,26 @@ export default class BankCard extends Component {
</View>
<View style={styles.lineView}/>
<View style={styles.inputView}>
<Text style={[styles.wordText, {width: 76, color: '#444444'}]}>开户城市</Text>
<TouchableOpacity
style={{flexDirection: 'row', height: 44, alignItems: 'center'}} activeOpacity={0.8}
onPress={() => {
this.setState({
isShowLocationAlert: true
})
}}
>
<Text style={[styles.wordText, {
width: width-124,
paddingLeft: Platform.OS === 'ios' ? 0 : 12,
color: this.state.bankLocationStr === '' ? '#b0b0b0' : '#444444'
}]}>{this.state.bankLocationStr === '' ? '请选择开户城市' : this.state.bankLocationStr}</Text>
<Image style={styles.arrowImage} source={require('../images/arrow.png')}/>
</TouchableOpacity>
</View>
<View style={styles.lineView}/>
<View style={styles.inputView}>
<Text style={[styles.wordText, {width: 76, color: '#444444'}]}>分行 支行</Text>
<TextInput
ref="subBrandNameInput"
... ... @@ -196,6 +228,15 @@ export default class BankCard extends Component {
return (
<View style={styles.container}>
<CityPicker
isShow={this.state.isShowLocationAlert}
setCityInfo={({bankCityId, bankLocationStr})=> {
this.setState({
bankCityId,
bankLocationStr
})
}}
/>
<BankBranchModal
isShow={isShowBankAlert}
hiddenBankTipsAlert={this.props.hiddenBankTipsAlert}/>
... ...
... ... @@ -122,17 +122,17 @@ export default class Data extends Component {
if (this.props.settlementInfo.settlementInfoData.canSettlement) {
if (this.props.settlementInfo.settlementInfoData.settlementAmount <= 500) {
!this.props.addSettlement.isFetching && this.props.showSureDialog && this.props.showSureDialog();
} else {
// if (this.props.settlementInfo.settlementInfoData.settlementAmount <= 500) {
// !this.props.addSettlement.isFetching && this.props.showSureDialog && this.props.showSureDialog();
//
// } else {
if (!isIDBind) {
this.props.showBindAlertDialog && this.props.showBindAlertDialog();
return
} else {
this.props.showCheckSettleDialog && this.props.showCheckSettleDialog();
}
}
// }
} else {
this.props.showHelpDialog && this.props.showHelpDialog('您有正在处理中的提现,请耐心等待完成后再做新的提现操作');
... ...
/**
* CityPicker.js
*@author dennis
*@createtime 8/22/19
*@description 城市选着器
*/
'use strict'
import React, {Component} from 'react'
import {
Modal,
StyleSheet,
TouchableOpacity,
View,
Text,
Image,
FlatList,
} from 'react-native'
import {bindActionCreators} from 'redux'
import {connect} from 'react-redux'
import {Map} from 'immutable'
import * as allianceActions from '../../reducers/alliance/allianceActions'
const actions = [
allianceActions,
];
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 CityPicker extends Component{
constructor(props) {
super(props)
this.state = {
province: '',
city: '',
currentLevel: 0,
currenctProvinceid: 0,
currentCityid: 0,
isShow: props.isShow,
}
}
componentDidMount() {
this.props.actions.getLocationList()
}
componentWillReceiveProps(nextProps){
// if (this.props.isShow != nextProps.isShow) {
this.setState({
isShow: nextProps.isShow
})
// }
}
startDismiss = () => {
this.setState({
isShow: false
})
}
pressLocationLevel = (level) => {
this.setState({
currentLevel: level
})
}
pressItem = (item) => {
if (this.state.currentLevel == 0) {
if (item.id !== this.state.currenctProvinceid) {
this.setState({
currenctProvinceid: item.id,
province: item.caption,
currentCityid: 0,
city: ''
})
this.props.setCityInfo && this.props.setCityInfo({
bankCityId: '',
bankLocationStr: '',
})
this.props.actions.getLocationSuccess(item.sub, 1)
}
} else {
if (item.id !== this.state.currentCityid) {
this.setState({
currentCityid: item.id,
city: item.caption,
})
this.props.setCityInfo && this.props.setCityInfo({
bankCityId: item.id,
bankLocationStr: item.caption,
})
}
}
}
renderItem = ({item, index}) => {
let currentid = this.state.currentLevel == 0 ? this.state.currenctProvinceid : this.state.currentCityid
let isSelected = item.id == currentid
return (
<View style={styles.item}>
<TouchableOpacity
style={[styles.item, styles.itemRow]}
activeOpacity={1}
onPress={() => {
this.pressItem(item)
}}
>
<Text style={isSelected ? styles.locationNameChoosen : styles.locationName}>{item.caption}</Text>
{isSelected ? <Image
resizeMode={'contain'}
source={require('../../../brandStore/image/filter/brandstore_filter_selected.png')}
style={styles.selectImage}/>: null}
</TouchableOpacity>
</View>
)
}
render() {
let {
cityLocationInfo
} = this.props.alliance
let allData = this.state.currentLevel == 0 ? cityLocationInfo.get('provinceList').toJS() : cityLocationInfo.get('cityList').toJS()
allData = allData || []
return (
<Modal
visible={this.state.isShow}
animationType={'none'}
transparent={true}
onRequestClose={() => {
}}
>
<View style={styles.container}>
<View style={[styles.mask]}>
<TouchableOpacity
activeOpacity={1}
onPress={this.startDismiss}
style={styles.modalBackground}/>
</View>
<View style={styles.contentContainer}>
<View style={styles.titleContainer}>
<Text style={styles.title}>
{'开户城市'}
</Text>
<TouchableOpacity style={styles.closeBtn}
activeOpacity={1}
onPress={this.startDismiss}
>
<Image
resizeMode={'contain'}
source={require('../../../studentCertification/images/close.png')}
style={styles.closeBtnImg}>
</Image>
</TouchableOpacity>
</View>
<View style={styles.locationChoosenContainer}>
<TouchableOpacity
activeOpacity={1}
style={this.state.currentLevel == 0 ? styles.areaChoosen : null}
onPress={() => {
this.pressLocationLevel(0)
}}
>
<Text style={this.state.currentLevel == 0 ? styles.areaCurrent : styles.area}>{this.state.province || '请选择'}</Text>
</TouchableOpacity>
<TouchableOpacity
activeOpacity={1}
style={this.state.currentLevel == 1 ? styles.areaChoosen : null}
onPress={() => {
this.pressLocationLevel(1)
}}
>
<Text style={this.state.currentLevel == 1 ? styles.areaCurrent : styles.area}>{this.state.city || '请选择'}</Text>
</TouchableOpacity>
</View>
<FlatList
renderItem={this.renderItem}
data={allData}
initialNumToRender={100}
keyExtractor={(item, index) => '' + index}
showsVerticalScrollIndicator={false}
style={styles.contentlist}
/>
</View>
</View>
</Modal>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'flex-end'
},
modalBackground: {
flex: 1,
},
mask: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
backgroundColor: 'rgba(0, 0, 0, 1)',
opacity: 0.4
},
contentContainer: {
paddingTop: 20,
backgroundColor: '#FFFFFF',
overflow: 'hidden',
paddingBottom: 3,
},
titleContainer: {
flexDirection: 'row',
alignItems: 'center',
height: 40,
},
title: {
flex: 1,
textAlign: 'center',
fontSize: 18,
color: 'gray'
},
closeBtn: {
width: 25,
height: 25,
marginRight: 10,
},
closeBtnImg: {
width: 15,
height: 15,
},
selectImage: {
tintColor: 'red',
marginLeft: 10,
},
locationChoosenContainer: {
flexDirection: 'row',
height: 35,
borderBottomWidth: 1,
borderBottomColor: '#f5f5f5',
// paddingLeft: 20,
},
areaChoosen: {
borderBottomWidth: 2,
borderBottomColor: 'red'
},
area: {
fontSize: 15,
color: 'black',
marginHorizontal: 10,
},
areaCurrent: {
fontSize: 15,
color: 'red',
marginHorizontal: 10,
},
locationName: {
fontSize: 15,
color: 'black'
},
locationNameChoosen: {
fontSize: 15,
color: 'red'
},
contentlist: {
height: 200,
paddingTop: 20,
paddingLeft: 20,
},
item: {
height: 40,
justifyContent: 'flex-start',
},
itemRow: {
flexDirection: 'row'
}
})
export default connect(mapStateToProps, mapDispatchToProps)(CityPicker)
... ...
... ... @@ -193,4 +193,8 @@ export default keyMirror({
INVITE_YOHO_RESOURCEINFO_REQUEST: null,
INVITE_YOHO_RESOURCEINFO_SUCCESS: null,
INVITE_YOHO_RESOURCEINFO_FAILURE: null,
GET_LOCATION_REQUEST: null,
GET_LOCATION_SUCCESS: null,
GET_LOCATION_FAILURE: null,
});
... ...
... ... @@ -62,8 +62,8 @@ class BankCardContainer extends Component {
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
_checkBankCard(name, idCardNo, bankCode, bankCardNo,bankBranch) {
this.props.actions.checkBankCard(name, idCardNo, bankCode, bankCardNo,bankBranch);
_checkBankCard(name, idCardNo, bankCode, bankCardNo,bankBranch,bankCityId) {
this.props.actions.checkBankCard(name, idCardNo, bankCode, bankCardNo,bankBranch, bankCityId);
}
_bindBankCard(bankInfo) {
... ...
... ... @@ -144,8 +144,36 @@ const {
HIDE_TOAST,
SHOW_LOADING,
GET_LOCATION_REQUEST,
GET_LOCATION_SUCCESS,
GET_LOCATION_FAILURE,
} = require('../../constants/actionTypes').default;
export function getLocationRequest(level) {
return {
type: GET_LOCATION_REQUEST,
payload: level
}
}
export function getLocationSuccess(json, level) {
return {
type: GET_LOCATION_SUCCESS,
payload: json,
level
}
}
export function getLocatonFailure(error, level) {
return {
type: GET_LOCATION_FAILURE,
payload: error,
level
}
}
export function showTipsAlertDialog() {
return {
type: SHOW_TIPS_ALERT_DIALOG,
... ... @@ -1385,12 +1413,12 @@ export function getBankList() {
};
}
export function checkBankCard(name, idCardNo, bankCode, bankCardNo,bankBranch) {
export function checkBankCard(name, idCardNo, bankCode, bankCardNo,bankBranch, bankCityId) {
return (dispatch, getState) => {
let {app} = getState();
let fetchCheckBankCard = (uid) => {
dispatch(checkBankCardRequest());
return new AllianceService(app.host).fetchCheckBankCard(uid, name, idCardNo, bankCode, bankCardNo,bankBranch)
return new AllianceService(app.host).fetchCheckBankCard(uid, name, idCardNo, bankCode, bankCardNo,bankBranch, bankCityId)
.then(json => {
dispatch(showBankInfoDialog());
dispatch(checkBankCardSuccess(json)); //校验成功后,显示二次确认弹框
... ... @@ -1592,3 +1620,18 @@ export function getIdentityCardInfo() {
});
};
}
export function getLocationList(level=0, id=0) {
return (dispatch, getState) => {
let {app} = getState();
dispatch(getLocationRequest(level))
return new AllianceService(app.host).getLocationList(id)
.then(json => {
dispatch(getLocationSuccess(json, level))
})
.catch(error => {
dispatch(getLocatonFailure(error, level))
})
}
}
... ...
... ... @@ -178,6 +178,7 @@ let InitialState = Record({
bankCardNo: null,
bankCode: null,
bankBranch: '',
bankCityId: '',
error: null,
})),
... ... @@ -238,6 +239,15 @@ let InitialState = Record({
list: List(),
})),
cityLocationInfo: new (Record({
isProvinceFetching: false,
isCityFetching: false,
provinceError: null,
cityError: null,
provinceList: List(),
cityList: List(),
}))
});
export default InitialState;
... ...
... ... @@ -141,6 +141,10 @@ const {
QUERY_INVITE_YOHOLIST_SUCCESS,
QUERY_INVITE_YOHOLIST_FAILURE,
GET_LOCATION_REQUEST,
GET_LOCATION_SUCCESS,
GET_LOCATION_FAILURE,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
... ... @@ -584,6 +588,7 @@ export default function couponReducer(state = initialState, action) {
bankCode,
bankCardNo,
bankBranch,
bankCityId,
} = action.payload;
return state.setIn(['checkBankCardResult', 'isFetching'], false)
.setIn(['checkBankCardResult', 'name'], name)
... ... @@ -591,6 +596,7 @@ export default function couponReducer(state = initialState, action) {
.setIn(['checkBankCardResult', 'bankCode'], bankCode)
.setIn(['checkBankCardResult', 'bankCardNo'], bankCardNo)
.setIn(['checkBankCardResult', 'bankBranch'], bankBranch)
.setIn(['checkBankCardResult', 'bankCityId'], bankCityId)
.setIn(['checkBankCardResult', 'message'], null)
.setIn(['checkBankCardResult', 'error'], null);
}
... ... @@ -758,6 +764,42 @@ export default function couponReducer(state = initialState, action) {
.setIn(['inviteYohoList', 'error'], action.payload);
}
case GET_LOCATION_REQUEST: {
if (action.payload == 0) {//province
return state.setIn(['cityLocationInfo', 'isProvinceFetching'], true)
.setIn(['cityLocationInfo', 'provinceError'], null)
} else {
return state.setIn(['cityLocationInfo', 'isCityFetching'], true)
.setIn(['cityLocationInfo', 'cityError'], null)
}
}
case GET_LOCATION_SUCCESS: {
if (action.level == 0) {//province
return state.setIn(['cityLocationInfo', 'isProvinceFetching'], false)
.setIn(['cityLocationInfo', 'provinceError'], null)
.setIn(['cityLocationInfo', 'provinceList'], Immutable.fromJS(action.payload))
} else {
return state.setIn(['cityLocationInfo', 'isCityFetching'], false)
.setIn(['cityLocationInfo', 'cityError'], null)
.setIn(['cityLocationInfo', 'cityList'], Immutable.fromJS(action.payload))
}
}
case GET_LOCATION_FAILURE: {
if (action.level == 0) {//province
return state.setIn(['cityLocationInfo', 'isProvinceFetching'], false)
.setIn(['cityLocationInfo', 'provinceError'], null)
.setIn(['cityLocationInfo', 'provinceList'], Immutable.fromJS([]))
} else {
return state.setIn(['cityLocationInfo', 'isCityFetching'], false)
.setIn(['cityLocationInfo', 'cityError'], null)
.setIn(['cityLocationInfo', 'cityList'], Immutable.fromJS([]))
}
}
}
return state;
}
... ...
... ... @@ -509,4 +509,23 @@ export default class AllianceService {
});
}
// 获取省市列表
async getLocationList(id = 0) {
return await this.api.get({
url: '',
body: {
method: 'app.address.getlist',
id
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
}
... ...
/**
* 新品到着安卓首页(iOS为原生)
*/
'use strict'
import React, {Component} from 'react';
... ...