leon 1 tahun lalu
induk
melakukan
68bc271337

+ 1 - 1
src/_health/base/new_modal.tsx

@@ -142,7 +142,7 @@ export default function NewModal(props: {
                     <NewButton
                         onClick={dismiss}
                         type={NewButtonType.img}>
-                        <IconClose color={MainColorType.g02} width={rpxToPx(40)} height={rpxToPx(40)} />
+                        <IconClose color={MainColorType.g03} width={rpxToPx(40)} height={rpxToPx(40)} />
                     </NewButton>
                 </View>
             </View>

+ 17 - 6
src/_health/components/sticky_date_list.tsx

@@ -10,14 +10,15 @@ export default function StickyDateList(props: {
     onScroll: any,
     showDate: boolean,
     date: string,
-    disable?:boolean,
+    disable?: boolean,
+    scrollUpper?: any
 }) {
 
-    function headerDate(){
-        if (global.language=='en'){
-            return props.date.substring(0,4)
+    function headerDate() {
+        if (global.language == 'en') {
+            return props.date.substring(0, 4)
         }
-        return props.date.substring(0,5)
+        return props.date.substring(0, 5)
     }
 
     return <View style={{ position: 'relative' }}>
@@ -37,18 +38,28 @@ export default function StickyDateList(props: {
             opacity: props.showDate ? 1 : 0,
             color: MainColorType.g01
         }}>{headerDate()}
-            <View className="border_header_line"/>
+            <View className="border_header_line" />
             <View className="border_footer_line" />
         </View>
         <ScrollView style='height:100vh'
             enableBackToTop
             scrollY={!props.disable}
             refresherEnabled
+            upperThreshold={30}
+            onScrollToUpper={props.scrollUpper}
             refresherBackground={MainColorType.g05}
             onRefresherRefresh={props.onRefresherRefresh}
             refresherTriggered={props.isPulling}
             onScroll={props.onScroll}
             onScrollToLower={props.loadMore}
+            enhanced
+            onDragEnd={(e)=>{
+                console.log('end drag',e.detail.scrollTop)
+                props.onScroll(e)
+            }}
+            onRefresherPulling={(e)=>{
+                console.log('pulling page')
+            }}
         >
             {
                 props.header

+ 9 - 8
src/_health/pages/log_time.tsx

@@ -45,8 +45,7 @@ export default function LogTime() {
     else {
         router = useRouter()
     }
-    const [enterTime, setEnterTime] = useState(new Date().getTime())
-    const [enter_timestamp] = useState(new Date().getTime())
+    const [enterTime] = useState(new Date().getTime())
 
     const isSingle = router.params.single == '1'
     const isFast = router.params.window == 'FAST'
@@ -341,8 +340,8 @@ export default function LogTime() {
         // var hour = parseInt(time.split(':')[0])
         // var minute = parseInt(time.split(':')[1])
         // var date = obj.date
-        var now = new Date(obj.date + 'T' + time + ':' + dayjs(enter_timestamp).format('ss'))
-        now.setMilliseconds(new Date(enter_timestamp).getMilliseconds())
+        var now = new Date(obj.date + 'T' + time + ':' + dayjs(enterTime).format('ss'))
+        now.setMilliseconds(new Date(enterTime).getMilliseconds())
         // now.setHours(hour)
         // now.setMinutes(minute)
         // now.setSeconds(0)
@@ -539,6 +538,8 @@ export default function LogTime() {
 
         // return
 
+        params.requestId = enterTime
+
         if (posting) return
         setPosting(true)
         clockTimes(params).then(res => {
@@ -696,7 +697,7 @@ export default function LogTime() {
 
         var date = array[index].date//array[index].today ? "Today" : "Yesterday"
         var time = array[index].time
-        var min = enter_timestamp
+        var min = enterTime
         var max = new Date().getTime()
         if (iFast) {
             var timeline = index == 0 ? fast.timeline[0] : fast.timeline[1]
@@ -705,7 +706,7 @@ export default function LogTime() {
                 var fastScenario = getScenario(health.windows, 'FAST')
                 timeline = iStart ? fastScenario.timeline[0] : fastScenario.timeline[1]
                 if (fastScenario.status == 'WFS') {
-                    min = enter_timestamp - 24 * 3600 * 1000
+                    min = enterTime - 24 * 3600 * 1000
                     max = new Date().getTime()
                 }
                 else {
@@ -716,7 +717,7 @@ export default function LogTime() {
             else {
                 //fast_sleep 进入时,除了wfs情况前端处理,其他case后端处理
                 if (status == 'WFS') {
-                    min = enter_timestamp - 24 * 3600 * 1000
+                    min = enterTime - 24 * 3600 * 1000
                     max = new Date().getTime()
                 }
                 else if (status == 'OG2_MISALIGNED') {
@@ -740,7 +741,7 @@ export default function LogTime() {
         else {
             var timeline = index == 1 ? sleep.timeline[0] : sleep.timeline[1]
             if (status == 'WFS') {
-                min = enter_timestamp - 24 * 3600 * 1000
+                min = enterTime - 24 * 3600 * 1000
                 max = new Date().getTime()
             }
             else if (status == 'OG2_MISALIGNED') {

+ 4 - 1
src/_health/pages/long_fast.tsx

@@ -37,7 +37,7 @@ export default function LongFast() {
     const [editDuration, setEditDuration] = useState(false)
     const [showPicker, setShowPicker] = useState(false)
     const [duration, setDuration] = useState(0)
-
+    const [enterTime] = useState(new Date().getTime())
     const [time, setTime] = useState(dayjs().format('HH:mm'))
     const { t } = useTranslation()
     const [isPulling, setIsPulling] = useState(false)
@@ -163,6 +163,9 @@ export default function LongFast() {
             params.save_confirm = warn_code
         }
 
+        params.requestId = enterTime
+
+
         clockTimes(params).then(res => {
             if ((res as any).warn_code == 'SAVE_AS_IF') {
                 showAlert({

+ 2 - 0
src/_health/pages/long_fast_setting.tsx

@@ -46,8 +46,10 @@ export default function LongFastSetting() {
         if (!isToday) {
             now = now - 24 * 3600 * 1000
         }
+        // params.requestId = enterTime
 
         clockTimes({
+            requestId:enterTimestamp,
             check_items: [{
                 schedule_id: health.long_fast.timeline[0].schedule_id,
                 date: dayjs(now).format('YYYYMMDD'),

+ 1 - 0
src/features/health/MainConsole.scss

@@ -238,6 +238,7 @@
   padding-left: 40px;
   width: 750px;
   box-sizing: border-box;
+  position: relative;
 }
 
 

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

@@ -476,7 +476,7 @@ export default function MainConsole(props: { type: WindowType }) {
         if (!scenario.extra.choose_location) {
             return t('health.more_actions')
         }
-        return `${getCity()} | ${Math.abs(parseInt(scenario.extra.lat))}°${parseInt(scenario.extra.lat) < 0 ? 'S' : 'N'} ${Math.abs(parseInt(scenario.extra.lng))}°${parseInt(scenario.extra.lng) < 0 ? 'W' : 'E'}`
+        return `${getCity()}${Math.abs(parseInt(scenario.extra.lat))}°${parseInt(scenario.extra.lat) < 0 ? 'S' : 'N'} ${Math.abs(parseInt(scenario.extra.lng))}°${parseInt(scenario.extra.lng) < 0 ? 'W' : 'E'}`
     }
 
     function getCity() {
@@ -493,13 +493,15 @@ export default function MainConsole(props: { type: WindowType }) {
                 city = scenario.extra.address.country
             }
             else {
-                city = t('feature.track_time_duration.third_ring.unknown')
+                return ''
+                // city = t('feature.track_time_duration.third_ring.unknown')
             }
         }
         else {
-            city = t('feature.track_time_duration.third_ring.unknown')
+            return ''
+            // city = t('feature.track_time_duration.third_ring.unknown')
         }
-        return city
+        return city +' | '
     }
 
     function tapActionSheet(index) {
@@ -973,7 +975,7 @@ export default function MainConsole(props: { type: WindowType }) {
                         break
                 }
             }}>
-                <IconClose color={MainColorType.g01} width={rpxToPx(32)} height={rpxToPx(32)} />
+                <IconClose color={MainColorType.g03} width={rpxToPx(32)} height={rpxToPx(32)} />
             </NewButton>
         </View>
         // var strTitle = ''
@@ -1058,7 +1060,7 @@ export default function MainConsole(props: { type: WindowType }) {
 
         </View>
         {
-            user.isLogin && !hideGuideTip && !health.finish_setup && <View className="guide_tip h26" onClick={() => {
+            user.isLogin && (health.mode !='DAY' && health.mode !='NIGHT') && !hideGuideTip && !health.finish_setup && <View className="guide_tip h26" onClick={() => {
                 tapGuide();
                 setHideGuideTip(true)
             }}>{t('health.console_guide_tip')}
@@ -1071,7 +1073,7 @@ export default function MainConsole(props: { type: WindowType }) {
                 }} onClick={() => {
                     setHideGuideTip(true)
                 }}>
-                    <IconClose color={MainColorType.g01} width={rpxToPx(32)} height={rpxToPx(32)} />
+                    <IconClose color={MainColorType.g03} width={rpxToPx(32)} height={rpxToPx(32)} />
                 </NewButton>
 
             </View>

+ 3 - 2
src/features/health/MainHistory.tsx

@@ -672,7 +672,7 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
 
 
         return <View className="mark_done_tip" style={{
-            backgroundColor: getThemeColor(health.mode) + '1A'
+            backgroundColor: '#fff'//getThemeColor(health.mode) + '1A'
         }}>
             <View style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
                 {
@@ -699,8 +699,9 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
                         break
                 }
             }}>
-                <IconClose color={MainColorType.g01} width={rpxToPx(32)} height={rpxToPx(32)} />
+                <IconClose color={MainColorType.g03} width={rpxToPx(32)} height={rpxToPx(32)} />
             </NewButton>
+            <View className="border_footer_line" />
         </View>
     }
 

+ 2 - 23
src/features/health/MainHistory2.tsx

@@ -688,36 +688,15 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
         {/* {
             newJournalTip()
         } */}
-        {
+        {/* {
             (health.mode == 'EAT' || health.mode == 'ACTIVE') && <RightArrowRow title={health.mode == 'ACTIVE' ? t('health.title_active_journal') : t('health.title_food_journal')}
-                // showBadge={(health.mode == 'EAT' && health.eat_journal_tip) ||
-                //     (health.mode == 'ACTIVE' && health.active_journal_tip)}
                 onClick={() => {
-                    // if ((health.mode == 'EAT' && health.eat_journal_tip) ||
-                    //     (health.mode == 'ACTIVE' && health.active_journal_tip)) {
-                    //     getLatestJournal(false, {
-                    //         id: health.mode == 'EAT' ? global.eatTipId : global.activeTipId,
-                    //         user_confirmed: true
-                    //     }).then(res => {
-
-                    //     })
-                    // }
-
-
-                    // setTimeout(() => {
-                    //     if (health.mode == 'EAT') {
-                    //         dispatch(setEatTip(false))
-                    //     }
-                    //     else {
-                    //         dispatch(setActiveTip(false))
-                    //     }
-                    // }, 1000)
 
                     var showBadge = (health.mode == 'EAT' && health.eat_journal_tip) ||
                         (health.mode == 'ACTIVE' && health.active_journal_tip)
                     jumpPage('/pages/account/Journal?type=' + health.mode + `&show_tip=${showTipF() && false ? '1' : '0'}&show_badge=${showBadge ? 1 : 0}`)
                 }} />
-        }
+        } */}
         {
             list.length == 0 && <NoRecord />
         }

+ 26 - 5
src/pages/account/Journal.tsx

@@ -69,6 +69,10 @@ export default function Journal() {
         getJounalsData(1)
     }, [window])
 
+    useEffect(()=>{
+        console.log('last show status',showDate)
+    },[showDate])
+
     useEffect(() => {
         if (journals.length > 0) {
             setTimeout(() => {
@@ -163,22 +167,32 @@ export default function Journal() {
 
         if (itemLayouts.length > 0) {
             var i = -1
-            var date = ''
+            var dt = ''
             journals.forEach((item, index) => {
                 if (top >= itemLayouts[index] - 50) {
                     i = index
                     var currentDate = (journals[index].date + '').substring(0, 6)
-                    date = currentDate.substring(0, 4) + '年' + currentDate.substring(4, 6) + '月'
+                    dt = currentDate.substring(0, 4) + '年' + currentDate.substring(4, 6) + '月'
                 }
             })
 
             setShowDate(i != -1)
-            setDate(date)
+            setDate(dt)
         }
         else {
             setShowDate(false)
             setDate('')
         }
+
+        if (itemLayouts.length > 0 && itemLayouts[0] > top) {
+            setShowDate(false)
+            setDate('')
+            console.log(itemLayouts[0], showDate, date, top)
+        }
+        else {
+            console.log(itemLayouts[0], showDate, date, top)
+        }
+
     }
 
     function getTitle(item) {
@@ -490,7 +504,7 @@ export default function Journal() {
                     global.hideActiveArchiveTip = true
                 }
             }}>
-                <IconClose color={MainColorType.g01} width={rpxToPx(32)} height={rpxToPx(32)} />
+                <IconClose color={MainColorType.g03} width={rpxToPx(32)} height={rpxToPx(32)} />
             </NewButton>
         </View>
     }
@@ -503,6 +517,13 @@ export default function Journal() {
     }} isPulling={isPulling}
         onScroll={onScroll}
         showDate={showDate}
+        scrollUpper={
+            () => {
+                console.log('9527')
+                setDate('')
+                setShowDate(false)
+            }
+        }
         date={date}
         loadMore={() => {
             more()
@@ -576,7 +597,7 @@ export default function Journal() {
                                         }} />
                                     } */}
                                 </View>
-                                <View style={{ display: 'flex', flexDirection: 'column', flex: 1, width:rpxToPx(552), }}>
+                                <View style={{ display: 'flex', flexDirection: 'column', flex: 1, width: rpxToPx(552), }}>
                                     {/* {
                                     item.windows.map((window, i) => {
                                         return journalItem(window, i)

+ 4 - 3
src/pages/clock/Clock.tsx

@@ -200,11 +200,12 @@ export default function Clock() {
                 city = scenario.extra.address.country
             }
             else {
-                city = t('feature.track_time_duration.third_ring.unknown')
+                city = `${Math.abs(parseInt(scenario.extra.lat))}°${parseInt(scenario.extra.lat) < 0 ? 'S' : 'N'} ${Math.abs(parseInt(scenario.extra.lng))}°${parseInt(scenario.extra.lng) < 0 ? 'W' : 'E'}`
+                // city = t('feature.track_time_duration.third_ring.unknown')
             }
         }
         else {
-            city = t('feature.track_time_duration.third_ring.unknown')
+            city = `${Math.abs(parseInt(scenario.extra.lat))}°${parseInt(scenario.extra.lat) < 0 ? 'S' : 'N'} ${Math.abs(parseInt(scenario.extra.lng))}°${parseInt(scenario.extra.lng) < 0 ? 'W' : 'E'}`//t('feature.track_time_duration.third_ring.unknown')
         }
         return city
     }
@@ -212,7 +213,7 @@ export default function Clock() {
     function locationIcon() {
         if (!health.windows || !user.isLogin) return null
         var scenario = getScenario(health.windows, health.mode)
-        if ((health.mode == 'DAY' || health.mode == 'NIGHT') && scenario.extra.address) {
+        if ((health.mode == 'DAY' || health.mode == 'NIGHT') && scenario.extra.choose_location) {
             return <View className="navi-streak"
                 onClick={() => {
                     global.chooseLocation()

+ 1 - 1
src/pages/clock/ClockNew.tsx

@@ -382,7 +382,7 @@ export default function ClockNew(props: { children: any, onScroll: any }) {
                         }} onClick={() => {
                             setReminderAdd(false)
                         }}>
-                            <IconClose color={MainColorType.g01} width={rpxToPx(32)} height={rpxToPx(32)} />
+                            <IconClose color={MainColorType.g03} width={rpxToPx(32)} height={rpxToPx(32)} />
                         </NewButton>
 
                     </View>

+ 1 - 1
src/pages/discover/discover.tsx

@@ -67,7 +67,7 @@ export default function Discover() {
 
     return <View>
         <View >
-            <View className="main_column_space" />
+            {/* <View className="main_column_space" /> */}
             <IconTitleCell
                 onClick={() => {
                     if (!user.isLogin) {

+ 4 - 4
src/services/http/request.ts

@@ -61,7 +61,6 @@ export async function request<T>(param: RequestParam): Promise<T> {
 
     function performRequest(resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) {
         const { url, method, data } = param;
-        console.log(url)
         var requestTask: any = null;
         let header: any = {};
         const token = global.token ? global.token : ''; //await getStorage('token')
@@ -71,7 +70,7 @@ export async function request<T>(param: RequestParam): Promise<T> {
         // var timeZoneLocation = Intl.DateTimeFormat().resolvedOptions().timeZone
 
         header['content-type'] = 'application/json'
-        header['X-Project'] = process.env.TARO_ENV == 'rn' && kIsAndroid?'TIME':'FAST'
+        header['X-Project'] = process.env.TARO_ENV == 'rn' && kIsAndroid ? 'TIME' : 'FAST'
 
         header['X-Timezone'] = encodeURIComponent(JSON.stringify({
             id: getTimezoneId(),
@@ -79,12 +78,13 @@ export async function request<T>(param: RequestParam): Promise<T> {
             gmt: timeZoneFormatted
         }))
 
+        header['X-Request-Id'] = param.data && param.data.requestId ? param.data.requestId : new Date().getTime()
 
 
         header['X-Platform'] = Taro.getDeviceInfo().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'
+        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

+ 12 - 8
src/utils/time_format.ts

@@ -391,16 +391,16 @@ export class TimeFormatter {
   }
 
   //计算时间间隔
-  static calculateTimeDifference(startTimestamp: number, endTimestamp: number, showDays?: boolean,ignoreSeconds?:boolean): string {
-    if (ignoreSeconds){
+  static calculateTimeDifference(startTimestamp: number, endTimestamp: number, showDays?: boolean, ignoreSeconds?: boolean): string {
+    if (ignoreSeconds) {
       var date1 = new Date(startTimestamp)
       var date2 = new Date(endTimestamp)
-      date1.setSeconds(0,0)
-      date2.setSeconds(0,0)
+      date1.setSeconds(0, 0)
+      date2.setSeconds(0, 0)
       startTimestamp = date1.getTime()
       endTimestamp = date2.getTime()
     }
-    
+
     const diff = Math.abs(endTimestamp - startTimestamp);
     // 计算小时、分钟和秒数
     let hours = Math.floor(diff / (1000 * 60 * 60));
@@ -792,8 +792,12 @@ export class TimeFormatter {
       return '明天 ' + strTime;
 
     } else {
-      if (global.language == 'en') return dt.format('MMM DD ') + strTime;
-      return dt.format('MMMDD日 ') + strTime;
+      if (dt.format('YYYY') != dayjs().format('YYYY')) {
+        if (global.language == 'en') return dt.format('MMM D, YYYY ') + strTime;
+        return dt.format('YYYY年MMMD日 ') + strTime;
+      }
+      if (global.language == 'en') return dt.format('MMM D ') + strTime;
+      return dt.format('MMMD日 ') + strTime;
 
     }
   }
@@ -864,7 +868,7 @@ export class TimeFormatter {
     const endDate = date2.startOf('day');
     const days = endDate.diff(startDate, 'day')
     if (days > 0)
-      return '+' + days+(global.language=='en'?'d':'天');
+      return '+' + days + (global.language == 'en' ? 'd' : '天');
     return ''
   }