Leon 1 rok temu
rodzic
commit
b4e22192f8

+ 21 - 10
src/features/trackTimeDuration/components/DayNightCard.tsx

@@ -391,6 +391,8 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         }
         joingMember = false;
         Taro.chooseLocation({
+            latitude: authInfo && authInfo.lat ? authInfo.lat : undefined,
+            longitude: authInfo && authInfo.lat ? authInfo.lng : undefined,
             success: function (res) {
                 var today = new Date()
                 var yesterday = new Date(today.getTime() - 24 * 3600 * 1000)
@@ -432,17 +434,21 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
     }
 
     function getLocation() {
+        var city = ''
         if ((authInfo as any).address.city.length > 0) {
-            return (authInfo as any).address.city
+            city = (authInfo as any).address.city
         }
-        if ((authInfo as any).address.province.length > 0) {
-            return (authInfo as any).address.province
+        else if ((authInfo as any).address.province.length > 0) {
+            city = (authInfo as any).address.province
         }
-        if ((authInfo as any).address.country.length > 0) {
-            return (authInfo as any).address.country
+        else if ((authInfo as any).address.country.length > 0) {
+            city = (authInfo as any).address.country
         }
-        return t('feature.track_time_duration.third_ring.unknown')
-
+        else {
+            city = t('feature.track_time_duration.third_ring.unknown')
+        }
+        // return city +' | '+parseInt(authInfo.lat)+'°'+ ' '+parseInt(authInfo.lng)
+        return `${city} | ${Math.abs(parseInt(authInfo.lat))}°${parseInt(authInfo.lat) < 0 ? 'S' : 'N'} ${Math.abs(parseInt(authInfo.lng))}°${parseInt(authInfo.lng) < 0 ? 'W' : 'E'}`
     }
 
     function lowTimeColor() {
@@ -1005,9 +1011,14 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
                                             <View className={props.isNight ? 'night_location_btn' : 'day_location_btn'} onClick={auth}>{getLocation()}</View>
                                         </View>
                                         :
-                                        <View className='day_night_card_btn' style={{ backgroundColor: props.isNight ? ColorType.night : ColorType.day }} onClick={auth}>{
-                                            props.isNight ? t('feature.day_night.get_local_time') : t('feature.day_night.get_local_time_sunrise')
-                                        }</View>
+                                        <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
+                                            <View className={props.isNight ? 'night_location_btn' : 'day_location_btn'} onClick={auth}>
+                                                {props.isNight ? t('feature.day_night.get_local_time') : t('feature.day_night.get_local_time_sunrise')}
+                                            </View>
+                                        </View>
+                                // <View className='day_night_card_btn' style={{ backgroundColor: props.isNight ? ColorType.night : ColorType.day }} onClick={auth}>{
+                                //     props.isNight ? t('feature.day_night.get_local_time') : t('feature.day_night.get_local_time_sunrise')
+                                // }</View>
 
 
                             }