Leon 1 anno fa
parent
commit
edadf726a4

+ 2 - 2
src/app.config.ts

@@ -1,6 +1,6 @@
 const appConfig = defineAppConfig({
   pages: [
-    'pages/clock/Index',
+    // 'pages/clock/Index',
     'pages/clock/Clock',
     'pages/demo',
     'pages/food/Food',
@@ -86,7 +86,7 @@ process.env.TARO_ENV === 'weapp' && (appConfig.tabBar = {
   list: [
     {
       // pagePath: 'pages/clock/Clock',
-      pagePath: 'pages/clock/Index',
+      pagePath: 'pages/clock/Clock',
       text: '生物钟',
     },
     {

+ 1 - 1
src/components/navigation/TabBar.tsx

@@ -13,7 +13,7 @@ export default function Component(props: { index: number }) {
             case 0:
 
                 Taro.switchTab({
-                    url: '/pages/clock/Index'
+                    url: '/pages/clock/Clock'
                 })
                 break;
             case 2:

+ 7 - 2
src/context/locales/en.js

@@ -334,10 +334,15 @@ export default {
                 fast_duration: 'Fasting target duration',
                 sleep_duration: 'Sleep target duration',
                 real_fast_start_dt: 'Start time of fasting',
+                real_fast_start_tip:'Expected end time: {{time}}',
                 real_fast_end_dt: 'End time of fasting',
-                real_sleep_start_dt: 'Go-to-sleep time',
+                real_fast_end_tip:'Expected end time: {{time}}',
+                real_sleep_start_dt: 'Bedtime',
+                real_sleep_start_tip:'Expected wake-up time: {{time}}',
                 real_sleep_end_dt: 'Wake-up time',
-                target: 'Target'
+                real_sleep_end_tip:'Expected wake-up time: {{time}}',
+                target: 'Target',
+                
             },
             schedule: {
                 section_title: 'Today',

+ 5 - 1
src/context/locales/zh.js

@@ -337,9 +337,13 @@ export default {
                 fast_duration: '设置断食目标时长',    //时长picker title
                 sleep_duration: '设置睡眠目标时长',
                 real_fast_start_dt: '断食开始时间', //时间picker title
+                real_fast_start_tip:'预计{{time}} 结束',
                 real_fast_end_dt: '断食结束时间',
-                real_sleep_start_dt: '上床睡觉时间',
+                real_fast_end_tip:'原定于{{time}} 结束',
+                real_sleep_start_dt: '就寝时间',
+                real_sleep_start_tip:'预计{{time}} 起床',
                 real_sleep_end_dt: '起床时间',
+                real_sleep_end_tip:'原定于{{time}} 起床',
                 target: '目标'
             },
             schedule: {

+ 27 - 2
src/features/trackTimeDuration/components/ConsolePicker.tsx

@@ -168,17 +168,42 @@ const Component = forwardRef((props: {
         if (global.language == 'en') {
             return TimeFormatter.dateDescription(newDate, true) + ' ' + TimeFormatter.timeDescription(newDate)
         }
-        return TimeFormatter.dateDescription(newDate, true) + '' + TimeFormatter.timeDescription(newDate)
+        return TimeFormatter.dateDescription(newDate, true) + ' ' + TimeFormatter.timeDescription(newDate)
     }
 
     function getEndTimestamp(timestamp) {
         if (global.language == 'en') {
             return TimeFormatter.dateDescription(timestamp, true) + ' ' + TimeFormatter.timeDescription(timestamp)
         }
-        return TimeFormatter.dateDescription(timestamp, true) + '' + TimeFormatter.timeDescription(timestamp)
+        return TimeFormatter.dateDescription(timestamp, true) + ' ' + TimeFormatter.timeDescription(timestamp)
     }
 
+
     function pickerTimeText() {
+        if (props.isTimeout) {
+            if (props.isFast) {
+                return t('feature.track_time_duration.console.real_fast_end_tip',{time:getEndTimestamp(props.endTimestamp!)})
+            }
+            else {
+                return t('feature.track_time_duration.console.real_sleep_end_tip',{time:getEndTimestamp(props.endTimestamp!)})
+            }
+        }
+        if (props.isFast) {
+            if (props.isEnd) {
+                return t('feature.track_time_duration.console.real_fast_end_tip',{time:getEndTimestamp(props.endTimestamp!)})
+            }
+            return t('feature.track_time_duration.console.real_fast_start_tip',{time:getEndTime()})
+        }
+        else {
+            if (props.isEnd) {
+                return t('feature.track_time_duration.console.real_sleep_end_tip',{time:getEndTimestamp(props.endTimestamp!)})
+            }
+            return t('feature.track_time_duration.console.real_sleep_start_tip',{time:getEndTime()})
+
+        }
+    }
+
+    function pickerTimeText2() {
         if (props.isTimeout) {
             if (props.isFast) {
                 return `原定于${getEndTimestamp(props.endTimestamp!)}结束`

+ 5 - 0
src/features/trackTimeDuration/components/Discovery.tsx

@@ -192,6 +192,11 @@ export default function Discovery() {
             durationArc: (duration2 * 60) / (24 * 3600) * 2 * Math.PI
         }
 
+        if (ring.current_record && ring.current_record.scenario == 'SLEEP'){
+            realRing.color = ColorType.activity
+            currentDot.color = ColorType.activity
+        }
+
         if (!user.isLogin) {
             currentDot = null
             realRing = null

+ 3 - 0
src/pages/account/Setting.tsx

@@ -40,6 +40,9 @@ export default function Page() {
                     logout().then(res => {
                         dispatch(logoutSuccess())
                         if (process.env.TARO_ENV == 'weapp') {
+                            Taro.switchTab({
+                                url: '/pages/clock/Clock'
+                            })
                             Taro.navigateBack();
                         }
                         else {

+ 3 - 2
src/pages/clock/Clock.config.ts

@@ -2,7 +2,8 @@ export default definePageConfig({
     usingComponents: {
         // 'ec-canvas': '../../lib/ec-canvas/ec-canvas',
         // 'demo':'../../components/demo'
-        'MySVG':'../../components/basic/svg'
     },
+    // "disableScroll": true,
+    "enablePullDownRefresh": false,
     "navigationBarTitleText": ""
-})
+})

+ 30 - 47
src/pages/clock/Clock.scss

@@ -1,58 +1,41 @@
-/* #ifdef weapp */
-.console_box {
-  display: flex;
-  flex-direction: column;
-  align-items: center;
-  margin: 20px;
-  padding-top: 40px;
-  padding-bottom: 40px;
-  color: #fff;
-  // margin-bottom: 12px;
-  background-color: #1c1c1c;
-  border-radius: 40px;
+@import '@/utils/common.scss';
+.index_container{
+    display: flex;
+    flex-direction: column;
+    color: #fff;
 }
 
-/* #endif */
-
-/* #ifdef rn */
-
-/* #endif */
-
-.popDemo {
-  position: fixed;
-  top: 0;
-  left: 0;
-  z-index: 100000;
-  width: 100%;
-  height: 100%;
-  overflow: hidden;
-  display: flex;
-  justify-content: center;
-  align-items: center;
-  background-color: rgba($color: #000000, $alpha: 0.5);
+.discovery1{
+    margin-left: 46px;
+    font-weight: bold;
+    font-size: 48px;
+    line-height: 48px;
+    margin-bottom: 20px;
 }
 
-.clock_bg {
-  width: 578px;
-  height: 578px;
-  display: flex;
-  align-items: center;
-  justify-content: center;
+.count{
+    opacity: 0;
+    height: 0;
 }
 
-.swiper {
-  height: 360px;
-  
+
+
+.swiper1{
+    height: 850px;
 }
 
-.console_bg {
-  height: 360px;
-  overflow: hidden;
-  margin-bottom: 24px;
+/* #ifdef weapp */
+.fast_sleep_more {
+    background: linear-gradient(90deg, $fastColor 0%, $sleepColor 100%);
+    -webkit-background-clip: text;
+    background-clip: text;
+    color: transparent;
 }
+/* #endif */
 
-.swiperItem {
-  // height: 300px !important;
-  // height: auto !important;
-  // overflow: visible !important;
+.index_more{
+    margin-right: 46px;
+    line-height: 48px;
+    // margin-top: 64px;
+    // margin-bottom: 22px;
 }

+ 547 - 579
src/pages/clock/Clock.tsx

@@ -1,649 +1,617 @@
-import { Component, PropsWithChildren, useEffect, useRef, useState } from 'react'
-import { View, Text, Button, Input, Picker, Swiper, SwiperItem, Icon, PageContainer, ScrollView } from '@tarojs/components'
+import { View, Text, Image, ScrollView, PageContainer, Swiper, SwiperItem, Switch } from "@tarojs/components";
 import Tabbar from "@/components/navigation/TabBar";
-import '../index/index.scss'
+import IndexItem from '@/features/trackTimeDuration/components/IndexItem';
+import Rings from "@/features/trackTimeDuration/components/Rings";
 import './Clock.scss'
-// import './context/locales/index'
-import '@/context/locales/index'
-import Taro, { useDidShow, usePageScroll, useReady, useRouter, useShareAppMessage } from '@tarojs/taro'
-// import ComponentA from './component'
-
-
-import { useDispatch, useSelector } from 'react-redux';
-import { getInfoSuccess, logoutSuccess } from '@/store/user';
-import { wxPubFollow } from '@/services/permission';
-import { gobalConfigs, staticResources, uploadSessionKey } from '@/services/common';
-import Clocks from '@/features/trackTimeDuration/components/Clock';
-import Console from '@/features/trackTimeDuration/components/Console';
-import Schedule from '@/features/trackTimeDuration/components/Schedule';
-import { getChecks, getClocks } from '@/services/trackTimeDuration';
-import { setScenario } from '@/store/scenario';
-
-import { setSpecifiedStatus, setSpecifiedState, machine } from '@/store/trackTimeMachine';
-import trackTimeService from '@/store/trackTimeMachine';
-import { setWXFollow } from '@/store/permission';
-import Tooltip from '@/components/view/Tooltip'
-import RequestType, { thirdPartRequest } from '@/services/thirdPartRequest'
-import { setConfigs, setTabbarStatus } from '@/store/common'
-import RecordFastSleep from '@/features/trackTimeDuration/components/RecordFastSleep'
-import Box from '@/components/layout/Box'
-import Layout from '@/components/layout/layout'
-import { CheckBoxType, NaviBarTitleShowType, TemplateType } from '@/utils/types'
-import { updateScenario } from '@/store/time'
-import { ConsoleType, changeConsoleStatus } from '@/store/console'
-import TitleView from '@/features/trackTimeDuration/components/TitleView'
-import StatusIndicator from '@/features/trackTimeDuration/components/StatusIndicator'
-import { useTranslation } from 'react-i18next'
-import SectionHeader from '@/components/layout/SectionHeader'
-import Header from '@/components/layout/Header'
-import NoData from '@/components/view/NoData'
-import { ColorType } from '@/context/themes/color'
-import { jumpPage } from '@/features/trackTimeDuration/hooks/Common'
-import { ChooseScenarioBtn } from '@/features/common/SpecBtns'
-import { rpxToPx, vibrate } from '@/utils/tools'
+import { useDispatch, useSelector } from "react-redux";
+import { useDidHide, useDidShow, useReady, useShareAppMessage } from "@tarojs/taro";
+import Taro from "@tarojs/taro";
+import { getInfoSuccess } from "@/store/user";
+import { clockHome, clockSummaryRecords, clockSummaryStats, getClockRecords, getClocks, getPlans } from "@/services/trackTimeDuration";
+import { updateScenario } from "@/store/time";
+import { setConfigs } from "@/store/common";
+import { setScenario, setStep } from "@/store/scenario";
+import { useEffect, useState } from "react";
+import { IconPlus, IconRadioCheck, IconRadioCross } from "@/components/basic/Icons";
+import { ColorType } from "@/context/themes/color";
+import { bigRingRadius, getBgRing, getCommon, getDot, getSchedule, ringWidth, smallRingRadius } from "@/features/trackTimeDuration/hooks/RingData";
+import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
+import IndexConsole from "@/features/trackTimeDuration/components/IndexConsole";
 import Modal from '@/components/layout/Modal'
-// import TabBar from '../../components/Tabbar';
-
-// import Rings from '@components/view/Rings';
-
+import { rpxToPx } from "@/utils/tools";
+import RecordFastSleep from "@/features/trackTimeDuration/components/RecordFastSleep";
+import DayLight from "@/features/trackTimeDuration/components/DayLight";
+import { getInfo, latestLocation } from "@/services/user";
+import { TimeFormatter } from "@/utils/time_format";
+import WeekCalendar from "@/features/trackTimeDuration/components/WeekCalendar";
+import { useTranslation } from "react-i18next";
+import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
+import Layout from "@/components/layout/layout";
+import { ModalType, NaviBarTitleShowType, TemplateType } from "@/utils/types";
+import TitleView from "@/features/trackTimeDuration/components/TitleView";
+import ClockHeader from "@/features/trackTimeDuration/components/ClockHeader";
+import DurationPicker from "@/features/trackTimeDuration/components/DurationPicker";
+import SegmentPop from "@/features/trackTimeDuration/components/SegmentPop";
+import Box from "@/components/layout/Box";
+import DayNightCard from "@/features/trackTimeDuration/components/DayNightCard";
+import StageSelector from "@/features/trackTimeDuration/components/StageSelector";
+import { ChooseScenarioBtn } from "@/features/common/SpecBtns";
+import { clearNightStore, showNight } from "@/store/night";
+import { showDay } from "@/store/day";
+import { clientInfo, staticResources } from "@/services/common";
+import { changeFastDuration, changeSleepDuration, setCurrentRecord, setSchedule } from "@/store/ring";
+import { checkAuthorized } from "@/utils/check_authorized";
+import NoData from "@/components/view/NoData";
+import { AtActivityIndicator } from "taro-ui";
+
+let GradientText
 let useNavigation;
+let timer
+let pauseTimer = false;
 let AppState;
+
 if (process.env.TARO_ENV == 'rn') {
-  AppState = require("react-native").AppState
-  useNavigation = require("@react-navigation/native").useNavigation
+    AppState = require("react-native").AppState
+    GradientText = require('@/components/basic/GradientText').default
+    useNavigation = require("@react-navigation/native").useNavigation
 }
 
+const defaultValue = `[{"scenario":{"name":"FAST_SLEEP","count":0,"schedule":{"fast":{"start_time":"15:00","end_time":"08:00"},"sleep":{"start_time":"22:00","end_time":"07:00"}}},"current_record":{"scenario":"FAST_SLEEP","status":"WAIT_FOR_START","fast":{"status":"WAIT_FOR_START","target_start_time":1710514800000,"target_end_time":1710576000000},"sleep":{"status":"WAIT_FOR_START","target_start_time":1710540000000,"target_end_time":1710572400000}},"wx_pub_followed":false,"time_input_schema":{"min":60,"max":1380,"step":5},"theme_color":{"fast":"#00FFFF","sleep":"#8183FF"}},{"scenarios":[{"name":"FAST","count":0,"schedule":{"fast":{"start_time":"15:00","end_time":"08:00"}}},{"name":"SLEEP","count":0,"schedule":{"sleep":{"start_time":"22:00","end_time":"07:00"}}},{"name":"FAST_SLEEP","count":0,"schedule":{"fast":{"start_time":"15:00","end_time":"08:00"},"sleep":{"start_time":"22:00","end_time":"07:00"}}}],"select_count":0,"theme_color":{"fast":"#00FFFF","sleep":"#8183FF"}}]`
 
-export default function IndexPage() {
-  const dispatch = useDispatch();
-  const { t, i18n } = useTranslation()
-  const [checkData, setCheckData] = useState(null)
-  const user = useSelector((state: any) => state.user);
-  const time = useSelector((state: any) => state.time);
-
-  const consoleData = useSelector((state: any) => state.console);
-  const [counter, setCounter] = useState(0)
-  const [timerId, setTimerId] = useState(null)
-  const [needShowAddTip, setNeedShowAddTip] = useState(false)
-  const [showErrorPage, setErrorPage] = useState(false)
-
-  const [swiperIndex, setSwiperIndex] = useState(0)
-  const [autoPlay, setAutoPlay] = useState(false)
-
-  const [showModal, setShowModal] = useState(false)
-  const [modalDetail, setModalDetail] = useState<any>(null)
-
-  const [showModal2, setShowModal2] = useState(false)
-  const [modalDetail2, setModalDetail2] = useState<any>(null)
-  const [showSingleFastEnd, setShowSingleFastEnd] = useState(false)
-  const [consoleStatus, setConsoleStatus] = useState(consoleData.status)
-  const [showLogin, setShowLogin] = useState(false)
-  const [showTip, setShowTip] = useState(false)
-  const [isModal1, setIsModal1] = useState(false)
-  const [debugInfo, setDebugInfo] = useState(null)
-  const [loaded, setLoaded] = useState(false)
-
-  let navigation;
-  if (useNavigation) {
-    navigation = useNavigation()
-  }
-
-  global.dispatch = dispatch;
-
-  global.checkData = () => {
-    getCheckData()
-  }
-
-  useEffect(() => {
-    if (process.env.TARO_ENV == 'rn') {
-      AppState.addEventListener('change', handleAppStateChange);
+export default function Page() {
+    const dispatch = useDispatch();
+    global.dispatch = dispatch;
+    let navigation;
+    if (useNavigation) {
+        navigation = useNavigation()
     }
 
-    global.consoleType = 'idle'
-    dispatch(staticResources() as any);
-    // dispatch(gobalConfigs() as any);
-    trackTimeService.onTransition(state => {
-      if ((state.value as any).FAST_SLEEP == 'COMPLETED' ||
-        (state.value as any).FAST == 'ONGOING' ||
-        (state.value as any).SLEEP == 'ONGOING' ||
-        (state.value as any).FAST_SLEEP == 'ONGOING1' ||
-        (state.value as any).FAST_SLEEP == 'ONGOING2' ||
-        (state.value as any).FAST_SLEEP == 'ONGOING3' ||
-        (state.value as any).FAST == 'COMPLETED' ||
-        (state.value as any).SLEEP == 'COMPLETED') {
-        getCheckData()
-      }
-    })
+    const { t } = useTranslation()
+    const user = useSelector((state: any) => state.user);
+    const time = useSelector((state: any) => state.time);
+    const [count, setCount] = useState(0)
+    const [homeData, setHomeData] = useState(null)
+    const [loaded, setLoaded] = useState(false)
+    const [showErrorPage, setErrorPage] = useState(false)
 
+    const [showModal, setShowModal] = useState(false)
+    const [modalDetail, setModalDetail] = useState<any>(null)
 
-  }, [])
-
-  useEffect(() => {
-
-    const currentLanguage = i18n.language;
-    global.language = currentLanguage
-    console.log('current language', currentLanguage)
-  }, [])
-
-  const handleAppStateChange = (nextAppState) => {
-    checkTimeZone()
-  };
-
-  useEffect(() => {
-    setConsoleStatus(consoleData.status)
-    switch (consoleData.status) {
-      // case ConsoleType.going:
-      //   setShowSingleFastEnd(true)
-      //   setTimeout(() => {
-      //     setShowSingleFastEnd(false)
-      //     setSwiperIndex(1)
-      //     setAutoPlay(true)
-      //     dispatch(changeConsoleStatus({ status: ConsoleType.end }))
-      //   }, 2000)
-      //   break
-      case ConsoleType.end:
-        setTimeout(() => {
-          dispatch(changeConsoleStatus({ status: ConsoleType.idle }))
-        }, 2000)
-
-        break
-    }
-  }, [consoleData.status])
-
-  useEffect(() => {
-    if (user.isLogin) {
-      //检查用户是否添加过小程序
-      checkAddToMini();
-      //检查session是否过期
-      checkSession()
-      getCheckData()
-    }
-  }, [user.isLogin])
+    const [showModal2, setShowModal2] = useState(false)
+    const [modalDetail2, setModalDetail2] = useState<any>(null)
 
-  function checkTimeZone() {
-    var split = new Date().toString().split(' ');
-    var timeZoneFormatted = split[split.length - 2];
+    const [debugInfo, setDebugInfo] = useState(null)
 
+    const [records, setRecords] = useState([])
 
-    Taro.getStorage({
-      key: 'last_tz',
-      success: function (res) {
-        if (res.data && res.data != timeZoneFormatted) {
+    const permission = useSelector((state: any) => state.permission);
+    const common = useSelector((state: any) => state.common);
 
-          if (global.currentStatus != 'WAIT_FOR_START') {
-            Taro.showModal({
-              title: t('feature.track_time_duration.change_tz_alert.title'),
-              content: t('feature.track_time_duration.change_tz_alert.content', { tz: timeZoneFormatted }),
-              showCancel: false,
-              confirmText: t('feature.track_time_duration.change_tz_alert.confirm'),
-            })
+    const nightStore = useSelector((state: any) => state.night);
+    if (process.env.TARO_ENV == 'weapp') {
+        useShareAppMessage((e) => {
+          return {
+            title: t('feature.track_time_duration.common.share_title'),
+            path: 'pages/clock/Clock'
           }
-        }
-      },
-      complete: function () {
-        Taro.setStorage({ key: 'last_tz', data: timeZoneFormatted })
-      }
-    })
-  }
-
-  function checkSession() {
-    if (process.env.TARO_ENV === 'weapp') {
-      thirdPartRequest(RequestType.RequestTypeCheckSession).then(res => {
-      }).catch(err => {
-        console.log('session_key 已经失效,需要更新登录code')
-        thirdPartRequest(RequestType.RequestTypeWXLogin).then(result => {
-          uploadSessionKey({ type: 'WX_MP', code: (result as any).code });
         })
-      })
-    }
-  }
-
-  function checkAddToMini() {
-    process.env.TARO_ENV == 'weapp' &&
-      wx.checkIsAddedToMyMiniProgram({
-        success: (res) => {
-          if (!res.added) {
-            setNeedShowAddTip(true)
-          }
-        },
-        fail: (e) => {
-        }
-      });
-  }
-
-  useEffect(() => {
-    startTimer();
-    return () => {
-      // 在组件卸载时清除定时器
-      if (timerId) {
-        clearInterval(timerId);
       }
-    };
-  }, []);
 
-  const startTimer = () => {
-    // 避免重复启动定时器
-    if (timerId) {
-      return;
-    }
+    useEffect(() => {
+        dispatch(staticResources() as any);
+        timer = setInterval(() => {
+            if (global.pauseIndexTimer || pauseTimer) {
+                return
+            }
+            setCount((prevCounter) => prevCounter + 1)
 
-    const id = setInterval(() => {
-      setShowLogin(true)
-      if (global.showModal) {
-        return
-      }
-      setCounter((prevCounter) => prevCounter + 1);
-      //每天0点刷新一下打卡数据
-      var now = new Date()
-      if (now.getHours() == 0 && now.getMinutes() == 0) {
+        }, 1000)
+    }, [])
+
+    useEffect(() => {
+        if (process.env.TARO_ENV == 'weapp') {
+            loadWXCache()
+        }
+        else {
+            loadRNCache()
+        }
+
+        if (process.env.TARO_ENV == 'rn') {
+            AppState.addEventListener('change', handleAppStateChange);
+        }
+
+    }, [])
+
+    useEffect(() => {
         getCheckData()
-      }
-    }, 1000);
+        global.pauseIndexTimer = !user.isLogin
 
-    setTimerId(id as any);
-  };
+        if (user.isLogin) {
+            uploadUserClient();
 
+            checkAuthorized();
+        }
+        else {
+            dispatch(clearNightStore());
+        }
 
-  useReady(async () => {
+    }, [user.isLogin, time.status])
 
+    useReady(async () => {
+        const userData = await getStorage('userData');
+        if (userData) {
+            dispatch(getInfoSuccess(JSON.parse(userData as string)) as any);
+            getHistory()
 
-    const userData = await getStorage('userData');
-    if (userData) {
-      dispatch(getInfoSuccess(JSON.parse(userData as string)) as any);
-      setTimeout(() => {
-        checkWXPubFollow()
-        getCheckData()
 
-      }, 200)
+        }
 
-    }
-  })
+        // if (process.env.TARO_ENV == 'weapp') {
+        //     useShareAppMessage((e) => {
+        //         return {
+        //             title: t('feature.track_time_duration.common.share_title'),
+        //             path: 'pages/clock/Clock'
+        //         }
+        //     })
+        // }
 
-  if (process.env.TARO_ENV == 'weapp') {
-    useShareAppMessage((e) => {
-      return {
-        title: t('feature.track_time_duration.common.share_title'),
-        path: 'pages/clock/Clock'
-      }
     })
-  }
-
-  function clearTempScenarioCache() {
-    global.schedule_fast = null
-    global.schedule_sleep = null
-    Taro.removeStorage({
-      key: 'tempScenario',
-      success: function (res) {
-      }
+
+    useDidShow(() => {
+        checkTimeZone()
+        setCount(pre => pre + 1)
+        //resume timer
+        pauseTimer = false
+
+        if (user.isLogin) {
+            getInfo().then(res => {
+                dispatch(getInfoSuccess(res))
+            }).catch(e => {
+                Taro.stopPullDownRefresh()
+            })
+        }
+    })
+
+    useDidHide(() => {
+        //pause timer
+        pauseTimer = true
     })
-  }
 
-  usePageScroll((e) => {
-  })
+    global.refreshIndex = () => {
 
-  useDidShow(() => {
-    // global.updateTab(0)
-    global.showModal = false;
-    if (user.isLogin) {
-      checkWXPubFollow()
-      // getCheckData();
+        setCount((prevCounter) => prevCounter + 1)
     }
-    clearTempScenarioCache()
-  })
-
-  global.refreshTime = () => {
-    getCheckData()
-  }
 
-  global.showSingleFastEnd = () => {
-    setShowSingleFastEnd(true)
-  }
+    const handleAppStateChange = (nextAppState) => {
+        checkTimeZone()
+    };
 
-  function tapClock(e) {
-    if (process.env.TARO_ENV == 'weapp') {
-      e.stopPropagation()
-    }
-    if (!user.isLogin) {
-      jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
-    }
-    else {
-      vibrate()
-    }
-  }
-
-  function tapLogin(e) {
-    jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
-  }
-
-  function getCheckData() {
-    var res = global.selectData
-    setErrorPage(false)
-    dispatch(updateScenario((res as any).current_record))
-    dispatch(setConfigs((res as any).time_input_schema));
-    dispatch(setScenario((res as any).scenario));
-
-    if ((res as any).theme_color) {
-      global.fastColor = (res as any).theme_color.fast
-      global.sleepColor = (res as any).theme_color.sleep
+    function checkTimeZone() {
+        var split = new Date().toString().split(' ');
+        var timeZoneFormatted = split[split.length - 2];
+
+
+        Taro.getStorage({
+            key: 'last_tz',
+            success: function (res) {
+                if (res.data && res.data != timeZoneFormatted) {
+
+                    if (global.currentStatus != 'WAIT_FOR_START') {
+                        Taro.showModal({
+                            title: t('feature.track_time_duration.change_tz_alert.title'),
+                            content: t('feature.track_time_duration.change_tz_alert.content', { tz: timeZoneFormatted }),
+                            showCancel: false,
+                            confirmText: t('feature.track_time_duration.change_tz_alert.confirm'),
+                        })
+                    }
+                }
+            },
+            complete: function () {
+                Taro.setStorage({ key: 'last_tz', data: timeZoneFormatted })
+            }
+        })
     }
-    machine.context.checkData = res as any;
-
-    global.scenario = (res as any).current_record.scenario;
-    const currentState = trackTimeService.getSnapshot();
-    let json = {};
-    var key = (res as any).current_record.scenario
-    var status = (res as any).current_record.status
-    json[key] = status
-    currentState.value = json;
-    machine.context.currentStatus = `${key}.${status}`;//'mixed.ON_GOING2'
-    setCheckData(res as any)
-
-    setLoaded(true)
-
-    if ((res as any).current_record.status != 'ONGOING1') {
-      setSwiperIndex(0)
+
+    function uploadUserClient() {
+        var systemInfo = Taro.getSystemInfoSync();
+        console.log(systemInfo)
+        var split = new Date().toString().split(' ');
+        var timeZoneFormatted = split[split.length - 2];
+        clientInfo({
+            client: {
+                client_type: process.env.TARO_ENV == 'weapp' ? 'MP' : 'APP',
+                client_version: process.env.TARO_ENV == 'weapp' ? Taro.getAccountInfoSync().miniProgram.version : '1.0',//'1.0'
+                wx_version: process.env.TARO_ENV == 'weapp' ? systemInfo.version : '_'
+            },
+            meta: {
+                language: systemInfo.language,
+                time_zone: {
+                    id: Intl.DateTimeFormat().resolvedOptions().timeZone,
+                    name: timeZoneFormatted
+                },
+            },
+            device: {
+                brand: systemInfo.brand,
+                model: systemInfo.model,
+                platform: systemInfo.platform,
+                system: systemInfo.system
+            },
+            perm: {
+                wifi_enabled: systemInfo.wifiEnabled,
+                location_authorized: systemInfo.locationAuthorized,
+                location_enabled: systemInfo.locationEnabled
+            }
+        })
     }
-    else {
-      if (global.consoleType == 'going') {
-        setShowSingleFastEnd(true)
-        setTimeout(() => {
-          setShowSingleFastEnd(false)
-          setSwiperIndex(1)
-          setAutoPlay(true)
-          global.consoleType = 'end'
-          dispatch(changeConsoleStatus({ status: ConsoleType.end }))
-          setTimeout(() => {
-            global.consoleType = 'idle'
-          }, 2000)
-        }, 500)
-      }
-      else {
-      }
+
+    function loadWXCache() {
+        var showDayRing = Taro.getStorageSync('showDayRing') || false;
+        var showNightRing = Taro.getStorageSync('showNightRing') || false;
+        dispatch(showDay(showDayRing))
+        dispatch(showNight(showNightRing))
+        var gps = Taro.getStorageSync('gps')
+        if (gps) {
+            global.locationDetail = JSON.parse(gps)
+        }
+        var userData = Taro.getStorageSync('userData')
+        if (userData) {
+            dispatch(getInfoSuccess(JSON.parse(userData)));
+        }
+        // getCheckData()
     }
-    return
-    getClocks().then(res => {
-      debugger
-      setErrorPage(false)
-      dispatch(updateScenario((res as any).current_record))
-      dispatch(setConfigs((res as any).time_input_schema));
-      dispatch(setScenario((res as any).scenario));
-
-      if ((res as any).theme_color) {
-        global.fastColor = (res as any).theme_color.fast
-        global.sleepColor = (res as any).theme_color.sleep
-      }
-      machine.context.checkData = res as any;
-
-      global.scenario = (res as any).current_record.scenario;
-      const currentState = trackTimeService.getSnapshot();
-      let json = {};
-      var key = (res as any).current_record.scenario
-      var status = (res as any).current_record.status
-      json[key] = status
-      currentState.value = json;
-      machine.context.currentStatus = `${key}.${status}`;//'mixed.ON_GOING2'
-      setCheckData(res as any)
-
-      setLoaded(true)
-
-      if ((res as any).current_record.status != 'ONGOING1') {
-        setSwiperIndex(0)
-      }
-      else {
-        if (global.consoleType == 'going') {
-          setShowSingleFastEnd(true)
-          setTimeout(() => {
-            setShowSingleFastEnd(false)
-            setSwiperIndex(1)
-            setAutoPlay(true)
-            global.consoleType = 'end'
-            dispatch(changeConsoleStatus({ status: ConsoleType.end }))
-            setTimeout(() => {
-              global.consoleType = 'idle'
-            }, 2000)
-          }, 500)
+
+    async function loadRNCache() {
+        var showDayRing = await getStorage('showDayRing') || false;
+        var showNightRing = await getStorage('showNightRing') || false;
+        dispatch(showDay(showDayRing))
+        dispatch(showNight(showNightRing))
+        var gps = await getStorage('gps')
+        if (gps) {
+            global.locationDetail = JSON.parse(gps)
         }
-        else {
+        var userData = await getStorage('userData')
+        if (userData) {
+            dispatch(getInfoSuccess(JSON.parse(userData)));
         }
-      }
+        // getCheckData()
+    }
 
-    }).catch(e => {
-      setLoaded(true)
-      if (!checkData) {
-        setErrorPage(true)
-      }
-      else {
-      }
-    })
-  }
 
-  function checkWXPubFollow() {
-    var params;
-    if (global.forceRefreshWXPub) {
-      params = {
-        force_refresh: true
-      }
-    }
-    global.forceRefreshWXPub = false
-    wxPubFollow(params).then(res => {
-      dispatch(setWXFollow((res as any).wx_pub_followed));
-      console.log('当前的关注状态' + (res as any).wx_pub_followed);
+    function getCheckData() {
+        Promise.all([getClocks(), getPlans()]).then((list) => {
+            setErrorPage(false)
+            setCheckData(list)
+        }).catch((e) => {
+            setErrorPage(true)
+            var list = JSON.parse(defaultValue)
+            setCheckData(list)
+        })
 
-    })
-  }
-
-  async function getStorage(key: string) {
-    try {
-      const res = await Taro.getStorage({ key });
-      return res.data;
-    } catch {
-      return '';
+        getHistory()
     }
-  }
 
-  function schedule() {
-    if (!user.isLogin) {
-      return <View />
+    function setCheckData(list: any) {
+        setHomeData(list[0])
+        global.homeData = list[0]
+        global.currentStatus = list[0].current_record.status;
+        var array = list[1].scenarios
+        var schedule = null
+        array.map(item => {
+            if (item.name == 'FAST_SLEEP') {
+                schedule = item.schedule;
+            }
+        })
+        if (user.isLogin) {
+            dispatch(updateScenario(list[0].current_record))
+            dispatch(setConfigs(list[0].time_input_schema));
+            dispatch(setScenario(list[0].scenario));
+
+
+
+            global.scenario = list[0].scenario.name;
+        }
+        dispatch(setCurrentRecord(list[0].current_record))
+        dispatch(setSchedule(schedule))
+        setLoaded(true)
     }
-    return <Schedule data={(checkData as any).current_record} />
-  }
-
-  function needSwiper() {
-    var isNeed = time.scenario == 'FAST_SLEEP' &&
-      (time.status == 'WAIT_FOR_START' ||
-        time.status == 'ONGOING1' ||
-        time.status == 'ONGOING2')
-    if (showSingleFastEnd) {
-      return false;
+
+
+
+    function getHistory() {
+        if (user.isLogin)
+            getClockRecords({
+                page: 1,
+                limit: 1,
+                part_completed: true
+                // completed: true
+            }).then(res => {
+                setRecords((res as any).data)
+            })
     }
-    return isNeed
-  }
-
-  global.showClockModal = (isShow: boolean, detail: any, debugNode?: any) => {
-    global.showModal = isShow
-    setIsModal1(true)
-    setDebugInfo(debugNode)
-    setShowModal(isShow)
-    setModalDetail(detail)
-  }
-
-  global.showClockModal2 = (isShow: boolean, detail: any) => {
-    setDebugInfo(null)
-    global.showModal = isShow
-    setIsModal1(false)
-    setShowModal2(isShow)
-    setModalDetail2(detail)
-  }
-
-  function headerView() {
-    return <TitleView title={t('page.clock.title')} showAddBtn={loaded && !showErrorPage ? true : false}>
-      <StatusIndicator />
-    </TitleView>
-  }
-
-  function errorView() {
-    if (showErrorPage) {
-      return <NoData refresh={() => { getCheckData() }} />
+
+    global.indexPageRefresh = () => {
+        getCheckData()
     }
-    return <View />
-  }
 
-  function consoleView() {
-    if (!checkData) {
-      return <View />
+    global.showIndexModal = (isShow: boolean, detail: any, debugNode?: any) => {
+        global.showModal = isShow
+        setDebugInfo(debugNode)
+        setShowModal(isShow)
+        setModalDetail(detail)
     }
-    return <View className='console_bg'>
-      {
-        needSwiper() ? <Swiper className='swiper' indicatorColor='#333'
-          indicatorActiveColor='#999'
-          current={swiperIndex}
-          autoplay={autoPlay}
-          duration={300}
-          interval={300}
-          indicator-offset={[0, -30]}
-          indicator-height={30}
-          indicatorDots={global.consoleType == 'idle'}
-          onChange={(e) => {
-            setSwiperIndex(e.detail.current)
-            if (e.detail.current == 0)
-              setAutoPlay(false)
-          }}
-        >
-          <SwiperItem className='swiperItem'>
-            <Console />
-
-          </SwiperItem>
-
-          <SwiperItem className='swiperItem'>
-            <Console isNextStep={true} />
-          </SwiperItem>
-        </Swiper> :
-          <Console isNextStep={showSingleFastEnd} />
 
-      }
-    </View>
-  }
+    global.showIndexModal2 = (isShow: boolean, detail: any) => {
+        setDebugInfo(null)
+        global.showModal = isShow
+        setShowModal2(isShow)
+        setModalDetail2(detail)
+    }
 
-  usePageScroll((e) => {
-    if (e.scrollTop > 70) {
-      setShowTip(true)
+    global.changeTargetDuration = (duration: number, isFast: boolean) => {
+        var obj = JSON.parse(JSON.stringify(homeData))
+        var record = obj.current_record
+        if (isFast) {
+            record.fast.target_end_time = record.fast.target_start_time + duration * 60 * 1000
+        }
+        else {
+            record.sleep.target_end_time = record.sleep.target_start_time + duration * 60 * 1000
+        }
+        setHomeData(obj)
     }
-    else {
-      setShowTip(false)
+
+    global.updateFastSleepData = (data: any) => {
+        if (data.id == (homeData as any).current_record.id) {
+            var obj = JSON.parse(JSON.stringify(homeData))
+            obj.current_record = data
+            setHomeData(obj)
+        }
+
+        switch (data.scenario) {
+            case 'FAST':
+                if (data.status == 'WAIT_FOR_START') {
+                    dispatch(changeFastDuration(data.fast.target_end_time - data.fast.target_start_time))
+                }
+                break;
+            case 'SLEEP':
+                if (data.status == 'WAIT_FOR_START') {
+                    dispatch(changeSleepDuration(data.sleep.target_end_time - data.sleep.target_start_time))
+                }
+                break;
+            case 'FAST_SLEEP':
+                if (data.status == 'WAIT_FOR_START') {
+                    dispatch(changeFastDuration(data.fast.target_end_time - data.fast.target_start_time))
+                }
+                else if (data.status == 'ONGOING1') {
+                    debugger
+                    dispatch(changeSleepDuration(data.sleep.target_end_time - data.sleep.target_start_time))
+                }
+                break;
+        }
+
     }
 
-  })
-
-  function modalContent() {
-    if (showModal || showModal2) {
-      if (process.env.TARO_ENV == 'weapp') {
-        return <Modal
-          testInfo={debugInfo}
-          dismiss={() => {
-            setDebugInfo(null)
-            setShowModal(false); setShowModal2(false)
-          }}
-          confirm={() => { }}>
-          {
-            isModal1 ? modalDetail : modalDetail2
-          }
-        </Modal>
-      }
-      else if (process.env.TARO_ENV == 'rn') {
-        return <PageContainer style={{ backgroundColor: '#1c1c1c' }}
-          // overlayStyle='background-color:rgba(0,0,0,0.9)'
-          // custom-style='background-color:#1c1c1c'
-          overlayStyle={{ backgroundColor: 'rgba(0,0,0,0.9)' }}
-          customStyle={{ backgroundColor: '#1c1c1c' }}
-          closeOnSlideDown={false}
-          onBeforeEnter={() => {
-            Taro.hideTabBar();
-          }}
-          onBeforeLeave={() => {
-            Taro.showTabBar();
-          }}
-          onClick={() => { alert('b') }}
-          onClickOverlay={() => { alert('a') }}
-          onAfterLeave={() => { setShowModal(false); setShowModal2(false) }}
-          show={showModal || showModal2} round={true} overlay={true} position='bottom'
-        >
-          {
-            isModal1 ? modalDetail : modalDetail2
-          }
-        </PageContainer>
-      }
+    global.popScheduleAlert = (scenario, startTime) => {
+        if (permission.wxPubFollow) {
+            debugger
+            Taro.showModal({
+                title: t('feature.track_time_duration.reminders.schedule_title'),
+                content: scenario.name == 'FAST' ?
+                    t('feature.track_time_duration.reminders.enable_schedule_fast_content', { time: startTime }) :
+                    t('feature.track_time_duration.reminders.enable_schedule_sleep_content', { time: startTime }),
+                showCancel: false,
+                confirmText: t('feature.track_time_duration.reminders.ok')
+            })
+        }
+        else {
+            debugger
+            Taro.showModal({
+                title: t('feature.track_time_duration.reminders.schedule_title'),
+                content: scenario.name == 'FAST' ?
+                    t('feature.track_time_duration.reminders.schedule_fast_content', { time: startTime }) :
+                    t('feature.track_time_duration.reminders.schedule_sleep_content', { time: startTime }),
+                cancelText: t('feature.track_time_duration.reminders.later'),
+                confirmText: t('feature.track_time_duration.reminders.open'),
+                success: function (res) {
+                    if (res.confirm) {
+                        followWxPub()
+                    } else if (res.cancel) {
+                    }
+                }
+            })
+        }
     }
-    return <View />
-  }
 
+    global.popMixScheduleAlert = (time1, time2) => {
+        if (permission.wxPubFollow) {
+            Taro.showModal({
+                title: t('feature.track_time_duration.reminders.schedule_title'),
+                content: t('feature.track_time_duration.reminders.enable_schedule_mix_content', { time1: time1, time2: time2 }),
+                showCancel: false,
+                confirmText: t('feature.track_time_duration.reminders.ok')
+            })
+        }
+        else {
+            Taro.showModal({
+                title: t('feature.track_time_duration.reminders.schedule_title'),
+                content:
+                    t('feature.track_time_duration.reminders.schedule_mix_content'),
+                    cancelText: t('feature.track_time_duration.reminders.later'),
+                confirmText: t('feature.track_time_duration.reminders.open'),
+                success: function (res) {
+                    if (res.confirm) {
+                        followWxPub()
+                    } else if (res.cancel) {
+                    }
+                }
+                
+            })
+            
+        }
+    }
 
-  function detail() {
-    return (
-      <Layout type={TemplateType.customHeader} header={headerView()} title={t('page.clock.title')} titleShowStyle={NaviBarTitleShowType.scrollToShow}>
-        <View style={{ flex: 1, flexDirection: 'column', display: 'flex', backgroundColor: '#000', color: '#fff' }}>
-          {
-            needShowAddTip && showTip && <Tooltip title="添加到我的小程序" closeTip={() => { setNeedShowAddTip(false) }} />
-          }
+    function followWxPub() {
+        const resource = common.resources.filter((item: any) => {
+            return item.code == 'follow_wx_pub'
+        })
+        jumpPage('/pages/common/H5?title=fast16cc 关注服务号&url=' + resource[0].url)
+    }
 
-          <Box>
-            <View className='clock_bg' onClick={tapClock}>
-              <Clocks showCoverView={!global.showModal} />
-            </View>
-          </Box>
-          {
-            !user.isLogin && showLogin && <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', marginTop: rpxToPx(36) }}>
-              <ChooseScenarioBtn title={t('feature.auth.login.login_now')} background={ColorType.fast} onClick={tapLogin} />
-            </View>
-          }
-          {
-            errorView()
-          }
-          {
-            user.isLogin && consoleView()
-          }
-          {
-            user.isLogin && checkData && schedule()
-          }
-          {
-            user.isLogin && <View style={{ backgroundColor: global.isDebug ? 'pink' : 'transparent' }}>
-              {
-                checkData && (checkData as any).latest_record &&
-                <SectionHeader top={48} bottom={24} title={t('feature.track_time_duration.record_fast_sleep.header.latest_record')}>
-                  <Header title='' action={() => {
-                    jumpPage('/pages/common/RecordsHistory?type=time&title=time', 'RecordsHistory', navigation, {
-                      type: 'time',
-                      title: 'time'
-                    })
-                  }} />
-                </SectionHeader>
-              }
-            </View>
-          }
-          {
-            user.isLogin && checkData && (checkData as any).latest_record &&
-            <RecordFastSleep type='latest' data={(checkData as any).latest_record} delSuccess={getCheckData} index={10000}/>
-          }
-          <View style={{ height: process.env.TARO_ENV == 'rn' ? 0 : 100 }} />
-        </View>
+    function modalContent() {
+        if (showModal || showModal2) {
+            if (process.env.TARO_ENV == 'weapp') {
+                return <Modal
+                    testInfo={debugInfo}
+                    dismiss={() => {
+                        setDebugInfo(null)
+                        setShowModal(false);
+                        setShowModal2(false);
+                        global.pauseIndexTimer = false
+                    }}
+                    confirm={() => { }}>
+                    {
+                        showModal ? modalDetail : modalDetail2
+                    }
+                </Modal>
+            }
+            else if (process.env.TARO_ENV == 'rn') {
+                return <PageContainer style={{ backgroundColor: '#1c1c1c' }}
+                    // overlayStyle='background-color:rgba(0,0,0,0.9)'
+                    // custom-style='background-color:#1c1c1c'
+                    overlayStyle={{ backgroundColor: 'rgba(0,0,0,0.9)' }}
+                    customStyle={{ backgroundColor: '#1c1c1c' }}
+                    closeOnSlideDown={false}
+                    onBeforeEnter={() => {
+                        Taro.hideTabBar();
+                    }}
+                    onBeforeLeave={() => {
+                        Taro.showTabBar();
+                    }}
+                    onClick={() => { alert('b') }}
+                    onClickOverlay={() => { alert('a') }}
+                    onAfterLeave={() => { setShowModal(false); setShowModal2(false); global.pauseIndexTimer = false }}
+                    show={showModal || showModal2} round={true} overlay={true} position='bottom'
+                >
+                    {
+                        showModal ? modalDetail : modalDetail2
+                    }
+                </PageContainer>
+            }
+        }
+        return <View />
+    }
 
-        {
-          modalContent()
+    async function getStorage(key: string) {
+        try {
+            const res = await Taro.getStorage({ key });
+            return res.data;
+        } catch {
+            return '';
         }
+    }
+
+    function more() {
+        jumpPage('/pages/common/RecordsHistory?type=time&title=time', 'RecordsHistory', navigation, {
+            type: 'time',
+            title: 'time'
+        })
+    }
 
-      </Layout>
-    )
-  }
+    function tapLogin() {
+        if (!user.isLogin) {
+            jumpPage('/pages/account/ChooseAuth', 'ChooseAuth')
+            return
+        }
+    }
 
-  // if (process.env.TARO_ENV == 'rn') {
-  //   return <ScrollView>
-  //     {detail()}
-  //   </ScrollView>
-  // }
+    function headerView() {
+        return <ClockHeader homeData={homeData} />
+    }
 
+    var timestamp = new Date().getTime()
 
+    function render() {
+        if (!loaded) {
+            return <Layout type={TemplateType.customHeader} header={headerView()} title={t('page.clock.title')} titleShowStyle={NaviBarTitleShowType.scrollToShow}>
+                <View style={{ width: rpxToPx(750), height: rpxToPx(900), display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
+                    <AtActivityIndicator size={40} color="#fff" />
+                    <Tabbar index={0} />
+                </View>
+            </Layout>
+        }
+        return <Layout type={TemplateType.customHeader} header={headerView()} title={t('page.clock.title')} titleShowStyle={NaviBarTitleShowType.scrollToShow}>
+
+            <View className="index_container">
+                <Text className="count">{count}</Text>
+
+                <Box>
+                    <View>
+                        <IndexItem type="FAST_SLEEP" data={homeData} time={timestamp} showStage={false} />
+                        {
+
+                            user.isLogin ? <IndexConsole record={homeData} /> : <StageSelector />
+                        }
+
+                    </View>
+                </Box>
+
+                <DayNightCard isNight={true} count={count} />
+                {
+                    user.isLogin && records.length > 0 && <View style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', marginTop: rpxToPx(40), }}>
+                        {
+                            <Text className="discovery1" style={{ marginBottom: 0 }}>{t('feature.track_time_duration.record_fast_sleep.header.latest_record')}</Text>
+                        }
+                        {
+                            process.env.TARO_ENV == 'weapp' && <Text className="fast_sleep_more index_more" onClick={more}>{t('feature.track_time_duration.record_fast_sleep.header.btn_show_all')}</Text>
+                        }
+                        {
+                            process.env.TARO_ENV == 'rn' && <GradientText onClick={more} style={{ fontSize: rpxToPx(32), fontWeight: 'bold' }}>{t('feature.track_time_duration.record_fast_sleep.header.btn_show_all')}</GradientText>
+                        }
+                    </View>
+                }
+
+                {
+                    user.isLogin && records.length > 0 && <View className="fast_sleep_item_bg">
+                        <RecordFastSleep data={records[0]} type='record' index={-20000} />
+                    </View>
+                }
+                {
+                    loaded && !user.isLogin && <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', marginTop: rpxToPx(36) }}>
+                        <ChooseScenarioBtn title={t('feature.auth.login.login_now')} background={ColorType.fast} onClick={tapLogin} />
+                    </View>
+                }
+                {
+                    showErrorPage && <NoData refresh={() => { getCheckData() }} />
+                }
+
+                {
+                    user.isLogin && !showErrorPage && <View style={{ marginTop: rpxToPx(60), display: 'flex', flexDirection: 'column' }}>
+                        <Text className="discovery1" >周统计</Text>
+                        <WeekCalendar />
+                    </View>
+                }
+
+                <View style={{ height: 100 }} />
+                {
+                    modalContent()
+                }
+
+                {
+                    homeData && <SegmentPop data={homeData} />
+                }
+                {
+                    homeData && <DurationPicker record={(homeData as any).current_record} />
+                }
+                <Tabbar index={0} />
+            </View>
+        </Layout>
+    }
 
-  return <View>
-    {detail()}
-    {/* <Tabbar index={0} /> */}
-  </View>
+    // if (process.env.TARO_ENV == 'rn') {
+    //     return <ScrollView>
+    //         {
+    //             render()
+    //         }
+    //     </ScrollView>
+    // }
+    return render()
 }

+ 2 - 3
src/pages/clock/Index.config.ts → src/pages/clock/Clock2.config.ts

@@ -2,8 +2,7 @@ export default definePageConfig({
     usingComponents: {
         // 'ec-canvas': '../../lib/ec-canvas/ec-canvas',
         // 'demo':'../../components/demo'
+        'MySVG':'../../components/basic/svg'
     },
-    // "disableScroll": true,
-    "enablePullDownRefresh": false,
     "navigationBarTitleText": ""
-})
+})

+ 58 - 0
src/pages/clock/Clock2.scss

@@ -0,0 +1,58 @@
+/* #ifdef weapp */
+.console_box {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  margin: 20px;
+  padding-top: 40px;
+  padding-bottom: 40px;
+  color: #fff;
+  // margin-bottom: 12px;
+  background-color: #1c1c1c;
+  border-radius: 40px;
+}
+
+/* #endif */
+
+/* #ifdef rn */
+
+/* #endif */
+
+.popDemo {
+  position: fixed;
+  top: 0;
+  left: 0;
+  z-index: 100000;
+  width: 100%;
+  height: 100%;
+  overflow: hidden;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  background-color: rgba($color: #000000, $alpha: 0.5);
+}
+
+.clock_bg {
+  width: 578px;
+  height: 578px;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+.swiper {
+  height: 360px;
+  
+}
+
+.console_bg {
+  height: 360px;
+  overflow: hidden;
+  margin-bottom: 24px;
+}
+
+.swiperItem {
+  // height: 300px !important;
+  // height: auto !important;
+  // overflow: visible !important;
+}

+ 649 - 0
src/pages/clock/Clock2.tsx

@@ -0,0 +1,649 @@
+import { Component, PropsWithChildren, useEffect, useRef, useState } from 'react'
+import { View, Text, Button, Input, Picker, Swiper, SwiperItem, Icon, PageContainer, ScrollView } from '@tarojs/components'
+import Tabbar from "@/components/navigation/TabBar";
+import '../index/index.scss'
+import './Clock.scss'
+// import './context/locales/index'
+import '@/context/locales/index'
+import Taro, { useDidShow, usePageScroll, useReady, useRouter, useShareAppMessage } from '@tarojs/taro'
+// import ComponentA from './component'
+
+
+import { useDispatch, useSelector } from 'react-redux';
+import { getInfoSuccess, logoutSuccess } from '@/store/user';
+import { wxPubFollow } from '@/services/permission';
+import { gobalConfigs, staticResources, uploadSessionKey } from '@/services/common';
+import Clocks from '@/features/trackTimeDuration/components/Clock';
+import Console from '@/features/trackTimeDuration/components/Console';
+import Schedule from '@/features/trackTimeDuration/components/Schedule';
+import { getChecks, getClocks } from '@/services/trackTimeDuration';
+import { setScenario } from '@/store/scenario';
+
+import { setSpecifiedStatus, setSpecifiedState, machine } from '@/store/trackTimeMachine';
+import trackTimeService from '@/store/trackTimeMachine';
+import { setWXFollow } from '@/store/permission';
+import Tooltip from '@/components/view/Tooltip'
+import RequestType, { thirdPartRequest } from '@/services/thirdPartRequest'
+import { setConfigs, setTabbarStatus } from '@/store/common'
+import RecordFastSleep from '@/features/trackTimeDuration/components/RecordFastSleep'
+import Box from '@/components/layout/Box'
+import Layout from '@/components/layout/layout'
+import { CheckBoxType, NaviBarTitleShowType, TemplateType } from '@/utils/types'
+import { updateScenario } from '@/store/time'
+import { ConsoleType, changeConsoleStatus } from '@/store/console'
+import TitleView from '@/features/trackTimeDuration/components/TitleView'
+import StatusIndicator from '@/features/trackTimeDuration/components/StatusIndicator'
+import { useTranslation } from 'react-i18next'
+import SectionHeader from '@/components/layout/SectionHeader'
+import Header from '@/components/layout/Header'
+import NoData from '@/components/view/NoData'
+import { ColorType } from '@/context/themes/color'
+import { jumpPage } from '@/features/trackTimeDuration/hooks/Common'
+import { ChooseScenarioBtn } from '@/features/common/SpecBtns'
+import { rpxToPx, vibrate } from '@/utils/tools'
+import Modal from '@/components/layout/Modal'
+// import TabBar from '../../components/Tabbar';
+
+// import Rings from '@components/view/Rings';
+
+let useNavigation;
+let AppState;
+if (process.env.TARO_ENV == 'rn') {
+  AppState = require("react-native").AppState
+  useNavigation = require("@react-navigation/native").useNavigation
+}
+
+
+export default function IndexPage() {
+  const dispatch = useDispatch();
+  const { t, i18n } = useTranslation()
+  const [checkData, setCheckData] = useState(null)
+  const user = useSelector((state: any) => state.user);
+  const time = useSelector((state: any) => state.time);
+
+  const consoleData = useSelector((state: any) => state.console);
+  const [counter, setCounter] = useState(0)
+  const [timerId, setTimerId] = useState(null)
+  const [needShowAddTip, setNeedShowAddTip] = useState(false)
+  const [showErrorPage, setErrorPage] = useState(false)
+
+  const [swiperIndex, setSwiperIndex] = useState(0)
+  const [autoPlay, setAutoPlay] = useState(false)
+
+  const [showModal, setShowModal] = useState(false)
+  const [modalDetail, setModalDetail] = useState<any>(null)
+
+  const [showModal2, setShowModal2] = useState(false)
+  const [modalDetail2, setModalDetail2] = useState<any>(null)
+  const [showSingleFastEnd, setShowSingleFastEnd] = useState(false)
+  const [consoleStatus, setConsoleStatus] = useState(consoleData.status)
+  const [showLogin, setShowLogin] = useState(false)
+  const [showTip, setShowTip] = useState(false)
+  const [isModal1, setIsModal1] = useState(false)
+  const [debugInfo, setDebugInfo] = useState(null)
+  const [loaded, setLoaded] = useState(false)
+
+  let navigation;
+  if (useNavigation) {
+    navigation = useNavigation()
+  }
+
+  global.dispatch = dispatch;
+
+  global.checkData = () => {
+    getCheckData()
+  }
+
+  useEffect(() => {
+    if (process.env.TARO_ENV == 'rn') {
+      AppState.addEventListener('change', handleAppStateChange);
+    }
+
+    global.consoleType = 'idle'
+    dispatch(staticResources() as any);
+    // dispatch(gobalConfigs() as any);
+    trackTimeService.onTransition(state => {
+      if ((state.value as any).FAST_SLEEP == 'COMPLETED' ||
+        (state.value as any).FAST == 'ONGOING' ||
+        (state.value as any).SLEEP == 'ONGOING' ||
+        (state.value as any).FAST_SLEEP == 'ONGOING1' ||
+        (state.value as any).FAST_SLEEP == 'ONGOING2' ||
+        (state.value as any).FAST_SLEEP == 'ONGOING3' ||
+        (state.value as any).FAST == 'COMPLETED' ||
+        (state.value as any).SLEEP == 'COMPLETED') {
+        getCheckData()
+      }
+    })
+
+
+  }, [])
+
+  useEffect(() => {
+
+    const currentLanguage = i18n.language;
+    global.language = currentLanguage
+    console.log('current language', currentLanguage)
+  }, [])
+
+  const handleAppStateChange = (nextAppState) => {
+    checkTimeZone()
+  };
+
+  useEffect(() => {
+    setConsoleStatus(consoleData.status)
+    switch (consoleData.status) {
+      // case ConsoleType.going:
+      //   setShowSingleFastEnd(true)
+      //   setTimeout(() => {
+      //     setShowSingleFastEnd(false)
+      //     setSwiperIndex(1)
+      //     setAutoPlay(true)
+      //     dispatch(changeConsoleStatus({ status: ConsoleType.end }))
+      //   }, 2000)
+      //   break
+      case ConsoleType.end:
+        setTimeout(() => {
+          dispatch(changeConsoleStatus({ status: ConsoleType.idle }))
+        }, 2000)
+
+        break
+    }
+  }, [consoleData.status])
+
+  useEffect(() => {
+    if (user.isLogin) {
+      //检查用户是否添加过小程序
+      checkAddToMini();
+      //检查session是否过期
+      checkSession()
+      getCheckData()
+    }
+  }, [user.isLogin])
+
+  function checkTimeZone() {
+    var split = new Date().toString().split(' ');
+    var timeZoneFormatted = split[split.length - 2];
+
+
+    Taro.getStorage({
+      key: 'last_tz',
+      success: function (res) {
+        if (res.data && res.data != timeZoneFormatted) {
+
+          if (global.currentStatus != 'WAIT_FOR_START') {
+            Taro.showModal({
+              title: t('feature.track_time_duration.change_tz_alert.title'),
+              content: t('feature.track_time_duration.change_tz_alert.content', { tz: timeZoneFormatted }),
+              showCancel: false,
+              confirmText: t('feature.track_time_duration.change_tz_alert.confirm'),
+            })
+          }
+        }
+      },
+      complete: function () {
+        Taro.setStorage({ key: 'last_tz', data: timeZoneFormatted })
+      }
+    })
+  }
+
+  function checkSession() {
+    if (process.env.TARO_ENV === 'weapp') {
+      thirdPartRequest(RequestType.RequestTypeCheckSession).then(res => {
+      }).catch(err => {
+        console.log('session_key 已经失效,需要更新登录code')
+        thirdPartRequest(RequestType.RequestTypeWXLogin).then(result => {
+          uploadSessionKey({ type: 'WX_MP', code: (result as any).code });
+        })
+      })
+    }
+  }
+
+  function checkAddToMini() {
+    process.env.TARO_ENV == 'weapp' &&
+      wx.checkIsAddedToMyMiniProgram({
+        success: (res) => {
+          if (!res.added) {
+            setNeedShowAddTip(true)
+          }
+        },
+        fail: (e) => {
+        }
+      });
+  }
+
+  useEffect(() => {
+    startTimer();
+    return () => {
+      // 在组件卸载时清除定时器
+      if (timerId) {
+        clearInterval(timerId);
+      }
+    };
+  }, []);
+
+  const startTimer = () => {
+    // 避免重复启动定时器
+    if (timerId) {
+      return;
+    }
+
+    const id = setInterval(() => {
+      setShowLogin(true)
+      if (global.showModal) {
+        return
+      }
+      setCounter((prevCounter) => prevCounter + 1);
+      //每天0点刷新一下打卡数据
+      var now = new Date()
+      if (now.getHours() == 0 && now.getMinutes() == 0) {
+        getCheckData()
+      }
+    }, 1000);
+
+    setTimerId(id as any);
+  };
+
+
+  useReady(async () => {
+
+
+    const userData = await getStorage('userData');
+    if (userData) {
+      dispatch(getInfoSuccess(JSON.parse(userData as string)) as any);
+      setTimeout(() => {
+        checkWXPubFollow()
+        getCheckData()
+
+      }, 200)
+
+    }
+  })
+
+  if (process.env.TARO_ENV == 'weapp') {
+    useShareAppMessage((e) => {
+      return {
+        title: t('feature.track_time_duration.common.share_title'),
+        path: 'pages/clock/Clock'
+      }
+    })
+  }
+
+  function clearTempScenarioCache() {
+    global.schedule_fast = null
+    global.schedule_sleep = null
+    Taro.removeStorage({
+      key: 'tempScenario',
+      success: function (res) {
+      }
+    })
+  }
+
+  usePageScroll((e) => {
+  })
+
+  useDidShow(() => {
+    // global.updateTab(0)
+    global.showModal = false;
+    if (user.isLogin) {
+      checkWXPubFollow()
+      // getCheckData();
+    }
+    clearTempScenarioCache()
+  })
+
+  global.refreshTime = () => {
+    getCheckData()
+  }
+
+  global.showSingleFastEnd = () => {
+    setShowSingleFastEnd(true)
+  }
+
+  function tapClock(e) {
+    if (process.env.TARO_ENV == 'weapp') {
+      e.stopPropagation()
+    }
+    if (!user.isLogin) {
+      jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+    }
+    else {
+      vibrate()
+    }
+  }
+
+  function tapLogin(e) {
+    jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+  }
+
+  function getCheckData() {
+    var res = global.selectData
+    setErrorPage(false)
+    dispatch(updateScenario((res as any).current_record))
+    dispatch(setConfigs((res as any).time_input_schema));
+    dispatch(setScenario((res as any).scenario));
+
+    if ((res as any).theme_color) {
+      global.fastColor = (res as any).theme_color.fast
+      global.sleepColor = (res as any).theme_color.sleep
+    }
+    machine.context.checkData = res as any;
+
+    global.scenario = (res as any).current_record.scenario;
+    const currentState = trackTimeService.getSnapshot();
+    let json = {};
+    var key = (res as any).current_record.scenario
+    var status = (res as any).current_record.status
+    json[key] = status
+    currentState.value = json;
+    machine.context.currentStatus = `${key}.${status}`;//'mixed.ON_GOING2'
+    setCheckData(res as any)
+
+    setLoaded(true)
+
+    if ((res as any).current_record.status != 'ONGOING1') {
+      setSwiperIndex(0)
+    }
+    else {
+      if (global.consoleType == 'going') {
+        setShowSingleFastEnd(true)
+        setTimeout(() => {
+          setShowSingleFastEnd(false)
+          setSwiperIndex(1)
+          setAutoPlay(true)
+          global.consoleType = 'end'
+          dispatch(changeConsoleStatus({ status: ConsoleType.end }))
+          setTimeout(() => {
+            global.consoleType = 'idle'
+          }, 2000)
+        }, 500)
+      }
+      else {
+      }
+    }
+    return
+    getClocks().then(res => {
+      debugger
+      setErrorPage(false)
+      dispatch(updateScenario((res as any).current_record))
+      dispatch(setConfigs((res as any).time_input_schema));
+      dispatch(setScenario((res as any).scenario));
+
+      if ((res as any).theme_color) {
+        global.fastColor = (res as any).theme_color.fast
+        global.sleepColor = (res as any).theme_color.sleep
+      }
+      machine.context.checkData = res as any;
+
+      global.scenario = (res as any).current_record.scenario;
+      const currentState = trackTimeService.getSnapshot();
+      let json = {};
+      var key = (res as any).current_record.scenario
+      var status = (res as any).current_record.status
+      json[key] = status
+      currentState.value = json;
+      machine.context.currentStatus = `${key}.${status}`;//'mixed.ON_GOING2'
+      setCheckData(res as any)
+
+      setLoaded(true)
+
+      if ((res as any).current_record.status != 'ONGOING1') {
+        setSwiperIndex(0)
+      }
+      else {
+        if (global.consoleType == 'going') {
+          setShowSingleFastEnd(true)
+          setTimeout(() => {
+            setShowSingleFastEnd(false)
+            setSwiperIndex(1)
+            setAutoPlay(true)
+            global.consoleType = 'end'
+            dispatch(changeConsoleStatus({ status: ConsoleType.end }))
+            setTimeout(() => {
+              global.consoleType = 'idle'
+            }, 2000)
+          }, 500)
+        }
+        else {
+        }
+      }
+
+    }).catch(e => {
+      setLoaded(true)
+      if (!checkData) {
+        setErrorPage(true)
+      }
+      else {
+      }
+    })
+  }
+
+  function checkWXPubFollow() {
+    var params;
+    if (global.forceRefreshWXPub) {
+      params = {
+        force_refresh: true
+      }
+    }
+    global.forceRefreshWXPub = false
+    wxPubFollow(params).then(res => {
+      dispatch(setWXFollow((res as any).wx_pub_followed));
+      console.log('当前的关注状态' + (res as any).wx_pub_followed);
+
+    })
+  }
+
+  async function getStorage(key: string) {
+    try {
+      const res = await Taro.getStorage({ key });
+      return res.data;
+    } catch {
+      return '';
+    }
+  }
+
+  function schedule() {
+    if (!user.isLogin) {
+      return <View />
+    }
+    return <Schedule data={(checkData as any).current_record} />
+  }
+
+  function needSwiper() {
+    var isNeed = time.scenario == 'FAST_SLEEP' &&
+      (time.status == 'WAIT_FOR_START' ||
+        time.status == 'ONGOING1' ||
+        time.status == 'ONGOING2')
+    if (showSingleFastEnd) {
+      return false;
+    }
+    return isNeed
+  }
+
+  global.showClockModal = (isShow: boolean, detail: any, debugNode?: any) => {
+    global.showModal = isShow
+    setIsModal1(true)
+    setDebugInfo(debugNode)
+    setShowModal(isShow)
+    setModalDetail(detail)
+  }
+
+  global.showClockModal2 = (isShow: boolean, detail: any) => {
+    setDebugInfo(null)
+    global.showModal = isShow
+    setIsModal1(false)
+    setShowModal2(isShow)
+    setModalDetail2(detail)
+  }
+
+  function headerView() {
+    return <TitleView title={t('page.clock.title')} showAddBtn={loaded && !showErrorPage ? true : false}>
+      <StatusIndicator />
+    </TitleView>
+  }
+
+  function errorView() {
+    if (showErrorPage) {
+      return <NoData refresh={() => { getCheckData() }} />
+    }
+    return <View />
+  }
+
+  function consoleView() {
+    if (!checkData) {
+      return <View />
+    }
+    return <View className='console_bg'>
+      {
+        needSwiper() ? <Swiper className='swiper' indicatorColor='#333'
+          indicatorActiveColor='#999'
+          current={swiperIndex}
+          autoplay={autoPlay}
+          duration={300}
+          interval={300}
+          indicator-offset={[0, -30]}
+          indicator-height={30}
+          indicatorDots={global.consoleType == 'idle'}
+          onChange={(e) => {
+            setSwiperIndex(e.detail.current)
+            if (e.detail.current == 0)
+              setAutoPlay(false)
+          }}
+        >
+          <SwiperItem className='swiperItem'>
+            <Console />
+
+          </SwiperItem>
+
+          <SwiperItem className='swiperItem'>
+            <Console isNextStep={true} />
+          </SwiperItem>
+        </Swiper> :
+          <Console isNextStep={showSingleFastEnd} />
+
+      }
+    </View>
+  }
+
+  usePageScroll((e) => {
+    if (e.scrollTop > 70) {
+      setShowTip(true)
+    }
+    else {
+      setShowTip(false)
+    }
+
+  })
+
+  function modalContent() {
+    if (showModal || showModal2) {
+      if (process.env.TARO_ENV == 'weapp') {
+        return <Modal
+          testInfo={debugInfo}
+          dismiss={() => {
+            setDebugInfo(null)
+            setShowModal(false); setShowModal2(false)
+          }}
+          confirm={() => { }}>
+          {
+            isModal1 ? modalDetail : modalDetail2
+          }
+        </Modal>
+      }
+      else if (process.env.TARO_ENV == 'rn') {
+        return <PageContainer style={{ backgroundColor: '#1c1c1c' }}
+          // overlayStyle='background-color:rgba(0,0,0,0.9)'
+          // custom-style='background-color:#1c1c1c'
+          overlayStyle={{ backgroundColor: 'rgba(0,0,0,0.9)' }}
+          customStyle={{ backgroundColor: '#1c1c1c' }}
+          closeOnSlideDown={false}
+          onBeforeEnter={() => {
+            Taro.hideTabBar();
+          }}
+          onBeforeLeave={() => {
+            Taro.showTabBar();
+          }}
+          onClick={() => { alert('b') }}
+          onClickOverlay={() => { alert('a') }}
+          onAfterLeave={() => { setShowModal(false); setShowModal2(false) }}
+          show={showModal || showModal2} round={true} overlay={true} position='bottom'
+        >
+          {
+            isModal1 ? modalDetail : modalDetail2
+          }
+        </PageContainer>
+      }
+    }
+    return <View />
+  }
+
+
+  function detail() {
+    return (
+      <Layout type={TemplateType.customHeader} header={headerView()} title={t('page.clock.title')} titleShowStyle={NaviBarTitleShowType.scrollToShow}>
+        <View style={{ flex: 1, flexDirection: 'column', display: 'flex', backgroundColor: '#000', color: '#fff' }}>
+          {
+            needShowAddTip && showTip && <Tooltip title="添加到我的小程序" closeTip={() => { setNeedShowAddTip(false) }} />
+          }
+
+          <Box>
+            <View className='clock_bg' onClick={tapClock}>
+              <Clocks showCoverView={!global.showModal} />
+            </View>
+          </Box>
+          {
+            !user.isLogin && showLogin && <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', marginTop: rpxToPx(36) }}>
+              <ChooseScenarioBtn title={t('feature.auth.login.login_now')} background={ColorType.fast} onClick={tapLogin} />
+            </View>
+          }
+          {
+            errorView()
+          }
+          {
+            user.isLogin && consoleView()
+          }
+          {
+            user.isLogin && checkData && schedule()
+          }
+          {
+            user.isLogin && <View style={{ backgroundColor: global.isDebug ? 'pink' : 'transparent' }}>
+              {
+                checkData && (checkData as any).latest_record &&
+                <SectionHeader top={48} bottom={24} title={t('feature.track_time_duration.record_fast_sleep.header.latest_record')}>
+                  <Header title='' action={() => {
+                    jumpPage('/pages/common/RecordsHistory?type=time&title=time', 'RecordsHistory', navigation, {
+                      type: 'time',
+                      title: 'time'
+                    })
+                  }} />
+                </SectionHeader>
+              }
+            </View>
+          }
+          {
+            user.isLogin && checkData && (checkData as any).latest_record &&
+            <RecordFastSleep type='latest' data={(checkData as any).latest_record} delSuccess={getCheckData} index={10000}/>
+          }
+          <View style={{ height: process.env.TARO_ENV == 'rn' ? 0 : 100 }} />
+        </View>
+
+        {
+          modalContent()
+        }
+
+      </Layout>
+    )
+  }
+
+  // if (process.env.TARO_ENV == 'rn') {
+  //   return <ScrollView>
+  //     {detail()}
+  //   </ScrollView>
+  // }
+
+
+
+  return <View>
+    {detail()}
+    {/* <Tabbar index={0} /> */}
+  </View>
+}

+ 0 - 41
src/pages/clock/Index.scss

@@ -1,41 +0,0 @@
-@import '@/utils/common.scss';
-.index_container{
-    display: flex;
-    flex-direction: column;
-    color: #fff;
-}
-
-.discovery1{
-    margin-left: 46px;
-    font-weight: bold;
-    font-size: 48px;
-    line-height: 48px;
-    margin-bottom: 20px;
-}
-
-.count{
-    opacity: 0;
-    height: 0;
-}
-
-
-
-.swiper1{
-    height: 850px;
-}
-
-/* #ifdef weapp */
-.fast_sleep_more {
-    background: linear-gradient(90deg, $fastColor 0%, $sleepColor 100%);
-    -webkit-background-clip: text;
-    background-clip: text;
-    color: transparent;
-}
-/* #endif */
-
-.index_more{
-    margin-right: 46px;
-    line-height: 48px;
-    // margin-top: 64px;
-    // margin-bottom: 22px;
-}

+ 0 - 610
src/pages/clock/Index.tsx

@@ -1,610 +0,0 @@
-import { View, Text, Image, ScrollView, PageContainer, Swiper, SwiperItem, Switch } from "@tarojs/components";
-import Tabbar from "@/components/navigation/TabBar";
-import IndexItem from '@/features/trackTimeDuration/components/IndexItem';
-import Rings from "@/features/trackTimeDuration/components/Rings";
-import './Index.scss'
-import { useDispatch, useSelector } from "react-redux";
-import { useDidHide, useDidShow, useReady, useShareAppMessage } from "@tarojs/taro";
-import Taro from "@tarojs/taro";
-import { getInfoSuccess } from "@/store/user";
-import { clockHome, clockSummaryRecords, clockSummaryStats, getClockRecords, getClocks, getPlans } from "@/services/trackTimeDuration";
-import { updateScenario } from "@/store/time";
-import { setConfigs } from "@/store/common";
-import { setScenario, setStep } from "@/store/scenario";
-import { useEffect, useState } from "react";
-import { IconPlus, IconRadioCheck, IconRadioCross } from "@/components/basic/Icons";
-import { ColorType } from "@/context/themes/color";
-import { bigRingRadius, getBgRing, getCommon, getDot, getSchedule, ringWidth, smallRingRadius } from "@/features/trackTimeDuration/hooks/RingData";
-import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
-import IndexConsole from "@/features/trackTimeDuration/components/IndexConsole";
-import Modal from '@/components/layout/Modal'
-import { rpxToPx } from "@/utils/tools";
-import RecordFastSleep from "@/features/trackTimeDuration/components/RecordFastSleep";
-import DayLight from "@/features/trackTimeDuration/components/DayLight";
-import { getInfo, latestLocation } from "@/services/user";
-import { TimeFormatter } from "@/utils/time_format";
-import WeekCalendar from "@/features/trackTimeDuration/components/WeekCalendar";
-import { useTranslation } from "react-i18next";
-import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
-import Layout from "@/components/layout/layout";
-import { ModalType, NaviBarTitleShowType, TemplateType } from "@/utils/types";
-import TitleView from "@/features/trackTimeDuration/components/TitleView";
-import ClockHeader from "@/features/trackTimeDuration/components/ClockHeader";
-import DurationPicker from "@/features/trackTimeDuration/components/DurationPicker";
-import SegmentPop from "@/features/trackTimeDuration/components/SegmentPop";
-import Box from "@/components/layout/Box";
-import DayNightCard from "@/features/trackTimeDuration/components/DayNightCard";
-import StageSelector from "@/features/trackTimeDuration/components/StageSelector";
-import { ChooseScenarioBtn } from "@/features/common/SpecBtns";
-import { clearNightStore, showNight } from "@/store/night";
-import { showDay } from "@/store/day";
-import { clientInfo, staticResources } from "@/services/common";
-import { changeFastDuration, changeSleepDuration, setCurrentRecord, setSchedule } from "@/store/ring";
-import { checkAuthorized } from "@/utils/check_authorized";
-import NoData from "@/components/view/NoData";
-import { AtActivityIndicator } from "taro-ui";
-
-let GradientText
-let useNavigation;
-let timer
-let pauseTimer = false;
-let AppState;
-
-if (process.env.TARO_ENV == 'rn') {
-    AppState = require("react-native").AppState
-    GradientText = require('@/components/basic/GradientText').default
-    useNavigation = require("@react-navigation/native").useNavigation
-}
-
-const defaultValue = `[{"scenario":{"name":"FAST_SLEEP","count":0,"schedule":{"fast":{"start_time":"15:00","end_time":"08:00"},"sleep":{"start_time":"22:00","end_time":"07:00"}}},"current_record":{"scenario":"FAST_SLEEP","status":"WAIT_FOR_START","fast":{"status":"WAIT_FOR_START","target_start_time":1710514800000,"target_end_time":1710576000000},"sleep":{"status":"WAIT_FOR_START","target_start_time":1710540000000,"target_end_time":1710572400000}},"wx_pub_followed":false,"time_input_schema":{"min":60,"max":1380,"step":5},"theme_color":{"fast":"#00FFFF","sleep":"#8183FF"}},{"scenarios":[{"name":"FAST","count":0,"schedule":{"fast":{"start_time":"15:00","end_time":"08:00"}}},{"name":"SLEEP","count":0,"schedule":{"sleep":{"start_time":"22:00","end_time":"07:00"}}},{"name":"FAST_SLEEP","count":0,"schedule":{"fast":{"start_time":"15:00","end_time":"08:00"},"sleep":{"start_time":"22:00","end_time":"07:00"}}}],"select_count":0,"theme_color":{"fast":"#00FFFF","sleep":"#8183FF"}}]`
-
-export default function Page() {
-    const dispatch = useDispatch();
-    global.dispatch = dispatch;
-    let navigation;
-    if (useNavigation) {
-        navigation = useNavigation()
-    }
-
-    const { t } = useTranslation()
-    const user = useSelector((state: any) => state.user);
-    const time = useSelector((state: any) => state.time);
-    const [count, setCount] = useState(0)
-    const [homeData, setHomeData] = useState(null)
-    const [loaded, setLoaded] = useState(false)
-    const [showErrorPage, setErrorPage] = useState(false)
-
-    const [showModal, setShowModal] = useState(false)
-    const [modalDetail, setModalDetail] = useState<any>(null)
-
-    const [showModal2, setShowModal2] = useState(false)
-    const [modalDetail2, setModalDetail2] = useState<any>(null)
-
-    const [debugInfo, setDebugInfo] = useState(null)
-
-    const [records, setRecords] = useState([])
-
-    const permission = useSelector((state: any) => state.permission);
-    const common = useSelector((state: any) => state.common);
-
-    const nightStore = useSelector((state: any) => state.night);
-
-
-    useEffect(() => {
-        dispatch(staticResources() as any);
-        timer = setInterval(() => {
-            if (global.pauseIndexTimer || pauseTimer) {
-                return
-            }
-            setCount((prevCounter) => prevCounter + 1)
-
-        }, 1000)
-    }, [])
-
-    useEffect(() => {
-        if (process.env.TARO_ENV == 'weapp') {
-            loadWXCache()
-        }
-        else {
-            loadRNCache()
-        }
-
-        if (process.env.TARO_ENV == 'rn') {
-            AppState.addEventListener('change', handleAppStateChange);
-        }
-
-    }, [])
-
-    useEffect(() => {
-        getCheckData()
-        global.pauseIndexTimer = !user.isLogin
-
-        if (user.isLogin) {
-            uploadUserClient();
-
-            checkAuthorized();
-        }
-        else {
-            dispatch(clearNightStore());
-        }
-
-    }, [user.isLogin, time.status])
-
-    useReady(async () => {
-        const userData = await getStorage('userData');
-        if (userData) {
-            dispatch(getInfoSuccess(JSON.parse(userData as string)) as any);
-            getHistory()
-
-
-        }
-
-        // if (process.env.TARO_ENV == 'weapp') {
-        //     useShareAppMessage((e) => {
-        //         return {
-        //             title: t('feature.track_time_duration.common.share_title'),
-        //             path: 'pages/clock/Clock'
-        //         }
-        //     })
-        // }
-
-    })
-
-    useDidShow(() => {
-        checkTimeZone()
-        setCount(pre => pre + 1)
-        //resume timer
-        pauseTimer = false
-
-        if (user.isLogin) {
-            getInfo().then(res => {
-                dispatch(getInfoSuccess(res))
-            }).catch(e => {
-                Taro.stopPullDownRefresh()
-            })
-        }
-    })
-
-    useDidHide(() => {
-        //pause timer
-        pauseTimer = true
-    })
-
-    global.refreshIndex = () => {
-
-        setCount((prevCounter) => prevCounter + 1)
-    }
-
-    const handleAppStateChange = (nextAppState) => {
-        checkTimeZone()
-    };
-
-    function checkTimeZone() {
-        var split = new Date().toString().split(' ');
-        var timeZoneFormatted = split[split.length - 2];
-
-
-        Taro.getStorage({
-            key: 'last_tz',
-            success: function (res) {
-                if (res.data && res.data != timeZoneFormatted) {
-
-                    if (global.currentStatus != 'WAIT_FOR_START') {
-                        Taro.showModal({
-                            title: t('feature.track_time_duration.change_tz_alert.title'),
-                            content: t('feature.track_time_duration.change_tz_alert.content', { tz: timeZoneFormatted }),
-                            showCancel: false,
-                            confirmText: t('feature.track_time_duration.change_tz_alert.confirm'),
-                        })
-                    }
-                }
-            },
-            complete: function () {
-                Taro.setStorage({ key: 'last_tz', data: timeZoneFormatted })
-            }
-        })
-    }
-
-    function uploadUserClient() {
-        var systemInfo = Taro.getSystemInfoSync();
-        console.log(systemInfo)
-        var split = new Date().toString().split(' ');
-        var timeZoneFormatted = split[split.length - 2];
-        clientInfo({
-            client: {
-                client_type: process.env.TARO_ENV == 'weapp' ? 'MP' : 'APP',
-                client_version: process.env.TARO_ENV == 'weapp' ? Taro.getAccountInfoSync().miniProgram.version : '1.0',//'1.0'
-                wx_version: process.env.TARO_ENV == 'weapp' ? systemInfo.version : '_'
-            },
-            meta: {
-                language: systemInfo.language,
-                time_zone: {
-                    id: Intl.DateTimeFormat().resolvedOptions().timeZone,
-                    name: timeZoneFormatted
-                },
-            },
-            device: {
-                brand: systemInfo.brand,
-                model: systemInfo.model,
-                platform: systemInfo.platform,
-                system: systemInfo.system
-            },
-            perm: {
-                wifi_enabled: systemInfo.wifiEnabled,
-                location_authorized: systemInfo.locationAuthorized,
-                location_enabled: systemInfo.locationEnabled
-            }
-        })
-    }
-
-    function loadWXCache() {
-        var showDayRing = Taro.getStorageSync('showDayRing') || false;
-        var showNightRing = Taro.getStorageSync('showNightRing') || false;
-        dispatch(showDay(showDayRing))
-        dispatch(showNight(showNightRing))
-        var gps = Taro.getStorageSync('gps')
-        if (gps) {
-            global.locationDetail = JSON.parse(gps)
-        }
-        var userData = Taro.getStorageSync('userData')
-        if (userData) {
-            dispatch(getInfoSuccess(JSON.parse(userData)));
-        }
-        // getCheckData()
-    }
-
-    async function loadRNCache() {
-        var showDayRing = await getStorage('showDayRing') || false;
-        var showNightRing = await getStorage('showNightRing') || false;
-        dispatch(showDay(showDayRing))
-        dispatch(showNight(showNightRing))
-        var gps = await getStorage('gps')
-        if (gps) {
-            global.locationDetail = JSON.parse(gps)
-        }
-        var userData = await getStorage('userData')
-        if (userData) {
-            dispatch(getInfoSuccess(JSON.parse(userData)));
-        }
-        // getCheckData()
-    }
-
-
-    function getCheckData() {
-        Promise.all([getClocks(), getPlans()]).then((list) => {
-            setErrorPage(false)
-            setCheckData(list)
-        }).catch((e) => {
-            setErrorPage(true)
-            var list = JSON.parse(defaultValue)
-            setCheckData(list)
-        })
-
-        getHistory()
-    }
-
-    function setCheckData(list: any) {
-        setHomeData(list[0])
-        global.homeData = list[0]
-        global.currentStatus = list[0].current_record.status;
-        var array = list[1].scenarios
-        var schedule = null
-        array.map(item => {
-            if (item.name == 'FAST_SLEEP') {
-                schedule = item.schedule;
-            }
-        })
-        if (user.isLogin) {
-            dispatch(updateScenario(list[0].current_record))
-            dispatch(setConfigs(list[0].time_input_schema));
-            dispatch(setScenario(list[0].scenario));
-
-
-
-            global.scenario = list[0].scenario.name;
-        }
-        dispatch(setCurrentRecord(list[0].current_record))
-        dispatch(setSchedule(schedule))
-        setLoaded(true)
-    }
-
-
-
-    function getHistory() {
-        if (user.isLogin)
-            getClockRecords({
-                page: 1,
-                limit: 1,
-                part_completed: true
-                // completed: true
-            }).then(res => {
-                setRecords((res as any).data)
-            })
-    }
-
-    global.indexPageRefresh = () => {
-        getCheckData()
-    }
-
-    global.showIndexModal = (isShow: boolean, detail: any, debugNode?: any) => {
-        global.showModal = isShow
-        setDebugInfo(debugNode)
-        setShowModal(isShow)
-        setModalDetail(detail)
-    }
-
-    global.showIndexModal2 = (isShow: boolean, detail: any) => {
-        setDebugInfo(null)
-        global.showModal = isShow
-        setShowModal2(isShow)
-        setModalDetail2(detail)
-    }
-
-    global.changeTargetDuration = (duration: number, isFast: boolean) => {
-        var obj = JSON.parse(JSON.stringify(homeData))
-        var record = obj.current_record
-        if (isFast) {
-            record.fast.target_end_time = record.fast.target_start_time + duration * 60 * 1000
-        }
-        else {
-            record.sleep.target_end_time = record.sleep.target_start_time + duration * 60 * 1000
-        }
-        setHomeData(obj)
-    }
-
-    global.updateFastSleepData = (data: any) => {
-        if (data.id == (homeData as any).current_record.id) {
-            var obj = JSON.parse(JSON.stringify(homeData))
-            obj.current_record = data
-            setHomeData(obj)
-        }
-
-        switch (data.scenario) {
-            case 'FAST':
-                if (data.status == 'WAIT_FOR_START') {
-                    dispatch(changeFastDuration(data.fast.target_end_time - data.fast.target_start_time))
-                }
-                break;
-            case 'SLEEP':
-                if (data.status == 'WAIT_FOR_START') {
-                    dispatch(changeSleepDuration(data.sleep.target_end_time - data.sleep.target_start_time))
-                }
-                break;
-            case 'FAST_SLEEP':
-                if (data.status == 'WAIT_FOR_START') {
-                    dispatch(changeFastDuration(data.fast.target_end_time - data.fast.target_start_time))
-                }
-                else if (data.status == 'ONGOING1') {
-                    debugger
-                    dispatch(changeSleepDuration(data.sleep.target_end_time - data.sleep.target_start_time))
-                }
-                break;
-        }
-
-    }
-
-    global.popScheduleAlert = (scenario, startTime) => {
-        if (permission.wxPubFollow) {
-            debugger
-            Taro.showModal({
-                title: t('feature.track_time_duration.reminders.schedule_title'),
-                content: scenario.name == 'FAST' ?
-                    t('feature.track_time_duration.reminders.enable_schedule_fast_content', { time: startTime }) :
-                    t('feature.track_time_duration.reminders.enable_schedule_sleep_content', { time: startTime }),
-                showCancel: false,
-                confirmText: t('feature.track_time_duration.reminders.ok')
-            })
-        }
-        else {
-            debugger
-            Taro.showModal({
-                title: t('feature.track_time_duration.reminders.schedule_title'),
-                content: scenario.name == 'FAST' ?
-                    t('feature.track_time_duration.reminders.schedule_fast_content', { time: startTime }) :
-                    t('feature.track_time_duration.reminders.schedule_sleep_content', { time: startTime }),
-                cancelText: t('feature.track_time_duration.reminders.later'),
-                confirmText: t('feature.track_time_duration.reminders.open'),
-                success: function (res) {
-                    if (res.confirm) {
-                        followWxPub()
-                    } else if (res.cancel) {
-                    }
-                }
-            })
-        }
-    }
-
-    global.popMixScheduleAlert = (time1, time2) => {
-        if (permission.wxPubFollow) {
-            Taro.showModal({
-                title: t('feature.track_time_duration.reminders.schedule_title'),
-                content: t('feature.track_time_duration.reminders.enable_schedule_mix_content', { time1: time1, time2: time2 }),
-                showCancel: false,
-                confirmText: t('feature.track_time_duration.reminders.ok')
-            })
-        }
-        else {
-            Taro.showModal({
-                title: t('feature.track_time_duration.reminders.schedule_title'),
-                content:
-                    t('feature.track_time_duration.reminders.schedule_mix_content'),
-                    cancelText: t('feature.track_time_duration.reminders.later'),
-                confirmText: t('feature.track_time_duration.reminders.open'),
-                success: function (res) {
-                    if (res.confirm) {
-                        followWxPub()
-                    } else if (res.cancel) {
-                    }
-                }
-                
-            })
-            
-        }
-    }
-
-    function followWxPub() {
-        const resource = common.resources.filter((item: any) => {
-            return item.code == 'follow_wx_pub'
-        })
-        jumpPage('/pages/common/H5?title=fast16cc 关注服务号&url=' + resource[0].url)
-    }
-
-    function modalContent() {
-        if (showModal || showModal2) {
-            if (process.env.TARO_ENV == 'weapp') {
-                return <Modal
-                    testInfo={debugInfo}
-                    dismiss={() => {
-                        setDebugInfo(null)
-                        setShowModal(false);
-                        setShowModal2(false);
-                        global.pauseIndexTimer = false
-                    }}
-                    confirm={() => { }}>
-                    {
-                        showModal ? modalDetail : modalDetail2
-                    }
-                </Modal>
-            }
-            else if (process.env.TARO_ENV == 'rn') {
-                return <PageContainer style={{ backgroundColor: '#1c1c1c' }}
-                    // overlayStyle='background-color:rgba(0,0,0,0.9)'
-                    // custom-style='background-color:#1c1c1c'
-                    overlayStyle={{ backgroundColor: 'rgba(0,0,0,0.9)' }}
-                    customStyle={{ backgroundColor: '#1c1c1c' }}
-                    closeOnSlideDown={false}
-                    onBeforeEnter={() => {
-                        Taro.hideTabBar();
-                    }}
-                    onBeforeLeave={() => {
-                        Taro.showTabBar();
-                    }}
-                    onClick={() => { alert('b') }}
-                    onClickOverlay={() => { alert('a') }}
-                    onAfterLeave={() => { setShowModal(false); setShowModal2(false); global.pauseIndexTimer = false }}
-                    show={showModal || showModal2} round={true} overlay={true} position='bottom'
-                >
-                    {
-                        showModal ? modalDetail : modalDetail2
-                    }
-                </PageContainer>
-            }
-        }
-        return <View />
-    }
-
-    async function getStorage(key: string) {
-        try {
-            const res = await Taro.getStorage({ key });
-            return res.data;
-        } catch {
-            return '';
-        }
-    }
-
-    function more() {
-        jumpPage('/pages/common/RecordsHistory?type=time&title=time', 'RecordsHistory', navigation, {
-            type: 'time',
-            title: 'time'
-        })
-    }
-
-    function tapLogin() {
-        if (!user.isLogin) {
-            jumpPage('/pages/account/ChooseAuth', 'ChooseAuth')
-            return
-        }
-    }
-
-    function headerView() {
-        return <ClockHeader homeData={homeData} />
-    }
-
-    var timestamp = new Date().getTime()
-
-    function render() {
-        if (!loaded) {
-            return <Layout type={TemplateType.customHeader} header={headerView()} title={t('page.clock.title')} titleShowStyle={NaviBarTitleShowType.scrollToShow}>
-                <View style={{ width: rpxToPx(750), height: rpxToPx(900), display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
-                    <AtActivityIndicator size={40} color="#fff" />
-                    <Tabbar index={0} />
-                </View>
-            </Layout>
-        }
-        return <Layout type={TemplateType.customHeader} header={headerView()} title={t('page.clock.title')} titleShowStyle={NaviBarTitleShowType.scrollToShow}>
-
-            <View className="index_container">
-                <Text className="count">{count}</Text>
-
-                <Box>
-                    <View>
-                        <IndexItem type="FAST_SLEEP" data={homeData} time={timestamp} showStage={false} />
-                        {
-
-                            user.isLogin ? <IndexConsole record={homeData} /> : <StageSelector />
-                        }
-
-                    </View>
-                </Box>
-
-                <DayNightCard isNight={true} count={count} />
-                {
-                    user.isLogin && records.length > 0 && <View style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', marginTop: rpxToPx(40), }}>
-                        {
-                            <Text className="discovery1" style={{ marginBottom: 0 }}>{t('feature.track_time_duration.record_fast_sleep.header.latest_record')}</Text>
-                        }
-                        {
-                            process.env.TARO_ENV == 'weapp' && <Text className="fast_sleep_more index_more" onClick={more}>{t('feature.track_time_duration.record_fast_sleep.header.btn_show_all')}</Text>
-                        }
-                        {
-                            process.env.TARO_ENV == 'rn' && <GradientText onClick={more} style={{ fontSize: rpxToPx(32), fontWeight: 'bold' }}>{t('feature.track_time_duration.record_fast_sleep.header.btn_show_all')}</GradientText>
-                        }
-                    </View>
-                }
-
-                {
-                    user.isLogin && records.length > 0 && <View className="fast_sleep_item_bg">
-                        <RecordFastSleep data={records[0]} type='record' index={-20000} />
-                    </View>
-                }
-                {
-                    loaded && !user.isLogin && <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', marginTop: rpxToPx(36) }}>
-                        <ChooseScenarioBtn title={t('feature.auth.login.login_now')} background={ColorType.fast} onClick={tapLogin} />
-                    </View>
-                }
-                {
-                    showErrorPage && <NoData refresh={() => { getCheckData() }} />
-                }
-
-                {
-                    user.isLogin && !showErrorPage && <View style={{ marginTop: rpxToPx(60), display: 'flex', flexDirection: 'column' }}>
-                        <Text className="discovery1" >周统计</Text>
-                        <WeekCalendar />
-                    </View>
-                }
-
-                <View style={{ height: 100 }} />
-                {
-                    modalContent()
-                }
-
-                {
-                    homeData && <SegmentPop data={homeData} />
-                }
-                {
-                    homeData && <DurationPicker record={(homeData as any).current_record} />
-                }
-                <Tabbar index={0} />
-            </View>
-        </Layout>
-    }
-
-    // if (process.env.TARO_ENV == 'rn') {
-    //     return <ScrollView>
-    //         {
-    //             render()
-    //         }
-    //     </ScrollView>
-    // }
-    return render()
-}