Leon il y a 1 an
Parent
commit
f615a6e873

+ 38 - 12
src/components/input/LimitPickers.tsx

@@ -10,7 +10,10 @@ const Component = forwardRef((props: {
     limit: number, onChange: Function, onCancel: Function,
     isRealTime?: boolean, limitDay?: number, time?: number, themeColor?: string, title?: string,
     showEndTime?: boolean,
-    duration?: number
+    duration?: number,
+    isFast?: boolean,
+    isEnd?: boolean,
+    endTimestamp?: number
 }, ref) => {
 
     const days: string[] = [];
@@ -45,14 +48,14 @@ const Component = forwardRef((props: {
             date = new Date(global.set_time);
         }
 
-        date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 6) - values[0]));
+        date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 5) - values[0]));
         date.setHours(values[1])
         date.setMinutes(values[2])
         global.picker_time = date.getTime()
     }, [values])
 
 
-    for (let i = props.limitDay ? props.limitDay - 1 : 6; i >= 0; i--) {
+    for (let i = props.limitDay ? props.limitDay - 1 : 5; i >= 0; i--) {
         const date = new Date();
         date.setDate(today.getDate() - i);
 
@@ -126,7 +129,7 @@ const Component = forwardRef((props: {
         }
 
         var date = new Date();
-        date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 6) - values[0]));
+        date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 5) - values[0]));
         const year = date.getFullYear();
         const month = date.getMonth() + 1;
         const day = date.getDate();
@@ -145,7 +148,7 @@ const Component = forwardRef((props: {
 
         if (!props.isRealTime) {
             date = new Date(global.set_time);
-            date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 6) - values[0]));
+            date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 5) - values[0]));
         }
 
         // 
@@ -161,7 +164,7 @@ const Component = forwardRef((props: {
         }
 
 
-        date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 6) - values[0]));
+        date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 5) - values[0]));
         date.setHours(values[1])
         date.setMinutes(values[2])
         return date.getTime()
@@ -175,16 +178,39 @@ const Component = forwardRef((props: {
         return num < 10 ? `0${num}` : `${num}`;
     }
 
-    function getEndTime(){
+    function getEndTime() {
         var date = new Date(global.set_time);
-        date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 6) - values[0]));
+        date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 5) - values[0]));
         date.setHours(values[1])
         date.setMinutes(values[2])
-        var newDate = new Date(date.getTime()+props.duration!).getTime()
+        var newDate = new Date(date.getTime() + props.duration!).getTime()
         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)
