leon il y a 1 an
Parent
commit
fe05576993

+ 1 - 1
src/features/trackTimeDuration/components/CheckAccess.tsx

@@ -322,7 +322,7 @@ const CheckAccess = memo((props: { record: any, count: number }) => {
         const { start_time, end_time } = global.ring.schedule.fast
         var params: any = {
             scenario: 'FAST',
-            trigger_event: 'POPUP_DISQUALIFIED',
+            trigger_event: 'POPUP_PENDING_SUBSCRIBE_FAIL',
             method: 'USER_SET',
             schedule: {
                 fast: {

+ 46 - 51
src/features/trackTimeDuration/components/WeekCalendar.tsx

@@ -24,7 +24,7 @@ if (process.env.TARO_ENV == 'rn') {
 }
 
 
-const WeekCalendar = memo((props:{isFastSleep:boolean}) => {
+const WeekCalendar = memo((props: { isFastSleep: boolean }) => {
     const [calendars, setCalendars] = useState<any>([])
     const [current, setCurrent] = useState(0)
     const [summary, setSummary] = useState<any>(null)
@@ -55,6 +55,9 @@ const WeekCalendar = memo((props:{isFastSleep:boolean}) => {
         }
         var list: any = []
         var offset = 12 * 3600 * 1000 + pageIndex * pageSize * 24 * 3600 * 1000
+        if (!props.isFastSleep){
+            offset = pageIndex * pageSize * 24 * 3600 * 1000
+        }
         for (var i = 0; i < pageSize; i++) {
             list.push(`${i + pageIndex * pageSize},${timestamp - 7 * 24 * 3600 * 1000 * i - offset},${timestamp - 7 * 24 * 3600 * 1000 * i + 7 * 24 * 3600 * 1000 - offset}`)
         }
@@ -82,6 +85,9 @@ const WeekCalendar = memo((props:{isFastSleep:boolean}) => {
         }
         var list: any = []
         var offset = 12 * 3600 * 1000 + pageIndex * pageSize * 24 * 3600 * 1000
+        if (!props.isFastSleep){
+            offset = pageIndex * pageSize * 24 * 3600 * 1000
+        }
         for (var i = 0; i < pageSize; i++) {
             list.push(`${i + pageIndex * pageSize},${timestamp - 7 * 24 * 3600 * 1000 * i - offset},${timestamp - 7 * 24 * 3600 * 1000 * i + 7 * 24 * 3600 * 1000 - offset}`)
         }
@@ -177,8 +183,14 @@ const WeekCalendar = memo((props:{isFastSleep:boolean}) => {
 
     function getWeekDuration() {
         if (global.language == 'en') {
+            if (!props.isFastSleep) {
+                return `${t('feature.common.day_of_week_full.mon')}, ${getDate(calendarData.start)} - ${t('feature.common.day_of_week_full.mon')}, ${getDate(calendarData.end)}`
+            }
             return `${t('feature.common.day_of_week_full.sun')} ${t('feature.common.time_desc.afternoon')}, ${getDate(calendarData.start)} - ${t('feature.common.day_of_week_full.sun')} ${t('feature.common.time_desc.morning')}, ${getDate(calendarData.end)}`
         }
+        if (!props.isFastSleep) {
+            return `${getDate(calendarData.start)} ${t('feature.common.day_of_week_full.mon')} - ${getDate(calendarData.end)} ${t('feature.common.day_of_week_full.mon')}`
+        }
         return `${getDate(calendarData.start)} ${t('feature.common.day_of_week_full.sun')}${t('feature.common.time_desc.afternoon')} - ${getDate(calendarData.end)} ${t('feature.common.day_of_week_full.sun')}${t('feature.common.time_desc.morning')}`
     }
 
@@ -195,14 +207,14 @@ const WeekCalendar = memo((props:{isFastSleep:boolean}) => {
         }
     }
 
-    function showWeeklyItem(index){
-        if (process.env.TARO_ENV=='weapp'){
-            if (index >= current - 1 && index <= current + 1){
+    function showWeeklyItem(index) {
+        if (process.env.TARO_ENV == 'weapp') {
+            if (index >= current - 1 && index <= current + 1) {
                 return true
             }
             return false
         }
-        if (index >= current - 2 && index <= current + 2){
+        if (index >= current - 2 && index <= current + 2) {
             return true
         }
         return false
@@ -214,30 +226,30 @@ const WeekCalendar = memo((props:{isFastSleep:boolean}) => {
         <View className="calendar_summary_top">
             <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', flex: 1 }}>
                 {
-                    !summary || summary.fast.avg == 0 ? <View className="calendar-empty-bg" style={{ borderColor: props.isFastSleep?ColorType.fast:ColorType.food }}>
-                        <View className="calendar-empty-line" style={{ backgroundColor: props.isFastSleep?ColorType.fast:ColorType.food }} />
+                    !summary || summary.fast.avg == 0 ? <View className="calendar-empty-bg" style={{ borderColor: props.isFastSleep ? ColorType.fast : ColorType.food }}>
+                        <View className="calendar-empty-line" style={{ backgroundColor: props.isFastSleep ? ColorType.fast : ColorType.food }} />
                     </View> :
-                        <View className={lastFastValue > summary.fast.avg ? 'calendar-arrow-bg-down' : 'calendar-arrow-bg'} style={{ backgroundColor: props.isFastSleep?ColorType.fast:ColorType.food }}>
+                        <View className={lastFastValue > summary.fast.avg ? 'calendar-arrow-bg-down' : 'calendar-arrow-bg'} style={{ backgroundColor: props.isFastSleep ? ColorType.fast : ColorType.food }}>
                             <IconBigArrow color="#fff" width={rpxToPx(32)} />
                         </View>
                 }
                 <View className="calendar_summary_item">
-                    <Text className="calendar_summary_title">{props.isFastSleep?t('feature.track_time_duration.weekly.fast_average'):t('feature.track_time_duration.weekly.eat_average')}</Text>
-                    <Text className="calendar_summary_value" style={{ color: props.isFastSleep?ColorType.fast:ColorType.food }}>{!summary || summary.fast.avg == 0 ? t('feature.track_time_duration.record_fast_sleep.none') : TimeFormatter.calculateTimeDifference(new Date().getTime(), new Date().getTime() + summary.fast.avg)}</Text>
+                    <Text className="calendar_summary_title">{props.isFastSleep ? t('feature.track_time_duration.weekly.fast_average') : t('feature.track_time_duration.weekly.eat_average')}</Text>
+                    <Text className="calendar_summary_value" style={{ color: props.isFastSleep ? ColorType.fast : ColorType.food }}>{!summary || summary.fast.avg == 0 ? t('feature.track_time_duration.record_fast_sleep.none') : TimeFormatter.calculateTimeDifference(new Date().getTime(), new Date().getTime() + summary.fast.avg)}</Text>
                 </View>
             </View>
             <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', flex: 1 }}>
                 {
-                    !summary || summary.sleep.avg == 0 ? <View className="calendar-empty-bg" style={{ borderColor: props.isFastSleep?ColorType.sleep:ColorType.activity }}>
-                        <View className="calendar-empty-line" style={{ backgroundColor: props.isFastSleep?ColorType.sleep:ColorType.activity }} />
+                    !summary || summary.sleep.avg == 0 ? <View className="calendar-empty-bg" style={{ borderColor: props.isFastSleep ? ColorType.sleep : ColorType.activity }}>
+                        <View className="calendar-empty-line" style={{ backgroundColor: props.isFastSleep ? ColorType.sleep : ColorType.activity }} />
                     </View> :
-                        <View className={lastSleepValue > summary.sleep.avg ? 'calendar-arrow-bg-down' : 'calendar-arrow-bg'} style={{ backgroundColor: props.isFastSleep?ColorType.sleep:ColorType.activity }}>
+                        <View className={lastSleepValue > summary.sleep.avg ? 'calendar-arrow-bg-down' : 'calendar-arrow-bg'} style={{ backgroundColor: props.isFastSleep ? ColorType.sleep : ColorType.activity }}>
                             <IconBigArrow color="#fff" width={rpxToPx(32)} />
                         </View>
                 }
                 <View className="calendar_summary_item">
-                    <Text className="calendar_summary_title">{props.isFastSleep?t('feature.track_time_duration.weekly.sleep_average'):t('feature.track_time_duration.weekly.wake_average')}</Text>
-                    <Text className="calendar_summary_value" style={{ color: props.isFastSleep?ColorType.sleep:ColorType.activity }}>{!summary || summary.sleep.avg == 0 ? t('feature.track_time_duration.record_fast_sleep.none') : TimeFormatter.calculateTimeDifference(new Date().getTime(), new Date().getTime() + summary.sleep.avg)}</Text>
+                    <Text className="calendar_summary_title">{props.isFastSleep ? t('feature.track_time_duration.weekly.sleep_average') : t('feature.track_time_duration.weekly.wake_average')}</Text>
+                    <Text className="calendar_summary_value" style={{ color: props.isFastSleep ? ColorType.sleep : ColorType.activity }}>{!summary || summary.sleep.avg == 0 ? t('feature.track_time_duration.record_fast_sleep.none') : TimeFormatter.calculateTimeDifference(new Date().getTime(), new Date().getTime() + summary.sleep.avg)}</Text>
                 </View>
             </View>
 
@@ -289,52 +301,35 @@ const WeekCalendar = memo((props:{isFastSleep:boolean}) => {
                                 return <SwiperItem key={index}>
                                     {
                                         showWeeklyItem(index) ?
-                                            <WeekCalendarItem data={item} isCurrentWeek={index == calendars.length - 1} isFastSleep={props.isFastSleep}/> :
+                                            <WeekCalendarItem data={item} isCurrentWeek={index == calendars.length - 1} isFastSleep={props.isFastSleep} /> :
                                             <View style={{ width: parseInt(rpxToPx(658) + ''), flexShrink: 0 }} />
                                     }
                                 </SwiperItem>
                             })
                         }
                     </Swiper>
-                    {/* <ScrollView
-                        style={{
-                            marginLeft: parseInt(rpxToPx(46) + ''),
-                            width: parseInt(rpxToPx(658) + ''),
-                            height: parseInt(rpxToPx(520) + ''),
-                            flexDirection: 'row', display: 'flex',
-
-                        }}
-                        ref={ref}
-                        showScrollbar={false}
-                        onScroll={onScroll}
-                        onDragEnd={dragEnd}
-                        onDragStart={dragStart}
-                        scrollLeft={left}
-                        scrollX pagingEnabled={true}
-                        showsHorizontalScrollIndicator={false}
-                        enableFlex enhanced>
-                        {
-                            calendars.map((item, index) => {
-
-                                if (index == current || index == current - 1 || index == current + 1)
-                                    return <WeekCalendarItem data={item} key={index} isCurrentWeek={index == calendars.length - 1} />
-                                return <View key={index} style={{ width: parseInt(rpxToPx(658) + ''), flexShrink: 0 }} />
-                            })
-                        }
-
-                    </ScrollView> */}
-                </View>
-                <View className="chart_times" style={{ marginTop: parseInt(rpxToPx(60) + ''), marginBottom: parseInt(rpxToPx(60) + '') }}>
-                    <Text className="chart_times_txt" style={{ left: 0, top: 0 }}>12:00</Text>
-                    <Text className="chart_times_txt" style={{ left: 0, top: parseInt(rpxToPx(100 - 7) + '') }}>18:00</Text>
-                    <Text className="chart_times_txt" style={{ left: 0, top: parseInt(rpxToPx(200 - 5) + '') }}>24:00</Text>
-                    <Text className="chart_times_txt" style={{ left: 0, top: parseInt(rpxToPx(300 - 5) + '') }}>06:00</Text>
-                    <Text className="chart_times_txt" style={{ left: 0, bottom: 0 }}>12:00</Text>
                 </View>
+                {
+                    props.isFastSleep ? <View className="chart_times" style={{ marginTop: parseInt(rpxToPx(60) + ''), marginBottom: parseInt(rpxToPx(60) + '') }}>
+                        <Text className="chart_times_txt" style={{ left: 0, top: 0 }}>12:00</Text>
+                        <Text className="chart_times_txt" style={{ left: 0, top: parseInt(rpxToPx(100 - 7) + '') }}>18:00</Text>
+                        <Text className="chart_times_txt" style={{ left: 0, top: parseInt(rpxToPx(200 - 5) + '') }}>24:00</Text>
+                        <Text className="chart_times_txt" style={{ left: 0, top: parseInt(rpxToPx(300 - 5) + '') }}>06:00</Text>
+                        <Text className="chart_times_txt" style={{ left: 0, bottom: 0 }}>12:00</Text>
+                    </View> :
+                        <View className="chart_times" style={{ marginTop: parseInt(rpxToPx(60) + ''), marginBottom: parseInt(rpxToPx(60) + '') }}>
+                            <Text className="chart_times_txt" style={{ left: 0, top: 0 }}>00:00</Text>
+                            <Text className="chart_times_txt" style={{ left: 0, top: parseInt(rpxToPx(100 - 7) + '') }}>06:00</Text>
+                            <Text className="chart_times_txt" style={{ left: 0, top: parseInt(rpxToPx(200 - 5) + '') }}>12:00</Text>
+                            <Text className="chart_times_txt" style={{ left: 0, top: parseInt(rpxToPx(300 - 5) + '') }}>18:00</Text>
+                            <Text className="chart_times_txt" style={{ left: 0, bottom: 0 }}>24:00</Text>
+                        </View>
+                }
+
             </View>
 
         </View>
-        
+
     </View>
 })
 

+ 36 - 16
src/features/trackTimeDuration/components/WeekCalendarItem.tsx

@@ -15,7 +15,7 @@ dayjs.extend(utc)
 dayjs.extend(timezone)
 
 let timer
-export default function WeekCalendarItem(props: { data: any, isCurrentWeek: boolean,isFastSleep:boolean }) {
+export default function WeekCalendarItem(props: { data: any, isCurrentWeek: boolean, isFastSleep: boolean }) {
     const [charts, setCharts] = useState([])
     const [showCurrentTime, setShowCurrentTime] = useState(false)
     const [position, setPosition] = useState({ left: 0, top: 0 })
@@ -55,18 +55,18 @@ export default function WeekCalendarItem(props: { data: any, isCurrentWeek: bool
                 var real_start = item.real_start_time
                 var real_end = item.real_end_time
 
-                
+
 
                 //睡眠数据下,以fast_end为准
-                if (item.fast_real_end_timezone && item.fast_real_end_timezone.id){
-                    var strEnd = TimeFormatter.tzTimeFormateLocalTime(real_end, item.fast_real_end_timezone.id,'YYYY-MM-DDTHH:mm:ss')
+                if (item.fast_real_end_timezone && item.fast_real_end_timezone.id) {
+                    var strEnd = TimeFormatter.tzTimeFormateLocalTime(real_end, item.fast_real_end_timezone.id, 'YYYY-MM-DDTHH:mm:ss')
                     var duration = real_end - real_start
                     real_end = new Date(strEnd).getTime()
                     real_start = real_end - duration
                 }
 
                 else if (item.real_end_timezone && item.real_end_timezone.id) {
-                    var strEnd = TimeFormatter.tzTimeFormateLocalTime(real_end, item.real_end_timezone.id,'YYYY-MM-DDTHH:mm:ss')
+                    var strEnd = TimeFormatter.tzTimeFormateLocalTime(real_end, item.real_end_timezone.id, 'YYYY-MM-DDTHH:mm:ss')
                     var duration = real_end - real_start
                     real_end = new Date(strEnd).getTime()
                     real_start = real_end - duration
@@ -163,13 +163,21 @@ export default function WeekCalendarItem(props: { data: any, isCurrentWeek: bool
     function isTop() {
         var now = new Date()
         if (now.getHours() >= 12) {
+            if (!props.isFastSleep) return false;
             return true
         }
+        if (!props.isFastSleep) return true;
         return false
     }
 
     function weekIndex() {
         var week = new Date().getDay()
+        if (!props.isFastSleep){
+            if (week==0){
+                return 6;
+            }
+            return week-1;
+        }
         if (!isTop()) {
             return week - 1
         }
@@ -177,15 +185,27 @@ export default function WeekCalendarItem(props: { data: any, isCurrentWeek: bool
     }
     return <View className="chart_content" style={{ width: parseInt(rpxToPx(658) + '') }}>
         <View style={{ height: parseInt(rpxToPx(60) + '') }}>
-            <View className="chart_top_week">
-                <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(0) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 0 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(0)}</Text>
-                <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 1) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 1 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(1)}</Text>
-                <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 2) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 2 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(2)}</Text>
-                <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 3) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 3 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(3)}</Text>
-                <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 4) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 4 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(4)}</Text>
-                <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 5) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 5 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(5)}</Text>
-                <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 6) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 6 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(6)}</Text>
-            </View>
+            {
+                props.isFastSleep ? <View className="chart_top_week">
+                    <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(0) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 0 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(0)}</Text>
+                    <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 1) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 1 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(1)}</Text>
+                    <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 2) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 2 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(2)}</Text>
+                    <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 3) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 3 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(3)}</Text>
+                    <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 4) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 4 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(4)}</Text>
+                    <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 5) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 5 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(5)}</Text>
+                    <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 6) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 6 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(6)}</Text>
+                </View> :
+                    <View className="chart_top_week">
+                        <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(0) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 0 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(1)}</Text>
+                        <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 1) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 1 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(2)}</Text>
+                        <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 2) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 2 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(3)}</Text>
+                        <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 3) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 3 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(4)}</Text>
+                        <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 4) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 4 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(5)}</Text>
+                        <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 5) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 5 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(6)}</Text>
+                        <Text className="chart_week_text" style={{ left: parseInt(rpxToPx(94 * 6) + ''), opacity: props.isCurrentWeek && isTop() && weekIndex() == 6 ? 1 : 0.4 }}>{TimeFormatter.getDayOfWeek(0)}</Text>
+                    </View>
+            }
+
         </View>
 
         <View className="chart_detail">
@@ -209,7 +229,7 @@ export default function WeekCalendarItem(props: { data: any, isCurrentWeek: bool
                                 {
                                     (item as any).fasts.map((obj, k) => {
                                         return <View key={k} className="detailLine" style={{
-                                            backgroundColor: props.isFastSleep?ColorType.fast:ColorType.food,
+                                            backgroundColor: props.isFastSleep ? ColorType.fast : ColorType.food,
                                             top: rpxToPx(obj.begin * 400),
                                             height: rpxToPx(obj.height * 400)
                                         }} />
@@ -224,7 +244,7 @@ export default function WeekCalendarItem(props: { data: any, isCurrentWeek: bool
                                 {
                                     (item as any).sleeps.map((obj, j) => {
                                         return <View key={j} className="detailLine" style={{
-                                            backgroundColor: props.isFastSleep?ColorType.sleep:ColorType.activity,
+                                            backgroundColor: props.isFastSleep ? ColorType.sleep : ColorType.activity,
                                             top: rpxToPx(obj.begin * 400),
                                             height: rpxToPx(obj.height * 400)
                                         }} />