Leon hace 1 año
padre
commit
575d5dc483

+ 20 - 2
src/_health/pages/add_moment.tsx

@@ -145,10 +145,27 @@ export default function AddMoment() {
             edit()
             return
         }
+        var str = selDate + ' ' + time + ':' + dayjs(enterTimestmap).format('ss')
+        console.log('系统时间',new Date())
+        console.log('提交日期格式',str)
+        console.log('转成日期',new Date(str))
 
-        var date = new Date(selDate + ' ' + time + ':' + dayjs(enterTimestmap).format('ss'))
+        var date = new Date(selDate + 'T' + time + ':' + dayjs(enterTimestmap).format('ss'))
         date.setMilliseconds(new Date(enterTimestmap).getMilliseconds())
 
+        console.log('转成日期为时间戳',date.getTime())
+
+        if (true){
+            var dt2 = new Date()
+            dt2.setFullYear(parseInt(selDate.substring(0,4)))
+            dt2.setMonth(parseInt(selDate.substring(5,7))-1)
+            dt2.setDate(parseInt(selDate.substring(8,10)))
+            dt2.setHours(parseInt(time.substring(0,2)))
+            dt2.setMinutes(parseInt(time.substring(3,5)))
+            console.log(dt2)
+            date = dt2
+        }
+
         var params: any = {
             schedule_id: schedule_id,
             title: title,
@@ -188,6 +205,7 @@ export default function AddMoment() {
             set_time: global.set_time ? global.set_time : new Date().getTime(),
             confirm_time: new Date().getTime()
         }
+        console.log('打卡提交数据',params)
         if (posting) return
         setPosting(true)
         createMoment(params).then(res => {
@@ -219,7 +237,7 @@ export default function AddMoment() {
     }
 
     function edit() {
-        var date = new Date(selDate + ' ' + time + ':' + dayjs(enterTimestmap).format('ss'))
+        var date = new Date(selDate + 'T' + time + ':' + dayjs(enterTimestmap).format('ss'))
 
         var params: any = {
             schedule_id: schedule_id,

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

@@ -252,7 +252,6 @@ export default function LogTime() {
                     confirm_time: enterTime
                 }
             })
-            debugger
             setExpandIndex(0)
         }
         else {
@@ -282,7 +281,6 @@ export default function LogTime() {
                         title: i == 1 ? sleep.timeline[0].title : sleep.timeline[1].title
                     });
                 }
-                debugger
                 list.push({
                     event_id: timeline.event_id,
                     schedule_id: timeline.schedule_id,
@@ -364,7 +362,6 @@ export default function LogTime() {
             list[0].time = ''
             list[0].date = ''
         }
-        debugger
         setArray(list)
 
         setLoaded(true)
@@ -401,7 +398,6 @@ export default function LogTime() {
 
         var time = obj.time
         if (tempObj && tempObj.real && dayjs(tempObj.real.timestamp).format('YYYY-MM-DDTHH:mm') == obj.date + 'T' + time) {
-            debugger
             return tempObj.real.timestamp
         }
 
@@ -812,7 +808,6 @@ export default function LogTime() {
         var time = array[index].time
         var min = enterTime
         var max = new Date().getTime()
-        debugger
         if (iFast) {
             var timeline = index == 0 ? fast.timeline[0] : fast.timeline[1]
             if (!isFastWithSleep) {
@@ -854,6 +849,9 @@ export default function LogTime() {
         }
         else {
             var timeline = index == 1 ? sleep.timeline[0] : sleep.timeline[1]
+            if (isSingle){
+                timeline = sleep.timeline[0]
+            }
             if (status == 'WFS') {
                 min = enterTime - 24 * 3600 * 1000
                 max = new Date().getTime()
@@ -974,20 +972,6 @@ export default function LogTime() {
                 list[index].extra.confirm_time = new Date().getTime()
                 setArray(list)
             }}
-        // dateChange={(e) => {
-        //     debugger
-        //     var list = JSON.parse(JSON.stringify(array))
-        //     list[index].date = e
-        //     list[index].extra.confirm_time = new Date().getTime()
-        //     setArray(list)
-        // }}
-        // timeChange={(e) => {
-        //     debugger
-        //     var list = JSON.parse(JSON.stringify(array))
-        //     list[index].time = e
-        //     list[index].extra.confirm_time = new Date().getTime()
-        //     setArray(list)
-        // }}
         />
     }
 

+ 24 - 7
src/_health/pages/post_result.tsx

@@ -57,13 +57,27 @@ export default function PostResult() {
                 }
             }
 
-            var shareDate =  global.language == 'en' ? 'Today\'s' : '今日'
+            var timestamp = data.time.timestamp
+            var shareDate = ''
+            if (TimeFormatter.isToday(timestamp)) {
+                shareDate = global.language == 'en' ? 'Today\'s' : '今日'
+            }
+            else if (TimeFormatter.isYesterday(timestamp)) {
+                shareDate = global.language == 'en' ? 'Yesterday\'s' : '昨日'
+            }
+            else if (TimeFormatter.isTimestampInThisWeek(timestamp)) {
+                shareDate = global.language == 'en' ? (dayjs(timestamp).format('dddd') + '\'s') : dayjs(timestamp).format('dddd')
+            }
+            else {
+                shareDate = global.language == 'en' ? dayjs(timestamp).format('MMMM D') : dayjs(timestamp).format('MMMD日')
+            }
+
 
             var defaultImg = SHARE_COVER_URL + 'my_fast.jpg'
 
             switch (data.window) {
                 case 'FAST':
-                    title = t('health.share_check_in', { date: shareDate, type: t('health.fasting') })
+                    title = t('health.share_check_in', { date: shareDate, type: data.title })
                     defaultImg = SHARE_COVER_URL + 'my_fast.jpg'
                     break;
                 case 'EAT':
@@ -75,7 +89,7 @@ export default function PostResult() {
                     defaultImg = SHARE_COVER_URL + 'my_activity.jpg'
                     break;
                 case 'SLEEP':
-                    title = t('health.share_check_in', { date: shareDate, type: t('health.sleep') })
+                    title = t('health.share_check_in', { date: shareDate, type: data.title })
                     defaultImg = SHARE_COVER_URL + 'my_sleep.jpg'
                     break;
 
@@ -83,11 +97,11 @@ export default function PostResult() {
 
             var share_window_id = window_id ?? ''
             if (fast_type == 'LF') {
-                title = t('health.share_check_in', { date: shareDate, type: t('health.long_fast') })
+                title = t('health.share_check_in', { date: shareDate, type: data.title })
                 defaultImg = SHARE_COVER_URL + 'my_long_fast.jpg'
             }
             else if (op_page == 'FAST_WITH_SLEEP') {
-                title = t('health.share_check_in', { date: shareDate, type: t('health.fasting_with_sleep') })
+                title = t('health.share_check_in', { date: shareDate, type: data.title })
                 defaultImg = SHARE_COVER_URL + 'my_fast_with_sleep.jpg'
             }
             else if (op_page == 'HOME_EAT' || op_page == 'HOME_ACTIVE') {
@@ -103,10 +117,13 @@ export default function PostResult() {
             if (share_window_id.length > 0) {
                 sharePath += `&window_id=${share_window_id}`
             }
-
+            var nickname = user.nickname
+            if (nickname.length > 10) {
+                nickname.substring(0, 10) + '...'
+            }
 
             return {
-                title: title,
+                title: nickname + ': ' + title,
                 path: sharePath,
                 imageUrl: imageUrl
             }

+ 55 - 20
src/_health/pages/timeline_detail.tsx

@@ -30,11 +30,11 @@ import SingleImage from "../components/single_img";
 import { setFirstActiveId, setFirstEatId, setShowActionTip } from "@/store/health";
 import FastSleepPopupContent from "../components/fast_sleep_popup_content";
 import { StatusType } from "../base/status_indicator";
+import 'dayjs/locale/zh-cn';
+import 'dayjs/locale/en';
 
-let timestamp = 0;
 let useRoute;
 let useNavigation;
-let scenario = '';
 if (process.env.TARO_ENV == 'rn') {
     useRoute = require("@react-navigation/native").useRoute
     useNavigation = require("@react-navigation/native").useNavigation
@@ -85,7 +85,9 @@ export default function TimelineDetail() {
     if (process.env.TARO_ENV == 'weapp') {
 
         useShareAppMessage((e) => {
-            var { timestamp } = detail.publish
+            console.log(detail)
+            var timestamp = detail.events ? detail.events[0].time.timestamp : detail.moments[0].time.timestamp
+            console.log(timestamp)
             var shareDate = ''
             if (TimeFormatter.isToday(timestamp)) {
                 shareDate = global.language == 'en' ? 'Today\'s' : '今日'
@@ -97,7 +99,7 @@ export default function TimelineDetail() {
                 shareDate = global.language == 'en' ? (dayjs(timestamp).format('dddd') + '\'s') : dayjs(timestamp).format('dddd')
             }
             else {
-                shareDate = global.language == 'en' ? dayjs(timestamp).format('MMMM D') : dayjs(timestamp).format('MMMMD日')
+                shareDate = global.language == 'en' ? dayjs(timestamp).format('MMMM D') : dayjs(timestamp).format('MMMD日')
             }
 
             var title = ''
@@ -111,6 +113,7 @@ export default function TimelineDetail() {
                 defaultImg = SHARE_COVER_URL + 'my_long_fast.jpg'
             }
             else {
+
                 if (detail.events && detail.events.length > 0)
                     switch (detail.events[0].window) {
                         case 'FAST':
@@ -181,8 +184,14 @@ export default function TimelineDetail() {
                 strWindowId = ''
             }
             sharePath += `&window_id=${strWindowId}`
+            var nickname = detail.share_user ? detail.share_user.nickname : user.nickname
+            if (nickname.length > 10) {
+                nickname.substring(0, 10) + '...'
+            }
+            console.log('share_title', title)
+            console.log('sharePath', imageUrl)
             return {
-                title: title,
+                title: nickname + ': ' + title,
                 path: sharePath,
                 imageUrl: imageUrl
             }
@@ -199,16 +208,23 @@ export default function TimelineDetail() {
             backgroundColorBottom: '#ffffff'
         })
 
-        var title = ''
-        if (router.params.timestamp) {
-            setTitle(router.params.timestamp)
-        }
-        Taro.setNavigationBarTitle({
-            title: title
-        })
+        // var title = ''
+        // if (router.params.timestamp) {
+        //     setTimeout(() => {
+        //         setTitle(router.params.timestamp)
+        //     }, 100)
+
+        // }
+        // Taro.setNavigationBarTitle({
+        //     title: title
+        // })
     }, [showPop])
 
     function setTitle(timestamp) {
+        dayjs.locale(global.language == 'en' ? 'en' : 'zh-cn');
+        require('moment/locale/en-gb')
+        require('moment/locale/zh-cn')
+
         var title = ''
         var t = parseInt(timestamp + '')
         if (TimeFormatter.isToday(t)) {
@@ -218,18 +234,29 @@ export default function TimelineDetail() {
             title = TimeFormatter.getYesterdayUnit()
         }
         else {
-            if (global.language == 'en') {
-                title = dayjs(t).format('dddd, MMM D')
+            console.log(global.language)
+            if (global.language && global.language == 'zh') {
+                title = dayjs(t).format('MMMD日 dddd')
+
             }
             else {
-                title = dayjs(t).format('MMMD日 dddd')
+                title = dayjs(t).format('dddd, MMM D')
             }
         }
         Taro.setNavigationBarTitle({
-            title: title
+            title: title//global.language
         })
     }
 
+    useEffect(() => {
+        if (router.params.timestamp) {
+
+            setTitle(router.params.timestamp)
+
+        }
+
+    }, [global.language])
+
     useEffect(() => {
         Taro.onKeyboardHeightChange(res => {
             setBottom(res.height > 0 ? res.height : 20)
@@ -402,7 +429,7 @@ export default function TimelineDetail() {
             })
             return
         }
-        var dt = new Date(selDate + ' ' + time + ':' + dayjs(enterTimestmap).format('ss'))
+        var dt = new Date(selDate + 'T' + time + ':' + dayjs(enterTimestmap).format('ss'))
         dt.setMilliseconds(new Date(enterTimestmap).getMilliseconds())
         var params: any = {
             schedule_id: schedule_id,
@@ -674,6 +701,14 @@ export default function TimelineDetail() {
             url: '/pages/clock/Clock'
         })
     }
+
+    function postBtnColor() {
+        if (detail.window)
+            return getThemeColor(detail.window)
+        if (detail.events){
+            return getThemeColor(detail.events[0].window)
+        }
+    }
     return <View style={{ display: 'flex', flex: 1, flexDirection: 'column', backgroundColor: '#fff', height: '101vh' }}>
         {
             !showEmpty && <View className="detail_header">
@@ -861,8 +896,8 @@ export default function TimelineDetail() {
         <Text style={{ opacity: 0 }}>{count}</Text>
         <ListFooter />
         {
-            !window_id && ((health.mode != 'ACTIVE' && health.mode != 'EAT') || fast_type == 'LF') && <View className="add_note"><NewButton type={NewButtonType.link} title={t('health.add_note')} onClick={() => {
-                timestamp = new Date().getTime()
+            !uid && detail.windows && detail.windows[0].status != 'DONE' && ((health.mode != 'ACTIVE' && health.mode != 'EAT') || fast_type == 'LF') && <View className="add_note"><NewButton type={NewButtonType.link} title={t('health.add_note')} onClick={() => {
+                // timestamp = new Date().getTime()
                 setShowPop(true)
 
             }} /></View>
@@ -922,7 +957,7 @@ export default function TimelineDetail() {
 
 
                     <View style={{ flex: 1 }} />
-                    <View className="btn" style={{ backgroundColor: btnDisable ? '#b2b2b2' : getThemeColor(detail.window) }} onClick={tapPost}>{t('health.post')}</View>
+                    <View className="btn" style={{ backgroundColor: btnDisable ? '#b2b2b2' : postBtnColor() }} onClick={tapPost}>{t('health.post')}</View>
                 </View>
 
                 <View style={{ height: bottom, flexShrink: 0 }} />

+ 1 - 2
src/app.tsx

@@ -34,8 +34,6 @@ if (process.env.TARO_ENV == 'rn') {
 
 const App: React.FC<PropsWithChildren> = ({ children }) => {
 
-  // const dispatch = useDispatch();
-  console.log('app start')
 
   global.hideRingIcon = true
 
@@ -180,6 +178,7 @@ const App: React.FC<PropsWithChildren> = ({ children }) => {
   }
 
   function loadWXCache() {
+
     //   var showDayRing = Taro.getStorageSync('showDayRing') || false;
     //   var showNightRing = Taro.getStorageSync('showNightRing') || false;
     //   dispatch(showDay(showDayRing))

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

@@ -207,7 +207,7 @@ export default function Journal() {
         else {
             setShowDate(false)
             Taro.setNavigationBarTitle({
-                title: ''
+                title: pageTitle()//''
             })
             Taro.setNavigationBarColor({
                 backgroundColor: '#ffffff',

+ 7 - 3
src/pages/account/JournalDetail.tsx

@@ -95,7 +95,7 @@ export default function JournalDetail() {
                 shareDate = global.language == 'en'?(dayjs(timestamp).format('dddd')+'\'s'):dayjs(timestamp).format('dddd')
             }
             else {
-                shareDate = global.language == 'en'?dayjs(timestamp).format('MMMM D'):dayjs(timestamp).format('MMMMD日')
+                shareDate = global.language == 'en'?dayjs(timestamp).format('MMMM D'):dayjs(timestamp).format('MMMD日')
             }
             var title = t('health.share_all_journal',{date:shareDate})
             var defaultImg = SHARE_COVER_URL + 'my_journal.jpg'
@@ -108,12 +108,16 @@ export default function JournalDetail() {
                 defaultImg = SHARE_COVER_URL + 'my_activity_journal.jpg'
             }
 
-            debugger
             const uid = router.params.uid
 
             var imageUrl = imgs.length > 0 ? imgs[0] : defaultImg
+            var nickname = shareUser?shareUser.nickname:user.nickname
+            if (nickname.length>10){
+                nickname.substring(0,10)+'...'
+            }
+
             return {
-                title: title,
+                title: nickname+': '+title,
                 path: `pages/account/JournalDetail?date=${date}&uid=${uid ?? user.id}&window=${router.params.window}`,
                 imageUrl: imageUrl
                 // imageUrl:'/src/assets/_health/share_01.jpg'