提交 06aa4d7b authored 作者: 吴强's avatar 吴强

Merge branch 'master' of ssh://192.168.1.116:29418/bolan-root/frontend/manager-app-sz into wq

# Conflicts: # android/app/src/main/java/com/bolanmanagerapp/MainApplication.java # src/utils/config.js
上级 65b5e517
......@@ -43,8 +43,7 @@ public class MainApplication extends Application implements ReactApplication {
new CodePush(BuildConfig.CODEPUSH_KEY, getApplicationContext(), BuildConfig.DEBUG, "http://192.168.1.2:3000"),
new RNDeviceInfo(),
new IDCardReactPackage(),
new UpdaterReactPackage()
new IDCardReactPackage(),
//new UpdaterReactPackage(),
new VectorIconsPackage(),
new SplashScreenReactPackage()
);
......
......@@ -8,6 +8,11 @@ import {
} from 'react-native';
import Icon from 'react-native-vector-icons/MaterialIcons';
import Camera from 'react-native-camera';
import { getToken } from '../utils/auth';
import { errors } from '../utils/error';
import { encrypt } from '../utils/helper';
import config from '../utils/config';
import { futch } from '../utils/polyfill';
const styles = StyleSheet.create({
container: {
......@@ -51,7 +56,6 @@ const styles = StyleSheet.create({
padding: 5,
},
});
class CameraComponent extends React.Component {
constructor(props) {
super(props);
......@@ -69,6 +73,8 @@ class CameraComponent extends React.Component {
this.switchCam = this.switchCam.bind(this);
this.recording = this.recording.bind(this);
this.takePicture = this.takePicture.bind(this);
this.uploadImage = this.uploadImage.bind(this);
this.clear = this.clear.bind(this);
}
typeIcon= () => {
const { back, front } = Camera.constants.Type;
......@@ -78,7 +84,7 @@ class CameraComponent extends React.Component {
} else if (this.state.camera.type === front) {
return 'camera-rear';
}
}
};
camButton= () => {
if (!this.state.isRecording) {
......@@ -86,7 +92,7 @@ class CameraComponent extends React.Component {
} else {
return 'stop';
}
}
};
switchCam() {
let newType;
const { back, front } = Camera.constants.Type;
......@@ -129,6 +135,46 @@ class CameraComponent extends React.Component {
.then((data) => { console.log(data); this.setState({ imageURI: data.path }); })
.catch(err => console.error(err));
}
uploadImage() {
let token;
getToken().then((Apptoken) => {
if (!Apptoken) {
return Promise.reject(errors.tokenMissing());
}
token = encrypt(Apptoken);
const uri = `${config.apiContextPath}/resource/${token}`;
const formData = new global.FormData();
const file = { uri: this.state.imageURI, type: 'image/jpg', name: 'tupian.jpg' };
formData.append('file', file);
console.info(formData);
futch(uri, {
method: 'POST',
headers: {
'Content-Type': 'multipart/form-data',
},
body: formData,
}, (progressEvent) => {
const progress = progressEvent.loaded / progressEvent.total;
})
.then(request => request.responseText)// response.text())
.then((responseData) => {
const response = JSON.parse(responseData);
if (response.errorCode === 0) {
// 这里需要调用接口,对图片数据进行绑定,等待完善
// 页面跳转,跳转到前面的详情的页面
console.info('跳转');
this.props.navigation.navigate('DSRInfoDetail', this.props.navigation.state.params.pID);
}
})
.catch((error) => {
console.info(error);
});
});
}
clear() {
this.setState({ imageURI: '' });
}
render() {
if (this.state.imageURI === '') {
......@@ -148,7 +194,6 @@ class CameraComponent extends React.Component {
/>
<View style={[styles.overlay, styles.topOverlay]}>
<Icon.Button name={this.typeIcon()} size={36} backgroundColor="transparent" onPress={this.switchCam} />
<Icon.Button name={this.typeIcon()} size={36} backgroundColor="transparent" onPress={this.switchCam} />
</View>
<View style={[styles.overlay, styles.bottomOverlay]}>
<Icon.Button name="photo-camera" size={48} backgroundColor="transparent" onPress={this.takePicture} />
......@@ -158,10 +203,16 @@ class CameraComponent extends React.Component {
);
} else {
return (
<Image
style={{ height: Dimensions.get('window').height, width: Dimensions.get('window').width }}
source={{ uri: this.state.imageURI, isStatic: true }}
/>
<View style={styles.container}>
<Image
style={{ height: Dimensions.get('window').height, width: Dimensions.get('window').width }}
source={{ uri: this.state.imageURI, isStatic: true }}
/>
<View style={[styles.overlay, styles.bottomOverlay]}>
<Icon.Button name="clear" size={48} backgroundColor="transparent" onPress={this.clear} />
<Icon.Button name="done" size={48} backgroundColor="transparent" onPress={this.uploadImage} />
</View>
</View>
);
}
}
......
......@@ -25,7 +25,7 @@ class PickerComponent extends PureComponent {
onPickerChange={this.onPickerChange}
onOk={this.onOkButton}
>
<List.Item arrow="horizontal" onClick={this.onClick}>当前基地</List.Item>
<List.Item arrow="horizontal" onClick={this.onClick}>{this.props.title}</List.Item>
</Picker>
</List>
</View>
......
......@@ -70,6 +70,7 @@ export default {
arrayPath: [],
cols: 1,
userInfo: '',
currentJiDiName: undefined,
},
subscriptions: {
......@@ -87,6 +88,7 @@ export default {
datas.push({ label: name, value: path, children: [] });
return datas;
});
yield put({ type: 'setCols', payload: 1 });
yield put({ type: 'queryInit', payload: init });
yield put({ type: 'queryArryPath', payload: ['/'] });
yield put({ type: 'queryList', payload: datas });
......@@ -113,6 +115,8 @@ export default {
const { path, name } = yield call(currentDomain);
yield call(setDomain, name, path);
yield put({ type: 'queryInit', payload: path });
const currentJiDiName = name;
yield put({ type: 'setCurrentJiDiName', payload: currentJiDiName });
},
*logout(ignored, { put, call }) {
yield call(logout);
......@@ -126,9 +130,9 @@ export default {
*getUserInfo(ignored, { put, call }) {
const userInfo = yield call(getUser);
const domain = yield call(getDomain);
console.info(domain.path);
const list = yield call(fetchDomains, domain.path, true);
console.info(list[0].name);
const currentJiDiName = list[0].name;
yield put({ type: 'setCurrentJiDiName', payload: currentJiDiName });
yield put({ type: 'queryUserInfo', payload: userInfo });
},
},
......@@ -170,6 +174,12 @@ export default {
cols,
};
},
setCurrentJiDiName(state, { payload: currentJiDiName }) {
return {
...state,
currentJiDiName,
};
},
},
};
......@@ -7,7 +7,7 @@ import DSRInfo from './dangshireninfo/dsrinfo';
import DSRInfoDetail from './dangshireninfo/dsrinfodetail';
import peopleInfo from './peopleInfo/peopleInfo';
import domain from './domain';
import userInfo from './userinfo/userinfo';
import userInfomation from './userinfo/userinfo';
import QSInfo from './quanshuInfo/qsinfo';
import QSInfoDetail from './quanshuInfo/qsinfodetail';
import FWQuanShu from './houseinfo/fwquanshuDetail';
......@@ -22,7 +22,7 @@ export default [
DSRInfo,
DSRInfoDetail,
peopleInfo,
userInfo,
userInfomation,
QSInfo,
QSInfoDetail,
FWQuanShu,
......
export default {
namespace: 'userInfo',
namespace: 'userInfomation',
state: {
userName: undefined,
currentJiDiName: undefined,
jidiList: [],
currentJiDiPath: undefined,
},
subscriptions: {
setup({ dispatch }) { // eslint-disable-line
......@@ -18,13 +18,7 @@ export default {
userName,
};
},
setJiDiList(state, { payload: jidiList }) {
return {
...state,
jidiList,
};
},
setCurrentJiDi(state, { payload: currentJiDiName }) {
setCurrentJiDiName(state, { payload: currentJiDiName }) {
return {
...state,
currentJiDiName,
......
import { AsyncStorage } from 'react-native';
import { NavigationActions } from 'react-navigation';
import codePush from 'react-native-code-push';
// import codePush from 'react-native-code-push';
import { checkUpdate } from '../services/update';
export default {
namespace: 'welcome',
......@@ -9,7 +10,9 @@ export default {
effects: {
*init(ignored, { put, call }) {
try {
yield call(codePush.sync);
// yield call(codePush.sync);
// const promise = yield call(checkUpdate);
// console.info(promise);
} catch (e) {
console.log(e); // eslint-disable-line no-console
}
......
......@@ -4,7 +4,7 @@
import React from 'react';
import { createForm } from 'rc-form';
import { View, ScrollView } from 'react-native';
import { List, InputItem, Toast, WhiteSpace, WingBlank, TextareaItem } from 'antd-mobile';
import { List, InputItem, Toast, WhiteSpace, WingBlank } from 'antd-mobile';
import Icon from 'react-native-vector-icons/FontAwesome';
import { connect } from 'react-redux';
import { createAction } from '../../../utils';
......@@ -17,7 +17,7 @@ class DSRInfoDetailScreen extends React.Component {
}
onEdit =() => {
// this.props.dispatch(createAction('DSRInfoDetail/setEnable')(true));
this.props.navigation.navigate('CameraPhoto');
this.props.navigation.navigate('CameraPhoto', { pID: this.props.navigation.state.params });
};
onSubmit = () => {
this.props.form.validateFields({ force: true }, (error, value) => {
......@@ -121,13 +121,13 @@ class DSRInfoDetailScreen extends React.Component {
<WhiteSpace />
<WingBlank>
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
{/* <Icon.Button
<Icon.Button
name="edit"
backgroundColor="#08BBF9"
onPress={this.onEdit}
>
编辑
</Icon.Button> */}
资料上传
</Icon.Button>
</View>
<WhiteSpace />
<List>
......
......@@ -8,7 +8,7 @@ import PickerComponent from '../../../components/pickerComponent';
import { createAction } from '../../../utils/index';
// create a component
@connect(({ userInfo, domain }) => ({ userInfo, domain }))
@connect(({ userInfomation, domain }) => ({ userInfomation, domain }))
class UserInfoHomeScreen extends PureComponent {
componentDidMount() {
this.props.dispatch(createAction('domain/getUserInfo')());
......@@ -31,7 +31,7 @@ class UserInfoHomeScreen extends PureComponent {
Toast.offline('功能正在完善中...', 2);
};
render() {
const { list, listChildren, arrayPath, cols, userInfo } = this.props.domain;
const { list, listChildren, arrayPath, cols, userInfo, currentJiDiName } = this.props.domain;
let datas = [];
if (listChildren.length === 0) {
datas = list;
......@@ -70,7 +70,8 @@ class UserInfoHomeScreen extends PureComponent {
</View>
<WingBlank>
<View style={styles.pickerCom}>
<PickerComponent onClick={this.onClick} onPickerChange={this.onPickerChange} onOkButton={this.onOkButton} data={datas} pathVal={arrayPath} cols={cols} />
<List.Item extra={currentJiDiName} wrap>当前基地</List.Item>
<PickerComponent onClick={this.onClick} onPickerChange={this.onPickerChange} onOkButton={this.onOkButton} data={datas} pathVal={arrayPath} cols={cols} title="切换基地" />
</View>
</WingBlank>
</View>
......
......@@ -9,6 +9,7 @@ class WelcomeScreen extends Component {
componentDidMount() {
const { dispatch } = this.props;
dispatch(createAction('welcome/init')());
SplashScreen.hide();// 隐藏启动平
}
// 待改进,改成启动页,目前因为时间和技术的问题,搁置。wq write
......
......@@ -21,7 +21,7 @@ import config from '../utils/config';
/**
* 升级检查
* @returns {Promise.<RestResponse<VersionCheck>>}
* @returns {Promise.<VersionCheck>}
*/
export const checkUpdate = async () => {
return post(`${config.updateContextPath}/api/app/user/apps/check`, { name: config.productId, version: DeviceInfo.getVersion() });
......
......@@ -30,7 +30,7 @@ const config = {
productId: 'manager-app-sz',
footerText: '上海铂蓝信息科技有限公司',
contextPath: '',
updateContextPath: 'http://192.168.1.22/app',
updateContextPath: 'http://192.168.1.22:8080/app',
// apiContextPath: 'http://14.21.68.149:9089/test',
apiContextPath: 'http://192.168.1.22:8080/bm',
defaultDateFormat,
......
// eslint-disable-next-line global-require
export const fetch = require('react-native-fetch-polyfill').default;
export const futch = (url, opts = {}, onProgress) => {
return new Promise((res, rej) => {
const xhr = new global.XMLHttpRequest();
xhr.open(opts.method || 'get', url);
Object.keys(opts.headers).forEach((k) => {
xhr.setRequestHeader(k, opts.headers[k]);
});
// for (var k in opts.headers || {}) {
// console.info('*');
// xhr.setRequestHeader(k, opts.headers[k]);
// }
xhr.onload = e => res(e.target);
xhr.onerror = rej;
if (xhr.upload && onProgress) {
xhr.upload.onprogress = onProgress; // event.loaded / event.total * 100 ; //event.lengthComputable
}
xhr.send(opts.body);
});
};
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论