Authored by 张文文

添加身份证上传及身份证绑定接口调试

@@ -39,8 +39,9 @@ export default class Mine extends Component { @@ -39,8 +39,9 @@ export default class Mine extends Component {
39 let imageUrl = YH_Image.getSlicedUrl(ico, 50, 50, 2); 39 let imageUrl = YH_Image.getSlicedUrl(ico, 50, 50, 2);
40 let nickname = this.props.profile.nickname; 40 let nickname = this.props.profile.nickname;
41 41
42 - let uploadStyle = bindStatus ? {color: '#444444'} : {color: '#D0021B'};  
43 - let isUpload = bindStatus ? '已上传' : '未上传'; 42 + let uploadStatus = this.props.identityCardInfo.data;
  43 + let uploadStyle = uploadStatus ? {color: '#444444'} : {color: '#D0021B'};
  44 + let isUpload = uploadStatus ? '已上传' : '未上传';
44 45
45 //当前粉丝数空值判断 46 //当前粉丝数空值判断
46 let fansAmount = this.props.shareTotalInfo.shareTotalInfoData.fans; 47 let fansAmount = this.props.shareTotalInfo.shareTotalInfoData.fans;
  1 +/**
  2 + * Created by misty on 2019/06/05.
  3 + */
  4 +'use strict';
  5 +import React, {Component} from "react";
  6 +import ReactNative ,{
  7 + Dimensions,
  8 + StyleSheet,
  9 + Text,
  10 + View,
  11 + TouchableOpacity,
  12 + TextInput,
  13 + ScrollView,
  14 + Platform,
  15 + Image,
  16 + InteractionManager,
  17 +} from "react-native";
  18 +
  19 +import Prompt from "../../common/components/Prompt";
  20 +import YH_Image from "../../common/components/YH_Image";
  21 +import YH_ActionSheet from "../../common/components/YH_ActionSheet";
  22 +import ImagePicker from 'react-native-image-picker';
  23 +import LoadingIndicator from '../../common/components/LoadingIndicator';
  24 +
  25 +export default class NameAuthen extends Component {
  26 + constructor(props) {
  27 + super(props);
  28 + this.state = {
  29 + isBack: false,
  30 + backIDCardImageUri: '',
  31 + frontIDCardImageUri: '',
  32 + }
  33 + // this.renderCell = this.renderCell.bind(this)
  34 + this.renderHeader = this.renderHeader.bind(this)
  35 + this.renderMeritCell = this.renderMeritCell.bind(this)
  36 + this.renderIDCardAddDetailCell = this.renderIDCardAddDetailCell.bind(this)
  37 + this.actionsheetItemClick = this.actionsheetItemClick.bind(this)
  38 + }
  39 +
  40 + renderHeader(title) {
  41 + return <View style={styles.headerDetailContainer}>
  42 + <Text style={styles.headerTitle} numberOfLines={1}>{title}</Text>
  43 + </View>
  44 + }
  45 +
  46 + renderMeritCell(title) {
  47 + return <View style={styles.meritCell}>
  48 + <View style={styles.meritAnnotation}/>
  49 + <Text style={styles.headerDetailTitle}>{title}</Text>
  50 + </View>
  51 + }
  52 +
  53 + renderIDCardAddDetailCell() {
  54 + return (
  55 + <View style={styles.renderIDCardAddDetailCell}>
  56 + {this.renderIDCardAddCellImage(false)}
  57 + {this.renderIDCardAddCellImage(true)}
  58 + </View>
  59 + )
  60 + }
  61 +
  62 + renderIDCardAddCellImage(isBack) {
  63 + let title = isBack ? '反面照片' : '正面照片';
  64 + let image = isBack ? require('../images/cardBack.png') : require('../images/cardFront.png');
  65 + let imageUrl = isBack ? this.state.backIDCardImageUri : this.state.frontIDCardImageUri;
  66 + let hasImage = imageUrl.length > 0 ? true : false;
  67 + return (
  68 + <View style={styles.renderIDCardAddCellImage}>
  69 + <TouchableOpacity
  70 + activeOpacity={1.0}
  71 + onPress={() => {
  72 + if(!hasImage){
  73 + this.setState({
  74 + isBack,
  75 + })
  76 + this.refs.YH_ActionSheet.showModal();
  77 + }
  78 + }}>
  79 + {hasImage ?
  80 + <YH_Image resizeMode="contain" url={imageUrl} style={[styles.viewImage, {backgroundColor: 'transparent', borderWidth: 0,}]}/>
  81 + :
  82 + <View style={styles.viewImage}>
  83 + <Image style={styles.addImage} resizeMode={'contain'} source={require('../images/addID.png')}/>
  84 + <Text style={[styles.imageText, {marginTop: 13}]}>{title}</Text>
  85 + </View>
  86 + }
  87 + </TouchableOpacity>
  88 + <TouchableOpacity
  89 + activeOpacity={1.0}
  90 + style={styles.addImageClose}
  91 + onPress={() => {
  92 + if(isBack){
  93 + this.setState({
  94 + backIDCardImageUri: '',
  95 + })
  96 + }else {
  97 + this.setState({
  98 + frontIDCardImageUri: '',
  99 + })
  100 + }
  101 + }}>
  102 + {hasImage ?
  103 + <Image style={{height: 16,width: 16}} source={require('../images/imageShareClose.png')}/>
  104 + : null}
  105 + </TouchableOpacity>
  106 +
  107 + <View style={styles.renderIDCardSampleCellImage}>
  108 + <Image style={styles.cardImage} source={image}/>
  109 + <Text style={styles.cardImageEGtip}>(示例)</Text>
  110 + </View>
  111 +
  112 + </View>
  113 + )
  114 + }
  115 +
  116 + actionsheetItemClick(id){
  117 + this.props.showLoading && this.props.showLoading(true);
  118 + let that = this;
  119 + if(id == 1){
  120 + ReactNative.NativeModules.YH_MarketHelper.goUFOIDCardCameraVC(this.state.isBack).then(data => {
  121 + InteractionManager.runAfterInteractions(() => {
  122 + that.refs.YH_ActionSheet.cancelModal();
  123 + if(that.state.isBack){
  124 + that.setState({
  125 + backIDCardImageUri: data,
  126 + })
  127 + }else {
  128 + that.setState({
  129 + frontIDCardImageUri: data,
  130 + })
  131 + }
  132 + that.props.showLoading && that.props.showLoading(false);
  133 + });
  134 + })
  135 + .catch(error => {
  136 + that.refs.YH_ActionSheet.cancelModal();
  137 + that.props.showLoading && that.props.showLoading(false);
  138 + });
  139 + }else if(id == 2){
  140 +
  141 + if(Platform.OS == 'ios'){
  142 + let options = {
  143 + storageOptions: {
  144 + skipBackup: true,
  145 + path: 'images',
  146 + },
  147 + };
  148 + ImagePicker.launchImageLibrary(options, (response) => {
  149 + InteractionManager.runAfterInteractions(() => {
  150 + console.log(response);
  151 + that.refs.YH_ActionSheet.cancelModal();
  152 + let uri = response ? response.uri : '';
  153 + if(uri){
  154 + if(that.state.isBack){
  155 + that.setState({
  156 + backIDCardImageUri: uri,
  157 + })
  158 + }else {
  159 + that.setState({
  160 + frontIDCardImageUri: uri,
  161 + })
  162 + }
  163 + }
  164 + that.props.showLoading && that.props.showLoading(false);
  165 + });
  166 + });
  167 + }
  168 + else{
  169 + ReactNative.NativeModules.YH_MarketHelper.goPhotoVC().then(data => {
  170 + InteractionManager.runAfterInteractions(() => {
  171 + that.refs.YH_ActionSheet.cancelModal();
  172 + if(that.state.isBack){
  173 + that.setState({
  174 + backIDCardImageUri: data,
  175 + })
  176 + }else {
  177 + that.setState({
  178 + frontIDCardImageUri: data,
  179 + })
  180 + }
  181 + that.props.showLoading && that.props.showLoading(false);
  182 + });
  183 + })
  184 + .catch(error => {
  185 +
  186 + });
  187 + }
  188 + }
  189 + }
  190 +
  191 + render() {
  192 + let buttonDisabled = this.state.backIDCardImageUri.length == 0 || this.state.frontIDCardImageUri.length == 0
  193 + let isShowToast = this.props.isShowToast;
  194 + let toastMessage = this.props.toastMessage;
  195 +
  196 + return <View style={styles.mainContainer}>
  197 + <ScrollView style={styles.mainContainer}
  198 + keyboardShouldPersistTaps={'handled'}>
  199 +
  200 + {this.renderHeader('请上传身份证照片')}
  201 + {this.renderMeritCell('请上传原始比例清晰的身份证正反面。请勿进行裁剪涂改,否则无法通过审核。')}
  202 + {this.renderMeritCell('照片格式支持jpg、jpeg、png。')}
  203 + {this.renderMeritCell('身份证照片信息将加密处理,仅用于提现财务用途。')}
  204 + {this.renderMeritCell('身份证信息需与提现银行卡信息匹配,否则无法正常提现成功。')}
  205 +
  206 + {this.renderIDCardAddDetailCell()}
  207 + </ScrollView>
  208 +
  209 + <TouchableOpacity style={[styles.submitButton, buttonDisabled ? styles.disabledButton : {}]}
  210 + disabled={buttonDisabled}
  211 + onPress={()=> {
  212 + if (this.state.backIDCardImageUri.length > 0 && this.state.frontIDCardImageUri.length > 0) {
  213 + this.props.bindIdentityCard && this.props.bindIdentityCard(this.state.frontIDCardImageUri, this.state.backIDCardImageUri);
  214 +
  215 + }
  216 + }}>
  217 + <Text style={styles.buttonText}>{'提交'}</Text>
  218 + </TouchableOpacity>
  219 +
  220 + {isShowToast ? <Prompt
  221 + text={toastMessage}
  222 + duration={1500}
  223 + onPromptHidden={this.props.hideToastMessage}
  224 + /> : null}
  225 +
  226 + <YH_ActionSheet
  227 + ref="YH_ActionSheet"
  228 + items={[{title:'拍照',id:'1'},{title:'从相册中选择',id:'2'}]}
  229 + actionsheetItemClick={this.actionsheetItemClick}
  230 + modalTitle={""} />
  231 +
  232 + <LoadingIndicator
  233 + isVisible={this.props.isShowLoading}
  234 + />
  235 + </View>
  236 + }
  237 +}
  238 +
  239 +const { width } = Dimensions.get('window');
  240 +let styles = StyleSheet.create({
  241 + mainContainer: {
  242 + flex: 1,
  243 + backgroundColor: 'white',
  244 + },
  245 + headerDetailContainer: {
  246 + backgroundColor: 'white',
  247 + },
  248 + headerTitle: {
  249 + marginLeft: 15,
  250 + marginTop: 20,
  251 + fontFamily: 'PingFang-SC-Medium',
  252 + fontSize: 17,
  253 + color: '#444444',
  254 + letterSpacing: 0,
  255 + },
  256 + meritCell: {
  257 + marginTop: 10,
  258 + flexDirection: 'row',
  259 + paddingLeft: 15,
  260 + paddingRight: 10,
  261 + },
  262 + meritAnnotation: {
  263 + width: 3,
  264 + height: 3,
  265 + borderRadius: 1.5,
  266 + backgroundColor: '#B0B0B0',
  267 + marginTop: 8,
  268 + },
  269 + headerDetailTitle: {
  270 + fontFamily: 'PingFang-SC-Regular',
  271 + fontSize: 14,
  272 + color: '#B0B0B0',
  273 + letterSpacing: 0,
  274 + marginLeft: 5,
  275 + },
  276 +
  277 + cell: {
  278 + height: 50,
  279 + alignItems: 'center',
  280 + flexDirection: 'row',
  281 + paddingLeft: 15,
  282 + paddingRight: 15,
  283 + },
  284 + cellTitle: {
  285 + fontSize: 14,
  286 + fontFamily: 'PingFang-SC-Regular',
  287 + color: '#444444',
  288 + },
  289 + textInput: {
  290 + fontSize: 14,
  291 + marginLeft: 22,
  292 + fontFamily: 'PingFang-SC-Regular',
  293 + color: '#B0B0B0',
  294 + },
  295 + imageText: {
  296 + fontFamily: 'PingFang-SC-Regular',
  297 + color: '#B0B0B0',
  298 + fontSize: 14,
  299 + },
  300 + buttonText: {
  301 + color: 'white',
  302 + fontSize: 14,
  303 + fontWeight: 'bold',
  304 + },
  305 + submitButton: {
  306 + marginLeft: 15,
  307 + marginRight: 15,
  308 + marginBottom: 33,
  309 + height: 44,
  310 + backgroundColor: '#002B47',
  311 + alignItems: 'center',
  312 + justifyContent: 'center',
  313 + },
  314 + disabledButton: {
  315 + backgroundColor: '#CCCCCC'
  316 + },
  317 + line: {backgroundColor: '#EEEEEE', left: 20, right: 20, bottom: 0, height: 1, position: 'absolute'},
  318 +
  319 + renderIDCardAddDetailCell: {
  320 + flexDirection: 'row',
  321 + marginTop: 20,
  322 + marginLeft: 15,
  323 + marginRight: 15,
  324 + justifyContent: 'space-between',
  325 + alignItems: 'center',
  326 + },
  327 + renderIDCardAddCellImage: {
  328 + width: (width - 50)/2,
  329 + },
  330 + viewImage: {
  331 + height: 101,
  332 + width: (width - 50)/2,
  333 + flexDirection: 'column',
  334 + alignItems: 'center',
  335 + justifyContent: 'center',
  336 + borderRadius: 2,
  337 + borderWidth: 1,
  338 + borderStyle: 'dashed',
  339 + borderColor: '#f0f0f0',
  340 + },
  341 + addImage: {
  342 + height: 30,
  343 + width: 30,
  344 + },
  345 + addImageClose: {
  346 + position: 'absolute',
  347 + height: 16,
  348 + width: 16,
  349 + top: -4,
  350 + left: (width - 50)/2-10,
  351 + },
  352 + renderIDCardSampleCellImage: {
  353 + width: 80,
  354 + marginTop: 30,
  355 + marginLeft: ((width-50)/2-80)/2,
  356 + },
  357 + cardImage: {
  358 + width: 80,
  359 + height: 50,
  360 + },
  361 + cardImageEGtip: {
  362 + height: 13,
  363 + width: 80,
  364 + marginTop: 4,
  365 + fontFamily: 'PingFang-SC-Regular',
  366 + fontSize: 9,
  367 + color: '#999999',
  368 + letterSpacing: 0,
  369 + textAlign: 'center',
  370 + },
  371 +})
@@ -163,4 +163,16 @@ export default keyMirror({ @@ -163,4 +163,16 @@ export default keyMirror({
163 163
164 SHOW_TIP_MESSAGE: null, 164 SHOW_TIP_MESSAGE: null,
165 HIDDEN_TIP_MESSAGE: null, 165 HIDDEN_TIP_MESSAGE: null,
  166 +
  167 + IDENTITY_CARD_INFO_REQUEST: null,
  168 + IDENTITY_CARD_INFO_SUCCESS: null,
  169 + IDENTITY_CARD_INFO_FAILURE: null,
  170 +
  171 + BIND_IDENTITY_CARD_REQUEST: null,
  172 + BIND_IDENTITY_CARD_SUCCESS: null,
  173 + BIND_IDENTITY_CARD_FAILURE: null,
  174 +
  175 + SHOW_TOAST: null,
  176 + HIDE_TOAST: null,
  177 + SHOW_LOADING: null,
166 }); 178 });
@@ -44,6 +44,7 @@ class MineContainer extends Component { @@ -44,6 +44,7 @@ class MineContainer extends Component {
44 componentDidMount() { 44 componentDidMount() {
45 this.props.actions.getMineUserInfo(); 45 this.props.actions.getMineUserInfo();
46 this.props.actions.getSettlementInfo(); 46 this.props.actions.getSettlementInfo();
  47 + this.props.actions.getIdentityCardInfo();
47 this.props.actions.getMineResourceInfo(); 48 this.props.actions.getMineResourceInfo();
48 this.props.actions.getShareTotalInfo(); 49 this.props.actions.getShareTotalInfo();
49 } 50 }
@@ -75,6 +76,7 @@ class MineContainer extends Component { @@ -75,6 +76,7 @@ class MineContainer extends Component {
75 settlementInfo, 76 settlementInfo,
76 mineResourceInfo, 77 mineResourceInfo,
77 shareTotalInfo, 78 shareTotalInfo,
  79 + identityCardInfo,
78 } = this.props.alliance; 80 } = this.props.alliance;
79 let isFetching = settlementInfo.isFetching; 81 let isFetching = settlementInfo.isFetching;
80 return ( 82 return (
@@ -84,6 +86,7 @@ class MineContainer extends Component { @@ -84,6 +86,7 @@ class MineContainer extends Component {
84 settlementInfo={settlementInfo} 86 settlementInfo={settlementInfo}
85 mineResourceInfo={mineResourceInfo} 87 mineResourceInfo={mineResourceInfo}
86 shareTotalInfo={shareTotalInfo} 88 shareTotalInfo={shareTotalInfo}
  89 + identityCardInfo={identityCardInfo}
87 jumpWithUrl={this._jumpWithUrl} 90 jumpWithUrl={this._jumpWithUrl}
88 resourceJumpWithUrl={this._resourceJumpWithUrl} 91 resourceJumpWithUrl={this._resourceJumpWithUrl}
89 refreshSettlementInfo={this._refreshSettlementInfo} 92 refreshSettlementInfo={this._refreshSettlementInfo}
@@ -8,6 +8,9 @@ import {Map} from "immutable"; @@ -8,6 +8,9 @@ import {Map} from "immutable";
8 8
9 import * as allianceActions from '../reducers/alliance/allianceActions'; 9 import * as allianceActions from '../reducers/alliance/allianceActions';
10 10
  11 +import NameAuthen from "../components/NameAuthen";
  12 +import AllianceService from '../services/AllianceService';
  13 +
11 const actions = [ 14 const actions = [
12 allianceActions 15 allianceActions
13 ]; 16 ];
@@ -34,6 +37,10 @@ function mapDispatchToProps(dispatch) { @@ -34,6 +37,10 @@ function mapDispatchToProps(dispatch) {
34 class NameAuthenContainer extends Component { 37 class NameAuthenContainer extends Component {
35 constructor(props) { 38 constructor(props) {
36 super(props); 39 super(props);
  40 +
  41 + this.bindIdentityCard = this.bindIdentityCard.bind(this);
  42 + this.showLoading = this.showLoading.bind(this);
  43 + this.hideToastMessage = this.hideToastMessage.bind(this);
37 } 44 }
38 45
39 componentDidMount() { 46 componentDidMount() {
@@ -44,10 +51,60 @@ class NameAuthenContainer extends Component { @@ -44,10 +51,60 @@ class NameAuthenContainer extends Component {
44 51
45 } 52 }
46 53
  54 + showLoading(show){
  55 + this.props.actions.showLoading(show);
  56 + }
  57 +
  58 + hideToastMessage(){
  59 + this.props.actions.hideToastMessage();
  60 + }
  61 +
  62 + bindIdentityCard(frontIDCardImageUri, backIDCardImageUri) {
  63 + this.showLoading(true);
  64 +
  65 + console.log(backIDCardImageUri);
  66 + console.log(frontIDCardImageUri);
  67 + let param = [{code: 0,imageUri:frontIDCardImageUri.replace('file://','')},{code: 1,imageUri:backIDCardImageUri.replace('file://','')}];
  68 + NativeModules.YH_MarketHelper && NativeModules.YH_MarketHelper.postIDCardImage(param).then(data => {
  69 + let list = data;
  70 + let cardFrontUrl = '';
  71 + let cardBackUrl = '';
  72 + for (let i = 0; i < list.length; i++) {
  73 + const element = list[i];
  74 + if(element.code == 0){
  75 + cardFrontUrl = element.result;
  76 + }else if(element.code == 1){
  77 + cardBackUrl = element.result;
  78 + }
  79 + }
  80 +
  81 + this.showLoading(false);
  82 +
  83 + if(cardFrontUrl.length <= 0 || cardBackUrl.length <= 0){
  84 + this.props.actions.showToastMessage('图片上传失败!请重试!');
  85 + return;
  86 + }
  87 +
  88 + this.props.actions.bindIdentityCard(cardFrontUrl, cardBackUrl, function(json) {
  89 +
  90 + });
  91 + })
  92 + .catch(error => {
  93 + this.showLoading(false);
  94 + this.props.actions.showToastMessage(error.message || '网络请求错误');
  95 + });
  96 + }
  97 +
47 render() { 98 render() {
48 return ( 99 return (
49 <View style={styles.container}> 100 <View style={styles.container}>
50 - 101 + <NameAuthen
  102 + bindIdentityCard={this.bindIdentityCard}
  103 + showLoading={this.showLoading}
  104 + isShowLoading={this.props.alliance.isShowLoading}
  105 + isShowToast={this.props.alliance.isShowToast}
  106 + toastMessage={this.props.alliance.toastMessage}
  107 + hideToastMessage={this.hideToastMessage}/>
51 </View> 108 </View>
52 ); 109 );
53 } 110 }
@@ -112,6 +112,19 @@ const { @@ -112,6 +112,19 @@ const {
112 112
113 SHOW_BANK_TIPS_ALERT, 113 SHOW_BANK_TIPS_ALERT,
114 DISMISS_BANK_TIPS_ALERT, 114 DISMISS_BANK_TIPS_ALERT,
  115 +
  116 + IDENTITY_CARD_INFO_REQUEST,
  117 + IDENTITY_CARD_INFO_SUCCESS,
  118 + IDENTITY_CARD_INFO_FAILURE,
  119 +
  120 + BIND_IDENTITY_CARD_REQUEST,
  121 + BIND_IDENTITY_CARD_SUCCESS,
  122 + BIND_IDENTITY_CARD_FAILURE,
  123 +
  124 + SHOW_TOAST,
  125 + HIDE_TOAST,
  126 + SHOW_LOADING,
  127 +
115 } = require('../../constants/actionTypes').default; 128 } = require('../../constants/actionTypes').default;
116 129
117 export function showTipsAlertDialog() { 130 export function showTipsAlertDialog() {
@@ -629,6 +642,66 @@ export function invitedFriendsFailue(error) { @@ -629,6 +642,66 @@ export function invitedFriendsFailue(error) {
629 } 642 }
630 } 643 }
631 644
  645 +export function identityCardInfoRequest() {
  646 + return {
  647 + type: IDENTITY_CARD_INFO_REQUEST,
  648 + };
  649 +}
  650 +
  651 +export function identityCardInfoSuccess(json) {
  652 + return {
  653 + type: IDENTITY_CARD_INFO_SUCCESS,
  654 + payload: json
  655 + };
  656 +}
  657 +
  658 +export function identityCardInfoFailure(error) {
  659 + return {
  660 + type: IDENTITY_CARD_INFO_FAILURE,
  661 + payload: error
  662 + };
  663 +}
  664 +
  665 +export function bindIdentityCardRequest() {
  666 + return {
  667 + type: BIND_IDENTITY_CARD_REQUEST,
  668 + };
  669 +}
  670 +
  671 +export function bindIdentityCardSuccess(json) {
  672 + return {
  673 + type: BIND_IDENTITY_CARD_SUCCESS,
  674 + payload: json
  675 + };
  676 +}
  677 +
  678 +export function bindIdentityCardFailure(error) {
  679 + return {
  680 + type: BIND_IDENTITY_CARD_FAILURE,
  681 + payload: error
  682 + };
  683 +}
  684 +
  685 +export function showLoading(show) {
  686 + return {
  687 + type: SHOW_LOADING,
  688 + payload: show
  689 + };
  690 +}
  691 +
  692 +export function showToastMessage(value) {
  693 + return {
  694 + type: SHOW_TOAST,
  695 + payload: value
  696 + };
  697 +}
  698 +
  699 +export function hideToastMessage() {
  700 + return {
  701 + type: HIDE_TOAST,
  702 + };
  703 +}
  704 +
632 export function getSettlementInfo() { 705 export function getSettlementInfo() {
633 return (dispatch, getState) => { 706 return (dispatch, getState) => {
634 let {app} = getState(); 707 let {app} = getState();
@@ -1275,3 +1348,58 @@ function exposeProductListData(json) { @@ -1275,3 +1348,58 @@ function exposeProductListData(json) {
1275 res.product_list = list; 1348 res.product_list = list;
1276 return res; 1349 return res;
1277 } 1350 }
  1351 +
  1352 +
  1353 +export function bindIdentityCard(cardFrontUrl, cardBackUrl, callback) {
  1354 + return (dispatch, getState) => {
  1355 + let {app, alliance} = getState();
  1356 +
  1357 + let funBindIdentityCard = (uid) => {
  1358 + dispatch(bindIdentityCardRequest());
  1359 + return new AllianceService(app.host).bindIdentityCard(uid, cardFrontUrl, cardBackUrl)
  1360 + .then(json => {
  1361 + dispatch(bindIdentityCardSuccess(json));
  1362 +
  1363 + callback && typeof callback === 'function' && callback(json)
  1364 + })
  1365 + .catch(error => {
  1366 + dispatch(bindIdentityCardFailure(error));
  1367 + dispatch(showToastMessage(error.message));
  1368 + });
  1369 + };
  1370 +
  1371 + let uid = 0;
  1372 + ReactNative.NativeModules.YH_CommonHelper.uid()
  1373 + .then(uid => {
  1374 + funBindIdentityCard(uid)
  1375 + })
  1376 + .catch(error => {
  1377 + funBindIdentityCard(uid)
  1378 + });
  1379 + };
  1380 +}
  1381 +
  1382 +export function getIdentityCardInfo() {
  1383 + return (dispatch, getState) => {
  1384 + let {app} = getState();
  1385 + let fetchIdentityCardInfo = (uid) => {
  1386 + dispatch(identityCardInfoRequest());
  1387 + return new AllianceService(app.host).fetchIdentityCardInfo(uid)
  1388 + .then(json => {
  1389 + dispatch(identityCardInfoSuccess(json));
  1390 + })
  1391 + .catch(error => {
  1392 + dispatch(identityCardInfoFailure(error));
  1393 + });
  1394 + };
  1395 +
  1396 + let uid = 0;
  1397 + ReactNative.NativeModules.YH_CommonHelper.uid()
  1398 + .then(uid => {
  1399 + fetchIdentityCardInfo(uid)
  1400 + })
  1401 + .catch(error => {
  1402 + fetchIdentityCardInfo(uid)
  1403 + });
  1404 + };
  1405 +}
@@ -195,6 +195,22 @@ let InitialState = Record({ @@ -195,6 +195,22 @@ let InitialState = Record({
195 username: '', 195 username: '',
196 })), 196 })),
197 197
  198 +
  199 + bindIdentityCardResult: new (Record({
  200 + isFetching: false,
  201 + error: null,
  202 + })),
  203 +
  204 + identityCardInfo: new (Record({
  205 + isFetching: false,
  206 + error: null,
  207 + data: null,
  208 + })),
  209 +
  210 + isShowToast: false,
  211 + toastMessage: '',
  212 + isShowLoading: false,
  213 +
198 }); 214 });
199 215
200 export default InitialState; 216 export default InitialState;
@@ -111,6 +111,18 @@ const { @@ -111,6 +111,18 @@ const {
111 INVITED_FRIENDS_SUCCESS, 111 INVITED_FRIENDS_SUCCESS,
112 INVITED_FRIENDS_FAILURE, 112 INVITED_FRIENDS_FAILURE,
113 113
  114 + IDENTITY_CARD_INFO_REQUEST,
  115 + IDENTITY_CARD_INFO_SUCCESS,
  116 + IDENTITY_CARD_INFO_FAILURE,
  117 +
  118 + BIND_IDENTITY_CARD_REQUEST,
  119 + BIND_IDENTITY_CARD_SUCCESS,
  120 + BIND_IDENTITY_CARD_FAILURE,
  121 +
  122 + SHOW_TOAST,
  123 + HIDE_TOAST,
  124 + SHOW_LOADING,
  125 +
114 } = require('../../constants/actionTypes').default; 126 } = require('../../constants/actionTypes').default;
115 127
116 const initialState = new InitialState; 128 const initialState = new InitialState;
@@ -621,6 +633,39 @@ export default function couponReducer(state = initialState, action) { @@ -621,6 +633,39 @@ export default function couponReducer(state = initialState, action) {
621 return state.set('tipMessage', ''); 633 return state.set('tipMessage', '');
622 } 634 }
623 635
  636 + case IDENTITY_CARD_INFO_REQUEST: {
  637 + return state.setIn(['identityCardInfo', 'isFetching'], true)
  638 + .setIn(['identityCardInfo', 'error'], null);
  639 + }
  640 +
  641 + case IDENTITY_CARD_INFO_SUCCESS: {
  642 + return state.setIn(['identityCardInfo', 'isFetching'], false)
  643 + .setIn(['identityCardInfo', 'data'], action.payload)
  644 + .setIn(['identityCardInfo', 'error'], null);
  645 + }
  646 +
  647 + case IDENTITY_CARD_INFO_FAILURE: {
  648 + return state.setIn(['identityCardInfo', 'isFetching'], false)
  649 + .setIn(['identityCardInfo', 'error'], action.payload);
  650 + }
  651 +
  652 + case BIND_BANK_CARD_REQUEST:
  653 + return state.setIn(['bindIdentityCardResult', 'isFetching'], true);
  654 +
  655 + case BIND_BANK_CARD_SUCCESS:
  656 + return state.setIn(['bindIdentityCardResult', 'isFetching'], false);
  657 +
  658 + case BIND_BANK_CARD_FAILURE:
  659 + return state.setIn(['bindIdentityCardResult', 'isFetching'], false)
  660 + .setIn(['bindIdentityCardResult', 'error'], action.payload);
  661 +
  662 + case SHOW_LOADING:
  663 + return state.set('isShowLoading', action.payload);
  664 + case SHOW_TOAST:
  665 + return state.set('isShowToast', true).set('toastMessage', action.payload);
  666 + case HIDE_TOAST:
  667 + return state.set('isShowToast', false).set('toastMessage', '');
  668 +
624 } 669 }
625 return state; 670 return state;
626 } 671 }
@@ -417,4 +417,42 @@ export default class AllianceService { @@ -417,4 +417,42 @@ export default class AllianceService {
417 }); 417 });
418 } 418 }
419 419
  420 + //(查询是否绑定身份证)
  421 + async fetchIdentityCardInfo(uid) {
  422 + return await this.api.get({
  423 + url: '',
  424 + body: {
  425 + uid,
  426 + method: 'app.union.shareOrder.getIdentityCard',
  427 + }
  428 + })
  429 + .then((json) => {
  430 + return json;
  431 + })
  432 + .catch((error) => {
  433 + throw(error);
  434 + });
  435 + }
  436 +
  437 +
  438 + // 绑定身份证信息
  439 + async bindIdentityCard(uid, cardFrontUrl, cardBackUrl) {
  440 + return await this.api.get({
  441 + url: '',
  442 + body: {
  443 + method: 'app.union.shareOrder.bindIdentityCard',
  444 + uid,
  445 + cardFrontUrl,
  446 + cardBackUrl,
  447 + }
  448 + })
  449 + .then((json) => {
  450 + return json;
  451 + })
  452 + .catch((error) => {
  453 + throw(error);
  454 + });
  455 + }
  456 +
  457 +
420 } 458 }
  1 +import React from 'react';
  2 +import PropTypes from 'prop-types';
  3 +
  4 +import {
  5 +View,
  6 +StyleSheet,
  7 +Text,
  8 +Modal,
  9 +TouchableOpacity,
  10 +Dimensions
  11 +} from 'react-native'
  12 +const {width,height} =Dimensions.get('window')
  13 +
  14 +export default class YH_ActionSheet extends React.Component {
  15 + constructor(props){
  16 + super(props)
  17 + this.state = {
  18 + modalVisible:false,
  19 + }
  20 + }
  21 +
  22 + static propTypes={
  23 + items:PropTypes.array,
  24 + itemStyle:PropTypes.object,
  25 + actionTitleStyle:PropTypes.object,
  26 + itemTitleStyle:PropTypes.object,
  27 + modalTitle:PropTypes.string,
  28 + }
  29 + static defaultProps={
  30 + items:[],
  31 + itemStyle:{},
  32 + actionTitleStyle:{},
  33 + itemTitleStyle:{},
  34 + modalTitle:''
  35 + }
  36 +
  37 + showModal(){
  38 + this.setState({modalVisible:true})
  39 + }
  40 +
  41 + cancelModal(){
  42 + this.setState({modalVisible:false})
  43 + }
  44 +
  45 + clickItem(id){
  46 + this.props.actionsheetItemClick(id);
  47 + }
  48 +
  49 + render(){
  50 + let actionSheets = this.props.items.map((item,i)=>{
  51 + return(
  52 + <TouchableOpacity
  53 + key={i}
  54 + style={[styles.actionItem,this.props.itemStyle]}
  55 + onPress={()=>this.clickItem(item.id)}>
  56 + <Text style={[styles.actionItemTitle,this.props.itemTitleStyle]}
  57 + >{item.title}</Text>
  58 + </TouchableOpacity>
  59 + )
  60 + })
  61 +
  62 +
  63 + return <Modal animationType="fade" //slide
  64 + visible={this.state.modalVisible}
  65 + transparent={true}
  66 + onRequestClose={()=>this.setState({modalVisible:false})}>
  67 + <View style={styles.modalStyle}>
  68 + <View style={styles.subView}>
  69 + <View style={styles.itemContainer}>
  70 + {this.props.modalTitle ? <View style={[styles.itemContainer,{height:55,marginTop:5}]}>
  71 + <Text style={[styles.actionTitle,this.props.actionTitleStyle]}
  72 + >{this.props.modalTitle}</Text>
  73 + </View> : null}
  74 + {actionSheets}
  75 + </View>
  76 + <View style={[styles.itemContainer]}>
  77 + <TouchableOpacity
  78 + style={[styles.actionItem,this.props.itemStyle,{height:70,marginBottom:-5,backgroundColor:'white'}]}
  79 + onPress={()=>this.setState({modalVisible:false})}>
  80 + <Text style={[styles.actionItemTitle,this.props.itemTitleStyle,{color:'#999999',}]}>取消</Text>
  81 + </TouchableOpacity>
  82 + </View>
  83 + </View>
  84 + </View>
  85 + </Modal>
  86 + }
  87 +}
  88 +
  89 +const styles = StyleSheet.create({
  90 + modalStyle:{
  91 + justifyContent:'flex-end',
  92 + alignItems:'center',
  93 + flex:1,
  94 + backgroundColor:'rgba(0,0,0,0.2)',
  95 + },
  96 + subView:{
  97 + justifyContent:'flex-end',
  98 + alignItems:'center',
  99 + alignSelf:'stretch',
  100 + width:width,
  101 + backgroundColor:'white',
  102 + },
  103 + itemContainer:{
  104 + marginLeft:15,
  105 + marginRight:15,
  106 + marginBottom:0.5,
  107 + backgroundColor:'#fff',
  108 + justifyContent:'center',
  109 + alignItems:'center',
  110 + },
  111 + actionItem:{
  112 + width:width,
  113 + height:70,
  114 + alignItems:'center',
  115 + justifyContent:'center',
  116 + borderTopColor:'#EEEEEE',
  117 + borderTopWidth:0.5,
  118 + },
  119 + actionTitle:{
  120 + fontSize:14,
  121 + color:'#9EA3AD',
  122 + textAlign:'center',
  123 + },
  124 + actionItemTitle:{
  125 + fontSize:16,
  126 + color:'#000000',
  127 + textAlign:'center',
  128 + },
  129 +})
@@ -50,6 +50,7 @@ @@ -50,6 +50,7 @@
50 "redux-logger": "^3.0.6", 50 "redux-logger": "^3.0.6",
51 "redux-thunk": "^2.2.0", 51 "redux-thunk": "^2.2.0",
52 "stacktrace-js": "^2.0.0", 52 "stacktrace-js": "^2.0.0",
  53 + "react-native-image-picker": "^0.28.1",
53 "timeago.js": "^3.0.2" 54 "timeago.js": "^3.0.2"
54 }, 55 },
55 "devDependencies": { 56 "devDependencies": {