Authored by 张丽霞

学生认证,review by 孙凯

... ... @@ -21,12 +21,17 @@ import appInitialState from './reducers/app/appInitialState';
import studentInitialState from './reducers/student/studentInitialState';
import StudentContainer from './containers/StudentContainer';
import ZimaContainer from './containers/ZimaContainer';
import ProtocolContainer from './containers/ProtocolContainer';
import {
setPlatform,
setChannel,
} from './reducers/app/appActions';
import {
setZiamUrl,
} from './reducers/student/studentActions';
function getInitialState() {
const _initState = {
app: (new appInitialState()),
... ... @@ -42,12 +47,28 @@ export default function native(platform) {
render() {
const store = configureStore(getInitialState());
store.dispatch(setPlatform(platform));
let registerType = this.props.type;
let registerUrl = this.props.zimaUrl;
store.dispatch(setZiamUrl(registerUrl));
if (registerType == 'zima') {
return (
<Provider store={store}>
<ZimaContainer />
</Provider>
);
} else if(registerType == 'register'){
return (
<Provider store={store}>
<StudentContainer />
</Provider>
);
} else if(registerType == 'protocol'){
return (
<Provider store={store}>
<ProtocolContainer />
</Provider>
);
}
}
});
... ...
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import {isEmptyObject} from '../../utils/Utils';
import Immutable, {Map} from 'immutable';
const {
View,
Image,
Text,
TouchableOpacity,
Dimensions,
StyleSheet,
} = ReactNative;
export default class LatterListView extends React.Component {
constructor(props) {
super (props);
this.onTouchMove = this.onTouchMove.bind(this);
this.viewHeight = props.style.height;
}
shouldComponentUpdate(nextProps){
if (Immutable.is(Immutable.fromJS(nextProps.dataSource), Immutable.fromJS(this.props.dataSource))) {
return false;
} else {
return true;
}
}
onTouchMove(e) {
let {dataSource,distanceToContainer} = this.props;
let Y = e.nativeEvent.pageY - Math.ceil((this.viewHeight - dataSource.length * (itemHeight+2))/2) - 8 - distanceToContainer;
var index = Math.ceil(Y/(itemHeight+2))-1;
let sectionID = dataSource[index];
this.props.onLetterPress && this.props.onLetterPress(index,sectionID);
}
render() {
let {dataSource} = this.props;
if (dataSource.length == 0) {
return null;
}
let keyData = [];
keyData.push(<Image key={'search'} style={styles.image} source={require('../../images/search.png')}/>);
for (var i = 0; i < dataSource.length; i++) {
let name = dataSource[i];
if (name == '0-9') {
name = '0';
}
keyData.push(<Text key={i} style={styles.text}>{name}</Text>);
}
return (
<View style={[styles.container, {height: this.viewHeight}]} onTouchStart={this.onTouchMove} onTouchMove={this.onTouchMove} >
{keyData.map((elem, index) => {return elem;})}
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let itemHeight = 12;
let styles = StyleSheet.create({
container: {
position: 'absolute',
width: 20,
bottom : 1,
right: 1,
backgroundColor: 'rgba(255,255,255,0.2)',
alignItems: 'center',
justifyContent: 'center',
},
text: {
justifyContent: 'center',
textAlign: 'center',
fontSize: 10,
color: 'black',
backgroundColor: 'transparent',
marginTop: 2,
},
image: {
width: 8,
height: 8,
},
});
... ...
... ... @@ -12,47 +12,84 @@ import ReactNative, {
TouchableOpacity,
} from 'react-native';
import Immutable, {Map} from 'immutable';
import LatterListView from './LatterListView';
import YH_SearchBar from '../../../common/components/YH_SearchBar';
export default class ProvinceSchoolView extends Component {
constructor(props) {
super(props);
this._renderRow = this._renderRow.bind(this);
this._renderHeader = this._renderHeader.bind(this);
this._scrollToSection = this._scrollToSection.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2),
});
this._onTextChange = this._onTextChange.bind(this);
this.listView = null;
this.dataList = [];
this.latterList = [];
this.dataListShow = [];
this.latterListShow = [];
}
componentDidMount() {
}
_renderHeader() {
return (
<View style={styles.header}>
<Text>
搜索
</Text>
</View>
);
_onTextChange(text){
let newDataList = [];
let curViewType = this.props.resource.get('type');
let searchResultPageInfo = {
show: false,
type: {curViewType},
leftList: [],
rightList: [],
};
console.log(this.dataList);
console.log('this.dataList');
if (text != '') {
this.dataList.forEach((dataListItem, i) => {
let latter = this.latterList[i];
let list = dataListItem[latter].list;
let newDataListItem = {};
let newList = [];
list.forEach((listItem, i) => {
let name = curViewType=='school' ? listItem.schoolName:listItem.addresseeName;
if (name.indexOf(text) != -1) {
newList.push(listItem);
}
});
if (newList.length) {
newDataListItem[latter]={list:newList,count:0,separatorCount:0};
newDataList.push(newDataListItem);
}
});
console.log('====0000');
console.log(newDataList);
if (newDataList.length) {
searchResultPageInfo.show = true;
searchResultPageInfo.leftList = newDataList;
}
}
this.props.updateSearchResultPageInfo && this.props.updateSearchResultPageInfo(searchResultPageInfo);
}
_renderRow(rowData, sectionID, rowID, highlightRow) {
let separatorLatter='';
let latterObject = this.dataList[rowID];
let latterObject = this.dataListShow[rowID];
for (var key in latterObject) {
if (latterObject.hasOwnProperty(key)) {
separatorLatter = key;
}
}
let rowDataList = rowData[separatorLatter];
let rowDataListImmulate = Immutable.fromJS(rowDataList)
let rowDataList = rowData[separatorLatter].list;
let rowDataListImmulate = Immutable.fromJS(rowDataList);
let curViewType = this.props.resource.get('type');
return (
<View>
<View key={'sep' + rowID} style={styles.provinceLatterCell}>
... ... @@ -63,8 +100,7 @@ export default class ProvinceSchoolView extends Component {
{rowDataListImmulate.map((provinceItem, i) => {
return (
<TouchableOpacity activeOpacity={1.0} onPress={() => {
console.log('---111111');
console.log(provinceItem);
this._onTextChange('');
switch (this.props.resource.get('type')) {
case 'province':
this.props.hideProvinceSelectView && this.props.hideProvinceSelectView(provinceItem);
... ... @@ -78,7 +114,11 @@ export default class ProvinceSchoolView extends Component {
}}>
<View style={styles.provinceCell}>
<Text style={{marginLeft: 15}}>
{provinceItem.get('addresseeName')}
{curViewType == 'province' ?
provinceItem.get('addresseeName')
:provinceItem.get('schoolName')
}
</Text>
</View>
{i !== (rowDataListImmulate.size -1) ?
... ... @@ -96,23 +136,37 @@ export default class ProvinceSchoolView extends Component {
);
}
_scrollToSection(index,sectionID){
let item = this.sectionDataKey[sectionID];
console.log(index);
console.log(sectionID);
console.log('-------qqqq');
let {resource} = this.props;
let leftList = resource.get('leftList');
let rightList = resource.get('rightList');
rightList = rightList.toArray();
let item = this.dataListShow[index];
if (item) {
if (!item.y) {
this.needScrollSection = sectionID;
item.count = ScrollCount(sectionID,this.sectionData);
this.props.setInitialListSize && this.props.setInitialListSize(item.count);
this.props.setBrandData && this.props.setBrandData(this.sectionDataKey, this.props.selectedChannelId);
} else {
this.listView.scrollTo({x: 0, y: item.y, animated: false});
}
let distanceY = 30 * index + item[sectionID].count * 40 + item[sectionID].separatorCount * 1.5;
this.listView.scrollTo({x: 0, y: distanceY, animated: false});
}
}
render() {
let {resource} = this.props;
let {resource,searchResultPageInfo} = this.props;
let leftList = resource.get('leftList');
let rightList = resource.get('rightList');
let searchPlaceHolder = this.props.resource.get('type') == 'school' ? '搜索学校' : '搜索省份';
this.dataList = (leftList && leftList.size) ? leftList.toJS() : [];
this.latterList = rightList.toArray();
this.dataListShow = this.dataList;
this.latterListShow = this.latterList;
if (searchResultPageInfo.get('show')) {
leftList = searchResultPageInfo.get('leftList');
rightList = searchResultPageInfo.get('rightList');
this.dataListShow = (leftList && leftList.size) ? leftList.toJS() : [];
this.latterListShow = rightList.toArray();
}
return (
<View style={styles.container}>
<View style={styles.listViewContainer}>
... ... @@ -120,11 +174,25 @@ export default class ProvinceSchoolView extends Component {
ref={(ref)=>this.listView=ref}
contentContainerStyle={[styles.contentContainerStyle]}
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRows(this.dataList)}
dataSource={this.dataSource.cloneWithRows(this.dataListShow)}
renderRow={this._renderRow}
renderHeader={this._renderHeader}
showsHorizontalScrollIndicator={false}
/>
<LatterListView
style={{height: height - 64 - 200}}
dataSource={this.latterListShow}
distanceToContainer={200}
onLetterPress={this._scrollToSection}/>
</View>
<View style={styles.header}>
<YH_SearchBar
ref={(c) => {
this.searchBar = c;
}}
placeholder={searchPlaceHolder}
onClickCancel={this._onTextChange}
onTextChange={this._onTextChange}
/>
</View>
<TouchableOpacity activeOpacity={1.0} onPress={() => {
console.log('--close');
... ... @@ -159,7 +227,7 @@ let styles = StyleSheet.create({
position: 'absolute',
top: 0,
width: width,
height:height - 64 - 44,
height:height - 64,
backgroundColor: 'rgba(0,0,0,0.3)',
flexDirection: 'column-reverse',
flex: 1,
... ... @@ -176,9 +244,10 @@ let styles = StyleSheet.create({
},
listViewContainer: {
height: height - 64 - 200,
backgroundColor: '#dfe3e2',
backgroundColor: 'white',
},
contentContainerStyle: {
width: width - 20,
backgroundColor: '#dfe3e2',
},
contentContainer: {
... ... @@ -186,7 +255,6 @@ let styles = StyleSheet.create({
backgroundColor:'white',
},
provinceLatterCell: {
width: width - 30,
marginLeft: 15,
height: 30,
backgroundColor: '#dfe3e2',
... ...
... ... @@ -16,6 +16,8 @@ import ReactNative, {
import RegisterInfoCell from './RegisterInfoCell';
import ProvinceSchoolView from './ProvinceSchoolView';
import Immutable, {Record, List, Map} from 'immutable';
import Prompt from '../../../coupon/components/coupon/Prompt';
export default class Register extends Component {
... ... @@ -36,6 +38,7 @@ export default class Register extends Component {
offsety: 0,
pickerSelectValue: '',
};
this.hideTipMesage = this.hideTipMesage.bind(this);
}
componentDidMount() {
... ... @@ -73,20 +76,28 @@ export default class Register extends Component {
_hideSchoolSelectView(schoolItem){
let newPickerInfoJson = this.state.pickerInfo.toJS();
if (schoolItem) {
newPickerInfoJson.text = schoolItem.get('schoolName');
let newPickerInfo = Immutable.fromJS(newPickerInfoJson);
this.props.updateRegisterCellsInfo && this.props.updateRegisterCellsInfo(newPickerInfo);
}
this.props.hideSchoolSelectView && this.props.hideSchoolSelectView(schoolItem);
}
_hideProvinceSelectView(provinceItem){
let newPickerInfoJson = this.state.pickerInfo.toJS();
if (provinceItem) {
newPickerInfoJson.text = provinceItem.get('addresseeName');
let newPickerInfo = Immutable.fromJS(newPickerInfoJson);
this.props.updateRegisterCellsInfo && this.props.updateRegisterCellsInfo(newPickerInfo);
}
this.props.hideProvinceSelectView && this.props.hideProvinceSelectView(provinceItem);
}
hideTipMesage() {
this.props.showTipMesage && this.props.showTipMesage('');
}
renderSeparator(sectionID, rowID, adjacentRowHighlighted) {
return (
<View key={'sep' + rowID} style={styles.separator}>
... ... @@ -114,6 +125,7 @@ export default class Register extends Component {
<RegisterInfoCell
resource={rowData}
onPressRegisterInfoCell={this._onPressRegisterInfoCell}
updateRegisterCellsInfo={this.props.updateRegisterCellsInfo}
/>
);
}
... ... @@ -121,11 +133,12 @@ export default class Register extends Component {
render() {
let {registerPageInfo} = this.props;
let {provinceSchoolPageInfo} = registerPageInfo;
let {registerPageInfo,tipMessage} = this.props;
let {provinceSchoolPageInfo,searchResultPageInfo} = registerPageInfo;
let registerPageCells = registerPageInfo.get('registerPageCells').size?registerPageInfo.get('registerPageCells').toArray():[];
let dataSource ={
totalStudentRegister:[registerPageInfo.get('verifiedStudentTotal')],
registerPageCellsInfo:registerPageInfo.get('registerPageCells').size?registerPageInfo.get('registerPageCells').toArray():[],
totalStudentRegister: [registerPageInfo.get('verifiedStudentTotal')],
registerPageCellsInfo: registerPageCells,
};
let list = this.state.pickerList;
return (
... ... @@ -138,11 +151,26 @@ export default class Register extends Component {
renderSeparator={this.renderSeparator}
renderFooter={()=>{
return <View style={styles.descriptionContainer}>
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.gotoProtocol && this.props.gotoProtocol();
}}>
<Text style={styles.descriptionText}>同意
<Text style={{color: 'blue'}}>
Yoho!BUY有货学生认证协议
</Text>
</Text>
</TouchableOpacity>
<TouchableOpacity activeOpacity={1.0} onPress={() => {
console.log('--认证btn');
this.props.registerNow && this.props.registerNow();
}}>
<View style={styles.registerNowBtn}>
<Text style={{width: width - 30,textAlign: 'center',color:'white'}}>
立即认证
</Text>
</View>
</TouchableOpacity>
</View>
}}
... ... @@ -184,7 +212,6 @@ export default class Register extends Component {
<TouchableOpacity activeOpacity={1.0} onPress={() => {
console.log('---->');
this.setState({pickerList:List()});
}}>
<View style={styles.balckContainer} />
... ... @@ -198,13 +225,20 @@ export default class Register extends Component {
<ProvinceSchoolView
style={styles.provinceSchoolView}
resource={provinceSchoolPageInfo}
searchResultPageInfo={searchResultPageInfo}
showProvinceSelectView={this.props.showProvinceSelectView}
showSchoolSelectView={this.props.showSchoolSelectView}
hideProvinceSelectView={this._hideProvinceSelectView}
hideSchoolSelectView={this._hideSchoolSelectView}
updateSearchResultPageInfo={this.props.updateSearchResultPageInfo}
/>
:null
}
{(tipMessage && tipMessage != '') ? <Prompt
text={tipMessage}
duration={800}
onPromptHidden={this.hideTipMesage}
/> : null}
</View>
);
... ... @@ -269,10 +303,25 @@ let styles = StyleSheet.create({
complateTouchView: {
height: 40,
width: 50,
backgroundColor: 'red',
justifyContent: 'center',
},
provinceSchoolView: {
flex: 1,
},
descriptionContainer: {
flexDirection: 'column',
},
registerNowBtn: {
width: width - 30,
margin: 15,
height: 40,
backgroundColor: '#dfe3e2',
justifyContent: 'center',
borderRadius: 5,
},
descriptionText: {
paddingTop: 15,
textAlign: 'center',
}
});
... ...
... ... @@ -11,6 +11,7 @@ import ReactNative, {
TouchableOpacity,
Image,
} from 'react-native';
import Immutable from 'immutable';
export default class RegisterInfoCell extends Component {
... ... @@ -41,6 +42,18 @@ export default class RegisterInfoCell extends Component {
style={styles.rightTextInput}
editable={resource.get('touchAction')?false:true}
defaultValue={resource.get('text')}
maxLength={18}
onEndEditing={(event) => {
console.log('---text----');
if (resource.get('touchAction')) {
return;
} else {
let resourceJson = resource.toJS();
resourceJson.text = event.nativeEvent.text;
this.props.updateRegisterCellsInfo && this.props.updateRegisterCellsInfo(Immutable.fromJS(resourceJson));
}
console.log(event.nativeEvent.text);
}}
/>
{resource.get('touchAction')?
<Image style={styles.arrow}
... ...
... ... @@ -4,6 +4,7 @@ export default keyMirror({
SET_PLATFORM: null,
SET_CHANNEL: null,
SET_ZIMA_URL: null,
QUERY_REGISTER_PAGE_INFO_REQUEST: null,
QUERY_REGISTER_PAGE_INFO_SUCCESS: null,
... ... @@ -23,8 +24,12 @@ export default keyMirror({
UPDATE_REGISTER_PAGE_CELLS: null,
UPDATE_CUR_SCHOOL_INFO: null,
UPDATE_PROVINCE_SCHOOL_PAGE_INFO: null,
UPDATE_PICKER_INFO: null,
UPDATE_SEARCH_RESULT_PAGE_INFO: null,
SELECT_PROVINCE_ITEM: null,
SELECT_SCHOOL_ITEM: null,
SHOW_TIP_MESSAGE: null,
HIDE_TIP_MESSAGE: null,
});
... ...
'use strict'
import React, {Component} from 'react';
import ReactNative, {
StyleSheet,
Dimensions,
Platform,
View,
NativeModules,
InteractionManager,
NativeAppEventEmitter,
Text,
} from 'react-native'
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Map} from 'immutable';
import * as studentActions from '../reducers/student/studentActions';
let WEBVIEW_REF = 'webview';
const actions = [
studentActions,
];
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 ZimaContainer extends Component {
constructor(props) {
super(props);
}
render() {
let {student} = this.props;
let {registerPageInfo, zimaRegisterUrl} = student;
return (
<View style={styles.container}>
<Text style={styles.title}>认证协议</Text>
<Text style={styles.content}>1、全日制大学及硕士博士研究生</Text>
<Text style={styles.content}>2、学校在可选范围内,有部分学校可能暂未收录,后期会尽快添加</Text>
<Text style={styles.content}>3、每个学号只能认证一个有货账户</Text>
</View>
);
}
}
let styles = StyleSheet.create({
container: {
flex: 1,
},
title: {
fontSize: 18,
marginTop: 30,
marginLeft: 15,
marginBottom: 20,
},
content: {
fontSize: 14,
marginLeft: 15,
marginRight:15,
lineHeight: 20,
}
});
export default connect(mapStateToProps, mapDispatchToProps)(ZimaContainer);
... ...
... ... @@ -17,7 +17,7 @@ import {Map} from 'immutable';
import * as studentActions from '../reducers/student/studentActions';
import Student from '../components/student/Student';
import Register from '../components/student/Register';
import Result from '../components/student/Result';
// import Result from '../components/student/Result';
const actions = [
studentActions,
... ... @@ -56,6 +56,10 @@ class StudentContainer extends Component {
this._hideProvinceSelectView = this._hideProvinceSelectView.bind(this);
this._hideSchoolSelectView = this._hideSchoolSelectView.bind(this);
this._registerNow = this._registerNow.bind(this);
this._updateSearchResultPageInfo = this._updateSearchResultPageInfo.bind(this);
this._gotoProtocol = this._gotoProtocol.bind(this);
this._showTipMesage = this._showTipMesage.bind(this);
}
componentDidMount() {
... ... @@ -101,27 +105,43 @@ class StudentContainer extends Component {
_hideSchoolSelectView(schoolItemInfo) {
this.props.actions.hideSchoolSelectView(schoolItemInfo);
}
_updateSearchResultPageInfo(searchResultPageInfo){
this.props.actions.updateSearchResultPageInfo(searchResultPageInfo);
}
_registerNow() {
this.props.actions.registerNow();
}
_gotoProtocol() {
this.props.actions.gotoProtocol();
}
_showTipMesage(message) {
this.props.actions.showTipMesage(message);
}
render() {
let {student} = this.props;
let {registerPageInfo,productPageInfo} = student;
let {registerPageInfo,productPageInfo,tipMessage} = student;
return (
<View style={styles.container}>
<Result
<Register
registerPageInfo={registerPageInfo}
fetchStudentProducts={this._fetchStudentProducts}
resource={productPageInfo}
onPressProduct={this._onPressProduct}
// <Register
// registerPageInfo={registerPageInfo}
// onPressRegisterInfoCell={this._onPressRegisterInfoCell}
// updateRegisterCellsInfo={this._updateRegisterCellsInfo}
// showProvinceSelectView={this._showProvinceSelectView}
// showSchoolSelectView={this._showSchoolSelectView}
// hideProvinceSelectView={this._hideProvinceSelectView}
// hideSchoolSelectView={this._hideSchoolSelectView}
tipMessage={tipMessage}
onPressRegisterInfoCell={this._onPressRegisterInfoCell}
updateRegisterCellsInfo={this._updateRegisterCellsInfo}
showProvinceSelectView={this._showProvinceSelectView}
showSchoolSelectView={this._showSchoolSelectView}
hideProvinceSelectView={this._hideProvinceSelectView}
hideSchoolSelectView={this._hideSchoolSelectView}
registerNow={this._registerNow}
updateSearchResultPageInfo={this._updateSearchResultPageInfo}
gotoProtocol={this._gotoProtocol}
showTipMesage={this._showTipMesage}
/>
</View>
... ...
'use strict'
import React, {Component} from 'react';
import ReactNative, {
StyleSheet,
Dimensions,
Platform,
View,
NativeModules,
InteractionManager,
NativeAppEventEmitter,
WebView,
} from 'react-native'
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Map} from 'immutable';
import * as studentActions from '../reducers/student/studentActions';
let WEBVIEW_REF = 'webview';
const actions = [
studentActions,
];
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 ZimaContainer extends Component {
constructor(props) {
super(props);
}
render() {
let {student} = this.props;
let {registerPageInfo, zimaRegisterUrl} = student;
return (
<View style={styles.container}>
<WebView
ref={WEBVIEW_REF}
automaticallyAdjustContentInsets={false}
style={styles.webView}
source={{uri: zimaRegisterUrl}}
javaScriptEnabled={true}
domStorageEnabled={true}
decelerationRate="normal"
onNavigationStateChange={this.onNavigationStateChange}
onShouldStartLoadWithRequest={this.onShouldStartLoadWithRequest}
startInLoadingState={true}
/>
</View>
);
}
}
let styles = StyleSheet.create({
container: {
flex: 1,
},
});
export default connect(mapStateToProps, mapDispatchToProps)(ZimaContainer);
... ...
... ... @@ -3,9 +3,11 @@
import ReactNative from 'react-native';
import StudentService from '../../services/StudentService';
import Immutable, {Record, List, Map} from 'immutable';
const querystring = require('query-string');
const {
SET_PLATFORM,
SET_ZIMA_URL,
QUERY_REGISTER_PAGE_INFO_REQUEST,
QUERY_REGISTER_PAGE_INFO_SUCCESS,
... ... @@ -26,10 +28,14 @@ const {
UPDATE_REGISTER_PAGE_CELLS,
UPDATE_CUR_SCHOOL_INFO,
UPDATE_PROVINCE_SCHOOL_PAGE_INFO,
UPDATE_SEARCH_RESULT_PAGE_INFO,
SELECT_PROVINCE_ITEM,
SELECT_SCHOOL_ITEM,
SHOW_TIP_MESSAGE,
HIDE_TIP_MESSAGE,
} = require('../../constants/actionTypes').default;
export function setPlatform(platform) {
... ... @@ -39,6 +45,13 @@ export function setPlatform(platform) {
};
}
export function setZiamUrl(url) {
return {
type: SET_ZIMA_URL,
payload: url
};
}
export function queryRegisterPageInfoRequest() {
return {
type: QUERY_REGISTER_PAGE_INFO_REQUEST
... ... @@ -139,6 +152,13 @@ export function updateProvinceSchoolPageInfo(provinceSchoolPageInfo) {
}
}
export function updateSearchResultPageInfo(searchResultPageInfo) {
return {
type:UPDATE_SEARCH_RESULT_PAGE_INFO,
payload:searchResultPageInfo
}
}
export function selectSchoolItem(schoolItem) {
return {
type:SELECT_SCHOOL_ITEM,
... ... @@ -153,6 +173,19 @@ export function selectProvinceItem(provinceItem) {
}
}
export function showTipMesage(message) {
return {
type: SHOW_TIP_MESSAGE,
payload: message
}
}
export function hideTipMesage() {
return {
type: HIDE_TIP_MESSAGE,
}
}
export function getRegisterPageInfo() {
return (dispatch, getState) => {
dispatch(queryRegisterPageInfoRequest());
... ... @@ -210,8 +243,6 @@ export function getSchool(code=11) {
dispatch(querySchoolInfoListRequest());
return new StudentService(app.host).getSchool()
.then(result => {
console.log('getSchool');
console.log(result);
let schoolInfo = processSchoolData(result);
let curSchoolInfo = {
isFetching: false,
... ... @@ -220,7 +251,6 @@ export function getSchool(code=11) {
}
schoolCodeValueInfo[code]=curSchoolInfo;
//学校待处理
// dispatch(updateProvinceLatterList(provinceInfo));
dispatch(querySchoolInfoListSuccess({schoolCodeValueInfo,curSchoolInfo}));
})
.catch(error => {
... ... @@ -243,7 +273,27 @@ function processSchoolData(schoolList){
latterList.push(key);
}
}
return {latterList,latterSchoolObject};
//字母数组排序
latterList.sort();
//字母省份排序
let latterSchoollistSort = [];
let countOfBefore= 0;
let separatorCount=0;
for (var i = 0; i < latterList.length; i++) {
let key = latterList[i];
let latterObject = {};
latterObject[key] = {
list: latterSchoolObject[key],
count: countOfBefore,
separatorCount,
}
latterObject[key].count = countOfBefore;
latterSchoollistSort.push(latterObject);
countOfBefore += latterSchoolObject[key].length;
separatorCount += latterSchoolObject[key].length - 1;
}
return {latterList,latterSchoollistSort};
}
function processProvinceData(provinceList){
... ... @@ -264,11 +314,19 @@ function processProvinceData(provinceList){
latterList.sort();
//字母省份排序
let latterProvincelistSort = [];
let countOfBefore= 0;
let separatorCount=0;
for (var i = 0; i < latterList.length; i++) {
let key = latterList[i];
let latterObject = {};
latterObject[key] = latterProvinceObject[key];
latterObject[key] = {
list: latterProvinceObject[key],
count: countOfBefore,
separatorCount,
};
latterProvincelistSort.push(latterObject);
countOfBefore += latterProvinceObject[key].length;
separatorCount += latterProvinceObject[key].length -1;
}
return {latterList,latterProvincelistSort};
}
... ... @@ -360,11 +418,8 @@ export function updateRegisterCellsInfo(registerCellInfo) {
let {registerPageCells} = registerPageInfo;
let newRegisterPageCellsJson = registerPageCells.toJS();
registerPageCells.forEach((pageCellItem, i) => {
console.log('hahaha');
if (pageCellItem.get('type') == registerCellInfo.get('type')) {
newRegisterPageCellsJson[i] = registerCellInfo.toJS();
console.log('------->>>');
console.log(newRegisterPageCellsJson[i]);
}
});
dispatch(updateRegisterPageCells(Immutable.fromJS(newRegisterPageCellsJson)));
... ... @@ -407,6 +462,7 @@ export function showSchoolSelectView(){
leftList: curSchoolListInfo.get('curSchoolWithLatterList'),
rightList: curSchoolListInfo.get('curSchoolLatterList'),
}
dispatch(updateProvinceSchoolPageInfo(provinceSchoolPageInfo));
return;
} else {
... ... @@ -414,12 +470,10 @@ export function showSchoolSelectView(){
dispatch(querySchoolInfoListRequest());
return new StudentService(app.host).getSchool(curProvinceItem.get('areaCode'))
.then(result => {
console.log('getSchool');
console.log(result);
let schoolInfo = processSchoolData(result);
let curSchoolInfo = {
isFetching: false,
curSchoolWithLatterList: schoolInfo.latterSchoolObject,
curSchoolWithLatterList: schoolInfo.latterSchoollistSort,
curSchoolLatterList: schoolInfo.latterList,
}
schoolCodeValueInfo[curProvinceItem.get('areaCode')]=curSchoolInfo;
... ... @@ -428,7 +482,7 @@ export function showSchoolSelectView(){
provinceSchoolPageInfo = {
show: true,
type: 'school',
leftList: schoolInfo.latterSchoolObject,
leftList: schoolInfo.latterSchoollistSort,
rightList: schoolInfo.latterList,
}
dispatch(updateProvinceSchoolPageInfo(provinceSchoolPageInfo));
... ... @@ -474,3 +528,86 @@ export function hideSchoolSelectView(schoolItemInfo){
}
};
}
export function registerNow() {
return (dispatch, getState) => {
let {app, student} = getState();
let {registerPageInfo} = student;
let {registerPageCells} = registerPageInfo;
let tipMessage = '';
let clientType,collegeName,educationDegree,enrollmentYear,idNumber,name;
let registerNowAction =(uid) => {
registerPageCells.map((cellItem, i) => {
if (cellItem.get('text') == '') {
tipMessage = cellItem.get('title')+'不可为空';
}
switch (cellItem.get('type')) {
case 'name':
name = cellItem.get('text');
break;
case 'id':
idNumber = cellItem.get('text');
break;
case 'school':
collegeName = cellItem.get('text');
break;
case 'education':
educationDegree = cellItem.get('text');
break;
case 'years':
enrollmentYear = cellItem.get('text');
break;
}
});
if (tipMessage !== '') {
dispatch(showTipMesage(tipMessage));
return;
} else {
let params = {
college_name: collegeName,
education_degree: educationDegree,
enrollment_year: enrollmentYear,
uid: uid,
};
let jsonParam = querystring.stringify(params);
let backUrl = 'http://m.yohobuy.com/activity/student/verify?' +
jsonParam + '&';
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.h5","params":{"id":"74”,”islogin":"Y","type":9,"updateflag":"2adfw4e243abdefwqg1234dfarq","url":"${backUrl}"}}`;
let testUrl = `https://feature.yoho.cn/NEWS/1222APPWEEKNEWSBOY/index.html?title=一周速报&share_id=1445&openby:yohobuy={\"action\":\"go.h5\",\"params\":{\"param\":{\"share_id\":\"1445\",\"title\":\"一周速报\"},\"share\":\"/operations/api/v5/webshare/getShare\",\"shareparam\":{\"share_id\":\"1445\"},\"title\":\"一周速报\",\"url\":\"https://feature.yoho.cn/NEWS/1222APPWEEKNEWSBOY/index.html\"}}`;
return new StudentService(app.host).verifyidentity(uid, idNumber, name, url)
.then(result => {
console.log('--身份认证成功---');
console.log(result);
console.log('===========');
ReactNative.NativeModules.YH_StudentHelper.jumpToZimaVC(result);
})
.catch(error => {
console.log('--身份认证失败---');
console.log(error);
});
}
};
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
registerNowAction(uid);
})
.catch(error => {
ReactNative.NativeModules.YH_CommonHelper.login()
.then(uid => {
registerNowAction(uid);
})
.catch(error => {
});
});
};
}
export function gotoProtocol() {
return (dispatch, getState) => {
ReactNative.NativeModules.YH_StudentHelper.jumpToRegisterProtocolPage();
};
}
... ...
... ... @@ -27,16 +27,22 @@ let InitialState = Record({
leftList: List(),
rightList: List(),
})),
searchResultPageInfo: new (Record({
show: false,
type: '', //provice or school
leftList: List(),
rightList: List(),
})),
pickerInfo: Map(),//当前页面选中的cell的信息
})),
province: Map(),
productPageInfo: new (Record({
isFetching: false,
studentProducts: Map(),
error: null,
})),
tipMessage: '',
zimaRegisterUrl: '',
});
export default InitialState;
... ...
... ... @@ -5,6 +5,7 @@ import Immutable, {Map} from 'immutable';
const {
SET_PLATFORM,
SET_ZIMA_URL,
QUERY_REGISTER_PAGE_INFO_REQUEST,
QUERY_REGISTER_PAGE_INFO_SUCCESS,
... ... @@ -25,15 +26,23 @@ const {
UPDATE_REGISTER_PAGE_CELLS,
UPDATE_CUR_SCHOOL_INFO,
UPDATE_PROVINCE_SCHOOL_PAGE_INFO,
UPDATE_PICKER_INFO,
UPDATE_SEARCH_RESULT_PAGE_INFO,
SELECT_PROVINCE_ITEM,
SELECT_SCHOOL_ITEM,
SHOW_TIP_MESSAGE,
HIDE_TIP_MESSAGE,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
export default function studentReducer(state=initialState, action) {
switch(action.type) {
case SET_ZIMA_URL:{
return state.set('zimaRegisterUrl', action.payload);
}
case QUERY_REGISTER_PAGE_INFO_REQUEST: {
return state.setIn(['registerPageInfo', 'isFetching'], true);
}
... ... @@ -74,12 +83,24 @@ export default function studentReducer(state=initialState, action) {
case UPDATE_PROVINCE_SCHOOL_PAGE_INFO: {
return state.setIn(['registerPageInfo', 'provinceSchoolPageInfo'], Immutable.fromJS(action.payload));
}
case UPDATE_SEARCH_RESULT_PAGE_INFO: {
return state.setIn(['registerPageInfo', 'searchResultPageInfo'], Immutable.fromJS(action.payload));
}
case UPDATE_PICKER_INFO: {
return state.setIn(['registerPageInfo', 'pickerInfo'],action.payload);
}
case SELECT_PROVINCE_ITEM: {
return state.setIn(['registerPageInfo', 'curProvinceItem'], Immutable.fromJS(action.payload));
}
case SELECT_SCHOOL_ITEM: {
return state.setIn(['registerPageInfo', 'cueSchoolItem'], Immutable.fromJS(action.payload));
}
case SHOW_TIP_MESSAGE: {
return state.set('tipMessage',action.payload);
}
case HIDE_TIP_MESSAGE: {
return state.set('tipMessage','');
}
}
return state;
... ...
... ... @@ -84,4 +84,24 @@ export default class StudentService {
throw(error);
});
}
// verifyidentity(uid, idNumber, name, url)
async verifyidentity(uid, cert_no, name, page_url, client_type='iphone') {
return await this.api.get({
url: '',
body: {
method: 'app.student.verifyIdentity',
uid,
cert_no,
name,
page_url,
client_type,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
}
... ...
'use strict';
import ReactNative from 'react-native';
const {
PixelRatio,
} = ReactNative;
export function getSlicedUrl(src, width, height, mode = 1) {
if (!src) {
return '';
}
width = PixelRatio.getPixelSizeForLayoutSize(width);
height = PixelRatio.getPixelSizeForLayoutSize(height);
let newSrc = src;
if (src.indexOf('imageView') === -1 && src.indexOf('imageMogr') === -1) {
newSrc = src + '?imageView2/' + mode + '/w/' + width + '/h/' + height;
} else {
newSrc = src.replace('{mode}', mode)
.replace('{width}', width)
.replace('{height}', height);
}
return newSrc;
}
export function isEmptyObject(obj) {
for (var key in obj) {
return false;
}
return true;
}
export function ScrollCount(sessionID,list) {
let index = 0;
for(let k in list) {
let name = k;
index += list[k].length;
if (name == sessionID) {
break;
}
}
return index;
}
... ...