Leon 1 سال پیش
والد
کامیت
ed52ab9c37

+ 3 - 0
src/features/trackTimeDuration/components/DayLight.tsx

@@ -93,6 +93,9 @@ export default function DayLight() {
 
         global.showNightRing = isShow
         global.refreshIndex()
+        setTimeout(()=>{
+            global.refreshIndex()
+        },200)
 
         const gpsInfo = await getStorage('gps') || null
         if (gpsInfo) {

+ 14 - 25
src/features/trackTimeDuration/components/IndexItem.tsx

@@ -19,8 +19,6 @@ if (process.env.TARO_ENV == 'rn') {
     useNavigation = require("@react-navigation/native").useNavigation
 }
 
-let popTimer;
-let currentRecordTemp;
 export default function Component(props: { type: string, data: any, time: any, showStage?: boolean }) {
     const { t } = useTranslation()
     const [record, setRecord] = useState(props.data.current_record);
@@ -35,7 +33,6 @@ export default function Component(props: { type: string, data: any, time: any, s
 
     useEffect(() => {
         setRecord(props.data.current_record)
-        currentRecordTemp = props.data.current_record
     }, [props.data])
 
     useEffect(() => {
@@ -298,13 +295,7 @@ export default function Component(props: { type: string, data: any, time: any, s
         if (props.showStage) {
             return
         }
-        var node = schedules()
-        global.showIndexModal3(true, node, null);
-        popTimer = setInterval(() => {
-            var node = schedules()
-            global.showIndexModal3(true, node, null);
-        }, 1000)
-        global.popTimer = popTimer
+        global.showSegmentPop()
     }
 
     function nightDuration() {
@@ -325,19 +316,19 @@ export default function Component(props: { type: string, data: any, time: any, s
         }
     }
 
-    function schedules() {
-        var timestamp = new Date().getTime()//props.data.first_real_check_time
-        return <View style={{ display: 'flex', flexDirection: 'column' }}>
-            <TimelineStage data={currentRecordTemp} title={t('feature.track_time_duration.record_fast_sleep.pop_title')}
-                subTitle='今天' first_real_check_time={timestamp} />
-        </View>
-    }
-
     function fastPicker() {
+        if (!user.isLogin) {
+            jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+            return
+        }
         global.showFastPicker()
     }
 
     function sleepPicker(e) {
+        if (!user.isLogin) {
+            jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+            return
+        }
         if (record.status == 'ONGOING3') {
             return;
         }
@@ -371,14 +362,12 @@ export default function Component(props: { type: string, data: any, time: any, s
                     (props.type == 'SLEEP' || props.type == 'FAST_SLEEP') && <Text className="duration_value" onClick={sleepPicker} style={{ color: global.sleepColor ? global.sleepColor : ColorType.sleep }}>{sleepDuration()}</Text>
                 }
             </View>
-            {/* <Image className="arrow1" src={require('@/assets/images/arrow.png')} /> */}
-            <View className="record_arrow_bg" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }} onClick={goClock}>
-                <View style={{ flex: 1 }} />
-                {/* <Text className='recordTime'>{getArrowText()}</Text> */}
-                <Image className="arrow2" src={require('@/assets/images/arrow3.png')} />
-            </View>
+            {
+                !props.showStage && <View className="record_arrow_bg" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }} onClick={goClock}>
+                    <View style={{ flex: 1 }} />
+                    <Image className="arrow2" src={require('@/assets/images/arrow3.png')} />
+                </View>}
 
-            {/* <t-popup></t-popup> */}
 
         </View>
     </View>

+ 33 - 0
src/features/trackTimeDuration/components/SegmentPop.tsx

@@ -0,0 +1,33 @@
+import { View } from "@tarojs/components";
+import TimelineStage from "./TimelineStage";
+import { useTranslation } from "react-i18next";
+import { useState } from "react";
+import Modal from "@/components/layout/Modal.weapp";
+import { ModalType } from "@/utils/types";
+
+export default function SegmentPop(props: { data: any }) {
+    const [showModal, setShowModal] = useState(false)
+    const { t } = useTranslation()
+
+    global.showSegmentPop = () => {
+        setShowModal(true)
+    }
+
+    function schedules() {
+        var timestamp = new Date().getTime()//props.data.first_real_check_time
+        return <View style={{ display: 'flex', flexDirection: 'column' }}>
+            <TimelineStage data={props.data.current_record} title={t('feature.track_time_duration.record_fast_sleep.pop_title')}
+                subTitle='今天' first_real_check_time={timestamp} />
+        </View>
+    }
+
+
+    return <View style={{ width: 0, height: 0 }}>
+        {
+            showModal && <Modal children={schedules()}
+                modalType={ModalType.center}
+                dismiss={() => { setShowModal(false); }}
+                confirm={() => { }} />
+        }
+    </View>
+}

+ 36 - 9
src/features/trackTimeDuration/components/TimelineFastSleep.tsx

@@ -69,7 +69,35 @@ export default function TimelineFastSleep(props: { data: any, title?: string, fi
 
     }
 
-    function formateDate(obj: any, isEnd: boolean) {
+    function formateDate(obj: any, isEnd: boolean, isFastMode?: boolean) {
+        var now = new Date()
+        var seconds = now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds()
+        if (obj.status == 'WAIT_FOR_START') {
+            var list
+            if (isFastMode) {
+                if (isEnd) {
+                    list = scenario.schedule.fast.end_time.split(':')
+                }
+                else {
+                    list = scenario.schedule.fast.start_time.split(':')
+                }
+            }
+            else {
+                if (isEnd) {
+                    list = scenario.schedule.sleep.end_time.split(':')
+                }
+                else {
+                    list = scenario.schedule.sleep.start_time.split(':')
+                }
+            }
+            var t = parseInt(list[0]) * 3600 + parseInt(list[1])
+            if (t < seconds) {
+                return '明天'
+            }
+            else {
+                return '今天'
+            }
+        }
         if (isEnd) {
             if (obj.real_end_time) {
                 return TimeFormatter.dateDescription(obj.real_end_time, true)
@@ -116,14 +144,13 @@ export default function TimelineFastSleep(props: { data: any, title?: string, fi
         if (props.data.fast.real_start_time_zone) {
             timeZone = ' ' + props.data.fast.real_start_time_zone
         }
-        debugger
         timelineItems.push(
             {
                 status: getStatus(true, true, props.data),
                 title: getStatus(true, true, props.data) == 'padding' ?
                     t('feature.track_time_duration.common.start_fast') :
                     t('feature.track_time_duration.common.started_fasting'),
-                content: props.data.status == 'WAIT_FOR_START' ? formateDate(props.data.fast, false) + scenario.schedule.fast.start_time : formateDate(props.data.fast, false) + formateTime(props.data.fast, false),
+                content: props.data.status == 'WAIT_FOR_START' ? formateDate(props.data.fast, false, true) + scenario.schedule.fast.start_time : formateDate(props.data.fast, false) + formateTime(props.data.fast, false),
                 date: props.data.status == 'WAIT_FOR_START' ? '' : multTimeZone ? timeZone : '',
                 // (diffTimeZone ? timeZone : showDate(props.data.fast, false) ? formateDate(props.data.fast, false) : ''),
                 color: global.fastColor ? global.fastColor : ColorType.fast
@@ -136,8 +163,8 @@ export default function TimelineFastSleep(props: { data: any, title?: string, fi
             timeZone = ' ' + props.data.sleep.real_start_time_zone
         }
         var status = getStatus(false, true, props.data)
-        var strContent = props.data.status == 'WAIT_FOR_START' ? formateDate(props.data.sleep, false) + scenario.schedule.sleep.start_time : formateDate(props.data.sleep, false) + formateTime(props.data.sleep, false)
-        var strDate =  multTimeZone ? timeZone : ''
+        var strContent = props.data.status == 'WAIT_FOR_START' ? formateDate(props.data.sleep, false, false) + scenario.schedule.sleep.start_time : formateDate(props.data.sleep, false) + formateTime(props.data.sleep, false)
+        var strDate = multTimeZone ? timeZone : ''
         // (diffTimeZone ? timeZone : showDate(props.data.sleep, false) ? formateDate(props.data.sleep, false) : '')
         timelineItems.push(
             {
@@ -157,8 +184,8 @@ export default function TimelineFastSleep(props: { data: any, title?: string, fi
             timeZone = ' ' + props.data.sleep.real_end_time_zone
         }
         var status = getStatus(false, false, props.data)
-        var strContent: string = props.data.status == 'WAIT_FOR_START' ? formateDate(props.data.sleep, true) + scenario.schedule.sleep.end_time : formateDate(props.data.sleep, true) + formateTime(props.data.sleep, true)
-        var strDate =  multTimeZone ? timeZone : ''
+        var strContent: string = props.data.status == 'WAIT_FOR_START' ? formateDate(props.data.sleep, true, false) + scenario.schedule.sleep.end_time : formateDate(props.data.sleep, true) + formateTime(props.data.sleep, true)
+        var strDate = multTimeZone ? timeZone : ''
         // (diffTimeZone ? timeZone : showDate(props.data.sleep, true) ? formateDate(props.data.sleep, true) : '')
         timelineItems.push(
             {
@@ -183,8 +210,8 @@ export default function TimelineFastSleep(props: { data: any, title?: string, fi
                 title: getStatus(true, false, props.data) == 'padding' ?
                     t('feature.track_time_duration.common.end_fast') :
                     t('feature.track_time_duration.common.ended_fasting'),
-                content: props.data.status == 'WAIT_FOR_START' ? formateDate(props.data.fast, true) + scenario.schedule.fast.end_time : formateDate(props.data.fast, true) + formateTime(props.data.fast, true),
-                date:  multTimeZone ? timeZone : '',
+                content: props.data.status == 'WAIT_FOR_START' ? formateDate(props.data.fast, true, true) + scenario.schedule.fast.end_time : formateDate(props.data.fast, true) + formateTime(props.data.fast, true),
+                date: multTimeZone ? timeZone : '',
                 // (diffTimeZone ? timeZone : showDate(props.data.fast, true) ? formateDate(props.data.fast, true) : ''),
                 color: global.fastColor ? global.fastColor : ColorType.fast
             }

+ 2 - 1
src/features/trackTimeDuration/components/TimelineStage.weapp.tsx

@@ -51,13 +51,14 @@ export default function Component(props: { data: any, title?: string, subTitle?:
     }
 
     return <View style={{ display: 'flex', flexDirection: 'column', width: rpxToPx(578), height: rpxToPx(800) }}>
-        <View style={{ marginBottom: 0 }}>
+        <View style={{ marginBottom: 20 }}>
             <Segment titles={[
                 t('feature.track_time_duration.schedule.total_time'),
                 t('feature.track_time_duration.record_fast_sleep.timeline'),
             ]} changed={(e) => {
                 setSegmentIndex(e);
                 global.segmentIndex = e
+                console.log('segment item click',e)
             }} />
         </View>
         <View className="segment_detail" style={{

+ 4 - 3
src/features/trackTimeDuration/components/WeekCalendar.tsx

@@ -22,9 +22,7 @@ const WeekCalendar = memo(() => {
     const [minTime, setMinTime] = useState(0)
     const [left, setLeft] = useState(0)
     const [isLoading, setIsLoading] = useState(false)
-    const pageSize = 15
-
-    console.log('apple')
+    const pageSize = 14
 
     useEffect(() => {
         pageIndex = -1
@@ -149,7 +147,10 @@ const WeekCalendar = memo(() => {
                     enableFlex enhanced>
                     {
                         calendars.map((item, index) => {
+                            // return <View style={{width: parseInt(rpxToPx(658) + ''),
+                            // height: parseInt(rpxToPx(520) + ''),backgroundColor:'red',flexShrink:0}}><Text style={{color:'#fff'}}>{index}</Text></View>
 
+                            // // 
                             return <WeekCalendarItem data={item} key={index} />
                         })
                     }

+ 6 - 6
src/features/trackTimeDuration/components/WeekCalendarItem.tsx

@@ -65,16 +65,16 @@ export default function WeekCalendarItem(props: { data: any }) {
     }
     return <View className="chart_content" style={{width:parseInt(rpxToPx(658)+'')}}>
         <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>
-            <Text className="chart_week_text">周六</Text>
+            <Text className="chart_week_text">周六</Text> */}
         </View>
         <View className="chart_detail">
-            <View className="verticalLine" style={{ left: 0 }} />
+            {/* <View className="verticalLine" style={{ left: 0 }} />
             <View className="verticalLine" style={{ left: rpxToPx(94) }} />
             <View className="verticalLine" style={{ left: rpxToPx(94 * 2) }} />
             <View className="verticalLine" style={{ left: rpxToPx(94 * 3) }} />
@@ -83,7 +83,7 @@ export default function WeekCalendarItem(props: { data: any }) {
             <View className="verticalLine" style={{ left: rpxToPx(94 * 6) }} />
             <View className="horizontalLine" style={{ top: rpxToPx(100), backgroundColor: '#262626' }} />
             <View className="horizontalLine" style={{ top: rpxToPx(200), backgroundColor: '#383838' }} />
-            <View className="horizontalLine" style={{ top: rpxToPx(300), backgroundColor: '#262626' }} />
+            <View className="horizontalLine" style={{ top: rpxToPx(300), backgroundColor: '#262626' }} /> */}
             {
                 charts.map((item, index) => {
                     return <View className="lineContent" style={{ left: rpxToPx(94 * index) }}>
@@ -121,13 +121,13 @@ export default function WeekCalendarItem(props: { data: any }) {
             }
         </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>
-            <Text className="chart_week_text">周日</Text>
+            <Text className="chart_week_text">周日</Text> */}
         </View>
     </View>
 }

+ 16 - 31
src/pages/clock/Index.tsx

@@ -31,6 +31,7 @@ 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";
 
 let GradientText
 let useNavigation;
@@ -52,8 +53,6 @@ export default function Page() {
     const { t } = useTranslation()
     const user = useSelector((state: any) => state.user);
     const time = useSelector((state: any) => state.time);
-    const [showErrorPage, setErrorPage] = useState(false)
-    const [data, setData] = useState(null)
     const [count, setCount] = useState(0)
     const [homeData, setHomeData] = useState(null)
 
@@ -66,17 +65,11 @@ export default function Page() {
     const [showModal2, setShowModal2] = useState(false)
     const [modalDetail2, setModalDetail2] = useState<any>(null)
 
-    const [showModal3, setShowModal3] = useState(false)
-    const [modalDetail3, setModalDetail3] = useState<any>(null)
-
     const [debugInfo, setDebugInfo] = useState(null)
 
     const [isMulti, setIsMulti] = useState(false)
     const [records, setRecords] = useState([])
 
-    const [loaded, setLoaded] = useState(false)
-
-
     const [multiData, setMultiData] = useState([
         {
             title: '睡前断食',
@@ -142,7 +135,6 @@ export default function Page() {
     function getCheckData() {
         clockHome().then(res => {
             setHomeData(res as any)
-            setLoaded(true)
             global.homeData = res
 
             if (user.isLogin) {
@@ -281,13 +273,6 @@ export default function Page() {
         setModalDetail2(detail)
     }
 
-    global.showIndexModal3 = (isShow: boolean, detail: any) => {
-        setDebugInfo(null)
-        global.showModal = isShow
-        setShowModal3(isShow)
-        setModalDetail3(detail)
-    }
-
     global.changeTargetDuration = (duration: number, isFast: boolean) => {
         var obj = JSON.parse(JSON.stringify(homeData))
         var record = obj.fast_sleep.current_record
@@ -301,25 +286,18 @@ export default function Page() {
     }
 
     function modalContent() {
-        if (showModal || showModal2 || showModal3) {
+        if (showModal || showModal2) {
             if (process.env.TARO_ENV == 'weapp') {
-                if (showModal3) {
-                    return <Modal children={modalDetail3}
-                        modalType={ModalType.center}
-                        dismiss={() => { setShowModal3(false); clearInterval(global.popTimer) }}
-                        confirm={() => { }} />
-                }
                 return <Modal
                     testInfo={debugInfo}
                     dismiss={() => {
                         setDebugInfo(null)
                         setShowModal(false);
                         setShowModal2(false);
-                        setShowModal3(false);
                     }}
                     confirm={() => { }}>
                     {
-                        showModal ? modalDetail : showModal2 ? modalDetail2 : modalDetail3
+                        showModal ? modalDetail :  modalDetail2 
                     }
                 </Modal>
             }
@@ -339,10 +317,10 @@ export default function Page() {
                     onClick={() => { alert('b') }}
                     onClickOverlay={() => { alert('a') }}
                     onAfterLeave={() => { setShowModal(false); setShowModal2(false) }}
-                    show={showModal || showModal2 || showModal3} round={true} overlay={true} position='bottom'
+                    show={showModal || showModal2} round={true} overlay={true} position='bottom'
                 >
                     {
-                        showModal ? modalDetail : showModal2 ? modalDetail2 : modalDetail3
+                        showModal ? modalDetail :  modalDetail2
                     }
                 </PageContainer>
             }
@@ -410,6 +388,7 @@ export default function Page() {
                             <SwiperItem className='swiperItem'>
                                 <View>
                                     <IndexItem type="FAST_SLEEP" data={(homeData as any).fast_sleep} time={timestamp} showStage={false} />
+                                    <View style={{height:20}}/>
                                     <IndexConsole record={(homeData as any).fast_sleep} />
                                 </View>
 
@@ -419,7 +398,7 @@ export default function Page() {
                                 (homeData as any).fast_sleep.current_record.status == 'WAIT_FOR_START' &&
                                 <SwiperItem className='swiperItem'>
                                     <IndexItem type="FAST_SLEEP" data={(homeData as any).fast_sleep} time={timestamp + 2000} showStage={true} />
-                                    <View>
+                                    <View style={{marginTop:20}}>
                                         {
                                             isMulti ? <View>
                                                 {
@@ -503,18 +482,24 @@ export default function Page() {
                     </View>
                 }
 
-                {/* {
+                {
                     user.isLogin && <View>
                         <Text className="discovery">周统计</Text>
                         <WeekCalendar />
                     </View>
-                } */}
+                }
 
                 <View style={{ height: 100 }} />
                 {
                     modalContent()
                 }
-                {homeData && <DurationPicker record={(homeData as any).fast_sleep.current_record} />}
+
+                {
+                    homeData && <SegmentPop data={(homeData as any).fast_sleep} />
+                }
+                {
+                    homeData && <DurationPicker record={(homeData as any).fast_sleep.current_record} />
+                }
                 <Tabbar index={0} />
             </View>
         </Layout>