|
|
@@ -139,10 +139,13 @@ export default class HomePage extends Component {
|
|
|
})
|
|
|
storage.getStorage(KEY_STORE_GPS).then(data => {
|
|
|
//console.log("获取GPS缓存", data);
|
|
|
- if (data && data.latitude) {
|
|
|
- this.setState({
|
|
|
- lastRegion: data
|
|
|
- });
|
|
|
+ if (data) {
|
|
|
+ const location = JSON.parse(data);
|
|
|
+ if (location.latitude) {
|
|
|
+ this.setState({
|
|
|
+ lastRegion: location
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
console.log("获取GPS缓存-err", err);
|
|
|
@@ -523,11 +526,13 @@ export default class HomePage extends Component {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- saveGPSCache(location) {
|
|
|
- storage.setStorageJson(KEY_STORE_GPS, location);
|
|
|
- this.setState({
|
|
|
- lastRegion: location
|
|
|
- });
|
|
|
+ saveGPSCache(location={}) {
|
|
|
+ if (location.latitude) {
|
|
|
+ storage.setStorageJson(KEY_STORE_GPS, location);
|
|
|
+ this.setState({
|
|
|
+ lastRegion: location
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
render() {
|