Leon 1 yıl önce
ebeveyn
işleme
76a08d7596

+ 5 - 5
config/index.ts

@@ -17,11 +17,11 @@ const config = {
   },
   copy: {
     patterns: [
-      {
-        from: `node_modules/tdesign-miniprogram-taro/miniprogram_dist/`,
-        to: `dist/miniprogram_npm/tdesign-miniprogram/`,
-        ignore: ['*.ts', '*.map', 'type.js']
-      },
+      // {
+      //   from: `node_modules/tdesign-miniprogram-taro/miniprogram_dist/`,
+      //   to: `dist/miniprogram_npm/tdesign-miniprogram/`,
+      //   ignore: ['*.ts', '*.map', 'type.js']
+      // },
     ],
     options: {
     }

+ 2 - 0
src/context/locales/en.js

@@ -118,6 +118,8 @@ export default {
             become_pro: 'Become Pro',
             overnight: 'Overnight',
             day: 'Day',
+            eat:'Eat',
+            move:'Move',
             toast: {
                 min_value: 'Cannot go any lower',
                 max_value: 'Cannot go any higher',

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

@@ -120,6 +120,8 @@ export default {
             become_pro:'成为会员',
             overnight: '夜间',
             day: '白天',
+            eat:'进食',
+            move:'活动',
             toast: {
                 min_value: '不能再小了',
                 max_value: '不能再大了',

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

@@ -67,7 +67,7 @@ export default function ClockHeader(props: { homeData: any }) {
         var data = props.homeData.fast_sleep
         var status = data.current_record.status
         var itemList: any = []
-        itemList.push(t('feature.track_time_duration.action_sheet.set_sleep_goal'))
+        itemList.push(t('feature.track_time_duration.action_sheet.set_new_goals'))
         // if (status == 'WAIT_FOR_START') {
         //     itemList.push(t('feature.track_time_duration.action_sheet.set_new_goals'))
         //     itemList.push(t('feature.track_time_duration.action_sheet.set_fast_goal'))

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

@@ -250,7 +250,7 @@ export default function DayLight() {
                     t('feature.track_time_duration.third_ring.enter_location_desc')
             }</Text>
         }
-
+ 
         {
             showRing && <View style={{marginTop:rpxToPx(40)}}>
 

+ 27 - 36
src/features/trackTimeDuration/components/Discovery.tsx

@@ -284,20 +284,20 @@ export default function Discovery() {
             }
             {schedule && <View className="duration_bg">
                 {
-                    showRing && <Text className="duration_title">白天</Text>
+                    showRing && <Text className="duration_title">{t('feature.common.day')}</Text>
                 }
                 {
                     showRing &&
                     <Text className="duration_value" style={{ color: ColorType.day }}>{dayDuration()}</Text>
                 }
                 {
-                    <Text className="duration_title">限时进食</Text>
+                    <Text className="duration_title">{t('feature.common.eat')}</Text>
                 }
                 {
                     <Text className="duration_value" style={{ color: ColorType.food }}>{eatDuration()}</Text>
                 }
                 {
-                    <Text className="duration_title">活动</Text>
+                    <Text className="duration_title">{t('feature.common.move')}</Text>
                 }
                 {
                     <Text className="duration_value" style={{ color: ColorType.activity }}>{activityDuration()}</Text>
@@ -311,42 +311,33 @@ export default function Discovery() {
         <View className="food_btn1" style={{ backgroundColor: ColorType.activity }} onClick={goAcitivity}>
             <Text style={{ fontWeight: 'bold' }}>运动训练</Text>
         </View>
-        <View style={{
-            display: 'flex', flexDirection: 'row',
-            justifyContent: 'space-between',
-            marginLeft: rpxToPx(46), marginRight: rpxToPx(46)
-        }}>
-            <Text style={{ color: '#fff' }}>白天</Text>
-            <Switch checked={showRing}
-                color={ColorType.day}
-                onChange={(e) => {
-                    setShowRing(e.detail.value)
-                    uploadPerm({ show_day_ring: e.detail.value })
-                    Taro.setStorage({
-                        key: 'showDayRing',
-                        data: e.detail.value
-                    })
-                }}
-            />
-        </View>
-        <View>
-            <View style={{
-                display: 'flex', flexDirection: 'row',
-                justifyContent: 'space-between',
-                marginLeft: rpxToPx(46), marginRight: rpxToPx(46)
-            }}>
-                <Text style={{ color: '#fff' }}>Sunrise today</Text>
-                <Text style={{ color: '#fff' }}>{
+
+        <View className="cell_bg" style={{ marginTop: 20 }}>
+            <View className="cell_full">
+                <Text className="cell_title">{t('feature.common.day')}</Text>
+                <Switch checked={showRing}
+                    color={ColorType.day}
+                    onChange={(e) => {
+                        setShowRing(e.detail.value)
+                        uploadPerm({ show_day_ring: e.detail.value })
+                        Taro.setStorage({
+                            key: 'showDayRing',
+                            data: e.detail.value
+                        })
+                    }}
+                />
+            </View>
+            <View className="cell_line" style={{ height: 1 }} />
+            <View className="cell_full">
+                <Text className="cell_title">{t('feature.track_time_duration.third_ring.sunrise_today')}</Text>
+                <Text className="cell_value" style={{ color: '#fff' }}>{
                     dayNight.isMember && dayNight.gpsInfo ? dayNight.gpsInfo.daylights[0].sunrise : '06:00'
                 }</Text>
             </View>
-            <View style={{
-                display: 'flex', flexDirection: 'row',
-                justifyContent: 'space-between',
-                marginLeft: rpxToPx(46), marginRight: rpxToPx(46)
-            }}>
-                <Text style={{ color: '#fff' }}>Sunset today</Text>
-                <Text style={{ color: '#fff' }}>{
+            <View className="cell_line" style={{ height: 1 }} />
+            <View className="cell_full">
+                <Text className="cell_title">{t('feature.track_time_duration.third_ring.sunset_today')}</Text>
+                <Text className="cell_value" style={{ color: '#fff' }}>{
                     dayNight.isMember && dayNight.gpsInfo ? dayNight.gpsInfo.daylights[0].sunset : '18:00'
                 }</Text>
             </View>

+ 164 - 4
src/features/trackTimeDuration/components/DurationPicker.tsx

@@ -1,13 +1,23 @@
-import { View } from "@tarojs/components"
-import { useEffect, useState } from "react"
-import { durationIndex } from "../hooks/Console"
+import { PageContainer, View } from "@tarojs/components"
+import { useEffect, useRef, useState } from "react"
+import { durationDatas, durationIndex, getColor, getDurationTitle } from "../hooks/Console"
 import { useSelector } from "react-redux"
+import Taro from "@tarojs/taro"
+import { useTranslation } from "react-i18next"
+import PickerViews from "@/components/input/PickerViews"
+import { ColorType } from "@/context/themes/color"
+import { updateRecord } from "@/services/trackTimeDuration"
+import Modal from "@/components/layout/Modal.weapp";
 
 export default function DurationPicker(props: { record: any }) {
     const [showDurationPicker, setShowDurationPicker] = useState(false)
     const [fastPickerValue, setFastPickerValue] = useState([0, 0])
     const [sleepPickerValue, setSleepPickerValue] = useState([0, 0])
     const [showEditPicker, setShowEditPicker] = useState(false)
+    const [isFast, setIsFast] = useState(true)
+    const durationPickerRef = useRef(null)
+    const { t } = useTranslation()
+
     const common = useSelector((state: any) => state.common);
 
     useEffect(() => {
@@ -22,6 +32,156 @@ export default function DurationPicker(props: { record: any }) {
             setSleepPickerValue(durationIndex(current_record.sleep.target_start_time, current_record.sleep.target_end_time, common))
     }
 
+    global.showFastPicker = () => {
+        setFastDuration()
+    }
+
+    global.showSleepPicker = () => {
+        setSleepDuration()
+    }
+
+    function setFastDuration() {
+        setIsFast(true)
+        if (props.record.status == 'WAIT_FOR_START') {
+            setShowDurationPicker(true)
+        }
+        else {
+            setShowEditPicker(true)
+        }
+    }
+
+    function setSleepDuration() {
+        setIsFast(false)
+        if (props.record.status == 'WAIT_FOR_START') {
+            Taro.showToast({
+                title: t('feature.track_time_duration.common.start_fasting_first'),
+                icon: 'none'
+            })
+            return;
+        }
+        if (props.record.status == 'WAIT_FOR_START' || props.record.status == 'ONGOING1') {
+            setShowDurationPicker(true)
+        }
+        else {
+            setShowEditPicker(true)
+        }
+    }
+
+    function durationPickerContent() {
+        var color = getColor(props.record)
+        var title = getDurationTitle(props.record, t)
+        return <View style={{ color: '#fff', backgroundColor: 'transparent' }}>
+
+
+            <PickerViews ref={durationPickerRef}
+                onChange={durationChange}
+                items={durationDatas(common)}
+                value={isFast ? fastPickerValue : sleepPickerValue}
+                themeColor={color}
+                title={title}
+                showBtns={true}
+                onCancel={() => {
+                    setShowDurationPicker(false)
+                }} />
+        </View>
+    }
+
+    function editPickerContent() {
+        return <View style={{ color: '#fff', backgroundColor: 'transparent' }}>
+            <PickerViews ref={durationPickerRef}
+                onChange={durationChange}
+                items={durationDatas(common)}
+                value={isFast ? fastPickerValue : sleepPickerValue}
+                themeColor={isFast ? ColorType.fast : ColorType.sleep}
+                title={isFast ? t('feature.track_time_duration.action_sheet.edit_fasting_goal') :
+                    t('feature.track_time_duration.action_sheet.edit_sleeping_goal')}
+                showBtns={true}
+                onCancel={() => {
+                    setShowEditPicker(false)
+                }} />
+        </View>
+    }
+
+    function durationChange(e) {
+        // debugger
+        var count = (e[0] + common.duration.min) * 60 + e[1] * common.duration.step
+        // var count = (e[0] + 1) * 60 + e[1] * 5
+        if (showDurationPicker) {
+            global.changeTargetDuration(count, isFast)
+        }
+        else {
+            var params: any = {}
+            if (isFast) {
+                params = {
+                    fast: {
+                        target_duration: count * 60 * 1000
+                    }
+                }
+            }
+            else {
+                params = {
+                    sleep: {
+                        target_duration: count * 60 * 1000
+                    }
+                }
+            }
+            updateRecord({
+                ...params
+            }, props.record.id).then(res => {
+                global.indexPageRefresh()
+            }).catch(e => {
+
+            })
+        }
+        setShowDurationPicker(false)
+        setShowEditPicker(false)
+    }
+
+    function modalContent() {
+        if (showDurationPicker || showEditPicker) {
+            if (process.env.TARO_ENV == 'weapp') {
+                return <Modal
+                    testInfo={null}
+                    dismiss={() => {
+                        setShowDurationPicker(false)
+                        setShowEditPicker(false)
+                    }}
+                    confirm={() => { }}>
+                    {
+                        showDurationPicker ? durationPickerContent() : editPickerContent()
+                    }
+                </Modal>
+            }
+            else if (process.env.TARO_ENV == 'rn') {
+                return <PageContainer style={{ backgroundColor: '#1c1c1c' }}
+                    // overlayStyle='background-color:rgba(0,0,0,0.9)'
+                    // custom-style='background-color:#1c1c1c'
+                    overlayStyle={{ backgroundColor: 'rgba(0,0,0,0.9)' }}
+                    customStyle={{ backgroundColor: '#1c1c1c' }}
+                    closeOnSlideDown={false}
+                    onBeforeEnter={() => {
+
+                    }}
+                    onBeforeLeave={() => {
+                    }}
+                    onClick={() => { alert('b') }}
+                    onClickOverlay={() => { alert('a') }}
+                    onAfterLeave={() => { setShowDurationPicker(false); setShowEditPicker(false) }}
+                    show={showDurationPicker} round={true} overlay={true} position='bottom'
+                >
+                    {
+                        showDurationPicker ? durationPickerContent() : editPickerContent()
+                    }
+                </PageContainer>
+            }
+        }
+        return <View />
+    }
+
 
-    return <View style={{ width: 0, height: 0, opacity: 0 }} />
+    return <View style={{ width: 0, height: 0 }}>
+        {
+            modalContent()
+        }
+    </View>
 }

+ 2 - 21
src/features/trackTimeDuration/components/IndexItem.tsx

@@ -334,33 +334,14 @@ export default function Component(props: { type: string, data: any, time: any, s
     }
 
     function fastPicker() {
-        var node = schedules()
-        global.showIndexModal2(true, node, null);
-        popTimer = setInterval(() => {
-            var node = schedules()
-            global.showIndexModal2(true, node, null);
-        }, 1000)
-        global.popTimer = popTimer
+        global.showFastPicker()
     }
 
     function sleepPicker(e) {
         if (record.status == 'ONGOING3') {
             return;
         }
-        if (record.status == 'WAIT_FOR_START') {
-            Taro.showToast({
-                title: t('feature.track_time_duration.common.start_fasting_first'),
-                icon: 'none'
-            })
-            return;
-        }
-        var node = schedules()
-        global.showIndexModal2(true, node, null);
-        popTimer = setInterval(() => {
-            var node = schedules()
-            global.showIndexModal2(true, node, null);
-        }, 1000)
-        global.popTimer = popTimer
+        global.showSleepPicker()
     }
 
     return <View className="time_operate_item">

+ 5 - 157
src/features/trackTimeDuration/components/TotalTime.tsx

@@ -4,37 +4,18 @@ import { useTranslation } from "react-i18next";
 import { ColorType } from "@/context/themes/color";
 import { rpxToPx } from "@/utils/tools";
 import { TimeFormatter } from "@/utils/time_format";
-import Modal from "@/components/layout/Modal.weapp";
 import { useEffect, useRef, useState } from "react";
-import { durationDatas, durationIndex, getColor, getDurationTitle } from "../hooks/Console";
-import PickerViews from "@/components/input/PickerViews";
-import { useSelector } from "react-redux";
-import Taro from "@tarojs/taro";
-import { updateRecord } from "@/services/trackTimeDuration";
+
 
 export default function TotalTime(props: { record: any }) {
-    const [showDurationPicker, setShowDurationPicker] = useState(false)
-    const [fastPickerValue, setFastPickerValue] = useState([0, 0])
-    const [sleepPickerValue, setSleepPickerValue] = useState([0, 0])
-    const [showEditPicker, setShowEditPicker] = useState(false)
     const [count, setCount] = useState(0)
-    const common = useSelector((state: any) => state.common);
-    const [isFast, setIsFast] = useState(true)
-    const durationPickerRef = useRef(null)
     const { t } = useTranslation()
 
     useEffect(() => {
-        getStateDetail()
         setCount((pre) => pre + 1)
     }, [props.record])
 
-    function getStateDetail() {
-        var current_record = props.record
-        if (current_record.fast)
-            setFastPickerValue(durationIndex(current_record.fast.target_start_time, current_record.fast.target_end_time, common))
-        if (current_record.sleep)
-            setSleepPickerValue(durationIndex(current_record.sleep.target_start_time, current_record.sleep.target_end_time, common))
-    }
+
 
     function sleepCompleteStatus() {
         if (props.record.sleep.status == "NOT_STARTED") {
@@ -75,40 +56,21 @@ export default function TotalTime(props: { record: any }) {
     }
 
     function setFastDuration(e) {
-        setIsFast(true)
         if (disableChange(true)) return
         if (process.env.TARO_ENV == 'weapp') {
             e.stopPropagation()
         }
-        if (props.record.status == 'WAIT_FOR_START') {
-            setShowDurationPicker(true)
-        }
-        else {
-            setShowEditPicker(true)
-        }
+
+        global.showFastPicker()
     }
 
     function setSleepDuration(e) {
-
-        setIsFast(false)
         if (disableChange(false)) return
         if (process.env.TARO_ENV == 'weapp') {
             e.stopPropagation()
         }
 
-        if (props.record.status == 'WAIT_FOR_START') {
-            Taro.showToast({
-                title: t('feature.track_time_duration.common.start_fasting_first'),
-                icon: 'none'
-            })
-            return;
-        }
-        if (props.record.status == 'WAIT_FOR_START' || props.record.status == 'ONGOING1') {
-            setShowDurationPicker(true)
-        }
-        else {
-            setShowEditPicker(true)
-        }
+        global.showSleepPicker()
     }
 
     function disableChange(isFastStatus) {
@@ -165,117 +127,6 @@ export default function TotalTime(props: { record: any }) {
         </View>
     }
 
-    function durationPickerContent() {
-        var color = getColor(props.record)
-        var title = getDurationTitle(props.record, t)
-        return <View style={{ color: '#fff', backgroundColor: 'transparent' }}>
-
-
-            <PickerViews ref={durationPickerRef}
-                onChange={durationChange}
-                items={durationDatas(common)}
-                value={isFast ? fastPickerValue : sleepPickerValue}
-                themeColor={color}
-                title={title}
-                showBtns={true}
-                onCancel={() => {
-                    setShowDurationPicker(false)
-                }} />
-        </View>
-    }
-
-    function editPickerContent() {
-        return <View style={{ color: '#fff', backgroundColor: 'transparent' }}>
-            <PickerViews ref={durationPickerRef}
-                onChange={durationChange}
-                items={durationDatas(common)}
-                value={isFast ? fastPickerValue : sleepPickerValue}
-                themeColor={isFast ? ColorType.fast : ColorType.sleep}
-                title={isFast ? t('feature.track_time_duration.action_sheet.edit_fasting_goal') :
-                    t('feature.track_time_duration.action_sheet.edit_sleeping_goal')}
-                showBtns={true}
-                onCancel={() => {
-                    setShowEditPicker(false)
-                }} />
-        </View>
-    }
-
-    function durationChange(e) {
-        // debugger
-        var count = (e[0] + common.duration.min) * 60 + e[1] * common.duration.step
-        // var count = (e[0] + 1) * 60 + e[1] * 5
-        if (showDurationPicker) {
-            global.changeTargetDuration(count, isFast)
-        }
-        else {
-            var params: any = {}
-            if (isFast) {
-                params = {
-                    fast: {
-                        target_duration: count * 60 * 1000
-                    }
-                }
-            }
-            else {
-                params = {
-                    sleep: {
-                        target_duration: count * 60 * 1000
-                    }
-                }
-            }
-            updateRecord({
-                ...params
-            }, props.record.id).then(res => {
-                global.indexPageRefresh()
-            }).catch(e => {
-
-            })
-        }
-        setShowDurationPicker(false)
-        setShowEditPicker(false)
-    }
-
-    function modalContent() {
-        if (showDurationPicker || showEditPicker) {
-            if (process.env.TARO_ENV == 'weapp') {
-                return <Modal
-                    testInfo={null}
-                    dismiss={() => {
-                        setShowDurationPicker(false)
-                        setShowEditPicker(false)
-                    }}
-                    confirm={() => { }}>
-                    {
-                        showDurationPicker ? durationPickerContent() : editPickerContent()
-                    }
-                </Modal>
-            }
-            else if (process.env.TARO_ENV == 'rn') {
-                return <PageContainer style={{ backgroundColor: '#1c1c1c' }}
-                    // overlayStyle='background-color:rgba(0,0,0,0.9)'
-                    // custom-style='background-color:#1c1c1c'
-                    overlayStyle={{ backgroundColor: 'rgba(0,0,0,0.9)' }}
-                    customStyle={{ backgroundColor: '#1c1c1c' }}
-                    closeOnSlideDown={false}
-                    onBeforeEnter={() => {
-
-                    }}
-                    onBeforeLeave={() => {
-                    }}
-                    onClick={() => { alert('b') }}
-                    onClickOverlay={() => { alert('a') }}
-                    onAfterLeave={() => { setShowDurationPicker(false); setShowEditPicker(false) }}
-                    show={showDurationPicker} round={true} overlay={true} position='bottom'
-                >
-                    {
-                        showDurationPicker ? durationPickerContent() : editPickerContent()
-                    }
-                </PageContainer>
-            }
-        }
-        return <View />
-    }
-
     return <View style={{ width: rpxToPx(600) }}>
         {
             props.record.fast && <View>
@@ -342,9 +193,6 @@ export default function TotalTime(props: { record: any }) {
                 </View>
             </View>
         }
-        {
-            modalContent()
-        }
 
     </View>
 }

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

@@ -30,6 +30,7 @@ import Layout from "@/components/layout/layout";
 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";
 
 let GradientText
 let useNavigation;
@@ -513,6 +514,7 @@ export default function Page() {
                 {
                     modalContent()
                 }
+                {homeData && <DurationPicker record={(homeData as any).fast_sleep.current_record} />}
                 <Tabbar index={0} />
             </View>
         </Layout>