提交 3b113569 authored 作者: 吴强's avatar 吴强

人口上传头像,有点问题,就是无法改名字

上级 83e90ba3
...@@ -7,6 +7,7 @@ import { NavigationActions } from 'react-navigation'; ...@@ -7,6 +7,7 @@ import { NavigationActions } from 'react-navigation';
import { getData, getMeta } from '../../utils/DataTemplate'; import { getData, getMeta } from '../../utils/DataTemplate';
import { datasourceApi } from '../../services/datasource'; import { datasourceApi } from '../../services/datasource';
import { scan } from '../../services/idcard'; import { scan } from '../../services/idcard';
import {createOperations, editResource, uploadResource} from "../../services/resource";
export default { export default {
namespace: 'peopleInfo', namespace: 'peopleInfo',
...@@ -64,7 +65,7 @@ export default { ...@@ -64,7 +65,7 @@ export default {
yield put({ type: 'getPeopleDetailInfo', payload: { ...result[0] } }); yield put({ type: 'getPeopleDetailInfo', payload: { ...result[0] } });
yield put({ type: 'setEdit', payload: false }); yield put({ type: 'setEdit', payload: false });
}, },
*savePeopleInfo({ payload }, { put, call }) { *savePeopleInfo({ payload }, { put, select, call }) {
const coordinate = { const coordinate = {
containerType: 'module', containerType: 'module',
containerName: 'query-RKInfo', containerName: 'query-RKInfo',
...@@ -72,6 +73,15 @@ export default { ...@@ -72,6 +73,15 @@ export default {
}; };
const api = datasourceApi(coordinate); const api = datasourceApi(coordinate);
const result = yield call(api.create, payload); const result = yield call(api.create, payload);
console.info(result);
const { detailData } = yield select(state => state.peopleInfo);
console.info(detailData);
try {
const { arg } = yield call(uploadResource, detailData.photoUri);
yield call(editResource, arg, createOperations().setName(detailData.identityCard).setTags('身份证头像').use(`rel://DangShiRenRenKouXinXi/${result}`));
} catch (e) {
console.info(e);
}
if (result === null) { if (result === null) {
Toast.fail('信息重复!', 2); Toast.fail('信息重复!', 2);
} else { } else {
...@@ -135,6 +145,7 @@ export default { ...@@ -135,6 +145,7 @@ export default {
try { try {
Toast.loading('读卡中...', 0); Toast.loading('读卡中...', 0);
const result = yield call(scan); const result = yield call(scan);
console.info(result);
if (result) { if (result) {
yield put({ type: 'setdetailData', payload: result }); yield put({ type: 'setdetailData', payload: result });
} }
...@@ -162,7 +173,7 @@ export default { ...@@ -162,7 +173,7 @@ export default {
detailData: payload, detailData: payload,
}; };
}, },
setdetailData(state, { payload: { peopleName, idcard, birthDay, people, sex, addr } }) { setdetailData(state, { payload: { peopleName, idcard, birthDay, people, sex, addr, photoUri } }) {
const detailData = { const detailData = {
xingMing: peopleName, xingMing: peopleName,
identityCard: idcard, identityCard: idcard,
...@@ -170,6 +181,7 @@ export default { ...@@ -170,6 +181,7 @@ export default {
minZu: people, minZu: people,
xingBie: sex, xingBie: sex,
huJiDiZhi: addr, huJiDiZhi: addr,
photoUri,
}; };
return { ...state, detailData }; return { ...state, detailData };
}, },
......
...@@ -9,7 +9,7 @@ import { connect } from 'react-redux'; ...@@ -9,7 +9,7 @@ import { connect } from 'react-redux';
import Icon from 'react-native-vector-icons/FontAwesome'; import Icon from 'react-native-vector-icons/FontAwesome';
import { createAction } from '../../../utils'; import { createAction } from '../../../utils';
@connect(({ peopleInfo }) => ({ peopleInfo })) @connect(({ peopleInfo, loading }) => ({ peopleInfo, loading: !!loading.effects['peopleInfo/savePeopleInfo'] }))
class PeopleDetailEditScreen extends React.Component { class PeopleDetailEditScreen extends React.Component {
componentDidMount() { componentDidMount() {
this.props.dispatch(createAction('peopleInfo/getPeopleDetail')(this.props.peopleInfo.peopleID)); this.props.dispatch(createAction('peopleInfo/getPeopleDetail')(this.props.peopleInfo.peopleID));
......
...@@ -128,8 +128,14 @@ export async function uploadResource(path, error = () => {}, complete = () => {} ...@@ -128,8 +128,14 @@ export async function uploadResource(path, error = () => {}, complete = () => {}
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
path = path.substring(7); path = path.substring(7);
} }
// 读卡器读出来的照片是这种格式的
if (path.startsWith('file:/')) {
path = path.substring(5);
}
const { exists, mimeType } = await Upload.getFileInfo(path); const { exists, mimeType } = await Upload.getFileInfo(path);
console.info(mimeType);
if (exists) { if (exists) {
console.info(`exists:${exists}`);
const token = await getToken(); const token = await getToken();
let url; let url;
if (uri) { if (uri) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论