|
@@ -10,6 +10,7 @@ import Dialog from '../../components/Dialog';
|
|
|
import { Styles } from '../../components/Toolbar';
|
|
import { Styles } from '../../components/Toolbar';
|
|
|
import utils from '../../utils/utils';
|
|
import utils from '../../utils/utils';
|
|
|
import { PageList } from '../Router';
|
|
import { PageList } from '../Router';
|
|
|
|
|
+import { SettingUtil } from '../Settings';
|
|
|
import Maps from './maps/Maps';
|
|
import Maps from './maps/Maps';
|
|
|
import MapTool from './maps/MapTool';
|
|
import MapTool from './maps/MapTool';
|
|
|
import TopInfo from './maps/TopInfo';
|
|
import TopInfo from './maps/TopInfo';
|
|
@@ -32,6 +33,7 @@ export default class HomePage extends Component {
|
|
|
this.denied = true;
|
|
this.denied = true;
|
|
|
this.backSeconds = 0;
|
|
this.backSeconds = 0;
|
|
|
this.refreshTime = 0;
|
|
this.refreshTime = 0;
|
|
|
|
|
+ this.settingInfo = {}
|
|
|
this.filter = {
|
|
this.filter = {
|
|
|
parkingFee: 'ALL',
|
|
parkingFee: 'ALL',
|
|
|
connectorType: ''
|
|
connectorType: ''
|
|
@@ -45,7 +47,12 @@ export default class HomePage extends Component {
|
|
|
this.setState({
|
|
this.setState({
|
|
|
stationInfo: {}
|
|
stationInfo: {}
|
|
|
});
|
|
});
|
|
|
- this.checkPermission2Geo();
|
|
|
|
|
|
|
+ SettingUtil.getSettings(set => {
|
|
|
|
|
+ console.log("获取设置信息", set);
|
|
|
|
|
+ this.settingInfo = set;
|
|
|
|
|
+ this.checkPermission2Geo();
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
navigation.addListener('blur', () => {
|
|
navigation.addListener('blur', () => {
|
|
@@ -87,8 +94,12 @@ export default class HomePage extends Component {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- checkPermission2Geo() {
|
|
|
|
|
|
|
+ checkPermission2Geo(refresh) {
|
|
|
if (this.state.hasPermission) {
|
|
if (this.state.hasPermission) {
|
|
|
|
|
+ if (refresh) {
|
|
|
|
|
+ //避免关闭自动移动地图后无法点击按钮移动地图
|
|
|
|
|
+ this.state.stopList = []
|
|
|
|
|
+ }
|
|
|
this.infoGeoLocation();
|
|
this.infoGeoLocation();
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -164,10 +175,12 @@ export default class HomePage extends Component {
|
|
|
//console.log("getGeoLocation", region);
|
|
//console.log("getGeoLocation", region);
|
|
|
//if (this.state.stopList.length == 0) { //只加载一次
|
|
//if (this.state.stopList.length == 0) { //只加载一次
|
|
|
let time = new Date().getTime();
|
|
let time = new Date().getTime();
|
|
|
- if (this.state.stopList.length == 0 || time - this.refreshTime > 10000) { //一分钟(10秒)加载一次
|
|
|
|
|
- this.getStationList(region);
|
|
|
|
|
|
|
+ let interval = this.settingInfo.refreshInterval * 1000;
|
|
|
|
|
+ let first = this.state.stopList.length == 0;
|
|
|
|
|
+ if (first || time - this.refreshTime > interval) { //一分钟(10秒)加载一次
|
|
|
|
|
+ this.getStationList(region, first);
|
|
|
this.refreshTime = time;
|
|
this.refreshTime = time;
|
|
|
- } else {
|
|
|
|
|
|
|
+ } else if (this.settingInfo.alwaysLocation) {
|
|
|
this.setState({
|
|
this.setState({
|
|
|
region: region
|
|
region: region
|
|
|
});
|
|
});
|
|
@@ -188,7 +201,7 @@ export default class HomePage extends Component {
|
|
|
this.getStationList();
|
|
this.getStationList();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- getStationList(region) {
|
|
|
|
|
|
|
+ getStationList(region, first) {
|
|
|
Dialog.showProgressDialog('Loading...');
|
|
Dialog.showProgressDialog('Loading...');
|
|
|
apiStation.getAllStation(this.filter).then(res => {
|
|
apiStation.getAllStation(this.filter).then(res => {
|
|
|
Dialog.dismissLoading();
|
|
Dialog.dismissLoading();
|
|
@@ -218,7 +231,7 @@ export default class HomePage extends Component {
|
|
|
this.setState({
|
|
this.setState({
|
|
|
stopList: list
|
|
stopList: list
|
|
|
});
|
|
});
|
|
|
- if (region) {
|
|
|
|
|
|
|
+ if (region && (this.settingInfo.alwaysLocation || first)) {
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
this.setState({
|
|
this.setState({
|
|
|
region: region
|
|
region: region
|
|
@@ -318,7 +331,7 @@ export default class HomePage extends Component {
|
|
|
count={this.state.stopList.length}
|
|
count={this.state.stopList.length}
|
|
|
mapReady={this.state.mapReady}
|
|
mapReady={this.state.mapReady}
|
|
|
onFilter={data => this.findFilter(data)}
|
|
onFilter={data => this.findFilter(data)}
|
|
|
- onLocation={() => this.checkPermission2Geo()}
|
|
|
|
|
|
|
+ onLocation={() => this.checkPermission2Geo(true)}
|
|
|
/>
|
|
/>
|
|
|
</View>
|
|
</View>
|
|
|
<View style={styles.drawerLeftTouchView}></View>
|
|
<View style={styles.drawerLeftTouchView}></View>
|