Leon 1 tahun lalu
induk
melakukan
d4eb72d37c

+ 10 - 5
src/features/trackTimeDuration/components/DayLight.tsx

@@ -2,7 +2,8 @@ import { useEffect, useState } from 'react'
 import './DayLight.scss'
 import { View, Text, Switch, Image } from '@tarojs/components'
 import Taro from '@tarojs/taro'
-import { useSelector } from 'react-redux'
+import { useDispatch, useSelector } from 'react-redux'
+import { updateMember } from '@/store/day_night'
 export default function DayLight() {
     const [showRing, setShowRing] = useState(false)
     const [isTomorrow, setIsTomorrow] = useState(false)
@@ -11,14 +12,16 @@ export default function DayLight() {
     const [authInfo, setAuthInfo] = useState(null)
     const [sunriseTime, setSunriseTime] = useState('06:00')
     const [sunsetTime, setSunsetTime] = useState('18:00')
-
+    const dayNight = useSelector((state: any) => state.dayNight);
     const user = useSelector((state: any) => state.user);
+    const dispatch = useDispatch();
 
     useEffect(() => { getContent() }, [])
 
     useEffect(() => {
         setIsMember(user.test_user)
-        if (user.test_user) {
+        dispatch(updateMember({ isMember: user.test_user,authInfo }))
+        if (user.test_user && authInfo) {
             setSunriseTime('07:00')
             setSunsetTime('19:00')
         }
@@ -26,7 +29,7 @@ export default function DayLight() {
             setSunriseTime('06:00')
             setSunsetTime('18:00')
         }
-    }, [user.test_user])
+    }, [user.test_user,authInfo])
 
     async function getStorage(key: string) {
         try {
@@ -47,6 +50,7 @@ export default function DayLight() {
         const gpsInfo = await getStorage('gps') || null
         if (gpsInfo) {
             setAuthInfo(JSON.parse(gpsInfo))
+            dispatch(updateMember({ isMember: user.test_user, gpsInfo: JSON.parse(gpsInfo) }))
         }
         else {
             setAuthInfo(null)
@@ -91,6 +95,7 @@ export default function DayLight() {
                     key: 'gps',
                     data: JSON.stringify(res as any)
                 })
+                dispatch(updateMember({ isMember: user.test_user, gpsInfo: (res as any) }))
             },
             fail(res) {
                 Taro.showToast({
@@ -109,7 +114,7 @@ export default function DayLight() {
 
     return <View>
         <View className='daylight_row'>
-            <Text>{isNight ? 'Night ring' : 'Day ring'}</Text>
+            <Text>Night ring</Text>
             <Switch checked={showRing}
                 onChange={(e) => {
                     setShowRing(e.detail.value)

+ 24 - 5
src/features/trackTimeDuration/components/IndexItem.tsx

@@ -1,5 +1,5 @@
 import { View, Text, Image } from "@tarojs/components";
-import { getBgRing, getCommon, getDot, getReal, getSchedule, getTarget } from "../hooks/RingData";
+import { dotIsOuterRange, getBgRing, getCommon, getDot, getReal, getSchedule, getTarget } from "../hooks/RingData";
 import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
 import Rings from "./Rings";
 import './IndexItem.scss'
@@ -9,6 +9,7 @@ import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 import { TimeFormatter } from "@/utils/time_format";
 import { useSelector } from "react-redux";
 import { useEffect, useState } from "react";
+import Taro from "@tarojs/taro";
 
 let useNavigation;
 if (process.env.TARO_ENV == 'rn') {
@@ -18,6 +19,7 @@ export default function Component(props: { type: string, data: any, time: any })
     const { t } = useTranslation()
     const record = props.data.current_record;
     const user = useSelector((state: any) => state.user);
+    const dayNight = useSelector((state: any) => state.dayNight);
     const [stageList, setStageList] = useState([true, false, false])
     const [isStageMode, setIsStageMode] = useState(false)
     let navigation;
@@ -90,6 +92,10 @@ export default function Component(props: { type: string, data: any, time: any })
                 if (props.type == 'FAST_SLEEP') {
                     realRing1.color = ColorType.fast + '66'
 
+                    if (dotIsOuterRange(true, record.fast)) {
+                        currentDot1.color = ColorType.ring
+                    }
+
                     if (stageList[0]) {
 
                         const realRingBig: RealRing = {
@@ -148,6 +154,10 @@ export default function Component(props: { type: string, data: any, time: any })
                 else if (record.status == 'WAIT_FOR_START' || record.status == 'ONGOING1') {
                     realRing = getSchedule(record, false, true)
                     var currentDot = getDot(record, false)
+                    if (record.status == 'WAIT_FOR_START' && dotIsOuterRange(true, record.sleep)) {
+                        currentDot.color = ColorType.ring
+                    }
+
                     return <Rings common={common} bgRing={bgRing} currentDot={isStageMode ? null : currentDot} realRing={realRing} canvasId={props.type + props.time + 'small'} />
                 }
                 else if (record.sleep.status == 'NOT_COMPLETED') {
@@ -194,12 +204,21 @@ export default function Component(props: { type: string, data: any, time: any })
             startArc: 0,
             durationArc: 2
         }
-        var sunRise = 24 * 60 + (user.test_user ? 7 * 60 : 6 * 60)
-        var sunSet = user.test_user ? 19 * 60 : 18 * 60
+        var sunRise = 24 * 60 + (dayNight.gpsInfo && dayNight.isMember ? 7 * 60 : 6 * 60)
+        var sunSet = dayNight.gpsInfo && dayNight.isMember ? 19 * 60 : 18 * 60
         var duration = sunRise - sunSet
         realRingBig.startArc = (sunSet * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
         realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
-        return <Rings common={common} bgRing={bgRing} realRing={realRingBig} canvasId={props.type + props.time + 'day'} />
+
+        var currentDot = getDot(record, false)
+        if (dotIsOuterRange(false, null, { sunrise: dayNight.sunRise, sunset: dayNight.sunSet })) {
+            currentDot.color = ColorType.ring
+        }
+        else {
+            currentDot.color = ColorType.night + '66'
+        }
+
+        return <Rings common={common} bgRing={bgRing} realRing={realRingBig} currentDot={currentDot} canvasId={props.type + props.time + 'day'} />
     }
 
     function rings() {
@@ -290,7 +309,7 @@ export default function Component(props: { type: string, data: any, time: any })
                 }
                 {
                     props.type == 'FAST_SLEEP' && user.isLogin && global.showNightRing === true &&
-                    <Text className="duration_value" style={{color:ColorType.night}}>12小时</Text>
+                    <Text className="duration_value" style={{ color: ColorType.night }}>12小时</Text>
                 }
                 {
                     (props.type == 'FAST' || props.type == 'FAST_SLEEP') && <Text className="duration_title">{t('feature.track_time_duration.record_fast_sleep.item.fast')}</Text>

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

@@ -0,0 +1,82 @@
+.calendar_summary_top {
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+    margin-left: 46px;
+}
+
+.calendar_summary_item {
+    display: flex;
+    flex-direction: column;
+    width: 300px;
+}
+
+.calendar_summary_title {
+    font-size: 28px;
+    line-height: 28px;
+    color: #fff;
+    opacity: 0.6;
+}
+
+.calendar_summary_value {
+    margin-top: 6px;
+    font-size: 36px;
+    line-height: 36px;
+    font-weight: bold;
+    margin-bottom: 20px;
+}
+
+.calendar_summary_desc {
+    font-size: 24px;
+    line-height: 24px;
+    margin-left: 46px;
+    color: #fff;
+    opacity: 0.4;
+}
+
+.chart_bg {
+    width: 750px;
+    height: 520px;
+    background-color: #212121;
+    display: flex;
+    flex-direction: row;
+    position: relative;
+}
+
+.chart_scroll {
+    flex: 1;
+    margin-left: 46px;
+    border-radius: 16px;
+    overflow: hidden;
+    height: 520px;
+    width: 658px;
+    display: flex;
+    flex-direction: row;
+}
+
+.chart_content_bg{
+    position: absolute;
+    left: 46px;
+    right: 46px;
+    top: 60px;
+    bottom: 60px;
+    border-radius: 16px;
+    background: linear-gradient(180deg, #1C1C1C, #000000,#1C1C1C);
+}
+
+
+.chart_times {
+    width: 46px;
+    display: flex;
+    flex-direction: column;
+    justify-content: space-between;
+    margin-top: 60px;
+    margin-bottom: 60px;
+}
+
+.chart_times_txt {
+    font-size: 16px;
+    line-height: 16px;
+    color: #fff;
+    opacity: 0.4;
+}

+ 40 - 0
src/features/trackTimeDuration/components/WeekCalendar.tsx

@@ -0,0 +1,40 @@
+import { View, ScrollView, Text } from "@tarojs/components";
+import './WeekCalendar.scss'
+import { useState } from "react";
+import { ColorType } from "@/context/themes/color";
+import WeekCalendarItem from "./WeekCalendarItem";
+export default function WeekCalendar(props: { calendars: any }) {
+    const [current, setCurrent] = useState(props.calendars.length - 1)
+    return <View>
+        <View className="calendar_summary_top">
+            <View className="calendar_summary_item">
+                <Text className="calendar_summary_title">断食平均</Text>
+                <Text className="calendar_summary_value" style={{ color: ColorType.fast }}>123</Text>
+            </View>
+            <View className="calendar_summary_item">
+                <Text className="calendar_summary_title">睡眠平均</Text>
+                <Text className="calendar_summary_value" style={{ color: ColorType.sleep }}>123</Text>
+            </View>
+        </View>
+        <Text className="calendar_summary_desc">2月25日 周日中午 - 3月3日 周日中午</Text>
+        <View className="chart_bg">
+            <View className="chart_content_bg" />
+            <ScrollView className="chart_scroll" scrollX pagingEnabled={true} enableFlex enhanced>
+                {
+                    props.calendars.map((item) => {
+                        return <WeekCalendarItem />
+                    })
+                }
+
+            </ScrollView>
+            <View className="chart_times">
+                <Text className="chart_times_txt">12:00</Text>
+                <Text className="chart_times_txt">18:00</Text>
+                <Text className="chart_times_txt">24:00</Text>
+                <Text className="chart_times_txt">06:00</Text>
+                <Text className="chart_times_txt">12:00</Text>
+            </View>
+        </View>
+
+    </View>
+}

+ 38 - 0
src/features/trackTimeDuration/components/WeekCalendarItem.scss

@@ -0,0 +1,38 @@
+.chart_content{
+    display: flex;
+    flex-direction: column;
+    height: 520px;
+    width: 658px;
+    flex-shrink: 0;
+}
+
+.chart_top_week{
+    margin-top: 20px;
+    height: 40px;
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+}
+
+.chart_bottom_week{
+    margin-bottom: 20px;
+    height: 40px;
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+}
+
+.chart_detail{
+    display: flex;
+    position: relative;
+    flex: 1;
+}
+
+.chart_week_text{
+    font-size: 20px;
+    line-height: 40px;
+    color: #fff;
+    opacity: 0.4;
+    width: 86px;
+    margin-left: 8px;
+}

+ 25 - 0
src/features/trackTimeDuration/components/WeekCalendarItem.tsx

@@ -0,0 +1,25 @@
+import { View, Text } from "@tarojs/components";
+import './WeekCalendarItem.scss'
+export default function WeekCalendarItem() {
+    return <View className="chart_content">
+        <View className="chart_top_week">
+            <Text className="chart_week_text">周日</Text>
+            <Text className="chart_week_text">周一</Text>
+            <Text className="chart_week_text">周二</Text>
+            <Text className="chart_week_text">周三</Text>
+            <Text className="chart_week_text">周四</Text>
+            <Text className="chart_week_text">周五</Text>
+            <Text className="chart_week_text">周六</Text>
+        </View>
+        <View className="chart_detail"></View>
+        <View className="chart_bottom_week">
+            <Text className="chart_week_text">周一</Text>
+            <Text className="chart_week_text">周二</Text>
+            <Text className="chart_week_text">周三</Text>
+            <Text className="chart_week_text">周四</Text>
+            <Text className="chart_week_text">周五</Text>
+            <Text className="chart_week_text">周六</Text>
+            <Text className="chart_week_text">周日</Text>
+        </View>
+    </View>
+}

+ 24 - 1
src/features/trackTimeDuration/hooks/RingData.tsx

@@ -83,6 +83,29 @@ export const getDot = (data: any, isBigRing: boolean) => {
     }
 }
 
+export const dotIsOuterRange = (isTargetRange: boolean, scheduleData?: any, dayLightData?: any) => {
+    var date = new Date()
+    var minutes = date.getHours() * 60 + date.getMinutes()
+    if (isTargetRange) {
+
+        var scheduleStart = new Date(scheduleData!.target_start_time)
+        var scheduleEnd = new Date(scheduleData!.target_end_time)
+        var startMinute = scheduleStart.getHours() * 60 + scheduleStart.getMinutes()
+        var endMinute = scheduleEnd.getHours() * 60 + scheduleStart.getMinutes()
+        if (startMinute <= minutes && endMinute > minutes) {
+            return false;
+        }
+        return true;
+    }
+
+    var startMinute = parseInt(dayLightData.sunrise.split(':')[0]) * 60 + parseInt(dayLightData.sunrise.split(':')[1])
+    var endMinute = parseInt(dayLightData.sunset.split(':')[0]) * 60 + parseInt(dayLightData.sunset.split(':')[1])
+    if (startMinute <= minutes && endMinute > minutes) {
+        return true;
+    }
+    return false;
+}
+
 export const getTarget = (data: any, isBigRing: boolean) => {
     const targetRingBig: TargetRing = {
         color: '#FF0000',
@@ -107,7 +130,7 @@ export const getTarget = (data: any, isBigRing: boolean) => {
             // if (data.fast.real_start_time_zone) {
             //     timestamp = TimeFormatter.transferTimestamp(timestamp, data.fast.real_start_time_zone)
             // }
-            targetRingBig.color = (global.fastColor ? global.fastColor : ColorType.fast)+'66'
+            targetRingBig.color = (global.fastColor ? global.fastColor : ColorType.fast) + '66'
             targetRingBig.startArc = startArc(timestamp)
             targetRingBig.durationArc = durationArc(data.fast.target_start_time, data.fast.target_end_time)
         }

+ 38 - 18
src/pages/clock/Index.tsx

@@ -7,7 +7,7 @@ import { useDispatch, useSelector } from "react-redux";
 import { useDidShow, useReady } from "@tarojs/taro";
 import Taro from "@tarojs/taro";
 import { getInfoSuccess } from "@/store/user";
-import { clockHome, getClockRecords, getClocks } from "@/services/trackTimeDuration";
+import { clockHome, clockSummaryRecords, clockSummaryStats, getClockRecords, getClocks } from "@/services/trackTimeDuration";
 import { updateScenario } from "@/store/time";
 import { setConfigs } from "@/store/common";
 import { setScenario } from "@/store/scenario";
@@ -22,11 +22,13 @@ import { rpxToPx } from "@/utils/tools";
 import RecordFastSleep from "@/features/trackTimeDuration/components/RecordFastSleep";
 import DayLight from "@/features/trackTimeDuration/components/DayLight";
 import { getInfo } from "@/services/user";
+import { TimeFormatter } from "@/utils/time_format";
+import WeekCalendar from "@/features/trackTimeDuration/components/WeekCalendar";
 
 export default function Page() {
     const dispatch = useDispatch();
     global.dispatch = dispatch;
-    
+
     const user = useSelector((state: any) => state.user);
     const time = useSelector((state: any) => state.time);
     const [showErrorPage, setErrorPage] = useState(false)
@@ -47,6 +49,8 @@ export default function Page() {
     const [isMulti, setIsMulti] = useState(false)
     const [records, setRecords] = useState([])
 
+    const [calendars, setCalendars] = useState([])
+
 
     const [multiData, setMultiData] = useState([
         {
@@ -74,6 +78,10 @@ export default function Page() {
         // if (user.isLogin) {
         getCheckData()
         // }
+
+        if (user.isLogin) {
+            getRecords()
+        }
     }, [user.isLogin, time.status])
 
     useReady(async () => {
@@ -88,7 +96,6 @@ export default function Page() {
             getHistory()
 
 
-
         }
 
     })
@@ -111,19 +118,6 @@ export default function Page() {
     }
 
     function getCheckData() {
-        // getClocks().then(res => {
-        //     // setErrorPage(false)
-        //     // setData(res as any)
-        //     // 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
-        //     }
-        // })
-
         clockHome().then(res => {
             setHomeData(res as any)
         })
@@ -131,6 +125,23 @@ export default function Page() {
         getHistory()
     }
 
+    function getRecords() {
+        var timestamp = TimeFormatter.getMondayTimestamp()
+        var list: any = []
+        for (var i = 0; i < 7; i++) {
+            list.push(`${i},${timestamp - 7 * 24 * 3600 * 1000 * i},${timestamp - 7 * 24 * 3600 * 1000 * i + 7 * 24 * 3600 * 1000}`)
+            // list.push({
+            //     start:timestamp-7*24*3600*1000*i,
+            //     end:timestamp-7*24*3600*1000*i+24*3600*100,
+            //     index:i
+            // })
+        }
+        clockSummaryStats({ times: list.join(';') }).then(res => {
+            setCalendars((res as any).data)
+        })
+        // clockSummaryStats({start:new Date().getTime()-7*24*3600*1000,end:new Date().getTime()}).then(res => { })
+    }
+
     function getHistory() {
         if (user.isLogin)
             getClockRecords({
@@ -406,13 +417,22 @@ export default function Page() {
             {
                 user.isLogin && <DayLight />
             }
-            <Text className="discovery">最近</Text>
+            {
+                user.isLogin && <Text className="discovery">最近</Text>
+            }
             {
                 records.length > 0 && <View className="fast_sleep_item_bg">
                     <RecordFastSleep data={records[0]} type='record' delSuccess={() => { }} />
                 </View>
             }
 
+            {
+                user.isLogin && calendars.length > 0 && <View>
+                    <Text className="discovery">周统计</Text>
+                    <WeekCalendar calendars={calendars} />
+                </View>
+            }
+
 
             {/* 
             <View style={{ marginTop: 50 }}>
@@ -439,4 +459,4 @@ export default function Page() {
         </ScrollView>
     }
     return render()
-}
+}

+ 1 - 0
src/services/http/api.js

@@ -30,6 +30,7 @@ export const API_FAST_PLANS = `${baseUrl}/api/fast/plans`
 export const API_FAST_CHECKS = `${baseUrl}/api/fast/checks`
 export const API_FAST_CLOCKS = `${baseUrl}/api/fast/clocks`
 export const API_CLOCK_HOME = `${baseUrl}/api/clock/home`
+export const API_CLOCK_STATS = `${baseUrl}/api/clock/summary/stats`
 export const API_FAST_CHECK_ABANDONED = `${baseUrl}/api/fast/check-abandoned`
 export const API_FAST_RECORDS = `${baseUrl}/api/fast/records`
 export const API_FAST_SCHEDULES = `${baseUrl}/api/fast/schedules`

+ 11 - 1
src/services/trackTimeDuration.tsx

@@ -1,6 +1,6 @@
 
 import exp from 'constants';
-import { API_FAST_PLANS, API_FAST_CHECKS, API_FAST_CLOCKS, API_CLOCK_RECORDS, API_CLOCK_HOME } from './http/api'
+import { API_FAST_PLANS, API_FAST_CHECKS, API_FAST_CLOCKS, API_CLOCK_RECORDS, API_CLOCK_HOME, API_CLOCK_STATS, API_CLOCK_SUMMARY_RECORDS } from './http/api'
 import { request } from './http/request';
 
 export const getPlans = () => {
@@ -51,6 +51,16 @@ export const clockHome = () => {
     })
 }
 
+export const clockSummaryStats = (params:any)=>{
+    return new Promise((resolve) => {
+        request({
+            url: API_CLOCK_STATS, method: 'GET', data: { ...params }
+        }).then(res => {
+            resolve(res);
+        })
+    })
+}
+
 export const getClocks = () => {
     return new Promise((resolve, reject) => {
         request({

+ 58 - 0
src/store/day_night.tsx

@@ -0,0 +1,58 @@
+import { createSlice } from "@reduxjs/toolkit";
+
+
+interface dayNightState {
+    sunRise: string | '06:00',
+    sunSet: string | '18:00',
+    sunRiseTomorrow: string | '06:00',
+    sunSetTomorrow: string | '18:00',
+    showDayRing: boolean | false,
+    showNightRing: boolean | false,
+    isMember: boolean | false,
+    gpsInfo: Object | null,
+}
+
+const initialState: dayNightState = {
+    sunRise: '06:00',
+    sunSet: '18:00',
+    sunRiseTomorrow: '06:00',
+    sunSetTomorrow: '18:00',
+    showDayRing: false,
+    showNightRing: false,
+    isMember: false,
+    gpsInfo: null
+}
+
+const dayNightSlice = createSlice({
+    name: 'day_night',
+    initialState,
+    reducers: {
+        showDay(state, action) {
+            state.showDayRing = action.payload;
+        },
+        showNight(state, action) {
+            state.showNightRing = action.payload;
+        },
+        updateMember(state, action) {
+            var isMember = action.payload.isMember;
+            var gpsInfo = action.payload.gpsInfo;
+            state.isMember = isMember;
+            if (isMember && gpsInfo) {
+                state.sunRise = '07:00'
+                state.sunSet = '19:00'
+                state.sunRiseTomorrow = '07:00'
+                state.sunSetTomorrow = '19:00'
+                state.gpsInfo = gpsInfo
+            }
+            else {
+                state.sunRise = '06:00'
+                state.sunSet = '18:00'
+                state.sunRiseTomorrow = '06:00'
+                state.sunSetTomorrow = '18:00'
+            }
+        },
+    }
+});
+
+export default dayNightSlice.reducer;
+export const { showDay, showNight, updateMember } = dayNightSlice.actions;

+ 5 - 3
src/store/store.tsx

@@ -8,6 +8,7 @@ import timeReducer from './time';
 import modalReducer from './modal';
 import consoleReducer from './console';
 import workoutReducer from './workout';
+import dayNightReducer from './day_night';
 
 const store = configureStore({
   reducer: {
@@ -19,9 +20,10 @@ const store = configureStore({
     checkResult: resultReducer,
     codeResult: resultReducer,
     time: timeReducer,
-    modal:modalReducer,
-    console:consoleReducer,
-    workout:workoutReducer,
+    modal: modalReducer,
+    console: consoleReducer,
+    workout: workoutReducer,
+    dayNight: dayNightReducer
   },
 });
 

+ 44 - 26
src/utils/time_format.ts

@@ -113,13 +113,13 @@ export class TimeFormatter {
   }
 
   //显示完整日期
-  static timelineFullFormatTime(timestamp:number):string{
+  static timelineFullFormatTime(timestamp: number): string {
     var date = new Date(timestamp)
     var str = `${TimeFormatter.formatNumber(date.getHours())}:${TimeFormatter.formatNumber(date.getMinutes())}`;
-    if (global.language=='en'){
-      return `${TimeFormatter.getDayOfWeek(date.getDay())} ${TimeFormatter.getMonth(date.getMonth()+1)} ${date.getDate()} ${str}`
+    if (global.language == 'en') {
+      return `${TimeFormatter.getDayOfWeek(date.getDay())} ${TimeFormatter.getMonth(date.getMonth() + 1)} ${date.getDate()} ${str}`
     }
-    return `${TimeFormatter.getMonth(date.getMonth()+1)}${date.getDate()}日 ${TimeFormatter.getDayOfWeek(date.getDay())} ${str}`
+    return `${TimeFormatter.getMonth(date.getMonth() + 1)}${date.getDate()}日 ${TimeFormatter.getDayOfWeek(date.getDay())} ${str}`
   }
 
 
@@ -219,7 +219,7 @@ export class TimeFormatter {
     if (currentDate.getTime() - timestamp <= TimeFormatter.nowDuration * 1000) {
       return TimeFormatter.dateDescription(timestamp, true)
     }
-    if (global.language=='en'){
+    if (global.language == 'en') {
       return TimeFormatter.dateDescription(timestamp, true) + ' ' + TimeFormatter.timeDescription(timestamp)
     }
     return TimeFormatter.dateDescription(timestamp, true) + '' + TimeFormatter.timeDescription(timestamp)
@@ -475,34 +475,34 @@ export class TimeFormatter {
   }
 
   //获取时长单位
-  static  getSecondsUnit = (seconds,isFull?:boolean) =>{
-    if (global.language=='en'){
-      if (isFull){
-        return seconds>1?' seconds ':' second '
+  static getSecondsUnit = (seconds, isFull?: boolean) => {
+    if (global.language == 'en') {
+      if (isFull) {
+        return seconds > 1 ? ' seconds ' : ' second '
       }
-      return seconds>1?' secs ':' sec '
+      return seconds > 1 ? ' secs ' : ' sec '
     }
-    return  '秒'
+    return '秒'
   }
 
-  static  getMinutesUnit = (minutes,isFull?:boolean) =>{
-    if (global.language=='en'){
-      if (isFull){
-        return minutes>1?' minutes ':' minute '
+  static getMinutesUnit = (minutes, isFull?: boolean) => {
+    if (global.language == 'en') {
+      if (isFull) {
+        return minutes > 1 ? ' minutes ' : ' minute '
       }
-      return minutes>1?' mins ':' min '
+      return minutes > 1 ? ' mins ' : ' min '
     }
-    return  '分钟'
+    return '分钟'
   }
 
-  static  getHoursUnit = (hours,isFull?:boolean) =>{
-    if (global.language=='en'){
-      if (isFull){
-        return hours>1?' hours ':' hour '
+  static getHoursUnit = (hours, isFull?: boolean) => {
+    if (global.language == 'en') {
+      if (isFull) {
+        return hours > 1 ? ' hours ' : ' hour '
       }
-      return hours>1?' hrs ':' hr '
+      return hours > 1 ? ' hrs ' : ' hr '
     }
-    return  '小时'
+    return '小时'
   }
 
   static getTodayUnit = () => {
@@ -521,14 +521,14 @@ export class TimeFormatter {
     return global.language == 'en' ? 'Just now' : '刚刚'
   }
 
-  static getDayOfWeek = (index,isFull?:boolean) => {
+  static getDayOfWeek = (index, isFull?: boolean) => {
     var weeks = ['日', '一', '二', '三', '四', '五', '六']
     var weeks2 = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
     ];
-    var weeksFull = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']
+    var weeksFull = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
 
     if (global.language == 'en') {
-      if (isFull){
+      if (isFull) {
         return weeksFull[index]
       }
       return weeks2[index]
@@ -548,4 +548,22 @@ export class TimeFormatter {
     return index + '月'
   }
 
+  //获取本周一零点的时间戳
+  static getMondayTimestamp = () => {
+    const now = new Date();
+    const currentDay = now.getDay(); // Get the current day of the week (0 for Sunday, 1 for Monday, etc.)
+    const startOfWeek = new Date(now); // Create a new Date object with the current date and time
+    
+    // Calculate the difference in milliseconds to the beginning of the week
+    const diffToMonday = (currentDay - 1) * 24 * 60 * 60 * 1000; // Subtract 1 day worth of milliseconds for each day after Monday
+
+    startOfWeek.setTime(now.getTime() - diffToMonday); // Set the time to the beginning of the week (Monday at 00:00:00)
+    startOfWeek.setHours(0)
+    startOfWeek.setMinutes(0)
+    startOfWeek.setSeconds(0)
+    startOfWeek.setMilliseconds(0)
+    const timestamp = startOfWeek.getTime(); // Get the timestamp in milliseconds
+    return timestamp
+  }
+
 }