...
|
...
|
@@ -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();
|
|
|
};
|
|
|
} |
...
|
...
|
|