leon 1 anno fa
parent
commit
ae1c6f7767

+ 21 - 4
src/_health/base/new_button.tsx

@@ -4,6 +4,7 @@ import { rpxToPx, vibrate } from '@/utils/tools';
 import { useState } from 'react';
 import { IconMore } from '@/components/basic/Icons';
 import { MainColorType } from '@/context/themes/color';
+import Taro from '@tarojs/taro';
 
 export enum NewButtonType {
     fill = 'fill', //主题实色
@@ -77,7 +78,7 @@ export default function NewButton(props: {
     fontNormal?: boolean,
     labelBorder?: boolean,
     btnStyle?: any,
-    postBtn?:boolean
+    postBtn?: boolean
 }) {
 
     const [isTouched, setIsTouched] = useState(false)
@@ -201,9 +202,9 @@ export default function NewButton(props: {
                 justifyContent: 'center',
                 flexDirection: 'row',
                 flex: 1,
-                width:'100%',
-                height:'100%',
-                color: props.color?props.color:'#5C7099',
+                width: '100%',
+                height: '100%',
+                color: props.color ? props.color : '#5C7099',
                 fontSize: props.fontSize ? props.fontSize : rpxToPx(26),
                 opacity: isTouched ? 0.4 : 1,
             }
@@ -320,6 +321,22 @@ export default function NewButton(props: {
             }
             if (noTouch && props.postBtn) return;
             props.onClick()
+            if (props.type == NewButtonType.link) {
+                return
+            }
+
+            var platform = ''
+            if (Taro.getDeviceInfo) {
+                platform = Taro.getDeviceInfo().platform
+            }
+            else {
+                platform = Taro.getSystemInfoSync().platform
+            }
+
+            if (platform == 'windows' || platform == 'mac') {
+                return
+            }
+
             setNoTouch(true)
             setTimeout(() => {
                 setNoTouch(false)

+ 29 - 36
src/_health/pages/add_moment.tsx

@@ -24,6 +24,7 @@ import { rpxToPx } from "@/utils/tools";
 import StatusIndicator, { StatusType } from "../base/status_indicator";
 import { IconCheck } from "@/components/basic/Icons";
 import showActionSheet from "@/components/basic/ActionSheet";
+import { TimeFormatter } from "@/utils/time_format";
 
 
 let useRoute;
@@ -145,26 +146,15 @@ 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 str = selDate + ' ' + time + ':' + dayjs(enterTimestmap).format('ss')
+        // console.log('系统时间',new Date())
+        // console.log('提交日期格式',str)
+        // console.log('转成日期',new Date(str))
 
-        var date = new Date(selDate + 'T' + time + ':' + dayjs(enterTimestmap).format('ss'))
+        // var date = new Date(selDate + 'T' + time + ':' + dayjs(enterTimestmap).format('ss'))
+        var date = TimeFormatter.stringToDate(selDate, time)
         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,
@@ -191,7 +181,7 @@ export default function AddMoment() {
         if (is_temp) {
             params.event = health.mode == 'EAT' ? 'EAT_CUSTOM' : 'ACTIVE_CUSTOM'
         }
-        params.op_page = health.mode == 'EAT' ? 'HOME_EAT':'HOME_ACTIVE'
+        params.op_page = health.mode == 'EAT' ? 'HOME_EAT' : 'HOME_ACTIVE'
         // if (moment.target && moment.target.duration) {
         //     params.duration = durationT//moment.target.duration
         // }
@@ -205,19 +195,22 @@ export default function AddMoment() {
             set_time: global.set_time ? global.set_time : new Date().getTime(),
             confirm_time: new Date().getTime()
         }
-        console.log('打卡提交数据',params)
+        console.log('打卡提交数据', params)
         if (posting) return
         setPosting(true)
         createMoment(params).then(res => {
-            setTimeout(() => {
+            // setTimeout(() => {
                 setPosting(false)
-            }, 1000)
+            // }, 1000)
 
             if (process.env.TARO_ENV == 'weapp') {
                 // Taro.navigateBack();
                 Taro.redirectTo({
                     url: '/_health/pages/post_result?data=' + JSON.stringify(res)
                 })
+                // Taro.navigateTo({
+                //     url:'/_health/pages/post_result?data=' + JSON.stringify(res)
+                // })
             }
 
             Taro.disableAlertBeforeUnload({
@@ -237,8 +230,8 @@ export default function AddMoment() {
     }
 
     function edit() {
-        var date = new Date(selDate + 'T' + time + ':' + dayjs(enterTimestmap).format('ss'))
-
+        // var date = new Date(selDate + 'T' + time + ':' + dayjs(enterTimestmap).format('ss'))
+        var date = TimeFormatter.stringToDate(selDate, time)
         var params: any = {
             schedule_id: schedule_id,
             title: title,
@@ -329,7 +322,7 @@ export default function AddMoment() {
             success: (rsp) => {
                 if (rsp.statusCode != 200) {
                     Taro.showToast({
-                        title: '操作失败,请检查网络',
+                        title: global.language == 'en' ? 'Posting failed. Please check your network.' : '操作失败,请检查网络',
                         icon: 'none'
                     })
                     return
@@ -415,12 +408,12 @@ export default function AddMoment() {
         return true
     }
 
-    function tapPic(){
+    function tapPic() {
         showActionSheet({
-            title:'',
-            itemList:[t('health.choose_photo'),t('health.camera'),t('health.delete')],
+            title: '',
+            itemList: [t('health.choose_photo'), t('health.camera'), t('health.delete')],
             success: function (res) {
-                switch(res){
+                switch (res) {
                     case 0:
                         addImage(false)
                         break;
@@ -491,13 +484,13 @@ export default function AddMoment() {
                         {
                             labels.map((item, index) => {
                                 return <View className="add_page_tag_btn"
-                                style={{
-                                    backgroundColor:item.title==title?getThemeColor(health.mode):'#B2B2B21A',
-                                    color:item.title==title?'#fff':'#000'
-                                }}
-                                key={index} onClick={() => {
-                                    setTitle(item.title)
-                                }}>{item.title}</View>
+                                    style={{
+                                        backgroundColor: item.title == title ? getThemeColor(health.mode) : '#B2B2B21A',
+                                        color: item.title == title ? '#fff' : '#000'
+                                    }}
+                                    key={index} onClick={() => {
+                                        setTitle(item.title)
+                                    }}>{item.title}</View>
                             })
                         }
                         <View style={{ width: rpxToPx(40), flexShrink: 0 }} />
@@ -550,7 +543,7 @@ export default function AddMoment() {
         }
         {
             showTimePicker && <PostMomentTime
-                title={ t('health.log_time_title')}
+                title={t('health.log_time_title')}
                 time={time}
                 date={selDate}
                 isTemp={is_temp}

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

@@ -404,7 +404,9 @@ 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(enterTime).format('ss'))
+        // var now = new Date(obj.date + 'T' + time + ':' + dayjs(enterTime).format('ss'))
+        var now = TimeFormatter.stringToDate(obj.date, time)
+        now.setSeconds(parseInt(dayjs(enterTime).format('ss')))
         now.setMilliseconds(new Date(enterTime).getMilliseconds())
         // now.setHours(hour)
         // now.setMinutes(minute)

+ 5 - 1
src/_health/pages/long_fast_setting.tsx

@@ -15,6 +15,7 @@ import Taro from "@tarojs/taro";
 import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 import ChooseDateTime from "../components/choose_date_time";
 import StatusIndicator, { StatusType } from "../base/status_indicator";
+import { TimeFormatter } from "@/utils/time_format";
 
 export default function LongFastSetting() {
     const [showGoal, setShowGoal] = useState(true)
@@ -42,7 +43,10 @@ export default function LongFastSetting() {
 
     function commit() {
 
-        let now = new Date(dayjs().format('YYYY-MM-DDT') + time + ':'+dayjs(enterTimestamp).format('ss')).getTime()
+        // let now = new Date(dayjs().format('YYYY-MM-DDT') + time + ':'+dayjs(enterTimestamp).format('ss')).getTime()
+        var date = TimeFormatter.stringToDate(dayjs().format('YYYY-MM-DD'), time)
+        date.setSeconds(parseInt(dayjs(enterTimestamp).format('ss')))
+        var now = date.getTime()
         if (!isToday) {
             now = now - 24 * 3600 * 1000
         }

+ 16 - 13
src/_health/pages/post_result.tsx

@@ -25,6 +25,8 @@ if (process.env.TARO_ENV == 'rn') {
     useNavigation = require("@react-navigation/native").useNavigation
 }
 export default function PostResult() {
+
+
     const user = useSelector((state: any) => state.user);
 
     let router
@@ -242,6 +244,7 @@ export default function PostResult() {
         return ''
     }
 
+
     return <View className="post_result_container">
         {
             headerIcon()
@@ -321,32 +324,32 @@ export default function PostResult() {
                         Taro.navigateBack()
                     }
 
-                    if (data.status_change) {
-                        if (data.status_change.previous != data.status_change.current) {
-                            //灵动岛弹窗
-                            dispatch(setShowActionTip({
-                                isShow: true,
-                                isCompleted: false
-                            }))
-                        }
-                    }
+                    // if (data.status_change) {
+                    //     if (data.status_change.previous != data.status_change.current) {
+                    //         //灵动岛弹窗
+                    //         dispatch(setShowActionTip({
+                    //             isShow: true,
+                    //             isCompleted: false
+                    //         }))
+                    //     }
+                    // }
 
                 }}
             />
-            {/* {
-                showSwitchBtn() && <View style={{ marginTop: rpxToPx(36), width: rpxToPx(400), height: rpxToPx(72), display: 'flex' }}>
+            {
+                false && showSwitchBtn() && <View style={{ marginTop: rpxToPx(36), width: rpxToPx(400), height: rpxToPx(72), display: 'flex' }}>
                     <NewButton
                         type={NewButtonType.link}
                         title={swithBtnText()}
                         onClick={tapSwitch}
                     />
                 </View>
-            } */}
+            }
 
 
         </View>
         {
-            showSetting && <NewModal
+            showSetting && false && <NewModal
                 themeColor={getThemeColor(data.window)}
                 title='开启提醒'
                 dismiss={() => setShowSetting(false)}

+ 12 - 2
src/_health/pages/timeline_detail.tsx

@@ -81,6 +81,8 @@ export default function TimelineDetail() {
 
     const { schedule_id, event_id, window_id, isfastsleep, fast_type, disable_edit, uid, autoPost, op_page } = router.params
 
+    console.log('进入页面获取参数')
+
 
     if (process.env.TARO_ENV == 'weapp') {
 
@@ -288,6 +290,7 @@ export default function TimelineDetail() {
 
     function getDatas() {
         var showWindow = true
+        console.log('获取接口数据')
         if (!window_id || op_page == 'HOME_EAT' || op_page == 'HOME_ACTIVE') showWindow = false
         if (showWindow) {
             var params: any = {}
@@ -297,6 +300,7 @@ export default function TimelineDetail() {
             if (router.params.uid) {
                 params.share_user_id = router.params.uid
             }
+            console.log('获取window数据')
             getRecordDetail(window_id, params).then(res => {
                 if ((res as any).events && (res as any).events.length > 0 && (res as any).events[0].time)
                     setTitle((res as any).events[0].time.timestamp)
@@ -309,6 +313,7 @@ export default function TimelineDetail() {
                 if ((res as any).share_user) {
                     setShareUser((res as any).share_user)
                 }
+                console.log('获取window数据成功')
             }).catch(e => {
                 console.log('request failed', e)
                 setLoaded(true)
@@ -320,6 +325,7 @@ export default function TimelineDetail() {
             if (router.params.uid) {
                 params.share_user_id = router.params.uid
             }
+            console.log('获取event数据')
             getEvents(event_id, params).then(res => {
                 if ((res as any).time)
                     setTitle((res as any).time.timestamp)
@@ -330,6 +336,7 @@ export default function TimelineDetail() {
                 if ((res as any).share_user) {
                     setShareUser((res as any).share_user)
                 }
+                console.log('获取event数据成功')
             }).catch(e => {
                 console.log('request failed', e)
                 setLoaded(true)
@@ -392,7 +399,7 @@ export default function TimelineDetail() {
             success: (rsp) => {
                 if (rsp.statusCode != 200) {
                     Taro.showToast({
-                        title: '操作失败,请检查网络',
+                        title: global.language == 'en' ? 'Posting failed. Please check your network.' : '操作失败,请检查网络',
                         icon: 'none'
                     })
                     return
@@ -429,7 +436,9 @@ export default function TimelineDetail() {
             })
             return
         }
-        var dt = new Date(selDate + 'T' + time + ':' + dayjs(enterTimestmap).format('ss'))
+        // var dt = new Date(selDate + 'T' + time + ':' + dayjs(enterTimestmap).format('ss'))
+        var dt = TimeFormatter.stringToDate(selDate, time)
+        dt.setSeconds(parseInt(dayjs(enterTimestmap).format('ss')))
         dt.setMilliseconds(new Date(enterTimestmap).getMilliseconds())
         var params: any = {
             schedule_id: schedule_id,
@@ -697,6 +706,7 @@ export default function TimelineDetail() {
     }
 
     function backHome() {
+        
         Taro.reLaunch({
             url: '/pages/clock/Clock'
         })

+ 1 - 1
src/features/food/FoodConsole.tsx

@@ -170,7 +170,7 @@ export default function Component(props: { addItem: Function, firstItem: any })
             success: (rsp) => {
                 if (rsp.statusCode != 200) {
                     Taro.showToast({
-                        title: '操作失败,请检查网络',
+                        title: global.language == 'en' ? 'Posting failed. Please check your network.' : '操作失败,请检查网络',
                         icon: 'none'
                     })
                     return

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

@@ -785,8 +785,8 @@ export default function MainConsole(props: { type: WindowType }) {
 
     function tapClearLocation() {
         Taro.showModal({
-            title: '提示',
-            content: '确认清除位置数据?',
+            title: t('feature.location.clear_alert_title'),
+            content: t('feature.location.clear_alert_content'),
             success: function (res) {
                 if (res.confirm) {
                     clearLocation().then(res => {
@@ -830,7 +830,7 @@ export default function MainConsole(props: { type: WindowType }) {
         var strYesterday = `${yesterday.getFullYear()}-${TimeFormatter.padZero(yesterday.getMonth() + 1)}-${TimeFormatter.padZero(yesterday.getDate())}`
         var strTomorrow = `${tomorrow.getFullYear()}-${TimeFormatter.padZero(tomorrow.getMonth() + 1)}-${TimeFormatter.padZero(tomorrow.getDate())}`
         Taro.showLoading({
-            title: '加载中'
+            title: global.language == 'en' ? 'Loading' : '加载中'
         })
         systemLocation({
             lat: res.latitude,
@@ -1028,9 +1028,12 @@ export default function MainConsole(props: { type: WindowType }) {
                 <NewButton
                     type={NewButtonType.link}
                     title={switchText()}
-                    onClick={tapSwitchBtn}
+                    onClick={() => {
+                        tapSwitchBtn()
+                    }}
                 >
                 </NewButton>
+
             </View>
 
             {

+ 1 - 1
src/features/health/MainHistory.tsx

@@ -721,7 +721,7 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
 
         {
             (list.length >= 0 || health.mode == 'EAT' || health.mode == 'ACTIVE') && <View className="new_header_bg2">
-                <Text className="h50 w500">{t('health.recents')}</Text>
+                <Text className="h50 bold">{t('health.recents')}</Text>
 
                 {
                     (health.mode == 'EAT' || health.mode == 'ACTIVE') && <View style={{ marginTop: rpxToPx(0) }}><RightArrowRow

+ 5 - 0
src/features/health/MainSwiper.tsx

@@ -161,7 +161,12 @@ export default function MainSwiper(props: { count: number, pageChanged: Function
         scrollPage = current
     }
 
+    global.switchTap = ()=>{
+        switchMode()
+    }
+
     function switchMode() {
+        console.log('swiper switch',health.mode)
         switch (health.mode) {
             case 'FAST':
                 dispatch(setMode('EAT'));

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

@@ -1,4 +1,4 @@
-const online = process.env.TARO_ENV == 'weapp' ? false : false;
+const online = process.env.TARO_ENV == 'weapp' ? true : false;
 
 import { WX_VERSION as _WX_VERSION, APP_VERSION as _APP_VERSION, ANDROID_VERSION as _ANDROID_VERSION } from "../../../config/env";
 

+ 10 - 0
src/utils/time_format.ts

@@ -900,5 +900,15 @@ export class TimeFormatter {
     return date >= startOfWeek && date <= endOfWeek;
   }
 
+  static stringToDate = (date, time) => {
+    var dt = new Date()
+    dt.setFullYear(parseInt(date.substring(0, 4)))
+    dt.setMonth(parseInt(date.substring(5, 7)) - 1)
+    dt.setDate(parseInt(date.substring(8, 10)))
+    dt.setHours(parseInt(time.substring(0, 2)))
+    dt.setMinutes(parseInt(time.substring(3, 5)))
+    return dt
+  }
+
 }