+    }
+
+    function pickerTimeText() {
+        if (props.isFast) {
+            if (props.isEnd) {
+                return `原定于${getEndTimestamp(props.endTimestamp!)}结束`
+            }
+            return `预计${getEndTime()}结束`
+        }
+        else {
+            if (props.isEnd) {
+                return `原定于${getEndTimestamp(props.endTimestamp!)}起床`
+            }
+            return `预计${getEndTime()}起床`
+
+        }
     }
 
     function pickerDetail() {
@@ -229,7 +255,7 @@ const Component = forwardRef((props: {
             </View> */}
             </View>
             {
-                props.showEndTime && <Text className="pickerEndTime">预计{getEndTime()}结束</Text>
+                props.showEndTime && <Text className="pickerEndTime">{pickerTimeText()}</Text>
             }
             <View className='modal_operate'>
                 <View className='modal_btn' style={{ backgroundColor: color + alpha }} onClick={cancel}>

+ 23 - 4
src/components/input/LimitTimeoutPickers.tsx

@@ -10,7 +10,9 @@ import { TimeFormatter } from "@/utils/time_format";
 let todayIndex = -1
 const Component = forwardRef((props: {
     limit: number, onChange: Function, onCancel: Function,
-    isRealTime?: boolean, limitDay?: number, time: number, themeColor?: string, title?: string
+    isRealTime?: boolean, limitDay?: number, time: number, themeColor?: string, title?: string,
+    isFast?: boolean,
+    endTimestamp?: number
 }, ref) => {
 
     const days: string[] = [];
@@ -69,12 +71,12 @@ const Component = forwardRef((props: {
         const weekday = TimeFormatter.getDayOfWeek(date.getDay(), true);
         const formattedDate = global.language == 'en' ? `${weekday} ${TimeFormatter.getMonth(month)} ${day}` : `${TimeFormatter.getMonth(month)}${day}日 ${weekday}`;
         var today1 = new Date();
-        var yesterday = new Date(today1.getTime()-24*3600*1000)
-        if (date.getMonth()==today1.getMonth() && date.getDate()==today1.getDate()){
+        var yesterday = new Date(today1.getTime() - 24 * 3600 * 1000)
+        if (date.getMonth() == today1.getMonth() && date.getDate() == today1.getDate()) {
             days.push(TimeFormatter.getTodayUnit());
             todayIndex = i
         }
-        else if (date.getMonth()==yesterday.getMonth() && date.getDate()==yesterday.getDate()) {
+        else if (date.getMonth() == yesterday.getMonth() && date.getDate() == yesterday.getDate()) {
             days.push(TimeFormatter.getYesterdayUnit());
         }
         else {
@@ -199,6 +201,22 @@ const Component = forwardRef((props: {
         return num < 10 ? `0${num}` : `${num}`;
     }
 
+    function getEndTimestamp(timestamp) {
+        if (global.language == 'en') {
+            return TimeFormatter.dateDescription(timestamp, true) + ' ' + TimeFormatter.timeDescription(timestamp)
+        }
+        return TimeFormatter.dateDescription(timestamp, true) + '' + TimeFormatter.timeDescription(timestamp)
+    }
+
+    function pickerTimeText() {
+        if (props.isFast) {
+            return `原定于${getEndTimestamp(props.endTimestamp!)}结束`
+        }
+        else {
+            return `原定于${getEndTimestamp(props.endTimestamp!)}起床`
+        }
+    }
+
     function pickerDetail() {
         return <View style={{ display: 'flex', flexDirection: 'column' }}>
             <Text className='modal_title' style={{ color: color }}>{props.title ? props.title : '测试标题 '}</Text>
@@ -240,6 +258,7 @@ const Component = forwardRef((props: {
                 <Text style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>:</Text>
             </View> */}
             </View>
+            <Text className="pickerEndTime" style={{color:'red'}}>{pickerTimeText()}</Text>
             <View className='modal_operate'>
                 <View className='modal_btn' style={{ backgroundColor: color + alpha }} onClick={cancel}>
                     <Text className='modal_cancel_text' style={{ color: color, fontWeight: 'bold' }}>{t('feature.common.picker_cancel_btn')}</Text>

+ 6 - 1
src/context/locales/en.js

@@ -215,7 +215,12 @@ export default {
             stages: 'Stages',
             get_local_time: 'Show local nighttime',
             get_local_time_sunrise: 'Show local daytime',
-            to:' to '
+            to:' to ',
+            note:'Note',
+            alert_night_content:'Sunset and sunrise times are global annual averages. Actual times vary depending on your location and season.',
+            alert_day_content:'Sunrise and sunset times are global annual averages. Actual times vary depending on your location and season.',
+            got_it:'Got it',
+            more:'More'
         },
         track_time_duration: {
             common: {

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

@@ -220,7 +220,12 @@ export default {
             stages: '阶段',
             get_local_time: '显示当地时间',
             get_local_time_sunrise: '显示当地时间',
-            to: '至'
+            to: '至',
+            note:'提示',
+            alert_night_content:'日落日出时间为全球年平均值。\n实际时间会根据您所在的位置和季节有所变化。',
+            alert_day_content:'日出日落时间为全球年平均值。\n实际时间会根据您所在的位置和季节有所变化。',
+            got_it:'我知道了',
+            more:'更多'
         },
         track_time_duration: {
             common: {
@@ -253,7 +258,7 @@ export default {
 
                 enable_schedule_fast_content: '每日 {{time}} 提醒您开始断食。',
                 enable_schedule_sleep_content: '每日 {{time}} 提醒您就寝。',
-                enable_schedule_mix_content: '每日 {{time1}} 提醒您开始断食,每日 {{time2}} 提醒您就寝。',
+                enable_schedule_mix_content: '每日 {{time1}} 提醒您开始断食,\n每日 {{time2}} 提醒您就寝。',
                 enable_post_fast_content: '{{time}} 提醒您结束断食。',
                 enable_post_sleep_content: '{{time}} 提醒您起床。',
 

+ 13 - 4
src/features/trackTimeDuration/components/DayNightCard.tsx

@@ -894,13 +894,22 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
             e.stopPropagation()
         }
         if (user.test_user && authInfo && authInfo.lat) {
+            tapCard(e)
             return
         }
         Taro.showModal({
-            title: 'Note',
-            content: 'Sunset and sunrise times are global average. Actual times vary depending on your location and time of year.',
-            showCancel:false,
-            confirmText:'Got it'
+            title: t('feature.day_night.note'),
+            content: props.isNight ? t('feature.day_night.alert_night_content') : t('feature.day_night.alert_day_content'),
+            cancelText: t('feature.day_night.got_it'),
+            confirmText: t('feature.day_night.more'),
+            success: function (res) {
+                if (res.confirm) {
+                    setShowDetailPopup(true)
+                    // console.log('用户点击确定')
+                } else if (res.cancel) {
+                    console.log('用户点击取消')
+                }
+            }
         })
     }
 

+ 23 - 2
src/features/trackTimeDuration/components/IndexConsole.tsx

@@ -171,11 +171,23 @@ export default function IndexConsole(props: { record: any }) {
         if (operateType == 'startSleep' && currentRecord.sleep) {
             duration = currentRecord.sleep.target_end_time - currentRecord.sleep.target_start_time
         }
+
+        var endTimestamp = 0
+        if (operateType == 'endFast') {
+            endTimestamp = currentRecord.fast.target_end_time
+        }
+        else if (operateType == 'endSleep') {
+            endTimestamp = currentRecord.sleep.target_end_time
+        }
         return <View className="modal_content">
-            <LimitPickers ref={limitPickerRef} limit={limit} limitDay={8}
+            <LimitPickers ref={limitPickerRef} limit={limit} limitDay={7}
                 themeColor={color}
                 title={title}
-                showEndTime={operateType == 'startFast' || operateType == 'startSleep'}
+                showEndTime={true}
+                isFast={operateType == 'startFast' || operateType == 'endFast'}
+                isEnd={operateType == 'endFast' || operateType == 'endSleep'}
+                endTimestamp={endTimestamp}
+                // showEndTime={operateType == 'startFast' || operateType == 'startSleep'}
                 duration={duration}
                 onCancel={hidePicker} onChange={(e) => {
                     pickerConfirm(e)
@@ -194,10 +206,19 @@ export default function IndexConsole(props: { record: any }) {
             limit = 0
             targetTime = props.record.current_record.sleep.real_end_time + 60 * 1000
         }
+        var endTimestamp = 0
+        if (operateType == 'endFast') {
+            endTimestamp = currentRecord.fast.target_end_time
+        }
+        else if (operateType == 'endSleep') {
+            endTimestamp = currentRecord.sleep.target_end_time
+        }
         return <View className="modal_content">
             <LimitTimeoutPickers ref={limitPickerRef} limit={limit} limitDay={7}
                 themeColor={color}
                 title={title}
+                isFast={operateType == 'endFast'}
+                endTimestamp={endTimestamp}
                 time={operateType == 'endFast' ? new Date(targetTime).getTime() :
                     new Date(props.record.current_record.sleep.target_end_time).getTime()
                 }

+ 17 - 51
src/features/trackTimeDuration/components/SetSchedule.weapp.tsx

@@ -152,33 +152,14 @@ export default function Component() {
         global.indexPageRefresh()
 
         Taro.navigateBack({ delta: 3 }).then(res => {
-          if (permission.wxPubFollow) {
-            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') :
-                t('feature.track_time_duration.reminders.enable_schedule_sleep_content'),
-              showCancel: false,
-              confirmText: t('feature.track_time_duration.reminders.ok')
-            })
-          }
-          else {
-            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) {
-                }
-              }
-            })
-          }
+
         })
+
+        debugger
+        setTimeout(() => {
+          debugger
+          global.popScheduleAlert(scenario, startTime)
+        }, 1000)
       }).catch(e => {
         setBtnDisable(false)
       })
@@ -246,31 +227,16 @@ export default function Component() {
       setBtnDisable(false)
       dispatch(setStep('fast'))
       // global.checkData()
-      Taro.navigateBack({ delta: 4 }).then(res => {
-        if (permission.wxPubFollow) {
-          Taro.showModal({
-            title: t('feature.track_time_duration.reminders.schedule_title'),
-            content:
-              t('feature.track_time_duration.reminders.schedule_mix_content'),
-            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.enable_schedule_mix_content', { time1: scenario.schedule.fast.start_time, time2: scenario.schedule.sleep.start_time }),
-            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) {
-              }
-            }
-          })
-        }
-      })
+      Taro.navigateBack({ delta: 4 })
+
+      debugger
+      setTimeout(() => {
+        debugger
+        global.popMixScheduleAlert(scenario.schedule.fast.start_time, scenario.schedule.sleep.start_time)
+      }, 1000)
+
+
+
       global.indexPageRefresh()
     }).catch(e => {
       setBtnDisable(false)

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

@@ -84,6 +84,8 @@ export default function Page() {
 
     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);
 
@@ -381,6 +383,72 @@ export default function Page() {
 
     }
 
+    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') {