ソースを参照

google services

leon 1 年間 前
コミット
3ffae2b318

+ 7 - 0
android/app/build.gradle

@@ -84,6 +84,9 @@ project.ext.react = [
 
 apply from: "../../node_modules/react-native/react.gradle"
 
+//gms
+//apply plugin: 'com.google.gms.google-services'
+
 /**
  * Set this to true to create two separate APKs instead of one:
  *   - An APK that only works on ARM devices
@@ -288,6 +291,10 @@ dependencies {
     } else {
         implementation jscFlavor
     }
+
+    //gms
+//    implementation 'com.google.firebase:firebase-messaging:23.0.5'
+
 }
 
 if (isNewArchitectureEnabled()) {

+ 29 - 0
android/app/google-services.json

@@ -0,0 +1,29 @@
+{
+  "project_info": {
+    "project_number": "476230921453",
+    "project_id": "hola-aaa2b",
+    "storage_bucket": "hola-aaa2b.appspot.com"
+  },
+  "client": [
+    {
+      "client_info": {
+        "mobilesdk_app_id": "1:476230921453:android:d72b7b88aaa6875623b0e4",
+        "android_client_info": {
+          "package_name": "com.hye.fast"
+        }
+      },
+      "oauth_client": [],
+      "api_key": [
+        {
+          "current_key": "AIzaSyCttNbQvZIN0oIdofLgKX6rBw2o2AHMIUo"
+        }
+      ],
+      "services": {
+        "appinvite_service": {
+          "other_platform_oauth_client": []
+        }
+      }
+    }
+  ],
+  "configuration_version": "1"
+}

BIN
android/app/release/app-release.apk


+ 4 - 0
android/build.gradle

@@ -26,6 +26,8 @@ buildscript {
         classpath("com.android.tools.build:gradle:7.2.1")
         classpath("com.facebook.react:react-native-gradle-plugin")
         classpath("de.undercouch:gradle-download-task:5.0.1")
+        //gms
+//        classpath 'com.google.gms:google-services:4.3.8'
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
     }
@@ -59,6 +61,8 @@ allprojects {
             // expo-camera bundles a custom com.google.android:cameraview
             url "$rootDir/../node_modules/expo-camera/android/maven"
         }
+        //gms
+//        maven { url "https://maven.google.com" }
         maven { url 'https://maven.aliyun.com/repository/public' }
         maven { url 'https://maven.aliyun.com/repository/google' }
         maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }

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

@@ -611,7 +611,7 @@
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
 				EXCLUDED_ARCHS = "";
-				"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
+				"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
 				GCC_C_LANGUAGE_STANDARD = gnu99;
 				GCC_DYNAMIC_NO_PIC = NO;
 				GCC_NO_COMMON_BLOCKS = YES;

+ 1 - 0
package.json

@@ -103,6 +103,7 @@
 		"react-native-gesture-handler": "~2.9.0",
 		"react-native-haptic-feedback": "^2.2.0",
 		"react-native-linear-gradient": "^2.8.3",
+		"react-native-localize": "^3.1.0",
 		"react-native-pager-view": "~6.0.1",
 		"react-native-permissions": "^4.1.5",
 		"react-native-safe-area-context": "~4.4.1",

+ 0 - 1
src/features/daynight/AllRings.tsx

@@ -61,7 +61,6 @@ export default function AllRings(props: { data?: any, time?: any }) {
         var currentDot1 = getDot(record, true)
         var targetBigRing1 = getTarget(record, true)
         targetBigRing1.color = record.scenario == 'SLEEP' ? ColorType.sleep + '66' : ColorType.fast + '66'
-        debugger
         if (record.status == 'ONGOING') {
             var realRing1 = getReal(record, true, false)
             // debugger

+ 26 - 7
src/features/daynight/DayNightCard.tsx

@@ -437,10 +437,17 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
                         })
                         dispatch(updateMember({ isMember: isMember, gpsInfo: (data as any) }))
                         showRing()
-                        Taro.showToast({
-                            title: t('feature.day_night.location_updated'),
-                            icon: 'none'
-                        })
+                        if (Taro.getSystemInfoSync().platform == 'android' && process.env.TARO_ENV == 'rn') {
+                            var ToastAndroid = require('react-native').ToastAndroid;
+                            ToastAndroid.show(t('feature.day_night.location_updated'), ToastAndroid.LONG);
+                        }
+                        else {
+                            Taro.showToast({
+                                title: t('feature.day_night.location_updated'),
+                                icon: 'none'
+                            })
+                        }
+                        
                     })
                 },
                 fail(res) {
@@ -456,6 +463,18 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
                             }
                         })
                     }
+                    else {
+                        if (Taro.getSystemInfoSync().platform == 'android' && process.env.TARO_ENV == 'rn') {
+                            var ToastAndroid = require('react-native').ToastAndroid;
+                            ToastAndroid.show(t('feature.day_night.location_failed'), ToastAndroid.LONG);
+                        }
+                        else {
+                            Taro.showToast({
+                                title: t('feature.day_night.location_failed'),
+                                icon: 'none'
+                            })
+                        }
+                    }
                     console.log(res)
                     showRing()
                 },
@@ -872,7 +891,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
     function currentTime() {
         var now = new Date()
         if (authInfo && authInfo.timezone) {
-            var t1 = dayjs(now.getTime()).tz(authInfo.timezone.id)
+            var t1 = TimeFormatter.tzLocalTime(now.getTime(),authInfo.timezone.id)////dayjs(now.getTime()).tz(authInfo.timezone.id)
             if (now.getHours() == t1.hour() && now.getMinutes() == t1.minute()) {
                 return <View />
             }
@@ -885,7 +904,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         let offset = 0;
         if (authInfo && authInfo.timezone) {
             var current1 = dayjs()
-            var current = dayjs().tz(authInfo.timezone.id)
+            var current = TimeFormatter.tzLocalTime(now.getTime(),authInfo.timezone.id)//dayjs().tz(authInfo.timezone.id)
             offset = current.date() * 24 * 60 + current.hour() * 60 + current.minute() - current1.date() * 24 * 60 - current1.hour() * 60 - current1.minute()
         }
         var hour = Math.floor(Math.abs(offset) / 60)
@@ -907,7 +926,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
         // const current = dayjs().utcOffset(offset).format('YYYY-MM-DD HH:mm:ss')
         var current;
         if (authInfo && authInfo.timezone) {
-            current = dayjs().tz(authInfo.timezone.id).format('HH:mm')
+            current = TimeFormatter.tzTimeFormateLocalTime(new Date().getTime(),authInfo.timezone.id,'HH:mm')//dayjs().tz(authInfo.timezone.id).format('HH:mm')
         }
         else {
             current = dayjs().format('HH:mm')

+ 20 - 13
src/features/daynight/DayNightDetailPopup.tsx

@@ -303,13 +303,11 @@ export default function DayNightDetailPopup(props: {
     function diffTimeZone() {
         var now = new Date()
         if (props.authInfo && props.authInfo.timezone) {
-            var t1 = dayjs(now.getTime()).tz(props.authInfo.timezone.id)
+            var t1 = TimeFormatter.tzLocalTime(now.getTime(),props.authInfo.timezone.id)//dayjs(now.getTime()).tz(props.authInfo.timezone.id)
             if (now.getHours() == t1.hour() && now.getMinutes() == t1.minute()) {
-                console.log('a')
                 return false
             }
             else {
-                console.log('b')
                 return true
             }
         }
@@ -324,7 +322,8 @@ export default function DayNightDetailPopup(props: {
             if (isCompleted()) {
                 var newT;
                 if (props.authInfo.timezone) {
-                    newT = dayjs(props.authInfo.night_completed.sunset_ts).tz(props.authInfo.timezone.id).format('M月D日 HH:mm')
+                    newT = TimeFormatter.tzTimeFormateLocalTime(props.authInfo.night_completed.sunset_ts, props.authInfo.timezone.id, 'M月D日 HH:mm')
+                    //dayjs(props.authInfo.night_completed.sunset_ts).tz(props.authInfo.timezone.id).format('M月D日 HH:mm')
                 }
                 else {
                     newT = dayjs(props.authInfo.night_completed.sunset_ts).format('M月D日 HH:mm')
@@ -343,7 +342,9 @@ export default function DayNightDetailPopup(props: {
                 )
                 var newT2;
                 if (props.authInfo.timezone) {
-                    newT2 = dayjs(props.authInfo.night_completed.sunrise_ts).tz(props.authInfo.timezone.id).format('M月D日 HH:mm')
+                    newT2 = TimeFormatter.tzTimeFormateLocalTime(props.authInfo.night_completed.sunrise_ts, props.authInfo.timezone.id, 'M月D日 HH:mm')
+                    
+                    //dayjs(props.authInfo.night_completed.sunrise_ts).tz(props.authInfo.timezone.id).format('M月D日 HH:mm')
                 }
                 else {
                     newT2 = dayjs(props.authInfo.night_completed.sunrise_ts).format('M月D日 HH:mm')
@@ -364,8 +365,10 @@ export default function DayNightDetailPopup(props: {
 
                 var list = nightDurationDesc()
                 if (diffTimeZone() && global.nightObj) {
-                    list[0] = dayjs(global.nightObj.sunset.timestamp).tz(props.authInfo.timezone.id).format('M月D日')
-                    list[1] = dayjs(global.nightObj.sunrise.timestamp).tz(props.authInfo.timezone.id).format('M月D日')
+                    list[0] = TimeFormatter.tzTimeFormateLocalTime(global.nightObj.sunset.timestamp, props.authInfo.timezone.id, 'M月D日')
+                    list[1] = TimeFormatter.tzTimeFormateLocalTime(global.nightObj.sunrise.timestamp, props.authInfo.timezone.id, 'M月D日')
+                    // list[0] = dayjs(global.nightObj.sunset.timestamp).tz(props.authInfo.timezone.id).format('M月D日')
+                    // list[1] = dayjs(global.nightObj.sunrise.timestamp).tz(props.authInfo.timezone.id).format('M月D日')
 
                 }
                 timelineItems.push(
@@ -395,7 +398,8 @@ export default function DayNightDetailPopup(props: {
             if (isCompleted()) {
                 var newT;
                 if (props.authInfo.timezone) {
-                    newT = dayjs(props.authInfo.day_completed.sunrise_ts).tz(props.authInfo.timezone.id).format('M月D日 HH:mm')
+                    newT = TimeFormatter.tzTimeFormateLocalTime(props.authInfo.day_completed.sunrise_ts, props.authInfo.timezone.id, 'M月D日 HH:mm')
+                    // newT = dayjs(props.authInfo.day_completed.sunrise_ts).tz(props.authInfo.timezone.id).format('M月D日 HH:mm')
                 }
                 else {
                     newT = dayjs(props.authInfo.day_completed.sunrise_ts).format('M月D日 HH:mm')
@@ -412,7 +416,8 @@ export default function DayNightDetailPopup(props: {
                 )
                 var newT2;
                 if (props.authInfo.timezone) {
-                    newT2 = dayjs(props.authInfo.day_completed.sunset_ts).tz(props.authInfo.timezone.id).format('M月D日 HH:mm')
+                    newT2 = TimeFormatter.tzTimeFormateLocalTime(props.authInfo.day_completed.sunset_ts, props.authInfo.timezone.id, 'M月D日 HH:mm')
+                    // newT2 = dayjs(props.authInfo.day_completed.sunset_ts).tz(props.authInfo.timezone.id).format('M月D日 HH:mm')
                 }
                 else {
                     newT2 = dayjs(props.authInfo.day_completed.sunset_ts).format('M月D日 HH:mm')
@@ -430,8 +435,10 @@ export default function DayNightDetailPopup(props: {
             else {
                 var list = dayDurationDesc()
                 if (diffTimeZone() && global.dayObj) {
-                    list[0] = dayjs(global.dayObj.sunrise.timestamp).tz(props.authInfo.timezone.id).format('M月D日')
-                    list[1] = dayjs(global.dayObj.sunset.timestamp).tz(props.authInfo.timezone.id).format('M月D日')
+                    list[0] = TimeFormatter.tzTimeFormateLocalTime(global.dayObj.sunrise.timestamp, props.authInfo.timezone.id, 'M月D日')
+                    list[1] = TimeFormatter.tzTimeFormateLocalTime(global.dayObj.sunset.timestamp, props.authInfo.timezone.id, 'M月D日')
+                    // list[0] = dayjs(global.dayObj.sunrise.timestamp).tz(props.authInfo.timezone.id).format('M月D日')
+                    // list[1] = dayjs(global.dayObj.sunset.timestamp).tz(props.authInfo.timezone.id).format('M月D日')
 
                 }
                 timelineItems.push(
@@ -480,7 +487,7 @@ export default function DayNightDetailPopup(props: {
 
     function getTZOffset() {
         var current1 = dayjs()
-        var current = dayjs().tz(props.authInfo.timezone.id)
+        var current = TimeFormatter.tzLocalTime(new Date().getTime(),props.authInfo.timezone.id)//dayjs().tz(props.authInfo.timezone.id)
         var offset = current.date() * 24 * 60 + current.hour() * 60 + current.minute() - current1.date() * 24 * 60 - current1.hour() * 60 - current1.minute()
 
         var hour = Math.floor(Math.abs(offset) / 60)
@@ -505,7 +512,7 @@ export default function DayNightDetailPopup(props: {
 
     function diffentTZDesc() {
         var current1 = dayjs()
-        var current = dayjs().tz(props.authInfo.timezone.id)
+        var current = TimeFormatter.tzLocalTime(new Date().getTime(),props.authInfo.timezone.id)//dayjs().tz(props.authInfo.timezone.id)
         var offset = current.date() * 24 * 60 + current.hour() * 60 + current.minute() - current1.date() * 24 * 60 - current1.hour() * 60 - current1.minute()
         var hour = Math.floor(Math.abs(offset) / 60)
         var minute = Math.abs(offset) % 60

+ 2 - 2
src/features/daynight/DayNightRing.tsx

@@ -77,7 +77,7 @@ export default function DayNightRing(props: {
 
         if (authInfo && authInfo.timezone && authInfo.timezone.id) {
             var current1 = dayjs()
-            var current = dayjs().tz(authInfo.timezone.id)
+            var current = TimeFormatter.tzLocalTime(new Date().getTime(),authInfo.timezone.id)//dayjs().tz(authInfo.timezone.id)
             var offset = current.day() * 24 * 60 + current.hour() * 60 + current.minute() - current1.day() * 24 * 60 - current1.hour() * 60 - current1.minute()
             currentDot.offset = offset
         }
@@ -132,7 +132,7 @@ export default function DayNightRing(props: {
         currentDot.color = ColorType.night
         if (authInfo && authInfo.timezone && authInfo.timezone.id) {
             var current1 = dayjs()
-            var current = dayjs().tz(authInfo.timezone.id)
+            var current = TimeFormatter.tzLocalTime(new Date().getTime(),authInfo.timezone.id)//dayjs().tz(authInfo.timezone.id)
             var offset = current.date() * 24 * 60 + current.hour() * 60 + current.minute() - current1.date() * 24 * 60 - current1.hour() * 60 - current1.minute()
             currentDot.offset = offset
         }

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

@@ -10,6 +10,7 @@
     font-weight: bold;
     font-size: 48px;
     line-height: 48px;
+    height: 48px;
 }
 
 .detail_popup_subttitle {

+ 6 - 2
src/features/trackTimeDuration/components/CircadianDetailPopup.tsx

@@ -246,7 +246,7 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
 
         var fastRing: RealRing = null
         if (props.record.fast) {
-            var timestamp = TimeFormatter.transferTimestamp(props.record.fast.real_start_time, props.record.fast.real_end_timezone?props.record.fast.real_end_timezone.gmt:'')
+            var timestamp = TimeFormatter.transferTimestamp(props.record.fast.real_start_time, props.record.fast.real_end_timezone ? props.record.fast.real_end_timezone.gmt : '')
             fastRing = {
                 color: global.fastColor ? global.fastColor : ColorType.fast,
                 startArc: startArc(timestamp),//startArc(props.record.fast.real_start_time),
@@ -1027,8 +1027,12 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
 
 
     return <View className='detail_container'>
+        <View style={{display:'flex',flexDirection:'row',alignItems:'flex-end'}}>
+            <Text className='detail_popup_title'>{getTitle()}</Text>
+            <Text className='detail_popup_subttitle'> {getSubTitle()}</Text>
+        </View>
 
-        <Text className='detail_popup_title'>{getTitle()}<Text className='detail_popup_subttitle'> {getSubTitle()}</Text></Text>
+        {/* <Text className='detail_popup_title'>{getTitle()}<Text className='detail_popup_subttitle'> {getSubTitle()}</Text></Text> */}
         <View className='detail_tabbar'>
             <View onClick={() => { setTabIndex(0) }} className={tabIndex == 0 ? 'detail_tabitem_sel' : 'detail_tabitem_nor'}>{t('feature.day_night.overview')}</View>
             {

+ 11 - 6
src/features/trackTimeDuration/components/RecordFastSleep.tsx

@@ -20,7 +20,7 @@ import { ColorType } from "@/context/themes/color";
 import TimelineStage from "./TimelineStage";
 import { jumpPage } from "../hooks/Common";
 import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
-import { getTimezone, rpxToPx } from "@/utils/tools";
+import { getTimezone, getTimezoneId, rpxToPx } from "@/utils/tools";
 import { useDispatch, useSelector } from "react-redux";
 import { setSelID } from "@/store/common";
 import CircadianDetailPopup from "./CircadianDetailPopup";
@@ -433,7 +433,7 @@ const RecordFastSleep = memo((props: { data: any, type: string, index: number, d
         if (multiTimeZone) {
             if (props.data.first_timezone.id) {
                 if (Taro.getSystemInfoSync().platform == 'ios') {
-                    if (props.data.first_timezone.id == dayjs.tz.guess()) {
+                    if (props.data.first_timezone.id == getTimezoneId()) {
                         return recordTime()
                     }
                 }
@@ -443,10 +443,12 @@ const RecordFastSleep = memo((props: { data: any, type: string, index: number, d
                     }
                 }
                 if (global.language == 'en') {
-                    return dayjs(props.data.first_real_check_time).tz(props.data.first_timezone.id).format('MMM D z')
+                    return TimeFormatter.tzTimeFormateLocalTime(props.data.first_real_check_time, props.data.first_timezone.id,'MMM D z')
+                    // return dayjs(props.data.first_real_check_time).tz(props.data.first_timezone.id).format('MMM D z')
                 }
                 else {
-                    return dayjs(props.data.first_real_check_time).tz(props.data.first_timezone.id).format('M月D日 z')
+                    return TimeFormatter.tzTimeFormateLocalTime(props.data.first_real_check_time, props.data.first_timezone.id,'M月D日 z')
+                    // return dayjs(props.data.first_real_check_time).tz(props.data.first_timezone.id).format('M月D日 z')
                 }
             }
 
@@ -459,7 +461,7 @@ const RecordFastSleep = memo((props: { data: any, type: string, index: number, d
         if (diffTimeZone) {
             if (props.data.first_timezone.id) {
                 if (Taro.getSystemInfoSync().platform == 'ios') {
-                    if (props.data.first_timezone.id == dayjs.tz.guess()) {
+                    if (props.data.first_timezone.id == getTimezoneId()) {
                         return recordTime()
                     }
                 }
@@ -692,7 +694,10 @@ const RecordFastSleep = memo((props: { data: any, type: string, index: number, d
                 onClick={showDetail}
             >{recordDetail()}
             </RecordItem>
-            <View className={showDel ? 'btnDelete btnDeleteAni' : 'btnDelete'} onClick={tapDel}>{t('feature.track_time_duration.record_fast_sleep.delete')}</View>
+            {
+                process.env.TARO_ENV == 'weapp' && <View className={showDel ? 'btnDelete btnDeleteAni' : 'btnDelete'} onClick={tapDel}>{t('feature.track_time_duration.record_fast_sleep.delete')}</View>
+            }
+            
 
         </View>
         {/* {

+ 2 - 2
src/features/trackTimeDuration/components/TimelineFastSleep.tsx

@@ -293,7 +293,7 @@ export default function TimelineFastSleep(props: {
         var current
         if (props.data.fast) {
             if (props.data.fast.real_start_timezone && props.data.fast.real_start_timezone.id) {
-                current = dayjs().tz(props.data.fast.real_start_timezone.id)
+                current = TimeFormatter.tzLocalTime(new Date().getTime(),props.data.fast.real_start_timezone.id)//dayjs().tz(props.data.fast.real_start_timezone.id)
                 offset = current.date() * 24 * 60 + current.hour() * 60 + current.minute() - current1.date() * 24 * 60 - current1.hour() * 60 - current1.minute()
             }
             else {
@@ -302,7 +302,7 @@ export default function TimelineFastSleep(props: {
         }
         else {
             if (props.data.sleep.real_start_timezone && props.data.sleep.real_start_timezone.id) {
-                current = dayjs().tz(props.data.sleep.real_start_timezone.id)
+                current = TimeFormatter.tzLocalTime(new Date().getTime(),props.data.sleep.real_start_timezone.id)//dayjs().tz(props.data.sleep.real_start_timezone.id)
                 offset = current.date() * 24 * 60 + current.hour() * 60 + current.minute() - current1.date() * 24 * 60 - current1.hour() * 60 - current1.minute()
             }
             else {

+ 2 - 1
src/features/trackTimeDuration/components/WeekCalendarItem.tsx

@@ -58,7 +58,8 @@ export default function WeekCalendarItem(props: { data: any, isCurrentWeek: bool
                 if (item.real_end_timezone.id) {
 
 
-                    var strEnd = dayjs(real_end).tz(item.real_end_timezone.id).format('YYYY-MM-DDTHH:mm:ss')
+                    // var strEnd = dayjs(real_end).tz(item.real_end_timezone.id).format('YYYY-MM-DDTHH:mm:ss')
+                    var strEnd = TimeFormatter.tzTimeFormateLocalTime(real_end, item.real_end_timezone.id,'YYYY-MM-DDTHH:mm:ss')
                     var duration = real_end - real_start
                     // if (index = 1) {
                     //     if (new Date(strEnd)) {

+ 3 - 12
src/pages/clock/Clock.tsx

@@ -18,7 +18,7 @@ import { bigRingRadius, getBgRing, getCommon, getDot, getSchedule, ringWidth, sm
 import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
 import IndexConsole from "@/features/trackTimeDuration/components/IndexConsole";
 import Modal from '@/components/layout/Modal'
-import { compareVersion, getTimezone, getTimezoneName, rpxToPx } from "@/utils/tools";
+import { compareVersion, getTimezone, getTimezoneId, getTimezoneName, rpxToPx } from "@/utils/tools";
 import RecordFastSleep from "@/features/trackTimeDuration/components/RecordFastSleep";
 import DayLight from "@/features/trackTimeDuration/components/DayLight";
 import { getInfo, latestLocation } from "@/services/user";
@@ -51,7 +51,6 @@ import dayjs from 'dayjs'
 import DayNightSwiper from "@/features/daynight/DayNightSwiper";
 import showAlert from "@/components/basic/Alert";
 import { APP_VERSION, WX_VERSION } from "@/services/http/api";
-import { title } from "process";
 
 const utc = require('dayjs/plugin/utc')
 const timezone = require('dayjs/plugin/timezone')
@@ -125,12 +124,6 @@ export default function Page() {
     }
 
     useEffect(() => {
-        // var moment = require('moment-timezone');
-        // var aa = moment(new Date().getTime()).tz("America/Los_Angeles").format('YYYY-MM-DDTHH:mm:ss')
-        // showAlert({
-        //     title:'sss',
-        //     content:aa
-        // })
         dispatch(staticResources() as any);
         timer = setInterval(() => {
             var now = new Date()
@@ -264,8 +257,6 @@ export default function Page() {
         if (userData) {
             dispatch(getInfoSuccess(JSON.parse(userData as string)) as any);
             getHistory()
-
-
         }
 
     })
@@ -465,7 +456,7 @@ export default function Page() {
         var timeZoneId = ''
         var timeZoneName = ''
         if (Taro.getSystemInfoSync().platform == 'ios') {
-            timeZoneId = dayjs.tz.guess()
+            timeZoneId = getTimezoneId()
             timeZoneName = getTimezoneName()
         }
         clientInfo({
@@ -479,7 +470,7 @@ export default function Page() {
                 timezone: {
                     gmt: timeZoneFormatted,
                     id: timeZoneId,
-                    name:timeZoneName
+                    name: timeZoneName
                 },
             },
             device: {

+ 0 - 3
src/pages/clock/StreakDetail.tsx

@@ -32,13 +32,10 @@ export default function StreakDetail() {
     var router
     if (process.env.TARO_ENV == 'rn') {
         router = useRoute()
-        debugger
     }
     else {
         router = useRouter()
     }
-
-    debugger
     // const router = useRouter();
     const intro = JSON.parse((router.params as any).data)
     const isFast = (router.params as any).isFast == 1

+ 0 - 1
src/pages/common/RecordsHistory.scss

@@ -17,7 +17,6 @@
 .fast_sleep_item_bg {
     display: flex;
     flex-direction: column;
-    flex-direction: 0;
 }
 
 .filter_bar {

+ 2 - 5
src/pages/common/RecordsHistory.tsx

@@ -355,9 +355,9 @@ export default function Page() {
     function detail() {
         if (router.params.type == 'time') {
             return <View>
-                {
+                {/* {
                     user.test_user && <Text style={{ color: '#fff', position: 'absolute', right: 50, top: 0 }} onClick={() => global.clearHistory()}>删除全部</Text>
-                }
+                } */}
                 {
                     filters()
                 }
@@ -367,12 +367,9 @@ export default function Page() {
                             <RecordFastSleep key={index}
                                 data={item}
                                 index={index}
-                                // index={index+scenario} 
                                 type='record'
-                            // delSuccess={(item) => removeItem(item)} 
                             />
                         </View>
-                        // return <Schedule key={index} data={item} type="record" delSuccess={(item) => removeItem(item)} />
                     })
                 }
             </View>

+ 11 - 9
src/services/http/request.ts

@@ -5,7 +5,7 @@ import { useDispatch } from "react-redux";
 
 import dayjs from 'dayjs'
 import { APP_VERSION, WX_VERSION } from "./api";
-import { getTimezone, getTimezoneName } from "@/utils/tools";
+import { getTimezone, getTimezoneId, getTimezoneName } from "@/utils/tools";
 import showAlert from "@/components/basic/Alert";
 
 const utc = require('dayjs/plugin/utc')
@@ -73,17 +73,19 @@ export async function request<T>(param: RequestParam): Promise<T> {
         // var timeZoneLocation = Intl.DateTimeFormat().resolvedOptions().timeZone
 
         header['content-type'] = 'application/json'
-        header['X-Time-Zone'] = timeZoneFormatted; //new Date().getTimezoneOffset() / 60
-        // header['X-Time-Zone-Name'] = timeZoneName;
-        if (Taro.getSystemInfoSync().platform == 'ios') {
-            header['X-Time-Zone-Id'] = dayjs.tz.guess() ? dayjs.tz.guess() : '';
-        }
 
-        header['X-Timezone'] = {
-            id:Taro.getSystemInfoSync().platform == 'ios'?dayjs.tz.guess():'',
+        // console.log({
+        //     id:getTimezoneId(),
+        //     name:timeZoneName?timeZoneName:'',
+        //     gmt:timeZoneFormatted
+        // })
+        // debugger
+
+        header['X-Timezone'] = JSON.stringify({
+            id:getTimezoneId(),
             name:timeZoneName?timeZoneName:'',
             gmt:timeZoneFormatted
-        }
+        })
 
 
 

+ 30 - 1
src/utils/time_format.ts

@@ -1,3 +1,12 @@
+const utc = require('dayjs/plugin/utc')
+const timezone = require('dayjs/plugin/timezone')
+import dayjs from 'dayjs'
+
+dayjs.extend(utc)
+dayjs.extend(timezone)
+
+
+
 export class TimeFormatter {
   static nowDuration = 30
 
@@ -354,7 +363,7 @@ export class TimeFormatter {
       start = startTime.getTime()
       end = endTime.getTime()
     }
-    return TimeFormatter.calculateTimeDifference(start, end,showDays)
+    return TimeFormatter.calculateTimeDifference(start, end, showDays)
   }
 
   static durationFormate2(startTimestamp: number, endTimestamp: number) {
@@ -713,4 +722,24 @@ export class TimeFormatter {
     return parseInt(list[0]) * 3600 + parseInt(list[1]) * 60
   }
 
+  static tzTimeFormateLocalTime = (timestamp: number, timeZone: string, formate: string) => {
+    if (process.env.TARO_ENV == 'weapp') {
+      return dayjs(timestamp).tz(timeZone).format(formate)
+    }
+    else {
+      var moment = require('moment-timezone');
+      return moment(timestamp).tz(timeZone).format(formate)
+    }
+  }
+
+  static tzLocalTime = (timestamp: number,timeZone: string) => {
+    if (process.env.TARO_ENV == 'weapp') {
+      return dayjs(timestamp).tz(timeZone)
+    }
+    else {
+      var moment = require('moment-timezone');
+      return moment(timestamp).tz(timeZone)
+    }
+  }
+
 }

+ 20 - 1
src/utils/tools.ts

@@ -1,5 +1,12 @@
 import Taro from "@tarojs/taro";
 
+const utc = require('dayjs/plugin/utc')
+const timezone = require('dayjs/plugin/timezone')
+import dayjs from 'dayjs'
+
+dayjs.extend(utc)
+dayjs.extend(timezone)
+
 export function alphaToHex(alpha) {
     var alphaValue = Math.round(alpha * 255); // 将透明度乘以255并四舍五入
     var hexValue = alphaValue.toString(16); // 将整数转换为十六进制字符串
@@ -102,5 +109,17 @@ export function getTimezoneName(){
         return '';
     }
     return split[1].split(')')[0];
-    
+}
+
+export async function getTimezoneId(){
+    if (process.env.TARO_ENV == 'weapp') {
+        if (Taro.getSystemInfoSync().platform == 'ios') {
+            return dayjs.tz.guess()
+        }
+        return '';
+    }
+    else {
+        var getTimeZone = require('react-native-localize').getTimeZone
+        return await getTimeZone()
+    }
 }

+ 11 - 8
yarn.lock

@@ -14763,20 +14763,13 @@ mobile-detect@^1.4.2:
   resolved "https://registry.npmmirror.com/mobile-detect/-/mobile-detect-1.4.5.tgz#da393c3c413ca1a9bcdd9ced653c38281c0fb6ad"
   integrity sha512-yc0LhH6tItlvfLBugVUEtgawwFU2sIe+cSdmRJJCTMZ5GEJyLxNyC/NIOAOGk67Fa8GNpOttO3Xz/1bHpXFD/g==
 
-moment-timezone@^0.5.34:
+moment-timezone@^0.5.34, moment-timezone@^0.5.45:
   version "0.5.45"
   resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.45.tgz#cb685acd56bac10e69d93c536366eb65aa6bcf5c"
   integrity sha512-HIWmqA86KcmCAhnMAN0wuDOARV/525R2+lOLotuGFzn4HO+FH+/645z2wx0Dt3iDv6/p61SIvKnDstISainhLQ==
   dependencies:
     moment "^2.29.4"
 
-moment-timezone@^0.5.45:
-  version "0.5.45"
-  resolved "https://registry.npmmirror.com/moment-timezone/-/moment-timezone-0.5.45.tgz#cb685acd56bac10e69d93c536366eb65aa6bcf5c"
-  integrity sha512-HIWmqA86KcmCAhnMAN0wuDOARV/525R2+lOLotuGFzn4HO+FH+/645z2wx0Dt3iDv6/p61SIvKnDstISainhLQ==
-  dependencies:
-    moment "^2.29.4"
-
 moment@^2.29.4:
   version "2.30.1"
   resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae"
@@ -16774,6 +16767,11 @@ react-native-linear-gradient@^2.8.3:
   resolved "https://registry.yarnpkg.com/react-native-linear-gradient/-/react-native-linear-gradient-2.8.3.tgz#9a116649f86d74747304ee13db325e20b21e564f"
   integrity sha512-KflAXZcEg54PXkLyflaSZQ3PJp4uC4whM7nT/Uot9m0e/qxFV3p6uor1983D1YOBJbJN7rrWdqIjq0T42jOJyA==
 
+react-native-localize@^3.1.0:
+  version "3.1.0"
+  resolved "https://registry.yarnpkg.com/react-native-localize/-/react-native-localize-3.1.0.tgz#1b322c05af21fd3d78d44e9b747d872ab5155b10"
+  integrity sha512-A7Rrxl8vuAr5FAqtMFrM5ELLdmszohK6FoHL6qlgxx4HScyOnadoZksbvKHbn+zV5nE8kud2Z4kJM10cN120Zg==
+
 react-native-maps@^1.3.2:
   version "1.7.1"
   resolved "https://registry.npmmirror.com/react-native-maps/-/react-native-maps-1.7.1.tgz#e0b9d68542b4b59b5ca3df375ada7c860fb41f2e"
@@ -16870,6 +16868,11 @@ react-native-syan-image-picker@0.5.3:
   resolved "https://registry.npmmirror.com/react-native-syan-image-picker/-/react-native-syan-image-picker-0.5.3.tgz#4d1f164449abac11f60cde337ad1ac22ef554b19"
   integrity sha512-jDHKiv6jPrC3Dslhq2tDjqYC27HE0sNRzpthOY1//THgQpJ0Ht7B6EHvllWVaMw0V41kFVMixLxVQTMu/V7RSw==
 
+react-native-timezone@^3.0.1:
+  version "3.0.1"
+  resolved "https://registry.yarnpkg.com/react-native-timezone/-/react-native-timezone-3.0.1.tgz#028fe136a572b97a8011f175e5501c5efd0b63db"
+  integrity sha512-EElJM9zIfs6yPY2zwZn9JzCpSgXcUg+ZqR057Jlx3dnsVw65fF/2MNiEfwt+x9FaWBKXVDthLOtqNsQ4cs2w4g==
+
 react-native-webview@~11.23.0:
   version "11.23.1"
   resolved "https://registry.npmmirror.com/react-native-webview/-/react-native-webview-11.23.1.tgz#6a4bf2620e491dd4fecf4e6dc079005117fae12c"