Commit 7b3177fe authored by shiyunjie's avatar shiyunjie

Merge branch 'shiyunjie'

parents 23bcdd7e a70a5c8c
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, { Component } from 'react';
import {
View,
} from 'react-native';
import { SpringScrollView } from 'react-native-spring-scrollview';
import { CommonLottieHeader } from 'react-native-spring-scrollview/Customize/CommonLottieHeader';
import Picker from '../../components/Picker';
import Styles from '../../theme/Styles';
import { trailPolicyAPI } from '../InsuranceList/InsuranceAPI';
import {
BANNER,
PROCESS,
PAGE_TITLE,
BUTTON_GROUP,
LIST_ITEM,
CELL,
CHECKBOX,
PICKER,
DATE_PICKER,
IMAGE,
TAB,
MULTINPUT,
TEXTAREA,
PRODUCT_TITLE,
PRODUCT_BANNER,
PLAN_INFO,
PREM_GROUP,
PRODUCT_IMAGE,
SERVICE_IMAGE,
NOTICE_IMAGE,
INSURE_YEAR,
MULT,
JIACHENG,
AIFEIXIANG,
XUESHENGYIWAI,
} from './config/keys';
import {
getConfig,
} from './config';
import { renderPageByConfig } from '.';
import Button from '../../components/ThemeButton';
import SubmitButton from './components/SubmitButton';
type Props = {
routes : Array,
popTo : () => void,
blueId : string,
pageName : string,
};
const pageName = 'productDetail';
class BaseContainer extends Component {
constructor(props : Props) {
super(props);
//console.log('props', props);
const productDetail = getConfig(props.blueId)[props.pageName];
const { params } = props;
const { keys, layout } = productDetail;
this.productDetail = productDetail;
this.policy = {
mult: '',
prem: 99,
premTotal: 99,
};
this.state = {
params,
config: {},
keys,
};
//console.log('ProductDetailPage', this.state);
}
componentWillMount() : void {
const config = {};
const { params } = this.state;
const { keys, layout } = this.productDetail;
keys.forEach((key) => {
const data = this.fillData(key, this.productDetail[key], params);
//console.log('productDetail:', this.productDetail, layout[key], key);
config[key] = { ...layout[key], ...data };
});
this.setState({
config,
});
}
fillData = (key, lay, params) => {
const {
name, description, tagNameList, bannerIconUrl, guaranteeContent,
productIntroductionUrl, serviceProcessUrl,
} = params.detail;
//console.log('productIntroductionUrl', productIntroductionUrl);
switch (key) {
case PRODUCT_BANNER:
return {
uri: bannerIconUrl.url,
width: global.SCREEN_WIDTH,
height: global.SCREEN_WIDTH * bannerIconUrl.height / bannerIconUrl.width,
};
case PREM_GROUP:
return {
onSelect: (index) => {
//console.log('BUTTON_GROUP,onSelect', index);
switch (index) {
case 0:
this.policy.prem = 99;
break;
case 1:
this.policy.prem = 199;
break;
default:
break;
}
},
selectIndex: 0,
};
case PRODUCT_TITLE:
return {
h1: name, // title需要装填数据 主标题
h2: description, // title需要装填数据 副标题
label: tagNameList, // 多个展示标签
labelColor: '#cf4100', //颜色
};
case PLAN_INFO:
return {
label: {
icon: '', //左侧icon
h1: '保障计划', //主标题
rightIcon: '', //右侧icon
rightText: '查看保障详情', //右侧文字
onPress: () => {
}, //点击事件
},
data: JSON.parse(guaranteeContent),
};
case INSURE_YEAR:
return {};
case MULT:
return {
onChangeText: (value) => {
//console.log('ProductDetailPage_onChangeText', value);
this.policy.mult = value;
//console.log(this.policy.mult);
},
onEndEditing: () => {
},
value: this.state.mult,
};
case NOTICE_IMAGE:
return {};
case PRODUCT_IMAGE:
return {
uri: productIntroductionUrl.url,
width: global.SCREEN_WIDTH,
height: global.SCREEN_WIDTH * productIntroductionUrl.height / productIntroductionUrl.width,
label: {
icon: '', //左侧icon
h1: '特色产品', //主标题
rightIcon: '', //右侧icon
rightText: '', //右侧文字
onPress: () => {
}, //点击事件
},
};
case SERVICE_IMAGE:
return {
uri: serviceProcessUrl.url,
width: global.SCREEN_WIDTH,
height: global.SCREEN_WIDTH * serviceProcessUrl.height / serviceProcessUrl.width,
label: {
icon: '', //左侧icon
h1: '理赔流程', //主标题
rightIcon: '', //右侧icon
rightText: '', //右侧文字
onPress: () => {
}, //点击事件
},
};
default:
return {};
}
}
translateDataToRules = (key, rule, params) => {
switch (key) {
case BANNER:
return {};
case PAGE_TITLE:
return {};
case LIST_ITEM:
return {};
case PICKER:
return {};
default:
return {};
}
}
renderExtraViews = (viewType) => {
switch (viewType) {
case PICKER:
return this.renderPicker;
case 'submit':
return this.renderSubmit;
default:
return () => {};
}
}
renderSubmit = () => (
<SubmitButton />
)
renderPicker = (data) => {
//console.log('renderPicker:', data);
return (
<Picker {...data} />
);
}
renderInsureViews = (config, key, type) => {
renderPageByConfig(
config[key][type], this.renderExtraViews,
)(config[key]); // 第二个参数可以传入自己的方法根据自定义类型渲染组件
}
render() {
const { config, keys } = this.state;
//console.log('config:', config, keys);
const type = 'type';
return (
<SpringScrollView
ref={(com) => {
this.scrollView = com;
}}
onScroll={({ nativeEvent: { contentOffset: { x, y } } }) => {
//console.log('offset : x=', x, 'y=', y);
}}
styles={Styles.container}
inverted={false}
//onRefresh={this._onRefresh}
//onLoading={this._onLoading}
// allLoaded={this.state.allLoaded}
refreshHeader={CommonLottieHeader}
//loadingFooter={CommonLottieFooter}
>
<View>
{keys.map((key, index) => (
this.renderInsureViews(config, key, type)
))}
</View>
</SpringScrollView>
);
}
}
export default BaseContainer;
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, { Component } from 'react';
import {
View,
} from 'react-native';
import { SpringScrollView } from 'react-native-spring-scrollview';
import { CommonLottieHeader } from 'react-native-spring-scrollview/Customize/CommonLottieHeader';
import Picker from '../../components/Picker';
import Styles from '../../theme/Styles';
import { trailPolicyAPI } from '../InsuranceList/InsuranceAPI';
import {
BANNER,
PROCESS,
PAGE_TITLE,
BUTTON_GROUP,
LIST_ITEM,
CELL,
CHECKBOX,
PICKER,
DATE_PICKER,
IMAGE,
TAB,
MULTINPUT,
TEXTAREA,
PRODUCT_TITLE,
PRODUCT_BANNER,
PLAN_INFO,
PREM_GROUP,
PRODUCT_IMAGE,
SERVICE_IMAGE,
NOTICE_IMAGE,
INSURE_YEAR,
MULT,
JIACHENG,
AIFEIXIANG,
XUESHENGYIWAI,
} from './config/keys';
import {
getConfig,
} from './config';
import { renderPageByConfig } from './';
import Button from '../../components/ThemeButton';
import SubmitButton from './components/SubmitButton';
type Props = {
routes : Array,
popTo : () => void,
blueId : string,
pageName : string,
params: Object,
config: Object,
keys: Object
};
class PolicyContainer extends Component {
constructor(props : Props) {
super(props);
//console.log('props', props);
//const productDetail = getConfig(props.blueId)[props.pageName];
const { params, config, keys } = props;
//const { keys, layout } = productDetail;
//this.productDetail = productDetail;
//this.policy = {
// mult: '',
// prem: 99,
// premTotal: 99,
//};
this.state = {
params,
config,
keys,
};
//console.log('ProductDetailPage', this.state);
}
//componentWillMount() : void {
//const config = {};
//const { params } = this.state;
//const { keys, layout } = this.productDetail;
//keys.forEach((key) => {
// const data = this.fillData(key, this.productDetail[key], params);
// //console.log('productDetail:', this.productDetail, layout[key], key);
// config[key] = { ...layout[key], ...data };
//});
//this.setState({
// config,
//});
//}
//fillData = (key, lay, params) => {
// const {
// name, description, tagNameList, bannerIconUrl, guaranteeContent,
// productIntroductionUrl, serviceProcessUrl,
// } = params.detail;
// //console.log('productIntroductionUrl', productIntroductionUrl);
// switch (key) {
// case PRODUCT_BANNER:
// return {
// uri: bannerIconUrl.url,
// width: global.SCREEN_WIDTH,
// height: global.SCREEN_WIDTH * bannerIconUrl.height / bannerIconUrl.width,
// };
// case PREM_GROUP:
// return {
// onSelect: (index) => {
// //console.log('BUTTON_GROUP,onSelect', index);
// switch (index) {
// case 0:
// this.policy.prem = 99;
// break;
// case 1:
// this.policy.prem = 199;
// break;
// default:
// break;
// }
// },
// selectIndex: 0,
// };
// case PRODUCT_TITLE:
// return {
// h1: name, // title需要装填数据 主标题
// h2: description, // title需要装填数据 副标题
// label: tagNameList, // 多个展示标签
// labelColor: '#cf4100', //颜色
// };
// case PLAN_INFO:
// return {
// label: {
// icon: '', //左侧icon
// h1: '保障计划', //主标题
// rightIcon: '', //右侧icon
// rightText: '查看保障详情', //右侧文字
// onPress: () => {
// }, //点击事件
// },
// data: JSON.parse(guaranteeContent),
// };
// case INSURE_YEAR:
// return {};
// case MULT:
// return {
// onChangeText: (value) => {
// //console.log('ProductDetailPage_onChangeText', value);
// this.policy.mult = value;
// //console.log(this.policy.mult);
// },
// onEndEditing: () => {
// },
// value: this.state.mult,
// };
// case NOTICE_IMAGE:
// return {};
// case PRODUCT_IMAGE:
// return {
// uri: productIntroductionUrl.url,
// width: global.SCREEN_WIDTH,
// height: global.SCREEN_WIDTH * productIntroductionUrl.height / productIntroductionUrl.width,
// label: {
// icon: '', //左侧icon
// h1: '特色产品', //主标题
// rightIcon: '', //右侧icon
// rightText: '', //右侧文字
// onPress: () => {
// }, //点击事件
// },
// };
// case SERVICE_IMAGE:
// return {
// uri: serviceProcessUrl.url,
// width: global.SCREEN_WIDTH,
// height: global.SCREEN_WIDTH * serviceProcessUrl.height / serviceProcessUrl.width,
// label: {
// icon: '', //左侧icon
// h1: '理赔流程', //主标题
// rightIcon: '', //右侧icon
// rightText: '', //右侧文字
// onPress: () => {
// }, //点击事件
// },
// };
// default:
// return {};
// }
//}
//translateDataToRules = (key, rule, params) => {
// switch (key) {
// case BANNER:
// return {};
// case PAGE_TITLE:
// return {};
// case LIST_ITEM:
// return {};
// case PICKER:
// return {};
// default:
// return {};
// }
//}
//renderExtraViews = (viewType) => {
// switch (viewType) {
// case PICKER:
// return this.renderPicker;
// case 'submit':
// return this.renderSubmit;
// default:
// return () => {};
// }
//}
//
//
//renderSubmit = () => (
// <SubmitButton />
//)
//
//renderPicker = (data) => {
// //console.log('renderPicker:', data);
// return (
// <Picker {...data} />
// );
//}
componentWillReceiveProps(nextProps, nextContext : any) : void {
console.log('componentWillReceiveProps',nextProps)
const { params, config, keys } = nextProps;
this.setState({
params, config, keys
})
}
renderInsureViews = (config, key, type) => {
return (renderPageByConfig(
config[key][type], this.props.renderExtraViews,
)(config[key])); // 第二个参数可以传入自己的方法根据自定义类型渲染组件
}
render() {
const { config, keys } = this.state;
console.log('PolicyContainer_render:', config, keys,);
const type = 'type';
return (
<SpringScrollView
ref={(com) => {
this.scrollView = com;
}}
onScroll={({ nativeEvent: { contentOffset: { x, y } } }) => {
//console.log('offset : x=', x, 'y=', y);
}}
styles={[Styles.container]}
inverted={false}
//onRefresh={this._onRefresh}
//onLoading={this._onLoading}
// allLoaded={this.state.allLoaded}
refreshHeader={CommonLottieHeader}
//loadingFooter={CommonLottieFooter}
>
<View>
{keys.map((key, index) => (
this.renderInsureViews(config, key, type)
))}
</View>
</SpringScrollView>
);
}
}
export default PolicyContainer;
...@@ -18,6 +18,8 @@ import { ...@@ -18,6 +18,8 @@ import {
INSURED_TITLE, INSURED_TITLE,
INSURED_NAME, INSURED_NAME,
INSURED_ID_TYPE, INSURED_ID_TYPE,
BUTTON,
SUBMIT_BUTTON, AMOUNT_BUTTON,
} from './keys'; } from './keys';
...@@ -127,6 +129,9 @@ export default { ...@@ -127,6 +129,9 @@ export default {
begin: '', begin: '',
end: '', end: '',
}, },
[SUBMIT_BUTTON]: {
type: BUTTON,
}
}, },
rules: { rules: {
[INSURE_YEAR]: { [INSURE_YEAR]: {
...@@ -135,5 +140,5 @@ export default { ...@@ -135,5 +140,5 @@ export default {
}, },
keys: [POLICY_PROGRESS, APPLICANT_TITLE, APPLICANT_NAME, APPLICANT_ID_TYPE, APPLICANT_ID, keys: [POLICY_PROGRESS, APPLICANT_TITLE, APPLICANT_NAME, APPLICANT_ID_TYPE, APPLICANT_ID,
APPLICANT_BIRTHDAY, APPLICANT_GENDER, APPLICANT_MOBILE, APPLICANT_EMAIL, INSURED_TITLE, APPLICANT_BIRTHDAY, APPLICANT_GENDER, APPLICANT_MOBILE, APPLICANT_EMAIL, INSURED_TITLE,
INSURED_NAME, INSURED_ID_TYPE, INSURE_YEAR_TITLE, INSURE_YEAR], INSURED_NAME, INSURED_ID_TYPE, INSURE_YEAR_TITLE, INSURE_YEAR, SUBMIT_BUTTON],
}; };
...@@ -60,13 +60,22 @@ export const getConfig = (blueID) => { ...@@ -60,13 +60,22 @@ export const getConfig = (blueID) => {
return config; return config;
case AIFEIXIANG: case AIFEIXIANG:
// 爱飞翔 // 爱飞翔
if(config.productDetail[PREM_GROUP]){
delete config.productDetail[PREM_GROUP]; delete config.productDetail[PREM_GROUP];
}
if(premIndex !== -1){
config.productDetail.keys.splice(premIndex, 1); config.productDetail.keys.splice(premIndex, 1);
}
return config; return config;
case XUESHENGYIWAI: case XUESHENGYIWAI:
//学生意外 //学生意外
if(config.productDetail[PREM_GROUP]){
delete config.productDetail[PREM_GROUP]; delete config.productDetail[PREM_GROUP];
}
if(premIndex !== -1){
config.productDetail.keys.splice(premIndex, 1); config.productDetail.keys.splice(premIndex, 1);
}
return config; return config;
default: default:
return config; return config;
......
...@@ -18,6 +18,8 @@ export const PROGRESS = 'progress'; ...@@ -18,6 +18,8 @@ export const PROGRESS = 'progress';
export const GRAY_LABEL = 'grayLabel'; export const GRAY_LABEL = 'grayLabel';
export const DATE_RANGE = 'dateRange'; export const DATE_RANGE = 'dateRange';
export const NOTICE = 'notice'; export const NOTICE = 'notice';
export const AMOUNT_BUTTON = 'amountButton';
export const BUTTON = 'button';
// layout key 组件作用于哪个业务,是装填数据,绑定事件的依据 // layout key 组件作用于哪个业务,是装填数据,绑定事件的依据
...@@ -48,6 +50,7 @@ export const INSURED_PRODUCT = 'insureProduct'; ...@@ -48,6 +50,7 @@ export const INSURED_PRODUCT = 'insureProduct';
export const PAYMENT_TITLE = 'paymentTitle'; export const PAYMENT_TITLE = 'paymentTitle';
export const PAYMENT_NOTICE = 'paymentNotice'; export const PAYMENT_NOTICE = 'paymentNotice';
export const PAYMENT_TYPE = 'paymentType'; export const PAYMENT_TYPE = 'paymentType';
export const SUBMIT_BUTTON = 'submitButton';
// 保险ID // 保险ID
export const JIACHENG = '200000156'; export const JIACHENG = '200000156';
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
BANNER, BUTTON_GROUP, IMAGE, LIST_ITEM, MULTINPUT, PAGE_TITLE, PICKER, BANNER, BUTTON_GROUP, IMAGE, LIST_ITEM, MULTINPUT, PAGE_TITLE, PICKER,
PRODUCT_BANNER, PRODUCT_TITLE, PREM_GROUP, PLAN_INFO, INSURE_YEAR, MULT, PRODUCT_IMAGE, PRODUCT_BANNER, PRODUCT_TITLE, PREM_GROUP, PLAN_INFO, INSURE_YEAR, MULT, PRODUCT_IMAGE,
SERVICE_IMAGE, NOTICE, POLICY_PROGRESS, PROGRESS, INSURED_TITLE, GRAY_LABEL, INSURED_NAME, TEXT_INPUT, SERVICE_IMAGE, NOTICE, POLICY_PROGRESS, PROGRESS, INSURED_TITLE, GRAY_LABEL, INSURED_NAME, TEXT_INPUT,
INSURED_PREM, INSURED_PRODUCT, PAYMENT_TITLE, PAYMENT_NOTICE, CHECKBOX, PAYMENT_TYPE, INSURED_PREM, INSURED_PRODUCT, PAYMENT_TITLE, PAYMENT_NOTICE, CHECKBOX, PAYMENT_TYPE, SUBMIT_BUTTON, BUTTON,
} from './keys'; } from './keys';
export default { export default {
...@@ -55,7 +55,10 @@ export default { ...@@ -55,7 +55,10 @@ export default {
onSelect: () => {}, onSelect: () => {},
selectIndex: -1, selectIndex: -1,
}, },
[SUBMIT_BUTTON]: {
type: BUTTON,
}
}, },
rules: {}, rules: {},
keys: [POLICY_PROGRESS, INSURED_TITLE, INSURED_PRODUCT, INSURED_PREM, PAYMENT_TITLE, PAYMENT_TYPE], keys: [POLICY_PROGRESS, INSURED_TITLE, INSURED_PRODUCT, INSURED_PREM, PAYMENT_TITLE, PAYMENT_TYPE, SUBMIT_BUTTON],
}; };
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import { import {
BANNER, BUTTON_GROUP, IMAGE, LIST_ITEM, MULTINPUT, PAGE_TITLE, PICKER, BANNER, BUTTON_GROUP, IMAGE, LIST_ITEM, MULTINPUT, PAGE_TITLE, PICKER,
PRODUCT_BANNER, PRODUCT_TITLE, PREM_GROUP, PLAN_INFO, INSURE_YEAR, MULT, PRODUCT_IMAGE, PRODUCT_BANNER, PRODUCT_TITLE, PREM_GROUP, PLAN_INFO, INSURE_YEAR, MULT, PRODUCT_IMAGE,
SERVICE_IMAGE, NOTICE_IMAGE, SERVICE_IMAGE, SUBMIT_BUTTON, AMOUNT_BUTTON
} from './keys'; } from './keys';
export default { export default {
...@@ -96,18 +96,9 @@ export default { ...@@ -96,18 +96,9 @@ export default {
}, //点击事件 }, //点击事件
}, },
}, },
[NOTICE_IMAGE]: { [SUBMIT_BUTTON]: {
type: IMAGE, type: AMOUNT_BUTTON,
uri: '', }
label: {
icon: '', //左侧icon
h1: '', //主标题
rightIcon: '', //右侧icon
rightText: '', //右侧文字
onPress: () => {
}, //点击事件
},
},
}, },
rules: { rules: {
[INSURE_YEAR]: { // 串联 key 为 INSURE_YEAR的组件 [INSURE_YEAR]: { // 串联 key 为 INSURE_YEAR的组件
...@@ -115,5 +106,5 @@ export default { ...@@ -115,5 +106,5 @@ export default {
}, },
}, },
keys: [PRODUCT_BANNER, PRODUCT_TITLE, PREM_GROUP, PLAN_INFO, INSURE_YEAR, MULT, PRODUCT_IMAGE, keys: [PRODUCT_BANNER, PRODUCT_TITLE, PREM_GROUP, PLAN_INFO, INSURE_YEAR, MULT, PRODUCT_IMAGE,
SERVICE_IMAGE, NOTICE_IMAGE], SERVICE_IMAGE, SUBMIT_BUTTON],
}; };
...@@ -309,8 +309,9 @@ export function renderPageByConfig(type, renderCustomView?) { ...@@ -309,8 +309,9 @@ export function renderPageByConfig(type, renderCustomView?) {
// 有自定义方法执行传入的渲染方法 // 有自定义方法执行传入的渲染方法
if (renderCustomView) { if (renderCustomView) {
return renderCustomView(type); return renderCustomView(type);
}else {
return {};
} }
return () => {};
} }
} }
......
...@@ -36,7 +36,7 @@ import { ...@@ -36,7 +36,7 @@ import {
INSURED_ID_TYPE, INSURED_ID_TYPE,
INSURE_YEAR_TITLE, INSURE_YEAR_TITLE,
PICKER, PICKER,
DATE_RANGE, DATE_RANGE, BUTTON,
} from '../Agera-App-Insure/config/keys'; } from '../Agera-App-Insure/config/keys';
import { import {
getConfig, getConfig,
...@@ -44,7 +44,7 @@ import { ...@@ -44,7 +44,7 @@ import {
import { renderPageByConfig } from '../Agera-App-Insure'; import { renderPageByConfig } from '../Agera-App-Insure';
import Button from '../../components/ThemeButton'; import Button from '../../components/ThemeButton';
import SubmitButton from '../Agera-App-Insure/components/SubmitButton'; import SubmitButton from '../Agera-App-Insure/components/SubmitButton';
import BaseContainer from '../Agera-App-Insure/BaseContainer'; import PolicyContainer from '../Agera-App-Insure/PolicyContainer';
import localData from '../../utils/api/localData'; import localData from '../../utils/api/localData';
import ListItem from '../Agera-App-Insure/components/ListItem'; import ListItem from '../Agera-App-Insure/components/ListItem';
...@@ -185,10 +185,31 @@ class FillPolicyInfoPage extends Component { ...@@ -185,10 +185,31 @@ class FillPolicyInfoPage extends Component {
); );
} }
render() { renderSubmit = () => {
const { config, keys } = this.state;
const { pushTo } = this.props; const { pushTo } = this.props;
console.log('config:', config, keys); return(
<Button
title="下一步"
containerStyle={{ margin: 15 }}
onPress={() => pushTo('PaymentPage', { policy: this.policy })}
/>
)
}
renderExtraViews = (viewType) => {
console.log('renderExtraViews',viewType)
switch (viewType) {
case PICKER:
return this.renderPicker;
case BUTTON:
return this.renderSubmit;
default:
return () => {};
}
}
render() {
const { config, keys, params } = this.state;
const type = 'type'; const type = 'type';
return ( return (
<View style={Styles.container}> <View style={Styles.container}>
...@@ -196,40 +217,13 @@ class FillPolicyInfoPage extends Component { ...@@ -196,40 +217,13 @@ class FillPolicyInfoPage extends Component {
left={<BackButton />} left={<BackButton />}
title="太平保险" title="太平保险"
/> />
<SpringScrollView <PolicyContainer
ref={(com) => { params={params}
this.scrollView = com; config={config}
}} keys={keys}
onScroll={({ nativeEvent: { contentOffset: { x, y } } }) => { renderExtraViews={this.renderExtraViews}
//console.log('offset : x=', x, 'y=', y);
}}
styles={Styles.container}
inverted={false}
//onRefresh={this._onRefresh}
//onLoading={this._onLoading}
// allLoaded={this.state.allLoaded}
refreshHeader={CommonLottieHeader}
>
<View>
{keys.map((key, index) => (
renderPageByConfig(config[key][type], (viewType) => {
switch (viewType) {
case DATE_RANGE:
return this.renderPicker;
default:
return () => {};
}
})(config[key]) // 第二个参数可以传入自己的switch 方法根据自定义类型渲染组件
))}
</View>
<Button
title="下一步"
containerStyle={{ margin: 15 }}
onPress={() => pushTo('PaymentPage', { policy: this.policy })}
/> />
</SpringScrollView>
</View> </View>
); );
} }
} }
......
...@@ -40,7 +40,7 @@ import { ...@@ -40,7 +40,7 @@ import {
INSURED_PREM, INSURED_PREM,
INSURED_PRODUCT, INSURED_PRODUCT,
POLICY_PROGRESS, POLICY_PROGRESS,
PAYMENT_TYPE, PAYMENT_TYPE, BUTTON,
} from '../Agera-App-Insure/config/keys'; } from '../Agera-App-Insure/config/keys';
import { import {
getConfig, getConfig,
...@@ -48,7 +48,7 @@ import { ...@@ -48,7 +48,7 @@ import {
import { renderPageByConfig } from '../Agera-App-Insure'; import { renderPageByConfig } from '../Agera-App-Insure';
import Button from '../../components/ThemeButton'; import Button from '../../components/ThemeButton';
import SubmitButton from '../Agera-App-Insure/components/SubmitButton'; import SubmitButton from '../Agera-App-Insure/components/SubmitButton';
import BaseContainer from '../Agera-App-Insure/BaseContainer'; import PolicyContainer from '../Agera-App-Insure/PolicyContainer';
import localData from '../../utils/api/localData'; import localData from '../../utils/api/localData';
import ListItem from '../Agera-App-Insure/components/ListItem'; import ListItem from '../Agera-App-Insure/components/ListItem';
import { ENV, resourceURLMapping } from "../../utils/constants"; import { ENV, resourceURLMapping } from "../../utils/constants";
...@@ -135,11 +135,32 @@ class PaymentPage extends Component { ...@@ -135,11 +135,32 @@ class PaymentPage extends Component {
} }
} }
renderSubmit = () => {
const { pushTo } = this.props;
return(
<Button
title="确认支付"
containerStyle={{ margin: 15 }}
onPress={() => {pushTo('PolicyResultPage')}}
/>
)
}
renderExtraViews = (viewType) => {
console.log('renderExtraViews',viewType)
switch (viewType) {
case BUTTON:
return this.renderSubmit;
default:
return () => {};
}
}
translateDataToRules = (key, rul, params) => ({}) translateDataToRules = (key, rul, params) => ({})
render() { render() {
const { config, keys } = this.state; const { config, keys, params } = this.state;
const { pushTo } = this.props; const { pushTo } = this.props;
console.log('config:', config, keys); console.log('config:', config, keys);
const type = 'type'; const type = 'type';
...@@ -149,31 +170,12 @@ class PaymentPage extends Component { ...@@ -149,31 +170,12 @@ class PaymentPage extends Component {
left={<BackButton />} left={<BackButton />}
title="太平保险" title="太平保险"
/> />
<SpringScrollView <PolicyContainer
ref={(com) => { params={params}
this.scrollView = com; config={config}
}} keys={keys}
onScroll={({ nativeEvent: { contentOffset: { x, y } } }) => { renderExtraViews={this.renderExtraViews}
//console.log('offset : x=', x, 'y=', y);
}}
styles={Styles.container}
inverted={false}
//onRefresh={this._onRefresh}
//onLoading={this._onLoading}
// allLoaded={this.state.allLoaded}
refreshHeader={CommonLottieHeader}
>
<View>
{keys.map((key, index) => (
renderPageByConfig(config[key][type])(config[key]) // 第二个参数可以传入自己的switch 方法根据自定义类型渲染组件
))}
</View>
<Button
title="确认支付"
containerStyle={{ margin: 15 }}
onPress={() => {pushTo('PolicyResultPage')}}
/> />
</SpringScrollView>
</View> </View>
); );
......
...@@ -12,8 +12,6 @@ import { ...@@ -12,8 +12,6 @@ import {
} from 'react-native'; } from 'react-native';
import { compose } from 'redux'; import { compose } from 'redux';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { SpringScrollView } from 'react-native-spring-scrollview';
import { CommonLottieHeader } from 'react-native-spring-scrollview/Customize/CommonLottieHeader';
import { pop, push } from '../../BasicNavigator/actions'; import { pop, push } from '../../BasicNavigator/actions';
import NavigationBar, { NavHeight } from '../../components/NavigationBar'; import NavigationBar, { NavHeight } from '../../components/NavigationBar';
import BackButton from '../../components/BackButton'; import BackButton from '../../components/BackButton';
...@@ -21,7 +19,6 @@ import Picker from '../../components/Picker'; ...@@ -21,7 +19,6 @@ import Picker from '../../components/Picker';
import Styles from '../../theme/Styles'; import Styles from '../../theme/Styles';
import decorator from '../../utils/decorator'; import decorator from '../../utils/decorator';
import { trailPolicyAPI } from '../InsuranceList/InsuranceAPI'; import { trailPolicyAPI } from '../InsuranceList/InsuranceAPI';
import Text from '../../components/Text';
import { import {
BANNER, BANNER,
PROCESS, PROCESS,
...@@ -45,6 +42,7 @@ import { ...@@ -45,6 +42,7 @@ import {
NOTICE_IMAGE, NOTICE_IMAGE,
INSURE_YEAR, INSURE_YEAR,
MULT, MULT,
AMOUNT_BUTTON,
JIACHENG, JIACHENG,
AIFEIXIANG, AIFEIXIANG,
XUESHENGYIWAI, XUESHENGYIWAI,
...@@ -52,8 +50,8 @@ import { ...@@ -52,8 +50,8 @@ import {
import { import {
getConfig, getConfig,
} from '../Agera-App-Insure/config'; } from '../Agera-App-Insure/config';
import { renderPageByConfig } from '../Agera-App-Insure';
import SubmitButton from '../Agera-App-Insure/components/SubmitButton'; import SubmitButton from '../Agera-App-Insure/components/SubmitButton';
import PolicyContainer from '../Agera-App-Insure/PolicyContainer';
type Props = { type Props = {
routes : Array, routes : Array,
...@@ -197,7 +195,7 @@ class ProductDetailPage extends Component { ...@@ -197,7 +195,7 @@ class ProductDetailPage extends Component {
}, },
}; };
default: default:
return {}; return null;
} }
} }
...@@ -231,54 +229,50 @@ class ProductDetailPage extends Component { ...@@ -231,54 +229,50 @@ class ProductDetailPage extends Component {
); );
} }
render() { renderSubmit = () => {
const { config, keys } = this.state;
const { pushTo } = this.props; const { pushTo } = this.props;
console.log('config:', config, keys); console.log('renderSubmit',pushTo)
const type = 'type';
return ( return (
<View style={Styles.container}> <SubmitButton
<NavigationBar
left={<BackButton />}
title="太平保险"
/>
<SpringScrollView
ref={(com) => { ref={(com) => {
this.scrollView = com; this.submit = com;
}}
onScroll={({ nativeEvent: { contentOffset: { x, y } } }) => {
//console.log('offset : x=', x, 'y=', y);
}} }}
styles={Styles.container} value={this.policy.premTotal}
inverted={false} onPress={() => pushTo('FillPolicyInfoPage', { policy: this.policy })}
//onRefresh={this._onRefresh} />
//onLoading={this._onLoading} );
// allLoaded={this.state.allLoaded} }
refreshHeader={CommonLottieHeader}
//loadingFooter={CommonLottieFooter} renderExtraViews = (viewType) => {
> console.log('renderExtraViews',viewType)
<View>
{keys.map((key, index) => (
renderPageByConfig(config[key][type], (viewType) => {
switch (viewType) { switch (viewType) {
case PICKER: case PICKER:
return this.renderPicker; return this.renderPicker;
case AMOUNT_BUTTON:
return this.renderSubmit;
default: default:
return () => {}; return () => {};
} }
})(config[key]) // 第二个参数可以传入自己的switch 方法根据自定义类型渲染组件 }
))}
</View> render() {
<SubmitButton const { config, keys, params } = this.state;
ref={(com) => { const { pushTo } = this.props;
this.submit = com; console.log('config:', config, keys);
}} const type = 'type';
value={this.policy.premTotal} return (
onPress={() => pushTo('FillPolicyInfoPage', { policy: this.policy })} <View style={Styles.container}>
<NavigationBar
left={<BackButton />}
title="太平保险"
/>
<PolicyContainer
params={params}
config={config}
keys={keys}
renderExtraViews={this.renderExtraViews}
/> />
</SpringScrollView>
</View> </View>
); );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment