npmchenwei111
Version:
test1111
142 lines (128 loc) • 3.79 kB
JavaScript
/**
* Created by ziyu on 2017/6/23.
*
* 芝麻信用验证页面
*/
import React, { Component } from 'react'
import { DeviceEventEmitter, Image, StyleSheet, Text, View } from 'react-native'
import { fetchPost } from '../../../utils/Request'
import {px, px2dp, sp} from '../../../utils/Px2dp'
import RequestSimplify from '../../../utils/RequestSimplify'
import YTInvokeZiMaXinYongH5 from '../../../../src/native/public/YTInvokeZiMaXinYongH5'
import SubmitBtnRadius from '../views/SubmitBtnRadius'
import YTTextInput from '../../../../src/components/YTTextInput'
import ActionBar from '../../../bar/ActionBar'
import EmitterReactEvent from '../../../constant/EmitterReactEvent'
import R from '../../../assets/R'
import OpenApi from '../../../api/OpenApi'
class ZmxyPageScreen extends Component {
constructor (props) {
super(props)
this.state = {
userNameAndIdVO: {
realName: '',
identityNo: ''
},
btnData: {
text: '认证',
enable: true
}
}
}
static navigationOptions = ({navigation, screenProps}) => ({
header: <ActionBar
nav={navigation}
screenProps={screenProps}
data={{
title: '芝麻信用认证'
}}
/>
})
componentDidMount () {
fetchPost(OpenApi.get_zmxy_userinfo).then(res => {
if (res.code === 0) {
this.setState({
userNameAndIdVO: res.data.userNameAndIdVO
})
}
})
}
handleSubmit () {
RequestSimplify.fetch(OpenApi.get_zmxy_url, {}, (res) => {
this.props.navigation.goBack()
YTInvokeZiMaXinYongH5.jump(res.data.zmxyUrl).then(() => {
DeviceEventEmitter.emit(EmitterReactEvent.REFRESH_INDEX_PAGE)
}).catch((error) => {
DeviceEventEmitter.emit(EmitterReactEvent.REFRESH_INDEX_PAGE)
})
})
}
render () {
return (
<View style={styles.container}>
<View style={styles.title}>
<Image style={styles.logo} source={R.img.ic_zhima_logo_img}/>
</View>
<View style={{paddingHorizontal: px2dp(16)}}>
<View style={styles.formControl}>
<Text style={styles.formLabel}>姓名</Text>
<YTTextInput underlineColorAndroid='transparent' value={this.state.userNameAndIdVO.realName}
style={styles.formText} editable={false}/>
</View>
<View style={styles.formControl}>
<Text style={styles.formLabel}>身份证</Text>
<YTTextInput underlineColorAndroid='transparent' value={this.state.userNameAndIdVO.identityNo}
style={styles.formText} editable={false}/>
</View>
<View style={{marginTop: px2dp(50)}}>
<SubmitBtnRadius btnData={this.state.btnData} onPress={() => {
this.handleSubmit()
}}/>
</View>
</View>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
backgroundColor: R.color.bg_color,
paddingBottom: px2dp(43),
flex: 1
},
logo: {
width: px2dp(80),
height: px2dp(80)
},
title: {
alignItems: 'center',
paddingVertical: px2dp(42)
},
formControl: {
flexDirection: 'row',
borderBottomWidth: px2dp(1),
borderBottomColor: '#c9c9c9',
borderStyle: 'solid',
height: px(58),
alignItems: 'center'
},
formLabel: {
color: R.color.bar_color,
fontSize: sp(16),
textAlignVertical: 'center',
width: px2dp(100),
paddingLeft: px2dp(5),
paddingTop: 0,
paddingBottom: 0,
},
formText: {
textAlignVertical: 'center',
justifyContent: 'center',
flex: 1,
color: R.color.font_input_hint,
paddingTop: 0,
paddingBottom: 0,
backgroundColor: R.color.transparent
}
})
export default ZmxyPageScreen