Przeglądaj źródła

get location by rn

leon 1 rok temu
rodzic
commit
ae128f15d3

+ 1 - 1
ios/hola.xcodeproj/project.pbxproj

@@ -602,7 +602,7 @@
 				COPY_PHASE_STRIP = NO;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
-				EXCLUDED_ARCHS = i386;
+				EXCLUDED_ARCHS = arm64;
 				GCC_C_LANGUAGE_STANDARD = gnu99;
 				GCC_DYNAMIC_NO_PIC = NO;
 				GCC_NO_COMMON_BLOCKS = YES;

+ 5 - 0
src/features/trackTimeDuration/components/CircadianDetailPopup.scss

@@ -71,6 +71,7 @@
     justify-content: center;
 }
 
+/* #ifdef weapp */
 .detail_bottom_btn {
     display: flex;
     align-items: center;
@@ -83,6 +84,10 @@
     font-weight: bold;
     background: linear-gradient(90deg, #00FFFF 0%, #8961F5 100%);
 }
+/* #endif */
+
+/* #ifdef rn */
+/* #endif */
 
 .pop_ring_bg {
     display: flex;

+ 7 - 0
src/features/trackTimeDuration/components/DayNightCard.scss

@@ -69,6 +69,8 @@
     font-weight: bold;
 }
 
+
+/* #ifdef weapp */
 .buy_night {
     background: linear-gradient(to right, #1446B9, #AAFF00);
 }
@@ -77,6 +79,11 @@
     background: linear-gradient(to right, #C9DAFF, #AAFF00);
 }
 
+/* #endif */
+
+/* #ifdef rn */
+/* #endif */
+
 .day_location_btn {
     background-color: #C9DAFF33;
     color: #C9DAFF;

+ 18 - 5
src/features/trackTimeDuration/components/DayNightCard.tsx

@@ -170,14 +170,27 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
             }))
         }
         else {
-            var gps = Taro.getStorageSync('gps')
-            if (gps) {
-                locationDetail = JSON.parse(gps)
-                global.locationDetail = JSON.parse(gps)
-            }
+            getGPSCache()
         }
     }, [user.test_user])
 
+    async function getGPSCache() {
+        var gps = await getStorage('gps')
+        if (gps && gps.length>0) {
+            locationDetail = JSON.parse(gps)
+            global.locationDetail = JSON.parse(gps)
+        }
+    }
+
+    async function getStorage(key: string) {
+        try {
+            const res = await Taro.getStorage({ key });
+            return res.data;
+        } catch {
+            return '';
+        }
+    }
+
     function updateDate(data) {
 
         var today = new Date()

+ 13 - 0
src/features/trackTimeDuration/components/WeekCalendar.scss

@@ -55,6 +55,7 @@
     flex-direction: row;
 }
 
+/* #ifdef weapp */
 .chart_content_bg{
     position: absolute;
     left: 46px;
@@ -64,6 +65,18 @@
     border-radius:0;
     background: linear-gradient(180deg, #1C1C1C, #000000,#1C1C1C);
 }
+/* #endif */
+
+/* #ifdef rn */
+.chart_content_bg{
+    position: absolute;
+    left: 46px;
+    right: 46px;
+    top: 60px;
+    bottom: 60px;
+    border-radius:0;
+}
+/* #endif */
 
 
 .chart_times {

+ 11 - 0
src/pages/clock/Clock.tsx

@@ -577,6 +577,17 @@ export default function Page() {
     }
 
     function tapLogin() {
+        if (process.env.TARO_ENV=='rn'){
+            Taro.getLocation({
+                success(result) {
+                    console.log(result)
+                },
+                fail(res) {
+                    console.log(res)
+                },
+            })
+            return
+        }
         if (!user.isLogin) {
             jumpPage('/pages/account/ChooseAuth', 'ChooseAuth')
             return

+ 1 - 2
src/pages/rn/RNMain.tsx

@@ -4,7 +4,6 @@ import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
 import { createStackNavigator } from '@react-navigation/stack';
 
 import Clock from '../clock/Clock'
-import Index from '../clock/Index'
 import Metric from '../metric/Metric'
 import Workout from '../workout/Workout'
 import Profile from '../account/Profile'
@@ -63,7 +62,7 @@ const App: React.FC = () => {
 */
 
 export default function RNMain() {
-  const ClockPage = () => <Index />
+  const ClockPage = () => <Clock />
   const MetricPage = () => <Metric />
   const WorkoutPage = () => <Workout />
   const ProfilePage = () => <Profile />