Leon 2 tahun lalu
induk
melakukan
8ecd98a736

+ 4 - 2
src/components/input/PickerViews.tsx

@@ -1,12 +1,14 @@
 import { PickerView, PickerViewColumn, View, Text } from "@tarojs/components";
 import './PickerViews.scss'
 import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
+import { useTranslation } from "react-i18next";
 
 // export default function Component(props: { value: any, onChange: Function, items: any, height?: number, showBtns?: boolean, onCancel?: Function, }) {
 const Component = forwardRef((props: {
     value: any, onChange: Function, items: any, height?: number, showBtns?: boolean, onCancel?: Function,
     themeColor?: string, title?: string
 }, ref) => {
+    const {t} = useTranslation()
     const [v, setV] = useState([0])
     var color = props.themeColor ? props.themeColor : '#ff0000'
     var alpha = alphaToHex(0.4)
@@ -66,11 +68,11 @@ const Component = forwardRef((props: {
         </PickerView >
         <View className='modal_operate'>
             <View className='modal_btn' style={{ backgroundColor: color + alpha }} onClick={(e)=>{e.stopPropagation();props.onCancel!()}}>
-                <Text className='modal_cancel_text' style={{ color: color }}>取消</Text>
+                <Text className='modal_cancel_text' style={{ color: color }}>{t('feature.common.picker_cancel_btn')}</Text>
             </View>
             <View className='btn_space' />
             <View className='modal_btn' style={{ backgroundColor: color }} onClick={confirm}>
-                <Text className='modal_confirm_text' style={{ color: '#000' }}>确定</Text>
+                <Text className='modal_confirm_text' style={{ color: '#000' }}>{t('feature.common.picker_confirm_btn')}</Text>
             </View>
 
 

+ 4 - 2
src/components/input/Stepper.tsx

@@ -5,9 +5,11 @@ import './Stepper.scss'
 import { useEffect, useState } from "react";
 import Taro from "@tarojs/taro";
 import { IconMinus, IconPlus } from "../basic/Icons";
+import { useTranslation } from "react-i18next";
 
 export default function Component(props: { child: any, minus: Function, plus: Function, disableMinus?: boolean, disablePlus?: boolean,themeColor:string }) {
     const [timer, setTimer] = useState<NodeJS.Timeout | null>(null);
+    const {t} = useTranslation()
     useEffect(()=>{
         if(props.disableMinus){
             timer && clearInterval(timer);
@@ -24,7 +26,7 @@ export default function Component(props: { child: any, minus: Function, plus: Fu
         if (props.disableMinus) {
             Taro.showToast({
                 icon: 'none',
-                title: '不能再小了'
+                title: t('feature.common.toast.min_value')
             })
             return;
         }
@@ -36,7 +38,7 @@ export default function Component(props: { child: any, minus: Function, plus: Fu
         if (props.disablePlus){
             Taro.showToast({
                 icon: 'none',
-                title: '不能再大了'
+                title: t('feature.common.toast.max_value')
             })
             return;
         }

+ 5 - 3
src/components/view/NoData.tsx

@@ -1,10 +1,12 @@
-import { View,Text } from "@tarojs/components";
+import { View, Text } from "@tarojs/components";
 import './NoData.scss'
+import { useTranslation } from "react-i18next";
 export default function Component(props: { refresh: Function }) {
+    const { t } = useTranslation()
     return <View className="no_data_bg">
-        <Text className="no_data_text">加载失败</Text>
+        <Text className="no_data_text">{t('feature.common.no_data.title')}</Text>
         <View className="no_data_btn" onClick={() => props.refresh()}>
-            <Text className="no_data_btn_text">重试</Text>
+            <Text className="no_data_btn_text">{t('feature.common.no_data.retry_btn')}</Text>
         </View>
     </View>
 }

+ 115 - 24
src/context/locales/zh.js

@@ -6,8 +6,8 @@ export default {
         nutrition: '营养',
         more: '更多'
     },
-    share:{
-        title:'减脂/断食睡眠/身材管理/指标记录/运动打卡, 尽在fast16cc'
+    share: {
+        title: '减脂/断食睡眠/身材管理/指标记录/运动打卡, 尽在fast16cc'
     },
     page: {
         clock: {
@@ -20,7 +20,13 @@ export default {
             title: '指标',
         },
         more: {
-            title: '更多'
+            title: '更多',
+            un_login:'未登录',
+            stone:'逆龄石',
+            stone_desc:'会员体系升级中,期间指标记录限时免逆龄石记录\n敬请期待',
+            setting:'设置',
+            reset_session:'重置session',
+            debug_mode:'走查模式'
         },
         choose_scenario: {
             title: '选择生物钟',
@@ -43,7 +49,8 @@ export default {
             app_name: '',
             btn_create_account: '',
             btn_login: '登录',
-            btn_wechat: '微信登录'
+            btn_wechat: '微信登录',
+            slogan:'健康生物钟'
         },
         auth: {
             agreement: '已阅读并同意《用户协议》和《隐私政策》',
@@ -56,9 +63,13 @@ export default {
         },
         setting: {
             title: '设置',
+            version: '版本',
+            logout: '退出登录'
         },
         user_profile: {
-            title: '编辑资料'
+            title: '编辑资料',
+            nickname: '昵称',
+            save:'保存'
         }
 
 
@@ -75,8 +86,45 @@ export default {
             btn_done: '完成',
             btn_set_and_next: "下一步",// "Set and Next"
             btn_set_and_done: "完成",// "Set and Done"
+            toast: {
+                min_value: '不能再小了',
+                max_value: '不能再大了',
+                update_success: '更新成功',
+                input_nickname:'请输入昵称'
+            },
+            action_sheet: {
+                delete: '删除'
+            },
+            modal: {
+                delete_item_title: '删除',
+                delete_item_content: '确认要删除吗?',
+                delete_cancel_btn: '取消',
+                delete_confirm_btn: '确定',
+
+
+                delete_all_title: '删除',
+                delete_all_content: '确认删除全部记录?',
+                delete_all_cancel_btn: '取消',
+                delete_all_confirm_btn: '确定',
+
+                logout_title: '退出登录',
+                logout_content: '确定退出登录吗?',
+
+
+                deluser_title: '注销账号',
+                deluser_content: '确定注销此账号吗?',
+
+                reset_session_title: '重置session',
+                reset_session_content: '确认重置session吗?'
+            },
+            no_data: {
+                title: '加载失败',
+                retry_btn: '重试',
+                no_record: '无记录'
+            }
 
         },
+
         auth: {
             create_account: {
                 title: '注册账号',
@@ -102,25 +150,31 @@ export default {
             }
         },
         track_time_duration: {
+            common: {
+                start_fast: '开始断食',
+                end_fast: '结束断食',
+                start_sleep: '开始睡眠',
+                end_sleep: '结束睡眠'
+            },
             status_indicator: {
 
             },
-            follow_wx_pub:{
+            follow_wx_pub: {
                 //未关注状态
-                modal_unfollowed_title:'日程提醒',
-                modal_unfollowed_content:'关注公众号\n开启我的日程提醒!',
-                modal_unfollowed_cancel_btn:'返回',
-                modal_unfollowed_confirm_btn:'去开启',
+                modal_unfollowed_title: '日程提醒',
+                modal_unfollowed_content: '关注公众号\n开启我的日程提醒!',
+                modal_unfollowed_cancel_btn: '返回',
+                modal_unfollowed_confirm_btn: '去开启',
 
-                h5_unfollowed_title:'开启日程提醒',
+                h5_unfollowed_title: '开启日程提醒',
 
                 //已关注状态
-                modal_followed_title:'日程提醒已开启',
-                modal_followed_content:'要前往公众号查看吗?',
-                modal_followed_cancel_btn:'返回',
-                modal_followed_confirm_btn:'前往查看',
-                
-                h5_followed_title:'日程提醒',
+                modal_followed_title: '日程提醒已开启',
+                modal_followed_content: '要前往公众号查看吗?',
+                modal_followed_cancel_btn: '返回',
+                modal_followed_confirm_btn: '前往查看',
+
+                h5_followed_title: '日程提醒',
 
             },
             console: {
@@ -146,8 +200,8 @@ export default {
                 action_sheet_adjust_schedule: '调整日程', //点击弹出action_sheet的item
                 duration_goals_by_stage: '查看断食阶段目标',  //底部文字按钮 waite for start
                 current_stage: '查看当前断食阶段',              //底部文字按钮 onging
-                timeline:'日程',            //一级页面待开始进行中,segment index=0的值
-                stage:'阶段',
+                timeline: '日程',            //一级页面待开始进行中,segment index=0的值
+                stage: '阶段',
 
             },
             record_fast_sleep: {
@@ -159,9 +213,9 @@ export default {
                     fast: '断食',
                     sleep: '睡眠'
                 },
-                timeline:'时间线',  //modal弹窗 segment index=0的值
-                stage:'阶段',
-                pop_title:'详情'
+                timeline: '时间线',  //modal弹窗 segment index=0的值
+                stage: '阶段',
+                pop_title: '详情'
             },
 
             action_sheet: {
@@ -201,14 +255,51 @@ export default {
                     },
                 }
 
+            },
+            stage: {
+                a: '睡前断食',
+                b: '睡眠中断食',
+                c: '起床后断食',
+                wait_for_start: '待开始',
+                not_completed: '未完成',
+                not_started: '未开始'
             }
         },
         track_something: {
             btn_record: '记录',
             picker_datetime: '记录时间',
-            activity:{
-                pop_title:'详情'
+            activity: {
+                pop_title: '详情',
+                btn_status: {
+                    idle: '打卡',
+                    ing: '打卡中...',
+                    retry: '仍在打卡中...',
+                    success: '打卡成功',
+                    fail: '打卡失败'
+                },
+                open: '开启',
+                un_open: '未开启',
+                un_login: '未登录',
+                today_un_check: '今天待打卡',
+                check_history: '查看历史记录',
+                login_then_check: '登录后可开启打卡',
+                open_then_check: '开启后可打卡步数',
+                total: '总计',
+                sync: '同步',
+                check: '打卡'
+            },
+            metric: {
+                no_record: '无记录',
+                un_login: '未登录',
+                login_can_check: '登录后可记录',
+                check_unlock_data: '记录解锁趋势'
+            },
+            werun_auth: {
+                modal_open_setting_title: '提示',
+                modal_open_setting_content: '检测到您没有打开微信运动的权限,是否去设置打开?',
+                toast_reject_auth: '您已拒绝授权,无法获取步数'
             }
+
         }
     }
 }

+ 11 - 10
src/features/common/RecordItem.tsx

@@ -1,37 +1,38 @@
-import { View,Text } from "@tarojs/components";
+import { View, Text } from "@tarojs/components";
 import React from "react";
 import './RecordItem.scss'
 import Taro from "@tarojs/taro";
 import { TimeFormatter } from "@/utils/time_format";
+import { useTranslation } from "react-i18next";
 
 
-export default function Component(props: { children: React.ReactNode,onClick?:Function, delete?: Function, canDel?: boolean }) {
-
-    function click(e){
+export default function Component(props: { children: React.ReactNode, onClick?: Function, delete?: Function, canDel?: boolean }) {
+    const { t } = useTranslation()
+    function click(e) {
         if (props.onClick) {
             e.stopPropagation()
             props.onClick();
         }
         else {
             Taro.vibrateShort({
-                type:'medium'
+                type: 'medium'
             });
         }
     }
-    
+
     function longPress() {
         if (!props.delete) {
             return;
         }
         Taro.showActionSheet({
-            itemList: ['删除']
+            itemList: [t('feature.common.action_sheet.delete')]
         })
             .then(res => {
                 switch (res.tapIndex) {
                     case 0:
                         Taro.showModal({
-                            title: '删除',
-                            content: '确认要删除吗?',
+                            title: t('feature.common.modal.delete_item_title'),
+                            content: t('feature.common.modal.delete_item_content'),
                             success: function (res) {
                                 if (res.confirm) {
                                     props.delete!();
@@ -52,6 +53,6 @@ export default function Component(props: { children: React.ReactNode,onClick?:Fu
     //gesture  onClick onLongPress 有效
     return <View className="recordItem" onLongPress={longPress} onClick={click}>
         {props.children}
-        
+
     </View>
 }

+ 15 - 16
src/features/trackSomething/components/Activity.tsx

@@ -11,7 +11,6 @@ import MetricItem from "./MetricItem";
 import Layout from '@/components/layout/layout'
 import NoData from "@/components/view/NoData";
 import { ResultType, checkFail, checkRetry, checkStart, checkSuccess, resetStatus, setResult } from "@/store/action_results";
-import { uploadSessionKey } from "@/services/common";
 import RequestType, { thirdPartRequest } from "@/services/thirdPartRequest";
 import { NaviBarTitleShowType, TemplateType } from "@/utils/types";
 import { useTranslation } from "react-i18next";
@@ -142,7 +141,7 @@ export default function Component(props: any) {
                 checkout()
             }
             else {
-                setAuth(successAuth, refuseAuth)
+                setAuth(successAuth, refuseAuth,t)
             }
         }
         else {
@@ -302,31 +301,31 @@ export default function Component(props: any) {
         switch (checkResult.type) {
             case ResultType.idle:
                 {
-                    btnTitle = '打卡'
+                    btnTitle = t('feature.track_something.activity.btn_status.idle')
                     isEnable = true
                 }
                 break;
             case ResultType.ing:
                 {
-                    btnTitle = '打卡中...'
+                    btnTitle = t('feature.track_something.activity.btn_status.ing')
                     isEnable = false
                 }
                 break;
             case ResultType.retry:
                 {
-                    btnTitle = '仍在打卡中...'
+                    btnTitle = t('feature.track_something.activity.btn_status.retry')
                     isEnable = false
                 }
                 break;
             case ResultType.success:
                 {
-                    btnTitle = '打卡成功'
+                    btnTitle = t('feature.track_something.activity.btn_status.success')
                     isEnable = false
                 }
                 break;
             case ResultType.fail:
                 {
-                    btnTitle = '打卡失败'
+                    btnTitle = t('feature.track_something.activity.btn_status.fail')
                     isEnable = false
                 }
                 break;
@@ -341,7 +340,7 @@ export default function Component(props: any) {
         }
     }
     else {
-        btnTitle = '开启';
+        btnTitle = t('feature.track_something.activity.open');
         isEnable = true;
     }
 
@@ -357,7 +356,7 @@ export default function Component(props: any) {
                         showDetail = true
                         value = item.latest_record.items[0].value
                         if (item.latest_record.timestamp == 0) {
-                            desc = '今天待打卡'
+                            desc = t('feature.track_something.activity.today_un_check')
                         }
                         else {
                             desc = TimeFormatter.datetimeDescription(item.latest_record.timestamp)
@@ -365,19 +364,19 @@ export default function Component(props: any) {
 
                     }
                     else {
-                        desc = '今天待打卡'
+                        desc = t('feature.track_something.activity.today_un_check')
                     }
 
 
 
                     if (!user.isLogin) {
-                        value = '未登录'
-                        desc = '登录后可开启打卡'
+                        value = t('feature.track_something.activity.un_login')
+                        desc = t('feature.track_something.activity.login_then_check')//登录后可开启打卡'
                     }
                     else {
                         if (!allowRun) {
-                            value = '未开启'
-                            desc = '开启后可打卡步数'
+                            value = t('feature.track_something.activity.un_open')
+                            desc = t('feature.track_something.activity.open_then_check')
                         }
                         else {
                             // unit = '步'
@@ -388,8 +387,8 @@ export default function Component(props: any) {
                                 unit = '步'
                             }
                             else {
-                                value = '今日待打卡'
-                                desc = '查看历史记录'
+                                value = t('feature.track_something.activity.today_un_check')
+                                desc =  t('feature.track_something.activity.check_history')//'查看历史记录'
                             }
                         }
                     }

+ 2 - 1
src/features/trackSomething/components/ActivityHistory.tsx

@@ -65,7 +65,8 @@ export default function Component(props: { records: any[] }) {
     function schedules(item) {
         var timelineItems: any = [];
         for (var i = item.records.length - 1; i > 0; i--) {
-            var type = item.records[i].type == 'total' ? '总计' : item.records[i].type == 'sync' ? '同步' : '打卡'
+            var type = item.records[i].type == 'total' ? t('feature.track_something.activity.total') : 
+            item.records[i].type == 'sync' ? t('feature.track_something.activity.sync') : t('feature.track_something.activity.check')
             timelineItems.push(
                 {
                     status: 'done',

+ 11 - 11
src/features/trackSomething/components/Metric.tsx

@@ -1,16 +1,12 @@
 import { View, Text, ScrollView } from "@tarojs/components";
 import './Metric.scss'
-import { setAuth } from "../hooks/werun";
-import { usePullDownRefresh, useReady } from "@tarojs/taro";
 import { useSelector } from "react-redux";
 import { useEffect, useRef, useState } from "react";
 import Taro from "@tarojs/taro";
 import { metricCards, uploadMetric, uploadSteps } from "@/services/trackSomething";
 import { TimeFormatter } from "@/utils/time_format";
 import MetricItem from "./MetricItem";
-import { get } from "http";
 import Modal from "@/components/layout/Modal";
-import PickerViews from "@/components/input/PickerViews";
 import LimitPickers from "@/components/input/LimitPickers";
 import SlidngScale from "@/components/input/SlidngScale";
 import NoData from "@/components/view/NoData";
@@ -311,8 +307,8 @@ export default function Component(props: any) {
                 {
                     list.map((item: any, index: number) => {
                         var unit = ''
-                        var value = '无记录'
-                        var desc = '记录解锁趋势'
+                        var value = t('feature.track_something.metric.no_record')
+                        var desc = t('feature.track_something.metric.check_unlock_data')
                         var showDetail = false;
                         if (item.latest_record) {
                             unit = item.schemas[0].default_unit
@@ -322,8 +318,8 @@ export default function Component(props: any) {
                         }
 
                         if (!user.isLogin) {
-                            value = '未登录'
-                            desc = '登录后可记录'
+                            value = t('feature.track_something.metric.un_login')
+                            desc = t('feature.track_something.metric.login_can_check')
                         }
                         return <MetricItem title={item.name}
                             value={value}
@@ -373,7 +369,7 @@ export default function Component(props: any) {
                     display: 'flex', flexDirection: 'column',
                     width: '100%', color: '#000'
                 }}>
-                    <Text className='modal_title' style={{ color: (metricItem as any).theme_color }}>{(metricItem as any).name ? (metricItem as any).name : '测试标题 '}</Text>
+                    <Text className='modal_title' style={{ color: (metricItem as any).theme_color }}>{(metricItem as any).name ? (metricItem as any).name : ''}</Text>
                     <View style={{ position: 'relative' }}>
                         {
                             (metricItem as any).schemas.map((item, index) => {
@@ -400,11 +396,15 @@ export default function Component(props: any) {
                     </View>
                     <View className='modal_operate'>
                         <View className='modal_btn' style={{ backgroundColor: (metricItem as any).theme_color + alphaToHex(0.4) }} onClick={cancelModal}>
-                            <Text className='modal_cancel_text' style={{ color: (metricItem as any).theme_color }}>取消</Text>
+                            <Text className='modal_cancel_text' style={{ color: (metricItem as any).theme_color }}>{
+                                t('feature.common.picker_cancel_btn')
+                            }</Text>
                         </View>
                         <View className='btn_space' />
                         <View className='modal_btn' style={{ backgroundColor: (metricItem as any).theme_color }} onClick={confirmModal}>
-                            <Text className='modal_confirm_text' style={{ color: '#000' }}>确定</Text>
+                            <Text className='modal_confirm_text' style={{ color: '#000' }}>{
+                                t('feature.common.picker_confirm_btn')
+                            }</Text>
                         </View>
 
 

+ 5 - 8
src/features/trackSomething/hooks/werun.tsx

@@ -1,6 +1,6 @@
 import Taro from "@tarojs/taro";
 
-export const setAuth = (getRunData: Function, refuseAuth: Function) => {
+export const setAuth = (getRunData: Function, refuseAuth: Function, t: any) => {
     Taro.getSetting({
         success: res => {
             //第一步,检测是否有授权 - 没有授权
@@ -9,25 +9,23 @@ export const setAuth = (getRunData: Function, refuseAuth: Function) => {
                 Taro.authorize({
                     scope: 'scope.werun',
                     success: () => {
-                        console.log("授权了")
                         getRunData()
                     },
                     fail: () => {
                         Taro.showModal({
-                            title: '提示',
-                            content: '检测到您没有打开微信运动的权限,是否去设置打开?',
+                            title: t('feature.track_something.werun_auth.modal_open_setting_title'),
+                            content: t('feature.track_something.werun_auth.modal_open_setting_content'),
                             success: res => {
                                 if (res.confirm) {
                                     Taro.openSetting({
                                         success: res => {
                                             if (res.authSetting['scope.werun']) {
-                                                console.log("授权了")
                                                 getRunData()
                                                 //   this.getRunData();
                                             } else {
                                                 refuseAuth()
                                                 Taro.showToast({
-                                                    title: '您已拒绝授权,无法获取步数',
+                                                    title: t('feature.track_something.werun_auth.toast_reject_auth'),
                                                     icon: 'none'
                                                 });
                                             }
@@ -36,7 +34,7 @@ export const setAuth = (getRunData: Function, refuseAuth: Function) => {
                                 } else {
                                     refuseAuth()
                                     Taro.showToast({
-                                        title: '您已拒绝授权,无法获取步数',
+                                        title: t('feature.track_something.werun_auth.toast_reject_auth'),
                                         icon: 'none'
                                     });
                                 }
@@ -68,7 +66,6 @@ export const setAuth = (getRunData: Function, refuseAuth: Function) => {
                 });
             } else {
                 //第六步,已经授权直接进入保存逻辑
-                console.log("授权了")
                 getRunData()
                 //   this.getRunData();
             }

+ 0 - 30
src/features/trackTimeDuration/components/Console.tsx

@@ -246,33 +246,6 @@ export default function Component(props: { isNextStep?: boolean }) {
         }
     }
 
-    function targetView() {
-        if (props.isNextStep && (time.status == 'ONGOING1' || time.status == 'ONGOING2')) {
-            var opacity = textNextStepAlpha(time)
-            if (opacity == 1) {
-                return <View className="target_view" style={{ backgroundColor: '#FA51511A' }}>
-                    <Text className="target_text" style={{ color: '#FA5151' }}>超出目标结束</Text>
-                </View>
-            }
-            return <View className="target_view" style={{ backgroundColor: global.fastColor ? global.fastColor : ColorType.fast + '1A', opacity: opacity }}>
-                <Text className="target_text" style={{ color: global.fastColor ? global.fastColor : ColorType.fast }}>距离目标结束</Text>
-            </View>
-        }
-
-        if (time.status == 'ONGOING' || time.status == 'ONGOING2' || time.status == 'ONGOING3') {
-            var opacity = textAlpha(time)
-            if (opacity == 1) {
-                return <View className="target_view" style={{ backgroundColor: '#FA51511A' }}>
-                    <Text className="target_text" style={{ color: '#FA5151' }}>超出目标结束</Text>
-                </View>
-            }
-            return <View className="target_view" style={{ backgroundColor: isFast ? global.fastColor ? global.fastColor : ColorType.fast + '1A' : global.sleepColor ? global.sleepColor : ColorType.sleep + '1A', opacity: opacity }}>
-                <Text className="target_text" style={{ color: isFast ? global.fastColor ? global.fastColor : ColorType.fast : global.sleepColor ? global.sleepColor : ColorType.sleep }}>距离目标结束</Text>
-            </View>
-        }
-        return <View />
-    }
-
     function mixedBtns() {
         return <View className="btn_bg">
             {
@@ -555,9 +528,6 @@ export default function Component(props: { isNextStep?: boolean }) {
                     } minus={minus} plus={plus}
                         themeColor={isFast ? global.fastColor ? global.fastColor : ColorType.fast : global.sleepColor ? global.sleepColor : ColorType.sleep} disableMinus={disableMinus()} disablePlus={disablePlus()} />
                 }
-                {/* {
-                    targetView()
-                } */}
 
                 <View>
                     {

+ 0 - 200
src/features/trackTimeDuration/components/More.tsx

@@ -1,200 +0,0 @@
-import { View, Text } from "@tarojs/components";
-import Taro from "@tarojs/taro";
-import { forwardRef, useEffect, useRef, useState } from "react";
-import { useTranslation } from "react-i18next";
-import { useDispatch, useSelector } from "react-redux";
-import trackTimeService, { machine } from "@/store/trackTimeMachine"
-import { recordCheck } from "@/services/trackTimeDuration";
-import LimitPickers from "@/components/input/LimitPickers";
-import { endFast } from "../actions/TrackTimeActions";
-import Modal from "@/components/layout/Modal";
-import { setStep } from "@/store/scenario";
-import { TimeFormatter } from "@/utils/time_format";
-import { ColorType } from "@/context/themes/color";
-
-const Component = forwardRef((props, ref) => {
-    const isFastFirst = true;
-    const { t } = useTranslation()
-    const scenario = useSelector((state: any) => state.scenario);
-    const user = useSelector((state: any) => state.user);
-    const [isOpen, setIsOpen] = useState(false);
-    const [showModal, setShowModal] = useState(false);
-    const limitPickerRef = useRef<any>(null);
-    const dispatch = useDispatch();
-
-    useEffect(() => {
-        var value = trackTimeService.getSnapshot().value
-    }, [machine.context.currentStatus])
-
-    useEffect(() => {
-        trackTimeService.onTransition(state => {
-            var value = trackTimeService.getSnapshot().value
-        });
-    }, []);
-
-    function login() {
-        Taro.navigateTo({
-            url: '/pages/account/ChooseAuth'
-        })
-    }
-
-    function waitActionSheet() {
-        Taro.showActionSheet({
-            itemList: [t('feature.track_time_duration.action_sheet.change_schedule'), t('feature.track_time_duration.action_sheet.switch_scenario')]
-        })
-            .then(res => {
-                switch (res.tapIndex) {
-                    case 0:
-                        if (scenario.name == 'FAST_SLEEP') {
-                            dispatch(setStep(isFastFirst ? 'fast' : 'sleep'))
-                        }
-                        else if (scenario.name == 'SLEEP') {
-                            dispatch(setStep('sleep'))
-                        }
-                        else {
-                            dispatch(setStep('fast'))
-                        }
-                        Taro.navigateTo({
-                            url: '/pages/clock/SetSchedule'
-                        })
-                        break;
-                    case 1:
-                        Taro.navigateTo({
-                            url: '/pages/clock/ChooseScenario'
-                        })
-                        break;
-                }
-            })
-            .catch(err => {
-                console.log(err.errMsg)
-            })
-    }
-
-    function endFastActionSheet() {
-        Taro.showActionSheet({
-            itemList: [t('feature.track_time_duration.action_sheet.end_fast')]
-        })
-            .then(res => {
-                console.log(res.tapIndex)
-                switch (res.tapIndex) {
-                    case 0:
-                        {
-                            setShowModal(true)
-                            setIsOpen(true)
-                            global.set_time = new Date().getTime()
-                        }
-                        break;
-                }
-            })
-            .catch(err => {
-                console.log(err.errMsg)
-            })
-    }
-
-    function checkActionSheetData() {
-        console.log('checkActionSheetData')
-        if (!user.isLogin) {
-            return login()
-        }
-        var state = trackTimeService.getSnapshot().value
-        if ((state as any).FAST_SLEEP === 'WAIT_FOR_START' ||
-            (state as any).FAST === 'WAIT_FOR_START' ||
-            (state as any).SLEEP === 'WAIT_FOR_START') {
-            waitActionSheet()
-        }
-        else if ((state as any).FAST_SLEEP === 'ONGOING1' ||
-            (state as any).FAST_SLEEP === 'ONGOING2') {
-            endFastActionSheet()
-        }
-        else if ((state as any).FAST_SLEEP === 'ONGOING3') {
-            Taro.showToast({
-                title: '暂无更多操作',
-                icon: 'none',
-                duration: 2000
-            })
-        }
-    }
-
-    global.checkActionSheetData = checkActionSheetData
-
-    function layoutContent() {
-        var limit = global.set_time - 7 * 3600 * 1000 * 24;
-        var current_record = machine.context.checkData ? (machine.context.checkData as any).current_record : null;
-        global.limit = limit
-        if (current_record && current_record.last_real_check_time) {
-            limit = current_record.last_real_check_time
-            global.limit = limit
-            
-            //当set_time秒数<=latest_record_time秒数时,最小限制时间戳需+1分钟
-            if (new Date(global.set_time).getSeconds() <= new Date(current_record.last_real_check_time).getSeconds()) {
-                limit = limit + 60 * 1000
-            }
-        }
-
-        
-        return <LimitPickers ref={limitPickerRef}
-        title = '结束断食'
-        themeColor={global.fastColor?global.fastColor:ColorType.fast}
-        limit={limit} onCancel={() => { setIsOpen(false); setShowModal(false) }} 
-        onChange={(e) => {
-            endFast(e)
-            setIsOpen(false)
-        }} />
-
-    }
-
-    function testLayout() {
-        var current_record = machine.context.checkData ? (machine.context.checkData as any).current_record : null;
-        if (current_record == null) {
-            return <View />
-        }
-        return <View style={{ color: '#fff', paddingTop: 30, paddingLeft: 30, display: 'flex', flexDirection: 'column' }}>
-            <Text>check scenario:fast</Text>
-            <Text>check type:end</Text>
-            <Text style={{ marginTop: 30 }}>picker restriction</Text>
-            <Text style={{ marginLeft: 50 }}>min:{TimeFormatter.formatTimestamp(global.limit)}</Text>
-            <Text style={{ marginLeft: 50 }}>pick:{TimeFormatter.formatTimestamp(global.picker_time)}</Text>
-            <Text style={{ marginLeft: 50 }}>max{TimeFormatter.formatTimestamp(global.set_time)}</Text>
-
-            <Text style={{ marginTop: 30 }}>now:{TimeFormatter.formatTimestamp(new Date().getTime())}</Text>
-            <Text>elapsed:{TimeFormatter.calculateTimeDifference(global.picker_time, new Date().getTime())}</Text>
-
-            <Text style={{ marginTop: 30 }}>real start:{TimeFormatter.formatTimestamp(current_record.fast.real_start_time)}</Text>
-            <Text>real duration:{TimeFormatter.calculateTimeDifference(current_record.fast.real_start_time, new Date().getTime())}</Text>
-        </View>
-    }
-
-    return (
-        <View ref={ref} style={{ width: '100%', marginTop: 20, marginBottom: 20, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
-            <Text onClick={checkActionSheetData}>More Component</Text>
-            {
-                showModal && isOpen && <Modal children={layoutContent()} dismiss={() => setIsOpen(false)}
-                    testInfo={testLayout()}
-                    confirm={() => {
-                        var picker = limitPickerRef.current;
-                        endFast((picker as any).getConfirmData());
-                        setIsOpen(false);
-                    }} />
-            }
-            {/* {
-                showModal && <AtFloatLayout
-                    isOpened={isOpen}
-                    onClose={() => {
-                        setIsOpen(false)
-                        setShowModal(false)
-                    }}
-                    title="">
-                    {
-                        layoutContent()
-                    }
-
-
-                </AtFloatLayout>
-            } */}
-
-        </View>
-    )
-}
-)
-
-export default Component;

+ 15 - 13
src/features/trackTimeDuration/components/Stage.tsx

@@ -3,8 +3,10 @@ import './Stage.scss'
 import { TimeFormatter } from "@/utils/time_format";
 import { ColorType } from "@/context/themes/color";
 import { IconRadio, IconRadioCheck, IconRadioCross } from "@/components/basic/Icons";
+import { useTranslation } from "react-i18next";
 
 export default function Component(props: { data: any }) {
+    const { t } = useTranslation()
     function getTime(t1: number, t2: number) {
         return TimeFormatter.formateTimeDifference(t1, t2)
     }
@@ -15,7 +17,7 @@ export default function Component(props: { data: any }) {
 
     function getStepATime(obj) {
         if (obj.status == 'COMPLETED' && obj.sleep.status == 'NOT_STARTED') {
-            return '未完成'
+            return t('feature.track_time_duration.stage.not_completed')
         }
 
         return obj.status == 'ONGOING1' ?
@@ -25,21 +27,21 @@ export default function Component(props: { data: any }) {
     }
 
     function getStepBTime(obj) {
-        if (obj.status == 'ONGOING1') return '待开始'
+        if (obj.status == 'ONGOING1') return t('feature.track_time_duration.stage.wait_for_start')
         if (obj.status == 'ONGOING2') return getTime(obj.sleep.real_start_time, (new Date()).getTime())
         if (obj.status == 'WAIT_FOR_START') return getDuration(obj.sleep.target_end_time, obj.sleep.target_start_time)
-        if (obj.sleep.status == 'NOT_STARTED') return '未开始'
-        if (obj.sleep.status == 'NOT_COMPLETED') return '未完成'
+        if (obj.sleep.status == 'NOT_STARTED') return t('feature.track_time_duration.stage.not_started')
+        if (obj.sleep.status == 'NOT_COMPLETED') return t('feature.track_time_duration.stage.not_completed')
         return getDuration(obj.sleep.real_end_time, obj.sleep.real_start_time)
 
     }
 
     function getStepCTime(obj) {
-        if (obj.status == 'ONGOING1') return '待开始'
-        if (obj.status == 'ONGOING2') return '待开始'
+        if (obj.status == 'ONGOING1') return t('feature.track_time_duration.stage.wait_for_start')
+        if (obj.status == 'ONGOING2') return t('feature.track_time_duration.stage.wait_for_start')
         if (obj.status == 'ONGOING3') return getTime(obj.sleep.real_end_time, (new Date()).getTime())
         if (obj.status == 'WAIT_FOR_START') return getDuration(obj.fast.target_end_time, obj.sleep.target_end_time)
-        if (obj.sleep.status == 'NOT_COMPLETED' || obj.sleep.status == 'NOT_STARTED') return '未开始'
+        if (obj.sleep.status == 'NOT_COMPLETED' || obj.sleep.status == 'NOT_STARTED') return t('feature.track_time_duration.stage.not_started')
         return getDuration(obj.fast.real_end_time, obj.sleep.real_end_time)
     }
     function getStepAIcon(obj) {
@@ -83,11 +85,11 @@ export default function Component(props: { data: any }) {
             </View>
             <View className="timeline-detail" style={{ color: ColorType.fast, opacity: 1 }}>
 
-                <Text>睡前断食</Text>
+                <Text>{t('feature.track_time_duration.stage.a')}</Text>
                 <View className="timeline-date2" style={{ color: ColorType.fast, opacity: 1 }}>{getStepATime(props.data)}</View>
 
             </View>
-            <View className='timeline_line1 line1_bottom_space' style={{backgroundColor:props.data.status == 'ONGOING1'?ColorType.fast:'rgba(255,255,255,0.1)'}}/>
+            <View className='timeline_line1 line1_bottom_space' style={{ backgroundColor: props.data.status == 'ONGOING1' ? ColorType.fast : 'rgba(255,255,255,0.1)' }} />
             <View className='timeline-line-bg' style={{ width: 16, background: global.isDebug ? 'red' : 'transparent' }}>
                 {
                     getStepAIcon(props.data)
@@ -109,11 +111,11 @@ export default function Component(props: { data: any }) {
             </View>
             <View className="timeline-detail" style={{ color: ColorType.sleep, opacity: 1 }}>
 
-                <Text>睡眠中断食</Text>
+                <Text>{t('feature.track_time_duration.stage.b')}</Text>
                 <View className="timeline-date2" style={{ color: ColorType.sleep, opacity: 1 }}>{getStepBTime(props.data)}</View>
 
             </View>
-            <View className='timeline_line1 line1_bottom_space' style={{backgroundColor:props.data.status == 'ONGOING2'?ColorType.sleep:'rgba(255,255,255,0.1)'}} />
+            <View className='timeline_line1 line1_bottom_space' style={{ backgroundColor: props.data.status == 'ONGOING2' ? ColorType.sleep : 'rgba(255,255,255,0.1)' }} />
             <View className='timeline-line-bg' style={{ width: 16, background: global.isDebug ? 'red' : 'transparent' }}>
                 {
                     getStepBIcon(props.data)
@@ -134,11 +136,11 @@ export default function Component(props: { data: any }) {
                 </View>
             </View>
             <View className="timeline-detail" style={{ color: ColorType.fast, opacity: 1 }}>
-                <Text>起床后断食</Text>
+                <Text>{t('feature.track_time_duration.stage.c')}</Text>
                 <View className="timeline-date2" style={{ color: ColorType.fast, opacity: 1 }}>{getStepCTime(props.data)}</View>
 
             </View>
-            <View className={'timeline_line1 line1_bottom_zero'} style={{backgroundColor:props.data.status == 'ONGOING3'?ColorType.fast:'rgba(255,255,255,0.1)'}}/>
+            <View className={'timeline_line1 line1_bottom_zero'} style={{ backgroundColor: props.data.status == 'ONGOING3' ? ColorType.fast : 'rgba(255,255,255,0.1)' }} />
             <View className='timeline-line-bg' style={{ width: 16, background: global.isDebug ? 'red' : 'transparent' }}>
                 {
                     getStepCIcon(props.data)

+ 6 - 5
src/features/trackTimeDuration/components/TimelineFastSleep.tsx

@@ -3,9 +3,10 @@ import { TimeFormatter } from "@/utils/time_format";
 import { View } from "@tarojs/components";
 import getStatus from "../hooks/Record";
 import { ColorType } from "@/context/themes/color";
+import { useTranslation } from "react-i18next";
 
 export default function TimelineFastSleep(props: { data: any, title?: string }) {
-
+    const {t} = useTranslation()
     function formateTime(obj: any, isEnd: boolean) {
         if (isEnd) {
             if (obj.real_end_time) {
@@ -51,7 +52,7 @@ export default function TimelineFastSleep(props: { data: any, title?: string })
         timelineItems.push(
             {
                 status: getStatus(true, true, props.data),
-                title: '开始断食',
+                title: t('feature.track_time_duration.common.start_fast'),
                 content: formateTime(props.data.fast, false),
                 date: formateDate(props.data.fast, false),
                 color:global.fastColor?global.fastColor:ColorType.fast
@@ -62,7 +63,7 @@ export default function TimelineFastSleep(props: { data: any, title?: string })
         timelineItems.push(
             {
                 status: getStatus(false, true, props.data),
-                title: '开始睡眠',
+                title: t('feature.track_time_duration.common.start_sleep'),
                 content: formateTime(props.data.sleep, false),
                 date: formateDate(props.data.sleep, false),
                 color:global.sleepColor?global.sleepColor:ColorType.sleep
@@ -73,7 +74,7 @@ export default function TimelineFastSleep(props: { data: any, title?: string })
         timelineItems.push(
             {
                 status: getStatus(false, false, props.data),
-                title: '结束睡眠',
+                title: t('feature.track_time_duration.common.end_sleep'),
                 content: formateTime(props.data.sleep, true),
                 date: formateDate(props.data.sleep, true),
                 color:global.sleepColor?global.sleepColor:ColorType.sleep
@@ -84,7 +85,7 @@ export default function TimelineFastSleep(props: { data: any, title?: string })
         timelineItems.push(
             {
                 status: getStatus(true, false, props.data),
-                title: '结束断食',
+                title: t('feature.track_time_duration.common.end_fast'),
                 content: formateTime(props.data.fast, true),
                 date: formateDate(props.data.fast, true),
                 color:global.fastColor?global.fastColor:ColorType.fast

+ 1 - 1
src/pages/account/ChooseAuth.scss

@@ -6,7 +6,7 @@
     // justify-content: center;
 }
 
-.slogon{
+.slogan{
     margin-top: 20px;
     font-size: 48px;
     line-height: 48px;

+ 4 - 2
src/pages/account/ChooseAuth.tsx

@@ -9,9 +9,11 @@ import { useEffect, useState } from "react";
 import { wxLogin } from "@/services/user";
 import { ColorType } from "@/context/themes/color";
 import { ChooseScenarioBtn } from "@/features/common/SpecBtns";
+import { useTranslation } from "react-i18next";
 
 export default function Page() {
     const dispatch = useDispatch();
+    const {t} = useTranslation()
     var code = '';
 
     const user = useSelector((state: any) => state.user);
@@ -65,8 +67,8 @@ export default function Page() {
 
     return <View className="container choose_container">
         <Texts text='fast16cc' type={TextType.big} />
-        <Text className="slogon">健康生物钟</Text>
-        <ChooseScenarioBtn title='微信登录' onClick={login} background={ColorType.fast} />
+        <Text className="slogan">{t('page.choose_auth.slogan')}</Text>
+        <ChooseScenarioBtn title={t('page.choose_auth.btn_wechat')} onClick={login} background={ColorType.fast} />
         {/* <View style={{ height: 100 }} /> */}
 
         {/* <Buttons title='微信登录' onClick={login} btnStyle={{ width: 289, marginBottom: 30,backgroundColor:ColorType.fast }} /> */}

+ 6 - 4
src/pages/account/EditPage.tsx

@@ -7,11 +7,13 @@ import { updateSuccess } from "@/store/user";
 import { Input, View, Text } from "@tarojs/components";
 import Taro from "@tarojs/taro";
 import { useState } from "react";
+import { useTranslation } from "react-i18next";
 import { useDispatch, useSelector } from "react-redux";
 
 export default function Page() {
     const user = useSelector((state: any) => state.user);
     const [value, setValue] = useState(user.nickname);
+    const {t} = useTranslation()
     const dispatch = useDispatch();
 
     const handleChange = (e) => {
@@ -21,7 +23,7 @@ export default function Page() {
     function save() {
         if (value.length == 0) {
             Taro.showToast({
-                title: '请输入昵称',
+                title: t('feature.common.toast.input_nickname'),
                 icon: 'none'
             })
             return;
@@ -29,7 +31,7 @@ export default function Page() {
         update({ nickname: value }).then(res => {
             dispatch(updateSuccess({ nickname: value }));
             Taro.showToast({
-                title: '更新成功',
+                title: t('feature.common.toast.update_success'),
                 icon: 'none'
             })
 
@@ -44,11 +46,11 @@ export default function Page() {
     return <View>
         <View style={{height:20}}></View>
         {/* <Input type="nickname" placeholder="请输入昵称" style={{ color: '#fff' }} value={value} onInput={handleChange} /> */}
-        <Inputs placeholder="请输入昵称" value={value} onChange={handleChange} onConfirm={save}
+        <Inputs placeholder={t('feature.common.toast.input_nickname')} value={value} onChange={handleChange} onConfirm={save}
             openType="nickname"
         />
         <Footer>
-        <ChooseScenarioBtn title='保存' onClick={save} background={ColorType.fast} />
+        <ChooseScenarioBtn title={t('page.user_profile.save')} onClick={save} background={ColorType.fast} />
         </Footer>
         {/* <Text onClick={save} style={{ color: '#fff' }}>保存</Text> */}
     </View>

+ 10 - 10
src/pages/account/Profile.tsx

@@ -53,8 +53,8 @@ export default function Page() {
 
     function reset() {
         Taro.showModal({
-            title: '重置session',
-            content: '确认重置session吗?',
+            title: t('feature.common.modal.reset_session_title'),
+            content: t('feature.common.modal.reset_session_content'),
             success: res => {
                 if (res.confirm) {
                     delSession({ type: 'WX_MP' })
@@ -66,8 +66,8 @@ export default function Page() {
 
     function clear() {
         Taro.showModal({
-            title: '注销账号',
-            content: '确定注销此账号吗?',
+            title: t('feature.common.modal.deluser_title'),
+            content: t('feature.common.modal.deluser_content'),
             success: res => {
                 if (res.confirm) {
                     dispatch(clear() as any);
@@ -126,20 +126,20 @@ export default function Page() {
                             }} /> : <Image src={require('@/assets/images/user.png')} className="avatar_placeholder" />
                         }
                     </View>
-                    <Text className="nickname">{user.isLogin ? user.nickname : '未登录'}</Text>
+                    <Text className="nickname">{user.isLogin ? user.nickname : t('page.more.un_login')}</Text>
                     {/* <Text className="username">{user.isLogin ? '用户名未设置' : ''}</Text> */}
                 </View>
             </Box>
 
             <Box>
                 <View className="balance" onClick={tapBalance}>
-                    <Text className="title">逆龄石</Text>
-                    <Text className="desc">{'会员体系升级中,期间指标记录限时免逆龄石记录\n敬请期待'}</Text>
+                    <Text className="title">{t('page.more.stone')}</Text>
+                    <Text className="desc">{t('page.more.stone_desc')}</Text>
                 </View>
             </Box>
             {
                 user.isLogin && <View onClick={goSetting}>
-                    <TableCell title="设置" showArrow={true} showMarginBottom={true}></TableCell>
+                    <TableCell title={t('page.more.setting')} showArrow={true} showMarginBottom={true}></TableCell>
                 </View>
             }
             {/* {user.isLogin && <Box >
@@ -156,11 +156,11 @@ export default function Page() {
             }
             {
                 user.isLogin && user.test_user && <TableCell title="session" showArrow={true} onClick={reset}>
-                    <Text style={{ opacity: 0.8 }}>重置session</Text>
+                    <Text style={{ opacity: 0.8 }}>{t('page.more.reset_session')}</Text>
                 </TableCell>
             }
             {
-                user.isLogin && user.test_user && <TableCell title="走查模式" >
+                user.isLogin && user.test_user && <TableCell title={t('page.more.debug_mode')} >
                     <Switch checked={switchOn} onChange={switchChanged} />
                 </TableCell>
             }

+ 2 - 2
src/pages/account/ProfileSetting.tsx

@@ -69,7 +69,7 @@ export default function Page() {
         update({ avatar: url }).then(res => {
             dispatch(updateSuccess({ avatar: url }));
             Taro.showToast({
-                title: '更新成功',
+                title: t('feature.common.toast.update_success'),
                 icon: 'none'
             })
 
@@ -97,7 +97,7 @@ export default function Page() {
 
 
         <View onClick={editNickname}>
-            <TableCell title="昵称" showArrow={true} showMarginBottom={true}>
+            <TableCell title={t('page.user_profile.nickname')} showArrow={true} showMarginBottom={true}>
                 <Text style={{ opacity: 0.8 }}>{user.nickname}</Text>
             </TableCell>
         </View>

+ 4 - 17
src/pages/account/Setting.tsx

@@ -21,8 +21,8 @@ export default function Page() {
     }, [])
     function logoutF() {
         Taro.showModal({
-            title: '退出登录',
-            content: '确定退出登录吗?',
+            title: t('feature.common.modal.logout_title'),
+            content: t('feature.common.modal.logout_content'),
             success: res => {
                 if (res.confirm) {
                     dispatch(logout() as any);
@@ -32,26 +32,13 @@ export default function Page() {
 
     }
 
-    function clearF() {
-        Taro.showModal({
-            title: '注销账号',
-            content: '确定注销此账号吗?',
-            success: res => {
-                if (res.confirm) {
-                    dispatch(clear() as any);
-                }
-            }
-        })
-
-    }
-
     return <View style={{ color: '#fff',display:'flex',flexDirection:'column' }}>
         <View style={{height:20}}/>
-        <TableCell title="版本" ><Text style={{ opacity: 0.8 }}>1.2.3</Text></TableCell>
+        <TableCell title={t('page.setting.version')} ><Text style={{ opacity: 0.8 }}>1.2.3</Text></TableCell>
         {/* <Text style={{color:'#9E9E9E',textAlign:'center',fontSize:14}}>v1.2.2</Text> */}
         
         <Footer>
-            <ChooseScenarioBtn title='退出登录' onClick={logoutF} background={ColorType.fast} />
+            <ChooseScenarioBtn title={t('page.setting.logout')} onClick={logoutF} background={ColorType.fast} />
         </Footer>
         {/* <Buttons title='退出登录' onClick={logoutF} btnStyle={{ width: 289, marginBottom: 30 }} /> */}
 

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

@@ -169,8 +169,8 @@ export default function Page() {
         // debugger
         // page.refresh()
         Taro.showModal({
-            title: '提示',
-            content: '确认删除全部记录?',
+            title: t('feature.common.modal.delete_all_title'),
+            content: t('feature.common.modal.delete_all_content'),
             success: (res) => {
                 if (res.confirm) {
                     doClear()
@@ -261,7 +261,7 @@ export default function Page() {
         />
         {
             loaded && records.length == 0 && <View className="no_records_bg">
-                <Text className="no_records">无记录</Text>
+                <Text className="no_records">{t('feature.common.no_data.no_record')}</Text>
             </View>
         }
 

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

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