Leon %!s(int64=2) %!d(string=hai) anos
pai
achega
9de1bedada

+ 12 - 9
src/features/trackTimeDuration/components/Console.tsx

@@ -16,7 +16,7 @@ export default function Component() {
     const [key, setKey] = useState('');
     const [value, setValue] = useState('');
     const user = useSelector((state: any) => state.user);
-    // const common = useSelector((state: any) => state.common);
+    const common = useSelector((state: any) => state.common);
     const [isFast, setIsFast] = useState(true);
     const [fastValues, setFastValues] = useState<number[]>([0, 0]);
     const [sleepValues, setSleepValues] = useState<number[]>([0, 0]);
@@ -28,6 +28,7 @@ export default function Component() {
     const [showModal, setShowModal] = useState(false);
     const [fastPickerValue, setFastPickerValue] = useState([0,0])
     const [sleepPickerValue, setSleepPickerValue] = useState([0,0])
+    const [isOpenDurationPicker, setIsOpenDurationPicker] = useState(false)
 
     // const [pickerValue, setPickerValue] = useState([0,0])
 
@@ -93,7 +94,7 @@ export default function Component() {
                 setFastStr(fastTime);
                 var fastCount = current_record.fast.target_end_time - current_record.fast.target_start_time
                 setFastDuration(fastCount)
-                // setFastPickerValue(durationIndex(current_record.fast.target_start_time, current_record.fast.target_end_time, common))
+                setFastPickerValue(durationIndex(current_record.fast.target_start_time, current_record.fast.target_end_time, common))
                 // setFastPickerValue([fastCount / 60000 / 5 - 12])
             }
 
@@ -109,7 +110,7 @@ export default function Component() {
                 var sleepCount = current_record.sleep.target_end_time - current_record.sleep.target_start_time
 
                 setSleepDuration(sleepCount)
-                // setSleepPickerValue(durationIndex(current_record.sleep.target_start_time, current_record.sleep.target_end_time, common))
+                setSleepPickerValue(durationIndex(current_record.sleep.target_start_time, current_record.sleep.target_end_time, common))
                 // setSleepPickerValue([sleepCount / 60000 / 5 - 12])
             }
         }
@@ -205,9 +206,11 @@ export default function Component() {
     };
 
     function durationChange(e) {
-        var count = e[0] * 5 + 60;
+        var count = (e[0]+common.duration.min)*60+e[1]*common.duration.step
         isFast ? setFastDuration(count * 60000) : setSleepDuration(count * 60000);
-        isFast ? setFastPickerValue(e[0]) : setSleepPickerValue(e[0]);
+        isFast?setFastPickerValue(e):setSleepPickerValue(e)
+
+        setIsOpenDurationPicker(false)
     }
 
     function login() {
@@ -233,7 +236,7 @@ export default function Component() {
     }
 
     function showDurationPicker() {
-
+        setIsOpenDurationPicker(true)
     }
 
     if (!user.isLogin) {
@@ -245,10 +248,10 @@ export default function Component() {
         </View>
     }
 
-    const [isOpenDurationPicker, setIsOpenDurationPicker] = useState(false)
+    
     function durationPickerContent() {
         return <View style={{ color: '#000' }}>
-            {/* <PickerViews onChange={durationChange} items={durationDatas(common)} value={isFast?fastPickerValue:sleepPickerValue} height={200} showBtns={true} onCancel={() => { setIsOpenDurationPicker(false) }} /> */}
+            <PickerViews onChange={durationChange} items={durationDatas(common)} value={isFast?fastPickerValue:sleepPickerValue} height={200} showBtns={true} onCancel={() => { setIsOpenDurationPicker(false) }} />
         </View>
     }
     return (
@@ -268,7 +271,7 @@ export default function Component() {
             }
             {
                 (value == 'ONGOING1' || value == 'WAIT_FOR_START') &&
-                <Text onClick={showDurationPicker}>{durationFormate()}</Text>
+                <Text style={{marginBottom:10}} onClick={showDurationPicker}>时长:{durationFormate()}</Text>
                 // <PickerViews onChange={durationChange} items={[pickerDurations()]} value={isFast ? [fastPickerValue] : [sleepPickerValue]} />
                 // <TimePickers time={isFast ? fastStr : sleepStr} content="" change={handlePickerChange} isPickerView={true} />
             }

+ 2 - 2
src/features/trackTimeDuration/hooks/Console.tsx

@@ -39,10 +39,10 @@ export const durationDatas = (common: any) => {
 
 //通过开始时间和结束时间计算picker的index值,返回格式为[hourIndex,minuteIndex]
 export const durationIndex = (start: string, end: string,common: any) => {
-    if (start.indexOf(':') == -1) {
+    if ((start+'').indexOf(':') == -1) {
         start = TimeFormatter.formatTime(new Date(parseInt(start+'')));
     }
-    if (end.indexOf(':') == -1) {
+    if ((end+'').indexOf(':') == -1) {
         end = TimeFormatter.formatTime(new Date(parseInt(end+'')));
     }
 

+ 1 - 1
src/pages/clock.tsx

@@ -232,7 +232,7 @@ export default function IndexPage() {
       <TitleBar />
       <Clocks />
       <View className='console_box'>
-        {/* <Console /> */}
+        <Console />
       </View>
 
       <More ref={global.moreRef}/>