Leon пре 2 година
родитељ
комит
ea7712a374

+ 4 - 1
src/app.tsx

@@ -40,7 +40,10 @@ const App: React.FC<PropsWithChildren> = ({ children }) => {
 
   }
   else {
-    console.log('oppsu')
+    //关闭其中某些yellow警告
+    console.ignoredYellowBox = ['Warning: BackAndroid is deprecated. Please use BackHandler instead.', 'source.uri should not be an empty string', 'Invalid props.style key'];
+    // 关闭全部yellow警告
+    // console.disableYellowBox = true
     const test = require('./utils/push').default
     test()
     // jgPush()

+ 9 - 8
src/components/input/LimitPickers.tsx

@@ -16,8 +16,8 @@ const Component = forwardRef((props: {
     var alpha = alphaToHex(0.4)
     const [values, setValues] = useState([props.limitDay ? props.limitDay - 1 : 6, today.getHours(), today.getMinutes()])
     const [isDisableConfirm, setIsDisableConfirm] = useState(false)
-    const [count,setCount] = useState(0)
-    const {t} = useTranslation()
+    const [count, setCount] = useState(0)
+    const { t } = useTranslation()
 
     function alphaToHex(alpha) {
         var alphaValue = Math.round(alpha * 255); // 将透明度乘以255并四舍五入
@@ -143,7 +143,7 @@ const Component = forwardRef((props: {
 
     }
 
-    function onPickerEnd(e){
+    function onPickerEnd(e) {
         // console.log(e)
         // console.log(values)
         // setValues(values)
@@ -161,7 +161,7 @@ const Component = forwardRef((props: {
         if (process.env.TARO_ENV == 'weapp') {
             e.stopPropagation()
         }
-        
+
         var date = new Date();
         date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 6) - values[0]));
         const year = date.getFullYear();
@@ -231,28 +231,29 @@ const Component = forwardRef((props: {
                     value={values}
                     className="picker"
                     maskClass="picker-mask"
+                    style={{ color: '#fff' }}
                     onChange={onPickerChange}
                     onPickEnd={onPickerEnd}
                     immediateChange={true}
                     indicatorStyle='height: 50px;color:red;'>
-                    <PickerViewColumn style='flex:0 0 45%'>
+                    <PickerViewColumn color='red' style='flex:0 0 45%'>
                         {days.map(item => {
                             return (
-                                <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>{item}</View>
+                                <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff' }}>{item}</View>
                             );
                         })}
                     </PickerViewColumn>
                     <PickerViewColumn>
                         {hours.map(item => {
                             return (
-                                <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>{item < 10 ? `0${item}` : item}</View>
+                                <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff' }}>{item < 10 ? `0${item}` : item}</View>
                             );
                         })}
                     </PickerViewColumn>
                     <PickerViewColumn>
                         {minutes.map(item => {
                             return (
-                                <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>{item < 10 ? `0${item}` : item}</View>
+                                <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff' }}>{item < 10 ? `0${item}` : item}</View>
                             );
                         })}
                     </PickerViewColumn>

+ 1 - 0
src/components/input/PickerViews.tsx

@@ -52,6 +52,7 @@ const Component = forwardRef((props: {
     return <View className='modal_content' catchMove>
         <Text className='modal_title' style={{ color: color }}>{props.title ? props.title : '测试标题 '}</Text>
         <PickerView value={v}
+            style={{color:'#fff'}}
             onChange={onPickerChange}
             indicatorStyle='height: 50px;'
             immediateChange={true}

+ 19 - 2
src/components/layout/Modal.scss

@@ -95,15 +95,32 @@
     left: 0;
     z-index: 100000;
     right: 0;
-    bottom: 0;
+    height: 700;
+    // bottom: 0;
     overflow: hidden;
     display: flex;
     flex-direction: column;
-    background-color: red;
+    background-color: rgba(0,0,0,0.95);
     // background-color: rgba($color: #000000, $alpha: 0);
     // animation: modalBgAnim 0.2s linear forwards;
 }
 
+.modal_bottom_content {
+    // padding-bottom: 120px;
+    width: 750px;
+    background-color: #1c1c1c;
+    border-top-left-radius: 36px;
+    border-top-right-radius: 36px;
+    display: flex;
+    flex-shrink: 0;
+    flex-direction: column;
+    z-index: 1000000;
+    margin-bottom: 0;
+    // height: 400;
+    // margin-bottom: -1000px;
+    // animation: modalAnim 0.2s linear forwards;
+}
+
 /* #endif */
 
 

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

@@ -21,7 +21,7 @@ export default {
             title: '指标',
         },
         food: {
-            title: '饮食日记',
+            title: '饮食',
         },
         more: {
             title: '更多',
@@ -61,7 +61,7 @@ export default {
             agreement: '已阅读并同意《用户协议》和《隐私政策》',
         },
         records_history: {
-            time_title: '断食和睡眠记录',
+            time_title: '断食和睡眠',
             metric_title: '{{title}}记录',
             activity_title: '{{title}}记录',
             del_success: '删除成功'
@@ -163,6 +163,7 @@ export default {
         },
         track_time_duration: {
             common: {
+                share_title:'我的断食睡眠日记',
                 start_fast: '开始断食',
                 end_fast: '结束断食',
                 start_sleep: '开始睡眠',
@@ -310,6 +311,7 @@ export default {
             disable_switch_modal_btn:'我知道了'
         },
         workout:{
+            share_title:'我的运动日记',
             finish_title:'{{name}}计时训练中',
             finish_current:'请先结束训练',
             add_more:'添加更多',
@@ -341,6 +343,7 @@ export default {
                 check: '打卡'
             },
             metric: {
+                share_title:'我的指标记录',
                 no_record: '无记录',
                 un_login: '未登录',
                 login_can_check: '登录后可记录',

+ 2 - 0
src/features/workout/Workout.tsx

@@ -440,6 +440,8 @@ export default function Component(props: any) {
             if (!allowRun) {
                 return;
             }
+
+            
             jumpPage('/pages/common/RecordsHistory?type=activity&refreshList=getCards&title=' + item.name + '&themeColor=' + item.theme_color)
         }
         else {

+ 19 - 105
src/features/workout/WorkoutStopWatch.tsx

@@ -20,6 +20,7 @@ import { IconRadioCross, IconX } from "@/components/basic/Icons";
 
 var timer
 var lastStrTime
+var lastTimestamp
 export default function Component(props: { targetCount: any, end: Function }) {
     const router = useRouter();
 
@@ -153,7 +154,7 @@ export default function Component(props: { targetCount: any, end: Function }) {
         return strDuration.length == 0 ? '1秒' : strDuration
     }
 
-    function  twoTimeFormateList(start,end){
+    function twoTimeFormateList(start, end) {
         var time = Math.floor((end - start) / 1000);
         debugger
         return TimeFormatter.workoutTimeAndUnitList(time)
@@ -243,15 +244,6 @@ export default function Component(props: { targetCount: any, end: Function }) {
         var count = 0
         var schema = workout.item.schemas[0]
         if (schema.format == 'TIME_SECONDS') {
-            // for (var i=0;i<groups.length;i++){
-            //     var obj = groups[i]
-            //     if (obj.type=='REST'){
-            //         count+= Math.floor((obj.time-groups[i-1].time)/1000)
-            //     }
-            // }
-
-            debugger
-
             groups.map(item => {
                 if (item.type == 'WORK') {
                     var t = Math.floor((item.end - item.start) / 1000)
@@ -390,15 +382,11 @@ export default function Component(props: { targetCount: any, end: Function }) {
                 }
             ]
         }
+
         uploadWorkout(params).then(res => {
             clearCache()
             dispatch(endSuccess())
 
-            // var item = workout.item
-            // Taro.redirectTo({
-            //     url: '/pages/common/RecordsHistory?type=workout&refreshList=getCards&title=' + item.name + '&code=' + item.code + '&themeColor=' + item.theme_color
-            // })
-
             setTimeout(() => {
                 Taro.redirectTo({
                     url: '/pages/workout/WorkoutDetail?detail=' + JSON.stringify((res as any).latest_record) + '&title=' + workout.item.name + '&themeColor=' + workout.item.theme_color
@@ -410,6 +398,7 @@ export default function Component(props: { targetCount: any, end: Function }) {
             global.refreshWorkout()
         }).catch(e => {
             setIsPosting(false)
+            resume()
         })
 
     }
@@ -429,6 +418,7 @@ export default function Component(props: { targetCount: any, end: Function }) {
         clearInterval(timer)
         var tempTimestamp = new Date().getTime()
         setTempTime(tempTimestamp)
+        lastTimestamp = tempTimestamp
         Taro.showModal({
             title: '提示',
             content: '确认结束?',
@@ -465,6 +455,7 @@ export default function Component(props: { targetCount: any, end: Function }) {
     function numChange(e) {
         setPickerValue(e)
         setShowModal(false)
+
         var array = groups;
         array.push({
             index: index,
@@ -474,11 +465,12 @@ export default function Component(props: { targetCount: any, end: Function }) {
             value3: e.length > 2 ? pickerItems[2][e[2]] : null,
             type: 'REST'
         })
-        setIsDoing(false)
         if (needTerminal) {
             postData()
             return;
         }
+        setIsDoing(false)
+
 
         saveCache(array)
         setStartTime(tempTime)
@@ -486,61 +478,6 @@ export default function Component(props: { targetCount: any, end: Function }) {
         resume()
     }
 
-    function total() {
-        var schema = workout.item.schemas[0]
-        if (schema.format == 'TIME_SECONDS') {
-            var count = 0
-            // groups.map(item => {
-            //     if (item.type == 'REST') {
-            //         count += parseInt(item.value) * 3600 + parseInt(item.value2) * 60 + parseInt(item.value3)
-            //     }
-            // })
-
-            for (var i = 0; i < groups.length; i++) {
-                var obj = groups[i]
-                if (obj.type == 'REST') {
-                    count += Math.floor((obj.time - groups[i - 1].time) / 1000)
-                }
-            }
-            if (!count) {
-                return '0小时0分钟0秒'
-            }
-            return TimeFormatter.workoutTime(count)
-        }
-        var count = 0
-        for (var i = 0; i < groups.length; i++) {
-            var obj = groups[i]
-            if (obj.type == 'REST') {
-                var temp = 0
-                if (obj.value) {
-                    temp = parseInt(obj.value + '')
-                }
-                if (obj.value2) {
-                    temp *= parseInt(obj.value2 + '')
-                }
-                if (obj.value3) {
-                    temp *= parseInt(obj.value3 + '')
-                }
-                count += temp
-            }
-        }
-        var unit = ''
-        var array = workout.item.schemas[0].values
-
-        for (var i = 0; i < array.length; i++) {
-            unit += array[i].unit + '·'
-        }
-        return count + unit.substring(0, unit.length - 1)
-    }
-
-    function getGroupValue(item) {
-        var schema = workout.item.schemas[0]
-        if (schema.format == 'TIME_SECONDS') {
-            return ''
-            return item.value + item.value2 + item.value3
-        }
-        return item.value + (item.value2 ? 'x' + item.value2 : '') + (item.value3 ? 'x' + item.value3 : '')
-    }
 
     function needShowPicker() {
         var schema = workout.item.schemas[0]
@@ -631,7 +568,7 @@ export default function Component(props: { targetCount: any, end: Function }) {
     }
 
     return <View style={{ color: workout.item.theme_color, flexDirection: 'column', display: 'flex' }}>
-        <Text className="working_title" style={{fontSize:rpxToPx(56)}}>{workout.item.name}</Text>
+        <Text className="working_title" style={{ fontSize: rpxToPx(56) }}>{workout.item.name}</Text>
         <Text className="working_subtitle">计时训练</Text>
         {
             groups.length > 1 && groups.map((item, index) => {
@@ -642,7 +579,7 @@ export default function Component(props: { targetCount: any, end: Function }) {
                     <Box key={index} >
                         <View>
                             <Text className="working_index">{item.type == 'REST' ? `第${item.index}组` : '组间休息'}</Text>
-                            <View style={{  display: 'flex', flexDirection: 'row', alignItems: 'center', marginTop: item.type == 'REST' ? rpxToPx(60) : 0, marginBottom: item.type == 'REST' ? rpxToPx(0) : 0 }}>
+                            <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', marginTop: item.type == 'REST' ? rpxToPx(60) : 0, marginBottom: item.type == 'REST' ? rpxToPx(0) : 0 }}>
                                 {item.type == 'REST' && workout.item.schemas[0].format != 'TIME_SECONDS' &&
                                     <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
                                         {
@@ -652,7 +589,7 @@ export default function Component(props: { targetCount: any, end: Function }) {
                                             item.value2 && <IconX width={rpxToPx(32)} color={workout.item.theme_color} />
                                         }
                                         {
-                                            item.value2 && <View style={{width:1}} />
+                                            item.value2 && <View style={{ width: 1 }} />
                                         }
                                         {
                                             item.value2 && <MultiText values={[parseInt(item.value2)]} units={[workout.item.schemas[0].values[1].unit]} color={workout.item.theme_color} valueSize={rpxToPx(48)} unitSize={rpxToPx(32)} />
@@ -665,7 +602,7 @@ export default function Component(props: { targetCount: any, end: Function }) {
                                 }
                                 {
                                     item.type == 'REST' && workout.item.schemas[0].format == 'TIME_SECONDS' &&
-                                    <MultiText values={twoTimeFormateList(groups[index - 1].time,item.time).values} units={twoTimeFormateList(groups[index - 1].time,item.time).units} color={workout.item.theme_color} valueSize={rpxToPx(48)} unitSize={rpxToPx(32)} />
+                                    <MultiText values={twoTimeFormateList(groups[index - 1].time, item.time).values} units={twoTimeFormateList(groups[index - 1].time, item.time).units} color={workout.item.theme_color} valueSize={rpxToPx(48)} unitSize={rpxToPx(32)} />
                                 }
                                 <View style={{ flex: 1 }} />
 
@@ -710,39 +647,16 @@ export default function Component(props: { targetCount: any, end: Function }) {
                 totalSummary()
             }
             {/* <Text className="train_summary_value" style={{ color: workout.item.theme_color }}></Text> */}
-            <Text className="train_summary_title">用时</Text>
-            <Text className="train_summary_value" style={{ color: workout.item.theme_color }}>{groups.length > 0 && TimeFormatter.formateTimeNow(groups[0].time)}</Text>
+            <Text className="train_summary_title">已进行</Text>
+            <Text className="train_summary_value" style={{ color: workout.item.theme_color }}>{groups.length > 0 &&
+                (isPosting ? TimeFormatter.formateTimeNow(groups[0].time,lastTimestamp) :
+                    TimeFormatter.formateTimeNow(groups[0].time))}</Text>
             <Text className="train_summary_title">{groups.length > 0 && new Date().getTime() > groups[0].time + props.targetCount * 1000 ? '已超时' : '距结束'}</Text>
-            <Text className="train_summary_value" style={{ color: workout.item.theme_color }}>{groups.length > 0 && TimeFormatter.countdown(groups[0].time + props.targetCount * 1000)}</Text>
+            <Text className="train_summary_value" style={{ color: workout.item.theme_color }}>{groups.length > 0 &&
+                (isPosting ? TimeFormatter.countdown(groups[0].time + props.targetCount * 1000,lastTimestamp) :
+                    TimeFormatter.countdown(groups[0].time + props.targetCount * 1000))}</Text>
         </View>
 
-
-        {/* {
-            !router.params.content_only && <View style={{ display: 'flex', flexDirection: 'column', color: '#fff', marginLeft: rpxToPx(46) }}>
-                <Text style={{ fontSize: rpxToPx(40), fontWeight: 'bold' }}>实时训练统计</Text>
-                <Text style={{ opacity: 0.8, fontSize: rpxToPx(32), fontWeight: 'bold' }}>总量</Text>
-                <Text style={{ fontSize: rpxToPx(48), fontWeight: 'bold', marginTop: rpxToPx(10) }}>{total()}</Text>
-                <Text style={{ marginTop: 20 }}>计时</Text>
-                <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(40) }}>{planTime()}</Text>
-            </View>
-        }
-
-
-        {
-            !router.params.content_only && <View style={{ display: 'flex', flexDirection: 'row', color: '#fff', marginLeft: rpxToPx(46), marginBottom: 100, marginTop: rpxToPx(20) }}>
-                <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
-
-                    <Text style={{ color: workout.item.theme_color, fontSize: rpxToPx(36), fontWeight: 'bold' }}>{groups.length > 0 && TimeFormatter.formateTimeNow(groups[0].time)}</Text>
-                    <Text style={{ fontSize: rpxToPx(20), color: '#fff', opacity: 0.4 }}>已进行</Text>
-                </View>
-                <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', marginLeft: rpxToPx(80) }}>
-
-                    <Text style={{ color: workout.item.theme_color, fontSize: rpxToPx(36), fontWeight: 'bold' }}>{groups.length > 0 && TimeFormatter.countdown(groups[0].time + props.targetCount * 1000)}</Text>
-                    <Text style={{ fontSize: rpxToPx(20), color: '#fff', opacity: 0.4 }}>{groups.length > 0 && new Date().getTime() > groups[0].time + props.targetCount * 1000 ? '已超时' : '距结束'}</Text>
-                </View>
-            </View>
-        } */}
-
         {
             showModal && <Modal dismiss={() => {
                 setShowModal(false)

+ 1 - 1
src/pages/account/Setting.tsx

@@ -35,7 +35,7 @@ export default function Page() {
 
     return <View style={{ color: '#fff',display:'flex',flexDirection:'column' }}>
         <View style={{height:20}}/>
-        <TableCell title={t('page.setting.version')} ><Text style={{ opacity: 0.8 }}>1.2.10</Text></TableCell>
+        <TableCell title={t('page.setting.version')} ><Text style={{ opacity: 0.8 }}>1.3.0</Text></TableCell>
         {/* <Text style={{color:'#9E9E9E',textAlign:'center',fontSize:14}}>v1.2.2</Text> */}
         
         <Footer>

+ 1 - 1
src/pages/clock/Clock.weapp.tsx

@@ -217,7 +217,7 @@ export default function IndexPage() {
   if (process.env.TARO_ENV == 'weapp') {
     useShareAppMessage((e) => {
       return {
-        title: t('share.title'),
+        title: t('feature.track_time_duration.common.share_title'),
         path: 'pages/clock/Clock'
       }
     })

+ 3 - 3
src/pages/common/RecordsHistory.tsx

@@ -298,13 +298,13 @@ export default function Page() {
             return t('page.records_history.time_title')
         }
         else if (router.params.type == 'metric') {
-            return t('page.records_history.metric_title', { title: router.params.title })
+            return router.params.title
         }
         else if (router.params.type == 'workout') {
-            return t('page.records_history.metric_title', { title: router.params.title })
+            return router.params.title
         }
         else {
-            return t('page.records_history.activity_title', { title: router.params.title })
+            return router.params.title
         }
     }
 

+ 3 - 3
src/pages/metric/Metric.tsx

@@ -9,8 +9,8 @@ export default function Page() {
     if (process.env.TARO_ENV == 'weapp') {
         useShareAppMessage((e) => {
             return {
-                title: t('share.title'),
-                path: 'pages/clock/Clock'
+                title: t('feature.track_something.metric.share_title'),
+                path: 'pages/metric/Metric',
             }
         })
     }
@@ -21,6 +21,6 @@ export default function Page() {
     })
     return <View className="container">
         <Metric />
-        <Tabbar index={1}/>
+        <Tabbar index={1} />
     </View>
 }

+ 2 - 2
src/pages/workout/Workout.tsx

@@ -15,8 +15,8 @@ export default function Page() {
   if (process.env.TARO_ENV == 'weapp') {
     useShareAppMessage((e) => {
       return {
-        title: t('share.title'),
-        path: 'pages/clock/Clock'
+        title: t('feature.workout.share_title'),
+        path: 'pages/workout/Workout'
       }
     })
   }

+ 1 - 1
src/services/http/api.js

@@ -1,4 +1,4 @@
-let online = false;
+let online = true;
 export let baseUrl = online ? 'https://api.fast.liveplus.fun' : 'https://api.fast.dev.liveplus.fun';
 export let imgUrl = online
     ? 'https://api.fast.liveplus.fun/static/image/'

+ 6 - 4
src/utils/time_format.ts

@@ -284,8 +284,8 @@ export class TimeFormatter {
     return (hours < 10 ? `0${hours}` : `${hours}`) + ':' + (minutes < 10 ? `0${minutes}` : `${minutes}`);
   }
 
-  static countdown = (dt: number): string => {
-    const end = Date.now();
+  static countdown = (dt: number, end = Date.now()): string => {
+    // const end = Date.now();
     const time = end > dt ? Math.floor((end - dt) / 1000) : Math.ceil((dt - end) / 1000)//Math.ceil((end>dt?end-dt:dt-end)/1000);
     const hours = Math.floor(time / 3600);
     const minutes = Math.floor((time % 3600) / 60);
@@ -294,8 +294,8 @@ export class TimeFormatter {
   };
 
   //计算正计时
-  static formateTimeNow = (dt: number): string => {
-    const end = Date.now();
+  static formateTimeNow = (dt: number, end = Date.now()): string => {
+    // const end = Date.now();
     const time = Math.floor((end > dt ? end - dt : dt - end) / 1000);
     const hours = Math.floor(time / 3600);
     const minutes = Math.floor((time % 3600) / 60);
@@ -303,6 +303,8 @@ export class TimeFormatter {
     return `${TimeFormatter.padZero(hours)}:${TimeFormatter.padZero(minutes)}:${TimeFormatter.padZero(seconds)}`;
   };
 
+
+
   static workoutTime = (time: number): string => {
     const hours = Math.floor(time / 3600);
     const minutes = Math.floor((time % 3600) / 60);