Bläddra i källkod

修复站点消失问题

wudebin 1 månad sedan
förälder
incheckning
6e06c88716

+ 2 - 2
Strides-SPAPP/android/app/version.properties

@@ -1,2 +1,2 @@
-#Mon May 04 15:44:31 CST 2026
-VERSION_CODE=954
+#Mon May 04 18:07:10 CST 2026
+VERSION_CODE=957

+ 1 - 1
Strides-SPAPP/android/build.gradle

@@ -1,7 +1,7 @@
 // Top-level build file where you can add configuration options common to all sub-projects/modules.
 buildscript {
     ext {
-        versionName = "4.2.1" //★★★★★版本号★★★★★
+        versionName = "4.2.2" //★★★★★版本号★★★★★
         buildToolsVersion = "36.1.0"
         minSdkVersion = 24
         compileSdkVersion = 36

+ 1 - 1
Strides-SPAPP/app.json

@@ -2,7 +2,7 @@
   "name": "Strides",
   "displayName": "ChargEco",
   "versionCode": 940,
-  "versionName": "V4.2.1",
+  "versionName": "V4.2.2",
   "product": false,
   "debug": true,
   "isWhitelabel": true,

+ 4 - 3
Strides-SPAPP/app/pages/Settings.js

@@ -14,7 +14,7 @@ import storage, { getStorage, setStorage } from '../utils/storage';
 import app from '../../app.json';
 import TextView from '../components/TextView';
 
-export const SETTINGS_KEY = 'CHARGE_SETTINGS_V2'
+export const SETTINGS_KEY = 'CHARGE_SETTINGS_V3'
 export const SettingUtil = {
   getSettings: (back) => {
     if (!global.settingsInfo) {
@@ -27,7 +27,8 @@ export const SettingUtil = {
           back({
             alwaysLocation: true,
             moveMyLocation: true,
-            refreshInterval: 10
+            useApplesMap: false,
+            refreshInterval: 60
           })
         }
       })
@@ -45,7 +46,7 @@ export default class Settings extends Component {
         alwaysLocation: true,
         moveMyLocation: true,
         useApplesMap: false,
-        refreshInterval: undefined
+        refreshInterval: 60
       },
       userInfo: {
         notifyLowBalance: false,

+ 0 - 8
Strides-SPAPP/app/pages/charge/QRScanner.js

@@ -8,7 +8,6 @@ import TextView from '../../components/TextView';
 import { Camera, useCameraDevice, useCodeScanner } from 'react-native-vision-camera';
 import { check, PERMISSIONS, RESULTS } from 'react-native-permissions';
 import utils from '../../utils/utils';
-import app from '../../../app.json';
 
 const checkPermission = (back) => {
   if (isIOS) {
@@ -42,7 +41,6 @@ const checkPermission = (back) => {
 const QRScanner = ({ onResult, isActive }) => {
   const [flashOn, switchFlash] = useState(false);
   const [hasPermission, setHasPermission] = useState(false);
-  const [permissionStr, setPermissionStr] = useState("");
   const device = useCameraDevice('back');
   useEffect(() => {
     console.log("相机设备", device);
@@ -50,7 +48,6 @@ const QRScanner = ({ onResult, isActive }) => {
       setHasPermission(result);
     })
     Camera.requestCameraPermission().then(res => {
-      setPermissionStr(res);
       utils.logEventTracking("scan_camera_permission", res)
       if (!hasPermission) {
         setHasPermission(res == 'granted');
@@ -58,8 +55,6 @@ const QRScanner = ({ onResult, isActive }) => {
     }).catch(err => {
       console.warn("相机权限请求错误", err);
       utils.logEventTracking("scan_camera_permission_error", err)
-      setPermissionStr("Exception");
-      setHasPermission(false);
     });
   }, []);
   const codeScanner = useCodeScanner({
@@ -102,9 +97,6 @@ const QRScanner = ({ onResult, isActive }) => {
             name={flashOn ? "flashlight-on" : "flashlight-off"}
             size={36}
             color="#fff"/>
-          { (!isIOS && !app.product) &&
-            <TextView style={{color: "#fff", fontSize: 12}}>{permissionStr}</TextView>
-          }
         </Pressable>
       }
     </>

+ 38 - 31
Strides-SPAPP/app/pages/home/Home.js

@@ -41,6 +41,7 @@ export default class HomePage extends Component {
       permissionDenied: false,
       pinMessages: []
     };
+    this.isFirst = true;
     this.denied = true;
     this.backSeconds = 0;
     this.refreshTime = 0;
@@ -73,14 +74,16 @@ export default class HomePage extends Component {
     navigation.addListener('focus', () => {
       //console.log('------Home------', "Focus")
       this.onCloseInfo();
-      SettingUtil.getSettings(set => {
-        //console.log("获取设置信息", set);
-        this.settingInfo = set;
-        this.init();
-      })
-      this.setState({
-        isHide: false
-      });
+      if (this.state.isHide) {
+        SettingUtil.getSettings(set => {
+          //console.log("获取设置信息", set);
+          this.settingInfo = set;
+          this.init();
+        })
+        this.setState({
+          isHide: false
+        });
+      }
       /*if (!app.isWhitelabel) {
         MyStatusBar.setStatusBarThemes(MyStatusBar.DARK_STYLE, colorLight);
       }*/
@@ -116,6 +119,10 @@ export default class HomePage extends Component {
         this.showUpdateDialog(this.forceUpdateDialog);
       }
     });
+    SettingUtil.getSettings(set => {
+      //console.log("获取设置信息", set);
+      this.settingInfo = set;
+    })
     this.backHandler = BackHandler.addEventListener('hardwareBackPress', this.toExit)
     this.checkUpdateVersion();
     this.getPinMessage();
@@ -135,23 +142,23 @@ export default class HomePage extends Component {
     }
   }
 
-  init() {
+  init(init=false) {
     if (this.state.stopList.length == 0 && !this.refresh) {
       storage.getStorage(KEY_STORE_LIST).then(data => {
-        //console.log("获取站点缓存", "成功");
+        console.log("获取站点缓存", "成功");
         if (data) {
           const list = JSON.parse(data);
           this.setState({
             stopList: list
           }, () => {
-            this.checkPermission2Geo(true);
+            this.checkPermission2Geo(init);
           })
         } else {
-          this.checkPermission2Geo(true);
+          this.checkPermission2Geo(init);
         }
       }).catch(err => {
         console.log("获取站点缓存-err", err);
-        this.checkPermission2Geo(true);
+        this.checkPermission2Geo(init);
       })
       storage.getStorage(KEY_STORE_GPS).then(data => {
         //console.log("获取GPS缓存", data);
@@ -206,7 +213,7 @@ export default class HomePage extends Component {
       this.setState({
         mapReady: true
       }, () => {
-        this.init();
+        this.init(true);
       });
     }, 500);
   }
@@ -265,6 +272,7 @@ export default class HomePage extends Component {
         this.setState({
           hasPermission: true
         });
+        this.refresh = false;
         this.checkPermission2Geo();
       } else {
         this.noPermissionSite();
@@ -272,31 +280,30 @@ export default class HomePage extends Component {
     })
   }
 
-  checkPermission2Geo(refresh, button) {
+  checkPermission2Geo(button) {
     if (button && this.state.lastRegion.latitude) {
       this.setState({
         region: {...this.state.lastRegion}
       });
     }
-    if (this.refresh == refresh) {
+    console.log("checkPermission2Geo", button, this.refresh);
+    if (this.refresh) {
       return;
     }
-    if (refresh) {
-      //避免关闭自动移动地图后无法点击按钮移动地图
-      this.refresh = true
-    }
-    console.log("checkPermission2Geo", refresh, button);
+    //避免关闭自动移动地图后无法点击按钮移动地图
+    this.refresh = true
     //this.checkGPS();
     if (this.state.hasPermission) {
-      this.infoGeoLocation();
+      this.infoGeoLocation(button);
     } else {
       LocationPermission.checkPermission((hasPermission, canRequestPermission) => {
         if (hasPermission) {
           this.setState({
             hasPermission: true
           });
-          this.infoGeoLocation();
+          this.infoGeoLocation(button);
         } else {
+          this.refresh = false;
           if (canRequestPermission) {
             if (this.denied) {
               this.denied = false;
@@ -342,15 +349,15 @@ export default class HomePage extends Component {
         //if (this.state.stopList.length == 0) { //只加载一次
         let time = new Date().getTime();
         let interval = this.settingInfo.refreshInterval * 1000;//重复加载时间
-        let first = this.state.stopList.length == 0;//是否第一次加载
-        if (first || this.refresh || time - this.refreshTime > interval) { //一分钟(10秒)加载一次
-          this.getStationList(region, first || this.refresh);
+        if (this.isFirst || this.refresh || time - this.refreshTime > interval || region) { //一分钟(10秒)加载一次
+          this.getStationList(region, this.isFirst || this.refresh);
           this.refreshTime = time;
         } else if (this.settingInfo.moveMyLocation) {
           this.setState({
             region: region
           });
         }
+        this.refresh = false;
       }, error => {
         console.info("getGeoLocation", error);
         if (!again) {
@@ -358,11 +365,10 @@ export default class HomePage extends Component {
             this.infoGeoLocation(true);
           }, 2000);
         }
+        this.refresh = false;
       });
     } else {
-      setTimeout(() => {
-        this.infoGeoLocation(true);
-      }, 1000);
+      this.refresh = false;
     }
   }
 
@@ -386,6 +392,7 @@ export default class HomePage extends Component {
       this.setState({
         region: region
       });
+      this.isFirst = false;
     }
     apiStation.getAllStation(this.filter).then(res => {
       Dialog.dismissLoading();
@@ -584,7 +591,7 @@ export default class HomePage extends Component {
             onMapReady={() => this.onMapReady()}
             onFavorite={() => this.favoriteSite()}
             onCloseInfo={() => this.onCloseInfo()}
-            onLocation={() => this.checkPermission2Geo(true, true)}
+            onLocation={() => this.checkPermission2Geo(true)}
             useApplesMap={this.settingInfo.useApplesMap}
             showUserLocation={this.state.hasPermission && this.settingInfo.alwaysLocation}
             viewChargeStation={id => this.viewChargeStation(id)}/>
@@ -595,7 +602,7 @@ export default class HomePage extends Component {
             onMapReady={() => this.onMapReady()}
             onFavorite={() => this.favoriteSite()}
             onCloseInfo={() => this.onCloseInfo()}
-            onLocation={() => this.checkPermission2Geo(true, true)}
+            onLocation={() => this.checkPermission2Geo(true)}
             useApplesMap={this.settingInfo.useApplesMap}
             showUserLocation={this.state.hasPermission && this.settingInfo.alwaysLocation}
             viewChargeStation={id => this.viewChargeStation(id)}

+ 9 - 11
Strides-SPAPP/app/pages/home/MapUI.js

@@ -65,17 +65,15 @@ export default MapUI = React.memo(({
       />
       <PinMessage messageList={pinMessages}/>
       <View style={styles.mapContent}>
-        { !state.isHide &&
-          <Maps.Maps3
-            ready={state.mapReady}
-            region={state.region}
-            stopList={state.stopList}
-            onMapReady={onMapReady}
-            useApplesMap={useApplesMap}
-            onMarkerPress={viewChargeStation}
-            showUserLocation={showUserLocation}
-          />
-        }
+        <Maps.Maps3
+          ready={state.mapReady}
+          region={state.region}
+          stopList={state.stopList}
+          onMapReady={onMapReady}
+          useApplesMap={useApplesMap}
+          onMarkerPress={viewChargeStation}
+          showUserLocation={showUserLocation}
+        />
         <BottomSiteInfo
           visible={state.showStation}
           stationInfo={state.stationInfo}

+ 9 - 9
Strides-SPAPP/app/pages/home/maps/Maps3.js

@@ -14,16 +14,16 @@ export default Maps3 = ({ region, onMapReady, stopList, useApplesMap, showUserLo
   const superClusterRef = useRef();
 
   useEffect(() => {
-  if (isIOS) {
-    //mapRef.current.animateToRegion(region, 500);
-    mapRef.current.animateCamera({ center: region, zoom: 17 }, { duration: 500 });
-    //mapRef.current.animateCamera({ center: region, zoom: 17 }, 500); //移动地图到当前位置并放大
-  } else {
-    if (mapRef.current.moveCamera) {
-      mapRef.current.moveCamera(region, 17);
-      //mapRef.current.showUserLocation();
+    if (isIOS) {
+      //mapRef.current.animateToRegion(region, 500);
+      mapRef.current.animateCamera({ center: region, zoom: 17 }, { duration: 500 });
+      //mapRef.current.animateCamera({ center: region, zoom: 17 }, 500); //移动地图到当前位置并放大
+    } else {
+      if (mapRef.current.moveCamera) {
+        mapRef.current.moveCamera(region, 17);
+        //mapRef.current.showUserLocation();
+      }
     }
-  }
   }, [region])
 
   /*componentDidMount() {

+ 3 - 1
Strides-SPAPP/app/utils/utils.js

@@ -347,7 +347,9 @@ export default {
   },
   logEventTracking(event, message="") {
     if (app.debug && event && message) {
-      console.log("已记录事件跟踪", event, message);
+      if (!app.product) {
+        console.log("已记录事件跟踪", event, message);
+      }
       if (message) {
         crashlytics().log(event + ": " + message);
       } else {