leon 1 ano atrás
pai
commit
5aaf9d5bdd

+ 9 - 1
src/_health/components/sticky_date_list.tsx

@@ -11,6 +11,14 @@ export default function StickyDateList(props: {
     showDate: boolean,
     date: string
 }) {
+
+    function headerDate(){
+        if (global.language=='en'){
+            return props.date.substring(0,4)
+        }
+        return props.date.substring(0,5)
+    }
+
     return <View style={{ position: 'relative' }}>
         <View className="h26" style={{
             position: 'absolute',
@@ -27,7 +35,7 @@ export default function StickyDateList(props: {
             zIndex: 1,
             opacity: props.showDate ? 1 : 0,
             color: MainColorType.g01
-        }}>{props.date}
+        }}>{headerDate()}
             <View className="border_header_line"/>
             <View className="border_footer_line" />
         </View>

+ 1 - 1
src/_health/pages/add_moment.tsx

@@ -522,7 +522,7 @@ export default function AddMoment() {
             color={getThemeColor(health.mode)}
             width={rpxToPx(646)}
             height={rpxToPx(96)}
-            title="发布"
+            title={t('health.log')}
             onClick={save}
         /></View>
 

+ 1 - 1
src/_health/pages/guide_active.tsx

@@ -268,7 +268,7 @@ export default function GuideActive() {
         </Card>
     }
     return <View style={{ flex: 1, display: 'flex', flexDirection: 'column', height: '100vh' }}>
-        <View style={{ height: navigationBarHeight, backgroundColor: MainColorType.g05 }} />
+        <View style={{ height: navigationBarHeight, backgroundColor: MainColorType.g05,flexShrink:0 }} />
         <View className="navi-bar" style={{ height: navigationBarHeight, zIndex: 1000, backgroundColor: MainColorType.g05 }}>
 
             <View style={{

+ 1 - 1
src/_health/pages/guide_eat.tsx

@@ -248,7 +248,7 @@ export default function GuideEat() {
         </Card>
     }
     return <View style={{ flex: 1, display: 'flex', flexDirection: 'column', height: '100vh' }}>
-        <View style={{ height: navigationBarHeight, backgroundColor: MainColorType.g05 }} />
+        <View style={{ height: navigationBarHeight, backgroundColor: MainColorType.g05,flexShrink:0 }} />
         <View className="navi-bar" style={{ height: navigationBarHeight, zIndex: 1000, backgroundColor: MainColorType.g05 }}>
 
             <View style={{

+ 1 - 1
src/_health/pages/guide_full.tsx

@@ -86,7 +86,7 @@ export default function GuideFull() {
         </Card>
     }
     return <View style={{ flex: 1, display: 'flex', flexDirection: 'column', height: '100vh' }}>
-        <View style={{ height: navigationBarHeight, backgroundColor: MainColorType.g05 }} />
+        <View style={{ height: navigationBarHeight, backgroundColor: MainColorType.g05,flexShrink:0 }} />
         <View className="navi-bar" style={{ height: navigationBarHeight, zIndex: 1000, backgroundColor: MainColorType.g05 }}>
 
             <View style={{

+ 3 - 2
src/_health/pages/log_time.tsx

@@ -512,6 +512,7 @@ export default function LogTime() {
 
     function logItem(index: number, iFast: boolean, iStart: boolean, showLine: boolean) {
         const { fast, sleep } = data
+        debugger
         var schedule_time = ''
         var title = ''
 
@@ -533,7 +534,7 @@ export default function LogTime() {
             if (!iStart && fast.status == 'OG') {
                 schedule_time = dayjs(fast.target.end_timestamp).format('HH:mm')
             }
-            title = iStart ? 'Fast starts' : 'Fast ends'
+            title = iStart ? fast.timeline[0].title : fast.timeline[1].title
 
 
 
@@ -559,7 +560,7 @@ export default function LogTime() {
             if (!iStart && sleep.status == 'OG') {
                 schedule_time = dayjs(sleep.target.end_timestamp).format('HH:mm')
             }
-            title = iStart ? 'Bedtime' : 'Wake up'
+            title = iStart ? sleep.timeline[0].title : sleep.timeline[1].title
             if (array[index].disable) {
                 var timestamp = iStart ? sleep.real.start_timestamp : sleep.real.end_timestamp
                 date = dayjs(timestamp).format('YYYY-MM-DD')

+ 11 - 6
src/app.scss

@@ -465,6 +465,11 @@ page {
     line-height: 60px;
 }
 
+.h42{
+    font-size: 42px;
+    line-height: 50px;
+}
+
 .h44 {
     font-size: 44px;
     line-height: 52px;
@@ -596,16 +601,16 @@ text{
 }
 
 .cell_date {
-    margin-right: 24px;
-    width: 74px;
-    height: 68px;
+    // background-color: pink;
+    margin-right: 0px;
+    width: 122px;
+    height: 60px;
     flex-shrink: 0;
-    align-items: center;
+    flex-direction: row;
+    align-items: flex-end;
     justify-content: flex-start;
     display: flex;
     color: #000;
-    font-size: 50px;
-    font-weight: bold;
 }
 
 .history_year_month{

+ 7 - 0
src/app.tsx

@@ -74,9 +74,16 @@ const App: React.FC<PropsWithChildren> = ({ children }) => {
     global.language = 'en'
   }
   if (process.env.TARO_ENV == 'weapp') {
+    global.language = 'zh'
+    var value = Taro.getStorageSync('language')
+    if (value) {
+      // Do something with return value
+      global.language = value
+    }
     loadWXCache()
     global.isDebug = Taro.getStorageSync('isDebug')
 
+
     const updateManager = Taro.getUpdateManager()
     updateManager.onUpdateReady(function () {
       Taro.showModal({

+ 1 - 1
src/components/basic/Icons.tsx

@@ -594,7 +594,7 @@ export const IconCircle = (props: { width: number, color: string }) => {
     <g>
         <g>
             <ellipse cx="16" cy="15.999999046325684" rx="14.5" ry="14.499999046325684"
-                fill-opacity="0" stroke-opacity="1" stroke="${props.color}" fill="none" stroke-width="3" />
+                fill-opacity="0" stroke-opacity="1" stroke="${props.color}" fill="none" stroke-width="2" />
         </g>
     </g>
 </svg>`

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

@@ -940,7 +940,16 @@ export default {
         ok:'OK',
 
         logging:'logging',
-
         log:'Log',
+        recents:'Recents',
+        language:'Language',
+
+        fast_with_sleep:'Fast with Sleep',
+        long_fast:'Long Fast',
+        move_more:'Move More',
+        move_every_hour:'Move Every Hour',
+
+        log_extra_meal:'Log Extra Meal',
+        log_extra_activity:'Log Extra Activity',
     }
 }

+ 11 - 1
src/context/locales/zh.js

@@ -940,6 +940,16 @@ export default {
         ok:'我知道了',
 
         logging:'记录中',
-        log:'记录'
+        log:'记录',
+        recents:'最近记录',
+        language:'语言',
+
+        fast_with_sleep:'断食与睡眠',
+        long_fast:'长断食',
+        move_more:'走一走',
+        move_every_hour:'每小时走一走',
+
+        log_extra_meal:'记录额外一餐',
+        log_extra_activity:'记录额外活动',
     }
 }

+ 46 - 7
src/features/health/HistoryItem.tsx

@@ -16,6 +16,7 @@ import { rpxToPx } from "@/utils/tools";
 import NewButton, { NewButtonType } from "@/_health/base/new_button";
 import TimeTitleDesc from "@/_health/components/time_title_desc";
 import CoverList from "@/_health/components/cover_list";
+import { TimeFormatter } from "@/utils/time_format";
 
 export default function HistoryItem(props: {
     data: any,
@@ -26,7 +27,7 @@ export default function HistoryItem(props: {
     refresh?: Function,
     mode: string,
     fast_type?: string,
-    hideLine?:boolean
+    hideLine?: boolean
 }) {
     const health = useSelector((state: any) => state.health);
     let showActionSheetWithOptions;
@@ -128,8 +129,8 @@ export default function HistoryItem(props: {
         return count;
     }
 
-    function imgList(){
-        let array:any = [];
+    function imgList() {
+        let array: any = [];
         props.data.events.map((item) => {
             if (item.moments) {
                 item.moments.map(moment => {
@@ -145,15 +146,50 @@ export default function HistoryItem(props: {
 
     function historyDate() {
         if (!props.preData) {
+            if (global.language == 'zh' && TimeFormatter.isToday(props.data.window_range.start_timestamp)) {
+                return '今天'
+            }
+            if (global.language == 'zh' && TimeFormatter.isYesterday(props.data.window_range.start_timestamp)) {
+                return '昨天'
+            }
             return dayjs(props.data.window_range.start_timestamp).format('DD')
         }
         if (dayjs(props.data.window_range.start_timestamp).format('MM-DD') ==
             dayjs(props.preData.window_range.start_timestamp).format('MM-DD')) {
             return ''
         }
+        if (global.language == 'zh' && TimeFormatter.isToday(props.data.window_range.start_timestamp)) {
+            return '今天'
+        }
+        if (global.language == 'zh' && TimeFormatter.isYesterday(props.data.window_range.start_timestamp)) {
+            return '昨天'
+        }
         return dayjs(props.data.window_range.start_timestamp).format('DD')
     }
 
+    function historyMonth() {
+        if (!props.preData) {
+            if (global.language == 'zh' && TimeFormatter.isToday(props.data.window_range.start_timestamp)) {
+                return ''
+            }
+            if (global.language == 'zh' && TimeFormatter.isYesterday(props.data.window_range.start_timestamp)) {
+                return ''
+            }
+            return dayjs(props.data.window_range.start_timestamp).format('MMM')
+        }
+        if (dayjs(props.data.window_range.start_timestamp).format('MM-DD') ==
+            dayjs(props.preData.window_range.start_timestamp).format('MM-DD')) {
+            return ''
+        }
+        if (global.language == 'zh' && TimeFormatter.isToday(props.data.window_range.start_timestamp)) {
+            return ''
+        }
+        if (global.language == 'zh' && TimeFormatter.isYesterday(props.data.window_range.start_timestamp)) {
+            return ''
+        }
+        return dayjs(props.data.window_range.start_timestamp).format('MMM')
+    }
+
     function tapDel() {
         showAlert({
             title: '确定要放弃本次断食吗?',
@@ -198,10 +234,13 @@ export default function HistoryItem(props: {
     }
 
     return <View className="history_item2">
-        <View className="cell_date" >{historyDate()}</View>
+        <View className="cell_date" >
+            <View className="h42 bold" style={{ lineHeight: rpxToPx(60) + 'px' }}>{historyDate()}</View>
+            <View className="h24 bold" style={{ marginLeft: rpxToPx(6), marginTop: rpxToPx(11), lineHeight: rpxToPx(49) + 'px' }}>{historyMonth()}</View>
+        </View>
         <View className="history_content" >
 
-            <View style={{ display: 'flex', flexDirection: 'column', marginBottom: rpxToPx(12), flex: 1 }}>
+            <View style={{ display: 'flex', flexDirection: 'column', marginBottom: rpxToPx(12), flex: 1, paddingTop: rpxToPx(4) }}>
                 {
                     props.data.events.map((item, index) => {
                         return <TimeTitleDesc
@@ -224,7 +263,7 @@ export default function HistoryItem(props: {
                 }
             </View>
             {
-                mediaCount()>0 && <CoverList count={mediaCount()} imgs={imgList()}/>
+                mediaCount() > 0 && <CoverList count={mediaCount()} imgs={imgList()} />
             }
 
             <View className="history_duration_bg" style={{ marginTop: 0 }}>
@@ -290,6 +329,6 @@ export default function HistoryItem(props: {
         {
             !props.hideLine && <View className="border_footer_line" />
         }
-        
+
     </View>
 }

+ 7 - 7
src/features/health/MainConsole.tsx

@@ -421,7 +421,7 @@ export default function MainConsole(props: { type: WindowType }) {
                     if (!health.finish_setup) {
                         list.push(t('health.finish_setup'))
                     }
-                    list.push(t('health.add_active'))
+                    list.push(t('health.log_extra_activity'))
                     var scenario = getScenario(health.windows, 'ACTIVE')
                     if (scenario.status != 'WFS') {
                         list.push(t('health.mark_done'))
@@ -438,7 +438,7 @@ export default function MainConsole(props: { type: WindowType }) {
                     if (!health.finish_setup) {
                         list.push(t('health.finish_setup'))
                     }
-                    list.push(t('health.add_meal'))
+                    list.push(t('health.log_extra_meal'))
                     var scenario = getScenario(health.windows, 'EAT')
                     if (scenario.status != 'WFS') {
                         list.push(t('health.mark_done'))
@@ -552,10 +552,10 @@ export default function MainConsole(props: { type: WindowType }) {
             case t('health.finish_setup'):
                 tapGuide();
                 break;
-            case t('health.add_active'):
+            case t('health.log_extra_activity'):
                 jumpPage(`/_health/pages/add_moment?title=&is_temp=${true}`)
                 break;
-            case t('health.add_meal'):
+            case t('health.log_extra_meal'):
                 jumpPage(`/_health/pages/add_moment?title=加餐&is_temp=${true}`)
                 break;
             case t('health.mark_done'):
@@ -944,7 +944,7 @@ export default function MainConsole(props: { type: WindowType }) {
             health.mode == 'ACTIVE' && <View>
                 <View className="main_column_space" /><IconTitleCell
                     icon={<IconWalk width={rpxToPx(32)} color={MainColorType.active} />}
-                    title="Move More"
+                    title={t('health.move_more')}
                     onClick={() => {
                         jumpPage('/_health/pages/move')
                     }}
@@ -976,7 +976,7 @@ export default function MainConsole(props: { type: WindowType }) {
                     }}
                     showLine={health.mode == 'FAST'}
                     icon={<Image className="active_icon" src={require('@assets/_health/fast.png')} />}
-                    title="Fast with sleep"
+                    title={t('health.fast_with_sleep')}
                     desc={<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
                         {
                             fastWithSleepStatus()
@@ -1003,7 +1003,7 @@ export default function MainConsole(props: { type: WindowType }) {
                     jumpPage('/_health/pages/long_fast')
                 }}
                 icon={<Image className="active_icon" src={require('@assets/_health/fast.png')} />}
-                title="Long fast"
+                title={t('health.long_fast')}
                 desc={
                     longFastStatus()
                 }

+ 14 - 9
src/features/health/MainHistory.tsx

@@ -15,6 +15,7 @@ import { MainColorType } from "@/context/themes/color";
 import { IconArrow, IconCellArrow } from "@/components/basic/Icons";
 import NoRecord from "@/_health/components/no_record";
 import ListFooter from "@/_health/components/list_footer";
+import { useTranslation } from "react-i18next";
 
 let lastMode = ''
 let myScrollTop = 0
@@ -29,6 +30,7 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
     const user = useSelector((state: any) => state.user);
     const [loading, setLoading] = useState(false)
     const healthRef = useRef(health)
+    const { t } = useTranslation()
 
     useImperativeHandle(ref, () => ({
         onScroll: onScroll,
@@ -180,23 +182,26 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
         var showDate = false;
         var dateStr = ''
         if (index == 0) {
-            var currentDate = dayjs(list[index].window_range.start_timestamp).format('YYYY年M月')
-            var now = dayjs().format('YYYY年M月')
+            var currentDate = global.language=='en'?dayjs(list[index].window_range.start_timestamp).format('YYYY'):dayjs(list[index].window_range.start_timestamp).format('YYYY年')
+            var now = global.language=='en'?dayjs().format('YYYY'):dayjs().format('YYYY年')
+
+            if (currentDate != now) {
+                showDate = true
+                dateStr = currentDate
+            }
 
-            showDate = true
-            dateStr = currentDate
 
         }
         else {
-            var currentDate = dayjs(list[index].window_range.start_timestamp).format('YYYY年M月')
-            var now = dayjs(list[index - 1].window_range.start_timestamp).format('YYYY年M月')
+            var currentDate = global.language=='en'?dayjs(list[index].window_range.start_timestamp).format('YYYY'):dayjs(list[index].window_range.start_timestamp).format('YYYY年')
+            var now = global.language=='en'?dayjs().format('YYYY'):dayjs().format('YYYY年')
             if (currentDate != now) {
                 showDate = true
                 dateStr = currentDate
             }
         }
         if (showDate) {
-            return <View className="history_year_month h30 g01">{dateStr}</View>
+            return <View className="history_year_month h42 bold">{dateStr}</View>
         }
         return <View />
     }
@@ -204,7 +209,7 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
     function hideLine(index) {
         var currentDate = dayjs(list[index].window_range.start_timestamp).format('YYYY年M月D日')
         if (list.length > index + 1) {
-            var nextDate = dayjs(list[index+1].window_range.start_timestamp).format('YYYY年M月D日')
+            var nextDate = dayjs(list[index + 1].window_range.start_timestamp).format('YYYY年M月D日')
             if (currentDate == nextDate) return true
         }
         return false
@@ -218,7 +223,7 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
     return <View style={{ width: rpxToPx(750), marginTop: rpxToPx(36) }}>
         {
             (list.length >= 0 || health.mode == 'EAT') && <View className="recent">
-                <Text className="h50 bold" >Recent</Text>
+                <Text className="h42 bold" >{t('health.recents')}</Text>
                 {
                     health.mode == 'EAT' && <View onClick={() => {
                         jumpPage('/_health/pages/archive')

+ 106 - 28
src/pages/account/Album.tsx

@@ -14,6 +14,7 @@ import Taro from "@tarojs/taro";
 import StickyDateList from "@/_health/components/sticky_date_list";
 import ListFooter from "@/_health/components/list_footer";
 import CoverList from "@/_health/components/cover_list";
+import { TimeFormatter } from "@/utils/time_format";
 
 let myScrollTop = 0
 export default function Album() {
@@ -77,30 +78,30 @@ export default function Album() {
         })
     }
 
-    function historyMonth(index, preIndex) {
-        var showDate = false;
-        var dateStr = ''
-        if (index == 0) {
-            var currentDate = (medias[index].date + '').substring(0, 6)
-            var now = dayjs().format('YYYYMM')
+    // function historyMonth(index, preIndex) {
+    //     var showDate = false;
+    //     var dateStr = ''
+    //     if (index == 0) {
+    //         var currentDate = (medias[index].date + '').substring(0, 6)
+    //         var now = dayjs().format('YYYYMM')
 
-            showDate = true
-            dateStr = currentDate.substring(0, 4) + '年' + currentDate.substring(4, 6) + '月'
-        }
-        else {
-            var currentDate = (medias[index].date + '').substring(0, 6)
-            var now = (medias[index - 1].date + '').substring(0, 6)
-            if (currentDate != now) {
-                showDate = true
-                // dateStr = currentDate
-                dateStr = currentDate.substring(0, 4) + '年' + currentDate.substring(4, 6) + '月'
-            }
-        }
-        if (showDate) {
-            return <View className="history_year_month h30 g01">{dateStr}</View>
-        }
-        return <View />
-    }
+    //         showDate = true
+    //         dateStr = currentDate.substring(0, 4) + '年' + currentDate.substring(4, 6) + '月'
+    //     }
+    //     else {
+    //         var currentDate = (medias[index].date + '').substring(0, 6)
+    //         var now = (medias[index - 1].date + '').substring(0, 6)
+    //         if (currentDate != now) {
+    //             showDate = true
+    //             // dateStr = currentDate
+    //             dateStr = currentDate.substring(0, 4) + '年' + currentDate.substring(4, 6) + '月'
+    //         }
+    //     }
+    //     if (showDate) {
+    //         return <View className="history_year_month h30 g01">{dateStr}</View>
+    //     }
+    //     return <View />
+    // }
 
     function measureItemLayouts() {
         const query = Taro.createSelectorQuery()
@@ -111,7 +112,7 @@ export default function Album() {
             var layouts: any = []
             res.forEach((rect, index) => {
                 if (rect) {
-                    layouts[index] = rect.top+myScrollTop
+                    layouts[index] = rect.top + myScrollTop
                 }
             });
             setItemLayouts(layouts)
@@ -142,6 +143,80 @@ export default function Album() {
         }
     }
 
+    function historyYear(index) {
+        var showDate = false;
+        var dateStr2:any = ''
+        if (index == 0) {
+            var currentDate = global.language == 'en' ? dayjs(medias[index].timestamp).format('YYYY') : dayjs(medias[index].timestamp).format('YYYY年')
+            var now = global.language == 'en' ? dayjs().format('YYYY') : dayjs().format('YYYY年')
+
+            if (currentDate != now) {
+                showDate = true
+                dateStr2 = currentDate
+            }
+
+
+        }
+        else {
+            var currentDate = global.language == 'en' ? dayjs(medias[index].timestamp).format('YYYY') : dayjs(medias[index].timestamp).format('YYYY年')
+            var now = global.language == 'en' ? dayjs().format('YYYY') : dayjs().format('YYYY年')
+            if (currentDate != now) {
+                showDate = true
+                dateStr2 = currentDate
+            }
+        }
+        if (showDate) {
+            return <View className="history_year_month h42 bold">{dateStr2}</View>
+        }
+        return <View />
+    }
+
+    function historyDate(item, index) {
+        if (index == 0) {
+            if (global.language == 'zh' && TimeFormatter.isToday(item.timestamp)) {
+                return '今天'
+            }
+            if (global.language == 'zh' && TimeFormatter.isYesterday(item.timestamp)) {
+                return '昨天'
+            }
+            return dayjs(item.timestamp).format('DD')
+        }
+        if (dayjs(item.timestamp).format('MM-DD') ==
+            dayjs(medias[index - 1].timestamp).format('MM-DD')) {
+            return ''
+        }
+        if (global.language == 'zh' && TimeFormatter.isToday(item.timestamp)) {
+            return '今天'
+        }
+        if (global.language == 'zh' && TimeFormatter.isYesterday(item.timestamp)) {
+            return '昨天'
+        }
+        return dayjs(item.timestamp).format('DD')
+    }
+
+    function historyMonth(item, index) {
+        if (index == 0) {
+            if (global.language == 'zh' && TimeFormatter.isToday(item.timestamp)) {
+                return ''
+            }
+            if (global.language == 'zh' && TimeFormatter.isYesterday(item.timestamp)) {
+                return ''
+            }
+            return dayjs(item.timestamp).format('MMM')
+        }
+        if (dayjs(item.timestamp).format('MM-DD') ==
+            dayjs(medias[index - 1].timestamp).format('MM-DD')) {
+            return ''
+        }
+        if (global.language == 'zh' && TimeFormatter.isToday(item.timestamp)) {
+            return ''
+        }
+        if (global.language == 'zh' && TimeFormatter.isYesterday(item.timestamp)) {
+            return ''
+        }
+        return dayjs(item.timestamp).format('MMM')
+    }
+
     return <StickyDateList onRefresherRefresh={() => {
         setIsPulling(true)
         setPage(1)
@@ -199,13 +274,16 @@ export default function Album() {
             </View>
             {
                 medias.map((item, index) => {
-                    return <View key={index} id={`history-${index}`} style={{ display: 'flex', flexDirection: 'column' }}>
+                    return <View key={index} id={`history-${index}`} style={{ display: 'flex', flexDirection: 'column', paddingTop: rpxToPx(6), backgroundColor: '#fff' }}>
                         {
-                            historyMonth(index, index - 1)
+                            historyYear(index)
                         }
                         <View className="history_item2" >
-
-                            <Text className="cell_date">{(item.date + '').substring(6, 9)}</Text>
+                            <View className="cell_date" >
+                                <View className="h42 bold" style={{ lineHeight: rpxToPx(60) + 'px' }}>{historyDate(item, index)}</View>
+                                <View className="h24 bold" style={{ marginLeft: rpxToPx(6), marginTop: rpxToPx(11), lineHeight: rpxToPx(49) + 'px' }}>{historyMonth(item, index)}</View>
+                            </View>
+                            {/* <Text className="cell_date">{(item.date + '').substring(6, 9)}</Text> */}
                             <View style={{ display: 'flex', flex: 1 }}>
                                 <CoverList
                                     imgs={item.images}

+ 68 - 16
src/pages/account/Journal.tsx

@@ -12,6 +12,7 @@ import StickyDateList from "@/_health/components/sticky_date_list";
 import { MainColorType } from "@/context/themes/color";
 import ListFooter from "@/_health/components/list_footer";
 import TimeTitleDesc from "@/_health/components/time_title_desc";
+import { TimeFormatter } from "@/utils/time_format";
 
 let myScrollTop = 0
 export default function Journal() {
@@ -94,7 +95,7 @@ export default function Journal() {
             var layouts: any = []
             res.forEach((rect, index) => {
                 if (rect) {
-                    layouts[index] = rect.top+myScrollTop
+                    layouts[index] = rect.top + myScrollTop
                 }
             });
             setItemLayouts(layouts)
@@ -164,7 +165,7 @@ export default function Journal() {
                         return <TimeTitleDesc
                             key={index2 * 1000}
                             className="line1"
-                            style={{ width: array.length > 0 ? rpxToPx(370) : rpxToPx(532) }}
+                            style={{ width: array.length > 0 ? rpxToPx(350) : rpxToPx(512) }}
                             time={dayjs(item2.time.timestamp).format('HH:mm')}
                             title={getTitle(item2)}
                             desc={item2.moments && item2.moments.length > 0 ? item2.moments[0].description : ''}
@@ -178,32 +179,80 @@ export default function Journal() {
         </View>
     }
 
-    function historyMonth(index, preIndex) {
+    function historyYear(index) {
         var showDate = false;
-        var dateStr = ''
+        var dateStr2: any = ''
         if (index == 0) {
-            var currentDate = (journals[index].date + '').substring(0, 6)
-            var now = dayjs().format('YYYYMM')
+            var currentDate = global.language == 'en' ? dayjs(journals[index].publish_timestamp).format('YYYY') : dayjs(journals[index].publish_timestamp).format('YYYY年')
+            var now = global.language == 'en' ? dayjs().format('YYYY') : dayjs().format('YYYY年')
+
+            if (currentDate != now) {
+                showDate = true
+                dateStr2 = currentDate
+            }
 
-            showDate = true
-            dateStr = currentDate.substring(0, 4) + '年' + currentDate.substring(4, 6) + '月'
 
         }
         else {
-            var currentDate = (journals[index].date + '').substring(0, 6)
-            var now = (journals[index - 1].date + '').substring(0, 6)
+            var currentDate = global.language == 'en' ? dayjs(journals[index].publish_timestamp).format('YYYY') : dayjs(journals[index].publish_timestamp).format('YYYY年')
+            var now = global.language == 'en' ? dayjs().format('YYYY') : dayjs().format('YYYY年')
             if (currentDate != now) {
                 showDate = true
-                // dateStr = currentDate
-                dateStr = currentDate.substring(0, 4) + '年' + currentDate.substring(4, 6) + '月'
+                dateStr2 = currentDate
             }
         }
         if (showDate) {
-            return <View className="history_year_month h30 g01">{dateStr}</View>
+            return <View className="history_year_month h42 bold">{dateStr2}</View>
         }
         return <View />
     }
 
+    function historyDate(item, index) {
+        if (index == 0) {
+            if (global.language == 'zh' && TimeFormatter.isToday(item.publish_timestamp)) {
+                return '今天'
+            }
+            if (global.language == 'zh' && TimeFormatter.isYesterday(item.publish_timestamp)) {
+                return '昨天'
+            }
+            return dayjs(item.publish_timestamp).format('DD')
+        }
+        if (dayjs(item.publish_timestamp).format('MM-DD') ==
+            dayjs(journals[index - 1].publish_timestamp).format('MM-DD')) {
+            return ''
+        }
+        if (global.language == 'zh' && TimeFormatter.isToday(item.publish_timestamp)) {
+            return '今天'
+        }
+        if (global.language == 'zh' && TimeFormatter.isYesterday(item.publish_timestamp)) {
+            return '昨天'
+        }
+        return dayjs(item.publish_timestamp).format('DD')
+    }
+
+    function historyMonth(item, index) {
+        if (index == 0) {
+            if (global.language == 'zh' && TimeFormatter.isToday(item.publish_timestamp)) {
+                return ''
+            }
+            if (global.language == 'zh' && TimeFormatter.isYesterday(item.publish_timestamp)) {
+                return ''
+            }
+            return dayjs(item.publish_timestamp).format('MMM')
+        }
+        if (dayjs(item.publish_timestamp).format('MM-DD') ==
+            dayjs(journals[index - 1].publish_timestamp).format('MM-DD')) {
+            return ''
+        }
+        if (global.language == 'zh' && TimeFormatter.isToday(item.publish_timestamp)) {
+            return ''
+        }
+        if (global.language == 'zh' && TimeFormatter.isYesterday(item.publish_timestamp)) {
+            return ''
+        }
+        return dayjs(item.publish_timestamp).format('MMM')
+    }
+
     return <StickyDateList onRefresherRefresh={() => {
         setIsPulling(true)
         getJounalsData()
@@ -220,14 +269,17 @@ export default function Journal() {
                 journals.map((item, index) => {
                     return <View key={index}>
                         {
-                            historyMonth(index, index - 1)
+                            historyYear(index)
                         }
                         <View className="album_item" id={`history-${index}`} onClick={() => {
                             jumpPage('/pages/account/JournalDetail?detail=' + JSON.stringify(item))
                         }}>
 
-                            <Text className="cell_date">{(item.date + '').substring(6, 9)}</Text>
-                            <View style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
+                            <View className="cell_date" >
+                                <View className="h42 bold" style={{ lineHeight: rpxToPx(60) + 'px' }}>{historyDate(item, index)}</View>
+                                <View className="h24 bold" style={{ marginLeft: rpxToPx(6), marginTop: rpxToPx(11), lineHeight: rpxToPx(49) + 'px' }}>{historyMonth(item, index)}</View>
+                            </View>
+                            <View style={{ display: 'flex', flexDirection: 'column', flex: 1, paddingTop: rpxToPx(4) }}>
                                 {
                                     item.windows.map((window, i) => {
                                         return journalItem(window, i)

+ 34 - 3
src/pages/account/Setting.tsx

@@ -27,7 +27,7 @@ let hasCache = false;
 
 export default function Page() {
     const dispatch = useDispatch();
-    const { t } = useTranslation()
+    const { t, i18n } = useTranslation()
     const user = useSelector((state: any) => state.user);
     let showActionSheetWithOptions;
     if (process.env.TARO_ENV == 'rn') {
@@ -145,6 +145,19 @@ export default function Page() {
         }, 1500)
     }
 
+    function changeLanguage(){
+        if (global.language == 'en'){
+            global.language = 'zh'
+            Taro.setStorageSync('language','zh')
+            i18n.changeLanguage('zh')
+        }
+        else {
+            global.language = 'en'
+            Taro.setStorageSync('language','en')
+            i18n.changeLanguage('en')
+        }
+    }
+
     return <View style={{ color: '#fff', display: 'flex', flexDirection: 'column', flex: 1 }}>
         <View style={{ height: 20 }} />
         <Card>
@@ -155,11 +168,29 @@ export default function Page() {
                 height: rpxToPx(128),
                 boxSizing: 'border-box',
                 paddingLeft: rpxToPx(40),
-                paddingRight: rpxToPx(28)
+                paddingRight: rpxToPx(40),
+                position: 'relative'
 
             }}>
                 <Text className="h34" style={{ color: '#000' }}>{t('page.setting.version')}</Text>
                 <Text className="h30" style={{ color: MainColorType.g01 }}>{process.env.TARO_ENV == 'weapp' ? WX_VERSION : APP_VERSION}</Text>
+                <View className="border_footer_line" style={{left:rpxToPx(40)}}/>
+            </View>
+            <View 
+            onClick={changeLanguage}
+            style={{
+                display: 'flex', flexDirection: 'row',
+                justifyContent: 'space-between',
+                alignItems: 'center',
+                height: rpxToPx(128),
+                boxSizing: 'border-box',
+                paddingLeft: rpxToPx(40),
+                paddingRight: rpxToPx(40),
+                position: 'relative'
+                
+            }}>
+                <Text className="h34" style={{ color: '#000' }}>{t('health.language')}</Text>
+                <Text className="h30" style={{ color: MainColorType.g01 }}>{global.language=='en'?'English':'中文'}</Text>
             </View>
         </Card>
         {
@@ -178,7 +209,7 @@ export default function Page() {
                     />
                 </View>
 
-                <View style={{ height: rpxToPx(72),display:'flex' }}>
+                <View style={{ height: rpxToPx(72), display: 'flex' }}>
                     <NewButton
                         type={NewButtonType.link}
                         title={t('feature.common.modal.del')}

+ 3 - 0
src/services/http/request.ts

@@ -86,6 +86,9 @@ export async function request<T>(param: RequestParam): Promise<T> {
 
         header['X-Platform'] = Taro.getSystemInfoSync().platform == 'ios' ? 'IOS' : 'ANDROID'; //IOS ANDROID
         header['X-Lang'] = process.env.TARO_ENV == 'rn' ? global.language : 'zh' //zh en
+        if (process.env.TARO_ENV == 'weapp'){
+            header['X-Lang'] = global.language??'zh'
+        }
         header['X-Client-Type'] = process.env.TARO_ENV == 'rn' ? 'APP' : 'WX_APP' //WX_APP APP
         header['X-Client-Version'] = process.env.TARO_ENV == 'rn' ? kIsAndroid ? ANDROID_VERSION : APP_VERSION : WX_VERSION
         header['X-Day'] = dayjs().format('YYYYMMDD')

+ 14 - 0
src/utils/time_format.ts

@@ -832,5 +832,19 @@ export class TimeFormatter {
     }
   }
 
+  static isToday = (timestamp:number) =>{
+    if (dayjs().format('YYYY-MM-DD')==dayjs(timestamp).format('YYYY-MM-DD')){
+      return true
+    }
+    return false
+  }
+
+  static isYesterday = (timestamp:number)=>{
+    if (dayjs().format('YYYY-MM-DD')==dayjs(timestamp+24*3600*1000).format('YYYY-MM-DD')){
+      return true
+    }
+    return false
+  }
+
 }