Leon 1 year ago
parent
commit
f28ca95abe

+ 5 - 1
src/_health/base/new_date_time_picker.tsx

@@ -68,6 +68,10 @@ export default function NewDateTimePicker(props: {
 
 
     useEffect(() => {
+        loadData()
+    }, [props.count])
+
+    function loadData(){
         var hours: any = []
         var tempValues: any = [longValues(), 0, 0]
         var str = props.time ? props.time : dayjs().format('HH:mm')
@@ -92,7 +96,7 @@ export default function NewDateTimePicker(props: {
         setItems([longDatas(), hours, minutes])
         setValues(tempValues)
         setLoaded(true)
-    }, [])
+    }
 
     useEffect(() => {
         var hours: any = []

+ 4 - 2
src/_health/components/add_label.tsx

@@ -187,7 +187,8 @@ export default function AddLabel(props: {
                                 timeLabels.map((item, index) => {
                                     return <View className="label"
                                         style={{
-                                            backgroundColor: item.title == strLabel ? (isEat() ? getThemeColor('EAT') + '1A' : getThemeColor('ACTIVE') + '1A') : '#B2B2B21A'
+                                            backgroundColor: item.title == strLabel ? (isEat() ? getThemeColor('EAT') : getThemeColor('ACTIVE')) : '#B2B2B21A',
+                                            color:item.title==strLabel ?'#fff' : '#000',
                                         }}
                                         key={index} onClick={() => setStrLabel(item.title)}>{item.title}</View>
                                 })
@@ -248,7 +249,8 @@ export default function AddLabel(props: {
                             props.labels.map((item, index) => {
                                 return <View className="label"
                                     style={{
-                                        backgroundColor: item.title == value ? (isEat() ? getThemeColor('EAT') + '1A' : getThemeColor('ACTIVE') + '1A') : '#B2B2B21A'
+                                        backgroundColor: item.title == value ? (isEat() ? getThemeColor('EAT') : getThemeColor('ACTIVE')) : '#B2B2B21A',
+                                        color:item.title == value ?'#fff' : '#000',
                                     }}
                                     key={index} onClick={() => setValue(item.title)}>{item.title}</View>
                             })

+ 1 - 0
src/_health/components/choose_date_time.tsx

@@ -39,6 +39,7 @@ export default function ChooseDateTime(props: {
     const [count, setCount] = useState(0)
 
     useEffect(() => {
+        console.log('sss')
         setCount(count => count + 1)
     }, [props.count])
 

+ 2 - 1
src/_health/components/schedule_item.tsx

@@ -132,7 +132,8 @@ export default function ScheduleItem(props: {
                                 timeLabels.map((item, index) => {
                                     return <View className="label"
                                         style={{
-                                            backgroundColor: item.title == strLabel ? getThemeColor('ACTIVE') + '1A' : '#B2B2B21A'
+                                            backgroundColor: item.title == strLabel ? getThemeColor('ACTIVE') : '#B2B2B21A',
+                                            color:item.title == strLabel ?'#fff':'#000'
                                         }}
                                         key={index} onClick={() => setStrLabel(item.title)}>{item.title}</View>
                                 })

+ 25 - 3
src/_health/pages/add_moment.tsx

@@ -23,6 +23,7 @@ import NewButton, { NewButtonType } from "../base/new_button";
 import { rpxToPx } from "@/utils/tools";
 import StatusIndicator, { StatusType } from "../base/status_indicator";
 import { IconCheck } from "@/components/basic/Icons";
+import showActionSheet from "@/components/basic/ActionSheet";
 
 
 let useRoute;
@@ -395,6 +396,26 @@ export default function AddMoment() {
         return true
     }
 
+    function tapPic(){
+        showActionSheet({
+            title:'',
+            itemList:[t('health.choose_photo'),t('health.camera'),t('health.delete')],
+            success: function (res) {
+                switch(res){
+                    case 0:
+                        addImage(false)
+                        break;
+                    case 1:
+                        addImage(true)
+                        break;
+                    case 2:
+                        setImgUrl('')
+                        break;
+                }
+            }
+        })
+    }
+
 
     return <View>
         <View style={{
@@ -417,7 +438,7 @@ export default function AddMoment() {
                     text={getDate() + time}>
                     <IconCheck color="#fff" width={rpxToPx(24)} height={24} />
                 </StatusIndicator>
-                <View className="h22" style={{ color: MainColorType.link, marginTop: rpxToPx(8) }}>{t('health.edit_time')}</View>
+                <View className="h26" style={{ color: MainColorType.link, marginTop: rpxToPx(8) }}>{t('health.edit_time')}</View>
 
             </View>
 
@@ -452,7 +473,8 @@ export default function AddMoment() {
                             labels.map((item, index) => {
                                 return <View className="add_page_tag_btn"
                                 style={{
-                                    backgroundColor:item.title==title?getThemeColor(health.mode)+'1A':'#B2B2B21A'
+                                    backgroundColor:item.title==title?getThemeColor(health.mode):'#B2B2B21A',
+                                    color:item.title==title?'#fff':'#000'
                                 }}
                                 key={index} onClick={() => {
                                     setTitle(item.title)
@@ -476,7 +498,7 @@ export default function AddMoment() {
 
             <View className="form">
                 {
-                    imgUrl.length > 0 && <View className="cover" ><NewButton type={NewButtonType.img} onClick={() => addImage(false)}><Image src={imgUrl} mode="aspectFill" className="cover" /></NewButton></View>
+                    imgUrl.length > 0 && <View className="cover" ><NewButton type={NewButtonType.img} onClick={() => tapPic()}><Image src={imgUrl} mode="aspectFill" className="cover" /></NewButton></View>
                 }
                 {
                     imgUrl.length == 0 && <View style={{ display: 'flex', flexDirection: 'row' }}>

+ 24 - 3
src/_health/pages/guide_active.tsx

@@ -28,6 +28,8 @@ import Taro from "@tarojs/taro";
 let useRoute;
 let useNavigation;
 let scenario = '';
+let guideIndex = 0
+let timer;
 if (process.env.TARO_ENV == 'rn') {
     useRoute = require("@react-navigation/native").useRoute
     useNavigation = require("@react-navigation/native").useNavigation
@@ -43,6 +45,7 @@ export default function GuideActive() {
     const [showModal, setShowModal] = useState(false)
     const [labels, setLabels] = useState<any>([])
     const [posting, setPosting] = useState(false)
+    const [count,setCount] = useState(0)
     const { t } = useTranslation()
 
     let navigation, showActionSheetWithOptions;
@@ -62,6 +65,14 @@ export default function GuideActive() {
         setTimeout(() => {
             setHighlight(false)
         }, 2000)
+
+        timer = setInterval(()=>{
+            setCount(count=>count+1)
+        },1000)
+
+        return ()=>{
+            clearInterval(timer)
+        }
     }, [])
 
     function check(array, tapDone = false) {
@@ -135,14 +146,24 @@ export default function GuideActive() {
     }
 
     function items() {
+        console.log(labels.length)
         var items = list.filter(item => item.window == 'ACTIVE')
         if (items.length == 0) {
             if (labels.length == 0) return <View />
+
+            var seconds = new Date().getSeconds()
+            if (seconds % 3 == 0) {
+                guideIndex++;
+                if (guideIndex >= labels.length) {
+                    guideIndex = 0
+                }
+            }
+
             return <Card>
-                <OnBoard title={labels[0].title}
-                    desc={labels[0].time_label}
+                <OnBoard title={labels[guideIndex].title}
+                    desc={labels[guideIndex].time_label}
                     color={MainColorType.active}
-                    btnTitle={t('health.create_my_active')}
+                    btnTitle={t('health.add_my_first_activity')}
                     onClick={() => {
                         add()
                     }}

+ 33 - 30
src/_health/pages/log_time.tsx

@@ -68,7 +68,7 @@ export default function LogTime() {
     const [loaded, setLoaded] = useState(false)
     const [autoCheck, setAutoCheck] = useState(false)
     const [initCheck, setInitCheck] = useState(router.params.initCheck == '1')
-    const [initSeconds,setInitSeconds] = useState(router.params.initCheck == '1') //初始化时,带入打卡时的秒数
+    const [initSeconds, setInitSeconds] = useState(router.params.initCheck == '1') //初始化时,带入打卡时的秒数
     const [count, setCount] = useState(0)
 
     const [ignoreCheck, setIgnoreCheck] = useState(false)
@@ -330,30 +330,30 @@ export default function LogTime() {
     }
 
     function getTimestamp(obj) {
-        const {event_id} = obj
-        var tempObj:any = null
+        const { event_id } = obj
+        var tempObj: any = null
 
-        if (data.fast){
-            data.fast.timeline.map((item)=>{
-                if (item.event_id == event_id){
+        if (data.fast) {
+            data.fast.timeline.map((item) => {
+                if (item.event_id == event_id) {
                     tempObj = item
                 }
             })
         }
-        if (data.sleep){
-            data.sleep.timeline.map((item)=>{
-                if (item.event_id == event_id){
+        if (data.sleep) {
+            data.sleep.timeline.map((item) => {
+                if (item.event_id == event_id) {
                     tempObj = item
                 }
             })
         }
-        
+
         var time = obj.time
-        if (tempObj && tempObj.real && dayjs(tempObj.real.timestamp).format('YYYY-MM-DDTHH:mm')==obj.date + 'T' + time){
+        if (tempObj && tempObj.real && dayjs(tempObj.real.timestamp).format('YYYY-MM-DDTHH:mm') == obj.date + 'T' + time) {
             debugger
             return tempObj.real.timestamp
         }
-        
+
         // var hour = parseInt(time.split(':')[0])
         // var minute = parseInt(time.split(':')[1])
         // var date = obj.date
@@ -534,7 +534,6 @@ export default function LogTime() {
     }
 
     function commit(list, onlyCheck, save_confirm) {
-        debugger
         const sortedData = list.sort((a, b) => {
             return b.extra.confirm_time - a.extra.confirm_time; // 降序
         });
@@ -548,13 +547,6 @@ export default function LogTime() {
                 confirm_time: new Date().getTime()
             }
         }
-        if (save_confirm) {
-            params.save_confirm = save_confirm
-        }
-        // console.log(new Date().getTime())
-        // console.log(params)
-
-        // return
         if (onlyCheck) {
             var dt = new Date().getTime()
             params.requestId = dt
@@ -564,12 +556,21 @@ export default function LogTime() {
             params.requestId = requestId
         }
 
+        if (save_confirm) {
+            params.save_confirm = save_confirm
+            params.requestId = new Date().getTime()
+        }
+
+
+        console.log(requestId)
+
 
 
         if (posting) return
         setPosting(true)
-        clockTimes(params).then(res => {
-            if (onlyCheck){
+        const url = onlyCheck ? '?only_check=true' : ''
+        clockTimes(url, params).then(res => {
+            if (onlyCheck) {
                 setRequestId(new Date().getTime())
             }
 
@@ -577,6 +578,9 @@ export default function LogTime() {
                 setErrors([])
                 setConflicts([])
                 if (!onlyCheck) {
+                    Taro.redirectTo({
+                        url: './post_result?data=' + JSON.stringify(res)
+                    })
                     global.refreshWindow()
                     if (global.refreshHistory)
                         global.refreshHistory()
@@ -588,23 +592,21 @@ export default function LogTime() {
                     if (global.refreshLongFast) {
                         global.refreshLongFast()
                     }
-                    Taro.redirectTo({
-                        url: './post_result?data=' + JSON.stringify(res)
-                    })
-                    setTimeout(() => {
-                        setPosting(false)
-                    }, 1000)
                 }
                 else {
                     setPosting(false)
                 }
 
+                console.log('页面正常跳转到下一级')
+
 
 
             }
             else {
                 setPosting(false)
                 if ((res as any).warn_code == 'SAVE_AS_LF') {
+                    setRequestId(new Date().getTime())
+                    console.log(new Date().getTime())
                     showAlert({
                         title: 'Saving as Long Fast',
                         content: 'Fasting that lasts more than 24 hours will be saved as Long Fast. ',
@@ -620,6 +622,7 @@ export default function LogTime() {
                     return
                 }
                 if ((res as any).warn_code == 'SAVE_AS_IF') {
+                    setRequestId(new Date().getTime())
                     showAlert({
                         title: 'Saving as Intermittent Fasting',
                         content: 'Fasting that lasts fewer than 24 hours will be saved as Intermittent Fasting.',
@@ -878,7 +881,7 @@ export default function LogTime() {
             disable={array[index].disable}
             showError={showError}
             showLine={showLine}
-            targetTimestamp = {timeline.target.timestamp}
+            targetTimestamp={timeline.target.timestamp}
             enterTimestamp={enterTime}
             // footerTitle=""
             // footerTitle={changeTimeText(timeline.target.timestamp,data, time)}
@@ -1144,7 +1147,7 @@ export default function LogTime() {
             <NewButton
                 color={footerBtnColor()}
                 type={NewButtonType.fill}
-                title={isSingle?t('health.log_moment'):t('health.log_moments')}
+                title={isSingle ? t('health.log_moment') : t('health.log_moments')}
                 width={rpxToPx(646)}
                 height={rpxToPx(96)}
                 disable={errors.length > 0}

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

@@ -166,7 +166,7 @@ export default function LongFast() {
         params.requestId = enterTime
 
 
-        clockTimes(params).then(res => {
+        clockTimes('',params).then(res => {
             if ((res as any).warn_code == 'SAVE_AS_IF') {
                 showAlert({
                     title: 'Saving as Intermittent Fasting',

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

@@ -48,7 +48,7 @@ export default function LongFastSetting() {
         }
         // params.requestId = enterTime
 
-        clockTimes({
+        clockTimes('',{
             requestId:enterTimestamp,
             check_items: [{
                 schedule_id: health.long_fast.timeline[0].schedule_id,

+ 24 - 0
src/_health/pages/post_result.scss

@@ -77,4 +77,28 @@ page{
     padding-left: 52px;
     padding-top: 40px;
     padding-bottom: 57px;
+}
+
+.share_btn_bg2 {
+    position: relative;
+    width: 400px;
+    height: 72px;
+    // margin-left: 172px;
+}
+
+.share_icon_bg2 {
+    width: 400px;
+    height: 72px;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}
+
+.share_btn2 {
+    position: absolute;
+    opacity: 0;
+    left: 0;
+    top: 0;
+    right: 0;
+    bottom: 0;
 }

+ 79 - 4
src/_health/pages/post_result.tsx

@@ -1,5 +1,5 @@
-import { View, Image, Text, Switch } from "@tarojs/components";
-import Taro, { useRouter } from "@tarojs/taro";
+import { View, Image, Text, Switch, Button } from "@tarojs/components";
+import Taro, { useRouter, useShareAppMessage } from "@tarojs/taro";
 import './post_result.scss'
 import { getThemeColor } from "@/features/health/hooks/health_hooks";
 import { rpxToPx } from "@/utils/tools";
@@ -15,6 +15,7 @@ import Card from "../components/card";
 import { updateReminder } from "@/services/health";
 import StatusIndicator, { StatusType } from "../base/status_indicator";
 import { useTranslation } from "react-i18next";
+import { SHARE_COVER_URL } from "@/services/http/api";
 
 let useRoute;
 let useNavigation;
@@ -43,6 +44,70 @@ export default function PostResult() {
     const dispatch = useDispatch()
     const { t } = useTranslation()
 
+    if (process.env.TARO_ENV == 'weapp') {
+
+        useShareAppMessage((e) => {
+            var title = ''
+            const { window_id, event_id, fast_type, op_page } = data
+            if (!window_id && !event_id) {
+                return {
+                    title: title,
+                    path: `/pages/clock/Clock`,
+                }
+            }
+
+            // if (isfastsleep == '1') {
+            //     title = t('health.share_my_fast_sleep')
+            // }
+            // else if (islongfast == '1') {
+            //     title = t('health.share_my_long_fast')
+            // }
+            // else {
+            var defaultImg = SHARE_COVER_URL + 'my_fast.jpg'
+            switch (data.window) {
+                case 'FAST':
+                    title = t('health.share_my_fasting')
+                    defaultImg = SHARE_COVER_URL + 'my_fast.jpg'
+                    break;
+                case 'EAT':
+                    title = t('health.share_my_eating')
+                    defaultImg = SHARE_COVER_URL + 'my_meal.jpg'
+                    break;
+                case 'ACTIVE':
+                    title = t('health.share_my_activity')
+                    defaultImg = SHARE_COVER_URL + 'my_activity.jpg'
+                    break;
+                case 'SLEEP':
+                    title = t('health.share_my_sleep')
+                    defaultImg = SHARE_COVER_URL + 'my_sleep.jpg'
+                    break;
+
+            }
+
+            if (fast_type == 'LF') {
+                title = t('health.share_my_long_fast')
+                defaultImg = SHARE_COVER_URL + 'my_long_fast.jpg'
+            }
+            else if (op_page == 'FAST_WITH_SLEEP') {
+                title = t('health.share_my_fast_sleep')
+                defaultImg = SHARE_COVER_URL + 'my_fast_with_sleep.jpg'
+            }
+            var imgs = []//imgList()
+            var imageUrl = imgs.length > 0 ? imgs[0] : defaultImg
+            var type = ''
+            if (data.window_id) {
+                type = 'recent'
+            }
+
+
+            return {
+                title: title,
+                path: `/_health/pages/timeline_detail?fast_type=${fast_type}&type=${type}&window_id=${window_id}&event_id=${event_id}&uid=${user.id}&isfastsleep=${op_page == 'FAST_WITH_SLEEP'?1:0}&disable_edit=1&enter_type=share`,
+                imageUrl: imageUrl
+            }
+        })
+    }
+
     function getMainColor() {
         if (data.scenario == 'MOVE' && data.extra.move_status == 'SEDENTARY') {
             return MainColorType.g02
@@ -205,12 +270,22 @@ export default function PostResult() {
         }
 
         <View style={{ flex: 1 }} />
+        {
+            (data.window_id || data.event_id) && <View className="share_btn_bg2">
+
+                <View className="share_icon_bg2">
+                    <View className="h26" style={{ color: MainColorType.link }}>{t('health.share_moment')}</View>
+                </View>
+                <Button className="share_btn2" openType="share">1</Button>
+            </View>
+        }
+
         <View className="result_footer">
             <NewButton
                 type={NewButtonType.gray}
                 width={rpxToPx(400)}
                 height={rpxToPx(96)}
-                title="Done"
+                title={t('health.done')}
                 bold
                 onClick={() => {
                     if (global.tapDone) {
@@ -218,7 +293,7 @@ export default function PostResult() {
                     }
                     if (data.current_window) {
                         Taro.reLaunch({
-                            url:'/pages/clock/Clock'
+                            url: '/pages/clock/Clock'
                         })
                         // Taro.navigateBack({
                         //     delta: Taro.getCurrentPages().length-1

+ 9 - 0
src/_health/pages/timeline_detail.scss

@@ -138,4 +138,13 @@ html page {
     top: 0;
     right: 0;
     bottom: 0;
+}
+
+.no_data_bg2{
+    display: flex;
+    flex-direction: column;
+    // width: '100%';
+    // height: '100%';
+    align-items: center;
+    justify-content: center;
 }

+ 165 - 132
src/_health/pages/timeline_detail.tsx

@@ -6,11 +6,11 @@ import { useEffect, useState } from "react";
 import Taro, { useRouter, useShareAppMessage } from "@tarojs/taro";
 import dayjs from "dayjs";
 import { getScenario, getThemeColor } from "@/features/health/hooks/health_hooks";
-import { baseUrl } from "@/services/http/api";
+import { baseUrl, SHARE_COVER_URL } from "@/services/http/api";
 import { checkAuthorized } from "@/utils/check_authorized";
 import { createMoment, delEvents, delRecord, getEvents, getRecordDetail, makeDone } from "@/services/health";
 import NewButton, { NewButtonType } from "../base/new_button";
-import { IconClose, IconLongFast, IconShare } from "@/components/basic/Icons";
+import { IconClose, IconError, IconLongFast, IconShare } from "@/components/basic/Icons";
 import { rpxToPx, vibrate } from "@/utils/tools";
 import { MainColorType } from "@/context/themes/color";
 import NewModal from "../base/new_modal";
@@ -62,6 +62,7 @@ export default function TimelineDetail() {
     const [count, setCount] = useState(0)
     const [fastSleepPop, setFastSleepPop] = useState(false)
     const [shareUser, setShareUser] = useState<any>(null)
+    const [showEmpty, setShowEmpty] = useState(false)
     const dispatch = useDispatch()
 
     const { t } = useTranslation()
@@ -78,41 +79,48 @@ export default function TimelineDetail() {
         router = useRouter()
     }
 
-    const { schedule_id, event_id, window_id, isfastsleep, islongfast, disable_edit, uid } = router.params
+    const { schedule_id, event_id, window_id, isfastsleep, fast_type, disable_edit, uid } = router.params
 
 
     if (process.env.TARO_ENV == 'weapp') {
 
         useShareAppMessage((e) => {
             var title = ''
+            var defaultImg = SHARE_COVER_URL + 'my_fast.jpg'
             if (isfastsleep == '1') {
                 title = t('health.share_my_fast_sleep')
+                defaultImg = SHARE_COVER_URL + 'my_fast_with_sleep.jpg'
             }
-            else if (islongfast == '1') {
+            else if (fast_type == 'LF') {
                 title = t('health.share_my_long_fast')
+                defaultImg = SHARE_COVER_URL + 'my_long_fast.jpg'
             }
             else {
                 switch (health.mode) {
                     case 'FAST':
                         title = t('health.share_my_fasting')
+                        defaultImg = SHARE_COVER_URL + 'my_fast.jpg'
                         break;
                     case 'EAT':
                         title = t('health.share_my_eating')
+                        defaultImg = SHARE_COVER_URL + 'my_meal.jpg'
                         break;
                     case 'ACTIVE':
                         title = t('health.share_my_activity')
+                        defaultImg = SHARE_COVER_URL + 'my_activity.jpg'
                         break;
                     case 'SLEEP':
                         title = t('health.share_my_sleep')
+                        defaultImg = SHARE_COVER_URL + 'my_sleep.jpg'
                         break;
 
                 }
             }
             var imgs = imgList()
-            var imageUrl = imgs.length > 0 ? imgs[0] : 'https://background-pictures.oss-cn-beijing.aliyuncs.com/windows/eat2.jpg'
+            var imageUrl = imgs.length > 0 ? imgs[0] : defaultImg
             return {
                 title: title,
-                path: `/_health/pages/timeline_detail?type=${router.params.type}&schedule_id=${schedule_id}&window_id=${window_id}&event_id=${event_id}&uid=${uid ?? user.id}&isfastsleep=${isfastsleep}&disable_edit=1&enter_type=share`,
+                path: `/_health/pages/timeline_detail?type=${router.params.type}&fast_type=${fast_type}&schedule_id=${schedule_id}&window_id=${window_id}&event_id=${event_id}&uid=${uid ?? user.id}&isfastsleep=${isfastsleep}&disable_edit=1&enter_type=share`,
                 imageUrl: imageUrl
             }
         })
@@ -201,6 +209,9 @@ export default function TimelineDetail() {
                 if ((res as any).share_user) {
                     setShareUser((res as any).share_user)
                 }
+            }).catch(e => {
+                setLoaded(true)
+                setShowEmpty(true)
             })
         }
         else {
@@ -218,6 +229,9 @@ export default function TimelineDetail() {
                 if ((res as any).share_user) {
                     setShareUser((res as any).share_user)
                 }
+            }).catch(e => {
+                setLoaded(true)
+                setShowEmpty(true)
             })
         }
 
@@ -587,73 +601,74 @@ export default function TimelineDetail() {
 
 
     return <View style={{ display: 'flex', flex: 1, flexDirection: 'column', backgroundColor: '#fff', height: '101vh' }}>
-        <View className="detail_header">
-            <Image className="detail_header_header"
-                src={shareUser ? shareUser.avatar : user.avatar}
-                mode="aspectFill"
-            />
-            <View className="detail_header_content">
-                <Text className="detail_nickname">{shareUser ? shareUser.nickname : user.nickname}</Text>
-                {
-                    (!window_id || window_id == 'undefined') && (detail.scenario != 'MEAL' && detail.scenario != 'ACTIVITY') &&
-                    <TimeTitleDesc
-                        timeObj={detail.time}
-                        time={dayjs(detail.time.timestamp).format('HH:mm')}
-                        title={detail.title}
-                    />
-                }
-                {
-                    !window_id && detail.scenario == 'ACTIVITY' && !list &&
-                    <TimeTitleDesc
-                        timeObj={detail.time}
-                        time={dayjs(detail.time.timestamp).format('HH:mm')}
-                        title={detail.title}
-                    />
-                }
-                {
-                    list && list.map((item, index) => {
-                        return <View key={index} style={{ flexDirection: 'column', display: 'flex' }}>
-                            {
-                                (item.title || item.description) && <TimeTitleDesc
-                                    showPoint={detail.show}
-                                    timeObj={detail.time}
-                                    time={dayjs(item.time.timestamp).format('HH:mm')}
-                                    title={item.title}
-                                    desc={item.description}
-                                />
-                            }
-
-                        </View>
-                    })
-                }
-                {
-                    history && history.map((item, index) => {
-                        return <View key={index} style={{ flexDirection: 'column', display: 'flex' }}>
-                            {
-                                item.show && <TimeTitleDesc
-                                    timeObj={item.time}
-                                    time={dayjs(item.time.timestamp).format('HH:mm')}
-                                    title={item.title}
-                                    dayTag={dayTag(item)}
-                                    desc=''
-                                />
-                            }
-                            {
-                                item.moments && item.moments.map((moment, j) => {
-                                    return (moment.title || moment.description) && <View key={j * 10} style={{ flexDirection: 'column', display: 'flex' }}>
-                                        <TimeTitleDesc
-                                            showPoint={item.show}
-                                            timeObj={moment.time}
-                                            time={dayjs(moment.time.timestamp).format('HH:mm')}
-                                            title={moment.title}
-                                            dayTag={dayTag(moment)}
-                                            desc={moment.description}
-                                        />
-                                    </View>
-                                })
-                            }
+        {
+            !showEmpty && <View className="detail_header">
+                <Image className="detail_header_header"
+                    src={shareUser ? shareUser.avatar : user.avatar}
+                    mode="aspectFill"
+                />
+                <View className="detail_header_content">
+                    <Text className="detail_nickname">{shareUser ? shareUser.nickname : user.nickname}</Text>
+                    {
+                        (!window_id || window_id == 'undefined') && (detail.scenario != 'MEAL' && detail.scenario != 'ACTIVITY') &&
+                        <TimeTitleDesc
+                            timeObj={detail.time}
+                            time={dayjs(detail.time.timestamp).format('HH:mm')}
+                            title={detail.title}
+                        />
+                    }
+                    {
+                        !window_id && detail.scenario == 'ACTIVITY' && !list &&
+                        <TimeTitleDesc
+                            timeObj={detail.time}
+                            time={dayjs(detail.time.timestamp).format('HH:mm')}
+                            title={detail.title}
+                        />
+                    }
+                    {
+                        list && list.map((item, index) => {
+                            return <View key={index} style={{ flexDirection: 'column', display: 'flex' }}>
+                                {
+                                    (item.title || item.description) && <TimeTitleDesc
+                                        showPoint={detail.show}
+                                        timeObj={detail.time}
+                                        time={dayjs(item.time.timestamp).format('HH:mm')}
+                                        title={item.title}
+                                        desc={item.description}
+                                    />
+                                }
 
-                            {/* {
+                            </View>
+                        })
+                    }
+                    {
+                        history && history.map((item, index) => {
+                            return <View key={index} style={{ flexDirection: 'column', display: 'flex' }}>
+                                {
+                                    item.show && <TimeTitleDesc
+                                        timeObj={item.time}
+                                        time={dayjs(item.time.timestamp).format('HH:mm')}
+                                        title={item.title}
+                                        dayTag={dayTag(item)}
+                                        desc=''
+                                    />
+                                }
+                                {
+                                    item.moments && item.moments.map((moment, j) => {
+                                        return (moment.title || moment.description) && <View key={j * 10} style={{ flexDirection: 'column', display: 'flex' }}>
+                                            <TimeTitleDesc
+                                                showPoint={item.show}
+                                                timeObj={moment.time}
+                                                time={dayjs(moment.time.timestamp).format('HH:mm')}
+                                                title={moment.title}
+                                                dayTag={dayTag(moment)}
+                                                desc={moment.description}
+                                            />
+                                        </View>
+                                    })
+                                }
+
+                                {/* {
                                 item.moments && item.moments.map((moment, j) => {
                                     return <View key={j * 10} style={{ flexDirection: 'column', display: 'flex' }}>
                                         <TimeTitleDesc
@@ -675,10 +690,10 @@ export default function TimelineDetail() {
                                     desc=''
                                 />
                             } */}
-                        </View>
-                    })
-                }
-                {/* {
+                            </View>
+                        })
+                    }
+                    {/* {
                     <View className="media" style={{ marginRight: mediaCount() == 4 ? 80 : 0, marginTop: rpxToPx(24) }}>
                         {
                             list && list.map(moment => {
@@ -691,66 +706,84 @@ export default function TimelineDetail() {
 
                     </View>
                 } */}
-                {
-                    mediaCount() > 1 && <View style={{ marginTop: rpxToPx(17), display: 'flex', flexShrink: 0 }}>
-                        <CoverList imgs={imgList()} count={mediaCount()} />
-                    </View>
-                }
-                {
-                    mediaCount() == 1 && <View style={{ marginTop: rpxToPx(17), display: 'flex', flexShrink: 0 }}>
-                        <SingleImage url={imgList()[0]} />
-                    </View>
-                }
-                <View style={{ height: rpxToPx(17), flexShrink: 0, display: 'flex' }} />
-
-                {
-                    isfastsleep == '0' && history && detail.windows && detail.windows.map((item, index) => {
-                        return <TargetProgress key={index} showLine={index < detail.windows.length - 1}
-                            onClick={() => {
-                                vibrate()
-                            }}
-                            color={getThemeColor(item.window)}
-                            showRing={detail.fast_type == 'LF' ? false : true}
-                            desc={item.description}
-                            icon={
-                                detail.fast_type == 'LF' ? <IconLongFast color={MainColorType.fast} width={rpxToPx(32)} /> : null
-                            }
-                            canvasId={`${item.window}${item.window_range.start_timestamp}${index}aa`}
-                            startTimestamp={item.window_range.start_timestamp}
-                            endTimerstamp={item.window_range.end_timestamp}
+                    {
+                        mediaCount() > 1 && <View style={{ marginTop: rpxToPx(17), display: 'flex', flexShrink: 0 }}>
+                            <CoverList imgs={imgList()} count={mediaCount()} />
+                        </View>
+                    }
+                    {
+                        mediaCount() == 1 && <View style={{ marginTop: rpxToPx(17), display: 'flex', flexShrink: 0 }}>
+                            <SingleImage url={imgList()[0]} />
+                        </View>
+                    }
+                    <View style={{ height: rpxToPx(17), flexShrink: 0, display: 'flex' }} />
+
+                    {
+                        isfastsleep == '0' && history && detail.windows && detail.windows.map((item, index) => {
+                            return <TargetProgress key={index} showLine={index < detail.windows.length - 1}
+                                onClick={() => {
+                                    vibrate()
+                                }}
+                                color={getThemeColor(item.window)}
+                                showRing={detail.fast_type == 'LF' ? false : true}
+                                desc={item.description}
+                                icon={
+                                    detail.fast_type == 'LF' ? <IconLongFast color={MainColorType.fast} width={rpxToPx(32)} /> : null
+                                }
+                                canvasId={`${item.window}${item.window_range.start_timestamp}${index}aa`}
+                                startTimestamp={item.window_range.start_timestamp}
+                                endTimerstamp={item.window_range.end_timestamp}
+                            />
+                        })
+                    }
+                    {
+                        isfastsleep == '1' && history && detail.windows && detail.windows.length >= 2 && <TargetProgress
+                            onClick={showFastSleepPopDetail}
+                            showRing={true}
+                            doubleRing={true}
+                            first={detail.windows[0]}
+                            second={detail.windows[1]}
+                            canvasId={`double_${detail.windows[0].window_range.start_timestamp}`}
                         />
-                    })
-                }
-                {
-                    isfastsleep == '1' && history && detail.windows && detail.windows.length >= 2 && <TargetProgress
-                        onClick={showFastSleepPopDetail}
-                        showRing={true}
-                        doubleRing={true}
-                        first={detail.windows[0]}
-                        second={detail.windows[1]}
-                        canvasId={`double_${detail.windows[0].window_range.start_timestamp}`}
-                    />
-                }
-                {
-                    publish && <View style={{ display: 'flex', flexDirection: 'row', height: rpxToPx(60), marginTop: rpxToPx(17), alignItems: 'center' }}>
-                        {/* <Text className="h24 g02">{publish.edited ? '编辑于' : '发布于'}{dayjs(publish.timestamp).format('M月D日 HH:mm')}</Text> */}
-                        <Text className="h24 g02">{footerTime(publish)}</Text>
-                        <View style={{ flex: 1 }} />
-                        <View className="share_btn_bg">
-
-                            <View className="share_icon_bg">
-                                <IconShare color={MainColorType.link + 'cc'} width={rpxToPx(32)} />
+                    }
+                    {
+                        publish && <View style={{ display: 'flex', flexDirection: 'row', height: rpxToPx(60), marginTop: rpxToPx(17), alignItems: 'center' }}>
+                            {/* <Text className="h24 g02">{publish.edited ? '编辑于' : '发布于'}{dayjs(publish.timestamp).format('M月D日 HH:mm')}</Text> */}
+                            <Text className="h24 g02">{footerTime(publish)}</Text>
+                            <View style={{ flex: 1 }} />
+                            <View className="share_btn_bg">
+
+                                <View className="share_icon_bg">
+                                    <IconShare color={MainColorType.link + 'cc'} width={rpxToPx(32)} />
+                                </View>
+                                <Button className="share_btn" openType="share">1</Button>
                             </View>
-                            <Button className="share_btn" openType="share">1</Button>
+                            {!router.params.uid && <NewButton
+                                type={NewButtonType.more}
+                                onClick={tapMore}
+                            />}
                         </View>
-                        {!router.params.uid && <NewButton
-                            type={NewButtonType.more}
-                            onClick={tapMore}
-                        />}
-                    </View>
-                }
+                    }
+                </View>
+            </View>
+        }
+        {
+            showEmpty && <View className="no_data_bg2" style={{ marginTop: rpxToPx(256) }}>
+                <View style={{
+                    backgroundColor: MainColorType.g04,
+                    width: rpxToPx(108),
+                    height: rpxToPx(108),
+                    borderRadius: rpxToPx(54),
+                    display: 'flex',
+                    alignItems: 'center',
+                    justifyContent: 'center'
+                }}>
+                    <IconError width={rpxToPx(88)} color="#fff" />
+                </View>
+                <Text className="h50 g01 bold" style={{ marginBottom: rpxToPx(92), marginTop: rpxToPx(24) }}>{t('health.no_content')}</Text>
             </View>
-        </View>
+        }
+
         <Text style={{ opacity: 0 }}>{count}</Text>
         <ListFooter />
         {

+ 12 - 1
src/app.tsx

@@ -78,7 +78,18 @@ const App: React.FC<PropsWithChildren> = ({ children }) => {
     var value = Taro.getStorageSync('language')
     if (value) {
       // Do something with return value
-      global.language = value
+
+      if (value == 'wechat'){
+        const isZh = Taro.getAppBaseInfo().language == 'zh_CN'
+        global.language = isZh ? 'zh' : 'en'
+      }
+      else {
+        global.language = value
+      }
+      
+
+
+      
     }
     loadWXCache()
     global.isDebug = Taro.getStorageSync('isDebug')

+ 14 - 2
src/context/locales/en.js

@@ -999,7 +999,7 @@ export default {
         detail_complete_tip_head: 'All Completed Activity Logs will appear as a single ',
         detail_complete_tip_end: 'Journal Entry for the Day.',
 
-        title_journal: 'Journals',
+        title_journal: 'Journal',
         title_food_journal: 'Food Journal',
         title_active_journal: 'Activity Journal',
         journal_detail: 'Journal Details',
@@ -1012,7 +1012,7 @@ export default {
 
         metric: 'Metrics',
         photos: 'Photos',
-        schedules: 'Schedules',
+        schedules: 'Schedule',
         streaks: 'Streaks',
         windows: 'Windows',
         settings: 'Settings',
@@ -1079,5 +1079,17 @@ export default {
         del_cancel:'Cancel',
         meal_label:'Meal Label',
         activity_title:'Activity Title',
+
+        done:'Done',
+        share_moment:'Share Moment',
+        no_content:'No Content',
+
+        add_my_first_activity:'Add My First Activity',
+
+        choose_photo:'Choose from Photos',
+        camera:'Camera',
+        delete:'Delete',
+        photos:'Photos'
+
     }
 }

+ 9 - 1
src/context/locales/index.ts

@@ -9,7 +9,15 @@ function getLanguageSetting() {
   if (process.env.TARO_ENV == 'weapp') {
     var key = Taro.getStorageSync('language')
     if (key) {
-      initLocale(key)
+      if (key == 'wechat'){
+        const isZh = Taro.getAppBaseInfo().language == 'zh_CN'
+        // global.language = isZh ? 'zh' : 'en'
+        initLocale(isZh ? 'zh' : 'en')
+      }
+      else {
+        initLocale(key)
+      }
+      
     }
     else {
       initLocale('zh')

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

@@ -1082,5 +1082,16 @@ export default {
         del_cancel:'取消',
         meal_label:'餐次标签',
         activity_title:'活动标题',
+
+        done:'完成',
+        share_moment:'分享时刻',
+        no_content:'内容不存在',
+
+        add_my_first_activity:'添加我的第一个活动',
+
+        choose_photo:'从手机相册选择',
+        camera:'拍摄',
+        delete:'删除',
+        photos:'相册',
     }
 }

+ 4 - 0
src/features/health/History.scss

@@ -148,4 +148,8 @@
     width: 750px;
     box-sizing: border-box;
     // background-color: #fff;
+}
+
+.history_duration_placeholder{
+    
 }

+ 4 - 459
src/features/health/HistoryItem.tsx

@@ -37,200 +37,7 @@ export default function HistoryItem(props: {
     type?: string
 }) {
     const health = useSelector((state: any) => state.health);
-    let showActionSheetWithOptions;
-    function preview(obj) {
-        var list: any = []
 
-        props.data.events.map((item) => {
-            item.moments && item.moments.map(moment => {
-                moment.media && moment.media.map((obj) => {
-                    list.push(obj.url)
-                })
-            })
-
-        })
-
-
-        Taro.previewImage({
-            current: obj.url,
-            urls: list
-        })
-    }
-
-    //npm install react-native-text-size
-
-    function getTitle(item) {
-        if (item.title) return item.title
-        if (item.moments) {
-            return item.moments[0].title
-        }
-        // if (health.mode == 'FAST') {
-        //     return '开始断食'
-        // }
-        // else if (health.mode == 'SLEEP') {
-        //     return '开始睡眠'
-        // }
-        return ''
-    }
-
-    function ring() {
-        const common: RingCommon = {
-            useCase: 'ChooseScenario',
-            radius: 12,
-            lineWidth: 6,
-            isFast: true,
-            status: 'WAIT_FOR_START'
-        }
-
-        const bgRing: BgRing = {
-            color: MainColorType.ringBg
-        }
-
-        const realRing = {
-            hideBg: true,
-            color: props.mode == 'FAST,SLEEP' ? getThemeColor('FAST') : getThemeColor(health.mode),
-            startArc: startArc(props.data.window_range.start_timestamp),
-            durationArc: durationArc(props.data.window_range.start_timestamp, props.data.window_range.end_timestamp)
-        }
-        const canvasId = (props.mode == 'FAST,SLEEP' ? 'history_fast_sleep' + props.index : 'history_' + props.index) + props.type
-        return <Rings common={common} bgRing={bgRing} realRing={realRing} canvasId={canvasId} />
-    }
-
-    function ring2() {
-        const common: RingCommon = {
-            useCase: 'ChooseScenario',
-            radius: 12,
-            lineWidth: 6,
-            isFast: true,
-            status: 'WAIT_FOR_START'
-        }
-
-        const bgRing: BgRing = {
-            color: MainColorType.ringBg
-        }
-
-        const realRing = {
-            hideBg: true,
-            color: getThemeColor('SLEEP'),
-            startArc: startArc(props.data.events[1].time.timestamp),
-            durationArc: durationArc(props.data.events[1].time.timestamp, props.data.events[2].time.timestamp)
-        }
-
-
-        const canvasId = 'history2_props_mode' + props.index + props.type
-        return <Rings common={common} bgRing={bgRing} realRing={realRing} canvasId={canvasId} />
-    }
-
-    function mediaCount() {
-        let count = 0;
-        props.data.events.map((item) => {
-            if (item.moments) {
-                item.moments.map(moment => {
-                    moment.media.map((obj) => {
-                        count++
-                    })
-                })
-            }
-
-        })
-        return count;
-    }
-
-    function imgList() {
-        let array: any = [];
-        props.data.events.map((item) => {
-            if (item.moments) {
-                item.moments.map(moment => {
-                    moment.media.map((obj) => {
-                        array.push(obj.url)
-                    })
-                })
-            }
-
-        })
-        return array;
-    }
-
-    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: '确定要放弃本次断食吗?',
-            content: '放弃后断食不会本记录',
-            showCancel: true,
-            cancelText: '取消',
-            confirmText: '确定',
-            confirm: () => {
-                del()
-            }
-        })
-
-    }
-
-    function del() {
-        const { window_id } = props.data
-        delRecord({ ids: [window_id] }).then(res => {
-
-            global.refreshWindow()
-            global.refreshHistory()
-        })
-    }
-
-    function dayTag(index) {
-        if (index == 0) {
-            return ''
-        }
-        else {
-            var begin = props.data.events[0].time.timestamp
-            var end = props.data.events[index].time.timestamp
-
-            return TimeFormatter.dayTagText(begin, end)
-        }
-    }
 
     function goDetail(event_id?: any) {
         // debugger
@@ -243,246 +50,6 @@ export default function HistoryItem(props: {
 
     }
 
-    // if (props.mode == 'FAST,SLEEP'){
-    //     debugger
-    // }
-
-    function momentItem(moment) {
-        var hasImage = false
-        if (moment.media && moment.media.length > 0) hasImage = true
-        if (moment.title || moment.description) {
-            return <View style={{
-                display: 'flex',
-                flex: 1,
-                flexShrink: 0,
-                flexDirection: 'column',
-                backgroundColor: hasImage ? 'transparent' : '#fafafa',
-                paddingLeft: !hasImage ? rpxToPx(20) : rpxToPx(17),
-                paddingRight: !hasImage ? rpxToPx(20) : 0,
-                paddingTop: !hasImage ? rpxToPx(12) : 0,
-                paddingBottom: !hasImage ? rpxToPx(12) : 0
-            }}>
-                <TimeTitleDesc
-                    className={hasImage ? 'line3' : 'line2'}
-                    timeObj={moment.time}
-                    time=''
-                    // time={moment.time && dayjs(moment.time.timestamp).format('HH:mm')}
-                    // dayTag={dayTag(index)}
-                    title={moment.title}
-                    desc={moment.description}
-                />
-            </View>
-        }
-
-    }
-
-    function temp() {
-        return <View className="history_item2" onClick={goDetail}>
-            {/* <View className="cell_date" >
-                <View className="h42 w500" style={{ lineHeight: rpxToPx(60) + 'px' }}>{historyDate()}</View>
-                <View className="h24 w500" style={{ marginLeft: rpxToPx(6), marginTop: rpxToPx(13), lineHeight: rpxToPx(47) + 'px' }}>{historyMonth()}</View>
-            </View> */}
-            <TimelineDate timestamp={props.data.window_range.start_timestamp}
-                pre_timestamp={props.preData?props.preData.window_range.start_timestamp:null}
-            />
-            <View className="history_content" style={{ paddingTop: rpxToPx(4) }}>
-                {
-                    props.data.dataArray.map((content, i) => {
-                        return <View style={{ display: 'flex', flexDirection: 'row', marginBottom: rpxToPx(12), flex: 1 }} key={i}>
-                            {
-                                content.type == 'TEXT' && <View style={{
-                                    display: 'flex',
-                                    flex: 1,
-                                    flexShrink: 0,
-                                    flexDirection: 'column',
-                                    backgroundColor: '#fafafa',
-                                    paddingLeft: rpxToPx(20),
-                                    paddingRight: rpxToPx(20),
-                                    paddingTop: rpxToPx(12),
-                                    paddingBottom: rpxToPx(12)
-                                }}>{content.data.map((detail, j) => {
-                                    return <TimeTitleDesc
-                                        key={j * 100}
-                                        className={'line3'}
-                                        time=''
-                                        title={detail.title}
-                                        desc={detail.description}
-                                    />
-                                })}</View>
-                            }
-                            {
-                                content.type == 'PIC' && <CoverList imgs={content.data} count={content.data.length} />
-                            }
-                            {
-                                content.type == 'PIC_TEXT' && <Image
-                                    style={{ width: rpxToPx(178), height: rpxToPx(178), marginRight: rpxToPx(7), flexShrink: 0 }}
-                                    src={content.data[0].url}
-                                    onClick={(e) => {
-                                        if (process.env.TARO_ENV == 'weapp') {
-                                            e.stopPropagation()
-                                        }
-                                        Taro.previewImage({
-                                            current: content.data[0].url,
-                                            urls: [content.data[0].url]
-                                        })
-                                    }}
-                                    mode="aspectFill" />
-                            }
-                            {
-                                content.type == 'PIC_TEXT' && <View style={{
-                                    display: 'flex',
-                                    flex: 1,
-                                    flexShrink: 0,
-                                    flexDirection: 'column',
-                                    backgroundColor: 'transparent',
-                                    paddingLeft: rpxToPx(17),
-                                    paddingRight: 0,
-                                    paddingTop: 0,
-                                    paddingBottom: 0
-                                }}>
-                                    <TimeTitleDesc
-                                        className={'line3'}
-                                        time=''
-                                        title={content.data[0].title}
-                                        desc={content.data[0].description}
-                                    />
-                                </View>
-                            }
-                        </View>
-                    })
-                }
-                {/* {
-                props.data.events.map((event, i) => {
-                    return event.moments && event.moments.map((moment, j) => {
-                        return <View style={{ display: 'flex', flexDirection: 'row', marginBottom: rpxToPx(12), flex: 1 }} key={i * 100 + j}>
-                            {
-                                moment.media && moment.media.length > 0 && <Image
-                                    style={{ width: rpxToPx(178), height: rpxToPx(178), marginRight: rpxToPx(7), flexShrink: 0 }}
-                                    src={moment.media[0].url}
-                                    mode="aspectFill" />
-                            }
-                            {
-                                momentItem(moment)
-                            }
-                        </View>
-                    })
-                })
-            } */}
-
-                {/* <View style={{ display: 'flex', flexDirection: 'column', marginBottom: rpxToPx(12), flex: 1, paddingTop: rpxToPx(4) }}>
-                {
-                    props.data.events.map((item, index) => {
-                        return <TimeTitleDesc
-                            timeObj={item.time}
-                            time={item.time && dayjs(item.time.timestamp).format('HH:mm')}
-                            dayTag={dayTag(index)}
-                            title={getTitle(item)}
-                            desc={item.moments && item.moments.length > 0 ? item.moments[0].description : ''}
-                        />
-                    })
-                }
-            </View> */}
-                {/* {
-                mediaCount() > 0 && <CoverList count={mediaCount()} imgs={imgList()} />
-            } */}
-
-                {
-                    props.type != 'FAST,SLEEP' && props.mode != 'EAT' && props.mode != 'ACTIVE' && props.data.windows.map((item, index) => {
-                        return <TargetProgress key={index} showLine={index < props.data.windows.length - 1}
-                            color={getThemeColor(item.window)}
-                            showRing={props.fast_type != 'LF'}
-                            desc={item.description}
-                            icon={
-                                props.fast_type == 'LF' ? <IconLongFast color={MainColorType.fast} width={rpxToPx(32)} /> : null
-                            }
-                            canvasId={`${item.window}${item.window_range.start_timestamp}${index}`}
-                            startTimestamp={item.window_range.start_timestamp}
-                            endTimerstamp={item.window_range.end_timestamp}
-                        />
-                    })
-                }
-
-                {
-                    props.type == 'FAST,SLEEP' && <TargetProgress
-                        showRing={true}
-                        doubleRing={true}
-                        first={props.data.windows[0]}
-                        second={props.data.windows[1]}
-                        canvasId={`double_${props.data.windows[0].window_range.start_timestamp}`}
-                    />
-                }
-                {/* <TargetProgress showLine={props.mode == 'FAST,SLEEP' && props.data.events.length > 2}
-                color={props.mode == 'FAST,SLEEP' ? getThemeColor('FAST') : getThemeColor(health.mode)}
-                showRing={props.fast_type != 'LF'}
-                desc={props.data.window_range.end_timestamp ? formatMilliseconds(props.data.window_range.end_timestamp - props.data.window_range.start_timestamp) : ''}
-                icon={
-                    props.fast_type == 'LF' ? <IconLongFast color={MainColorType.fast} width={rpxToPx(32)} /> : null
-                }
-                canvasId={(props.mode == 'FAST,SLEEP' ? 'history_fast_sleep' + props.index : 'history_' + props.index) + props.type}
-                startTimestamp={props.data.window_range.start_timestamp}
-                endTimerstamp={props.data.window_range.end_timestamp}
-            />
-            {
-                props.mode == 'FAST,SLEEP' && props.data.events.length > 2 && <View className="history_duration_bg" style={{ marginTop: 0 }}>
-                    {
-                        props.fast_type != 'LF' && <View className="recent_ring_bg">
-                            {
-                                ring2()
-                            }
-                        </View>
-                    }
-                    {
-                        props.data.window_range.end_timestamp && <Text className="history_item_duration h26">{formatMilliseconds(props.data.events[2].time.timestamp - props.data.events[1].time.timestamp)}</Text>
-                    }
-                </View>
-            } */}
-                {/* {
-                props.isArchived && <View className="history_archived_row">
-                    <View className="history_archived" onClick={(e) => {
-                        if (process.env.TARO_ENV == 'weapp') {
-                            e.stopPropagation()
-                        }
-                        showActionSheet({
-                            showActionSheetWithOptions: showActionSheetWithOptions,
-                            title: 'Oprate Title',
-                            itemList: ['标记完成', '补记'],
-                            success: (res) => {
-                                // tapActionSheet(res)
-                                switch (res) {
-                                    case 1:
-                                        break;
-                                    case 0:
-                                        makeDone(props.data.window_id).then(res => {
-                                            global.refreshWindow()
-                                            global.refreshHistory()
-                                            if (props.refresh)
-                                                props.refresh()
-                                        })
-                                        break;
-                                }
-                            }
-                        });
-                    }}>
-                        <IconMore width={17} color="#b2b2b2" />
-                    </View>
-                </View>
-            } */}
-                <View style={{ height: rpxToPx(0), flexShrink: 0 }} />
-                {/* <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', height: rpxToPx(60), marginTop: rpxToPx(20) }}>
-                <View style={{ flex: 1 }} />
-                <NewButton type={NewButtonType.more}
-                    onClick={tapDel}
-                />
-            </View> */}
-            </View>
-            {/* 
-        {
-            !props.hideLine && <View className="border_footer_line" />
-        } */}
-
-        </View>
-    }
-
     function singleItem(type, url, obj, key) {
         return <View
             onClick={(e) => {
@@ -573,28 +140,6 @@ export default function HistoryItem(props: {
         if (props.data.texts.length == 0 && props.data.pics.length == 0) {
             return <View />
         }
-        // if (props.data.pics.length == 0) {
-        //     return <View style={{ display: 'flex', flexDirection: 'row', marginBottom: rpxToPx(12), flex: 1 }}><View style={{
-        //         display: 'flex',
-        //         flex: 1,
-        //         flexShrink: 0,
-        //         flexDirection: 'column',
-        //         backgroundColor: '#fafafa',
-        //         paddingLeft: rpxToPx(20),
-        //         paddingRight: rpxToPx(20),
-        //         paddingTop: rpxToPx(12),
-        //         paddingBottom: rpxToPx(12)
-        //     }}>{props.data.text.map((detail, j) => {
-        //         return <TimeTitleDesc
-        //             key={j * 100}
-        //             className={'line2'}
-        //             time=''
-        //             title={detail.title}
-        //             desc={detail.description}
-        //         />
-        //     })}</View>
-        //     </View>
-        // }
 
         return <View style={{ display: 'flex', flexDirection: 'row',
             // backgroundColor:'pink', 
@@ -642,10 +187,6 @@ export default function HistoryItem(props: {
     }
 
     return <View className="history_item2" onClick={goDetail}>
-        {/* <View className="cell_date" >
-            <View className="h42 w500" style={{ lineHeight: rpxToPx(60) + 'px' }}>{historyDate()}</View>
-            <View className="h24 w500" style={{ marginLeft: rpxToPx(6), marginTop: rpxToPx(13), lineHeight: rpxToPx(47) + 'px' }}>{historyMonth()}</View>
-        </View> */}
         <TimelineDate timestamp={props.data.window_range.start_timestamp}
                 pre_timestamp={props.preData?props.preData.window_range.start_timestamp:null}
             />
@@ -770,6 +311,10 @@ export default function HistoryItem(props: {
                     canvasId={`double_${props.data.windows[0].window_range.start_timestamp}`}
                 />
             }
+            {/* fast_sleep双环无法展示时,显示一个placeholder 骨架图 */}
+            {
+                props.type == 'FAST,SLEEP' && props.data.windows.length<2 && <View className='history_duration_bg' />
+            }
             <View style={{ height: rpxToPx(0), flexShrink: 0 }} />
         </View>
 

+ 17 - 38
src/features/health/MainConsole.tsx

@@ -34,6 +34,7 @@ let useNavigation;
 let min = 0
 let max = 0
 let defaultTimestamp = 0
+let guideIndex = 0
 
 let lastFastSleepStatus = ''
 
@@ -166,7 +167,7 @@ export default function MainConsole(props: { type: WindowType }) {
             case 'MARK_DONE':
                 {
                     setBtnDisable(true)
-                    clockTimes({
+                    clockTimes('',{
                         check_items: [{
                             schedule_id: item.schedule_id,
                             date: dayjs().format('YYYYMMDD'),
@@ -638,6 +639,12 @@ export default function MainConsole(props: { type: WindowType }) {
                 list = active.timeline
                 if (active.onboard == false && active.status == 'WFS') {
                     var seconds = new Date().getSeconds()
+                    if (seconds%3==0){
+                        guideIndex++;
+                        if (guideIndex>=list.length){
+                            guideIndex = 0
+                        }
+                    }
 
                     // return <Swiper autoplay>
                     //     {
@@ -658,9 +665,9 @@ export default function MainConsole(props: { type: WindowType }) {
                     //         })
                     //     }
                     // </Swiper>
-                    return <OnBoard title={list[0].title}
-                        desc={list[0].time_label}
-                        btnTitle="Create My Activities"
+                    return <OnBoard title={list[guideIndex].title}
+                        desc={list[guideIndex].time_label}
+                        btnTitle={t('health.add_my_first_activity')}
                         onClick={() => {
                             if (!user.isLogin) {
                                 jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
@@ -790,7 +797,9 @@ export default function MainConsole(props: { type: WindowType }) {
         var tomorrow = new Date(today.getTime() + 24 * 3600 * 1000 * 5)
         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:'加载中'
+        })
         systemLocation({
             lat: res.latitude,
             lng: res.longitude,
@@ -801,6 +810,9 @@ export default function MainConsole(props: { type: WindowType }) {
             coordinate_system_standard: process.env.TARO_ENV == 'weapp' ? 'GCJ-02' : 'WGS-84'
         }).then(data => {
             global.refreshWindow()
+            Taro.hideLoading()
+        }).catch((e)=>{
+            Taro.hideLoading()
         })
     }
 
@@ -981,39 +993,6 @@ export default function MainConsole(props: { type: WindowType }) {
                 <IconClose color={MainColorType.g03} width={rpxToPx(32)} height={rpxToPx(32)} />
             </NewButton>
         </View>
-        // var strTitle = ''
-        // if (scenario.archive_timestamp) {
-        //     var today = new Date().getDate()
-        //     var date = new Date(scenario.archive_timestamp).getDate()
-        //     if (today == date) {
-        //         strTitle = t('health.tonight_at', { time: dayjs(scenario.archive_timestamp).format('HH:mm') })
-        //     }
-        //     else {
-        //         strTitle = t('health.tomorrow_at', { time: dayjs(scenario.archive_timestamp).format('HH:mm') })
-        //     }
-        // }
-
-        // return <View className="mark_done_tip" style={{
-        //     backgroundColor: getThemeColor(health.mode) + '1A'
-        // }}>
-        //     <View style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
-        //         <Text className="h24 bold" style={{ color: getThemeColor(health.mode) }}>{strTitle}</Text>
-        //         <Text className="h24 bold">{t('health.all_logs', { scenario: health.mode == 'EAT' ? t('health.meals') : t('health.activities') })}<Text style={{ fontWeight: 'normal' }}>{t('health.will_collected')}</Text>{t('health.journal_end')}</Text>
-        //     </View>
-        //     <NewButton type={NewButtonType.img} btnStyle={{
-        //         height: rpxToPx(32),
-        //         width: rpxToPx(32)
-        //     }} onClick={() => {
-        //         if (health.mode == 'EAT') {
-        //             setHideEatArchiveTip(true)
-        //         }
-        //         else {
-        //             setHideActiveArchiveTip(true)
-        //         }
-        //     }}>
-        //         <IconClose color={MainColorType.g01} width={rpxToPx(32)} height={rpxToPx(32)} />
-        //     </NewButton>
-        // </View>
     }
 
     if (health.mode == '') return <View />

+ 20 - 23
src/pages/account/JournalDetail.tsx

@@ -19,6 +19,7 @@ import { journalDetail } from "@/services/health";
 import { useTranslation } from "react-i18next";
 import { IconShare } from "@/components/basic/Icons";
 import NewButton, { NewButtonType } from "@/_health/base/new_button";
+import { SHARE_COVER_URL } from "@/services/http/api";
 
 let useRoute;
 let useNavigation;
@@ -54,15 +55,6 @@ export default function JournalDetail() {
     // const [detail, setDetail] = useState(JSON.parse(router.params.detail))
 
     useEffect(() => {
-        Taro.getImageInfo({
-            src: './share_01.jpg',
-            success(result) {
-                debugger
-            },
-            fail(res) {
-                debugger
-            },
-        })
         if (date || router.params.window) {
             var params: any = {
                 window: router.params.window
@@ -92,15 +84,20 @@ export default function JournalDetail() {
     if (process.env.TARO_ENV == 'weapp') {
         useShareAppMessage((e) => {
             var title = t('health.share_my_journal')
+            var defaultImg = SHARE_COVER_URL + 'my_journal.jpg'
             if (router.params.window == 'EAT') {
                 title = t('health.share_my_food_journal')
+                defaultImg = SHARE_COVER_URL + 'my_meal_journal.jpg'
             }
             else if (router.params.window == 'ACTIVE') {
                 title = t('health.share_my_activity_journal')
+                defaultImg = SHARE_COVER_URL + 'my_activity_journal.jpg'
             }
+
+            console.log('share img url', defaultImg)
             const uid = router.params.uid
 
-            var imageUrl = imgs.length > 0 ? imgs[0] : 'https://background-pictures.oss-cn-beijing.aliyuncs.com/windows/eat2.jpg'
+            var imageUrl = imgs.length > 0 ? imgs[0] : defaultImg
             return {
                 title: title,
                 path: `pages/account/JournalDetail?date=${date}&uid=${uid ?? user.id}&window=${router.params.window}`,
@@ -268,9 +265,9 @@ export default function JournalDetail() {
         </View>
     }
 
-    function backHome(){
+    function backHome() {
         Taro.reLaunch({
-            url:'/pages/clock/Clock'
+            url: '/pages/clock/Clock'
         })
     }
 
@@ -335,17 +332,17 @@ export default function JournalDetail() {
             </View>
 
             {
-            router.params.uid && <View className="main_footer" style={{backgroundColor:'#fff'}}>
-                <NewButton
-                    type={NewButtonType.fill}
-                    color={MainColorType.success}
-                    title={t('health.back_home')}
-                    width={rpxToPx(646)}
-                    height={rpxToPx(96)}
-                    onClick={backHome}
-                />
-            </View>
-        }
+                router.params.uid && <View className="main_footer" style={{ backgroundColor: '#fff' }}>
+                    <NewButton
+                        type={NewButtonType.fill}
+                        color={MainColorType.success}
+                        title={t('health.back_home')}
+                        width={rpxToPx(646)}
+                        height={rpxToPx(96)}
+                        onClick={backHome}
+                    />
+                </View>
+            }
 
 
         </View>

+ 87 - 27
src/pages/account/Setting.tsx

@@ -13,7 +13,7 @@ import { logoutSuccess } from "@/store/user";
 import { kIsAndroid, rpxToPx } from "@/utils/tools";
 import { View, Text, Button } from "@tarojs/components";
 import Taro from "@tarojs/taro";
-import { useEffect } from "react";
+import { useEffect, useState } from "react";
 import { useTranslation } from "react-i18next";
 import { useDispatch, useSelector } from "react-redux";
 
@@ -29,6 +29,7 @@ export default function Page() {
     const dispatch = useDispatch();
     const { t, i18n } = useTranslation()
     const user = useSelector((state: any) => state.user);
+    const [languageType, setLanguageType] = useState('')
     let showActionSheetWithOptions;
     if (process.env.TARO_ENV == 'rn') {
         showActionSheetWithOptions = useActionSheet()
@@ -50,8 +51,33 @@ export default function Page() {
         Taro.getStorage({ key: 'notification' }).then(res => {
             hasCache = true;
         })
+
+        loadLanguage()
+
+
+        console.log(Taro.getAppBaseInfo().language)
     }, [])
 
+    async function loadLanguage() {
+        var lg = await getStorage('language')
+        if (lg.length > 0) {
+            switch (lg) {
+                case 'wechat':
+                    setLanguageType('微信系统语言')
+                    break
+                case 'zh':
+                    setLanguageType('中文')
+                    break
+                case 'en':
+                    setLanguageType('English')
+                    break
+            }
+        }
+        else {
+            setLanguageType('中文')
+        }
+    }
+
     async function getStorage(key: string) {
         try {
             const res = await Taro.getStorage({ key });
@@ -145,17 +171,51 @@ 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')
-        }
+    function changeLanguage() {
+        showActionSheet({
+            alertText: '更改语言',
+            itemList: ['中文', 'English', '微信系统语言'],
+            success: function (res) {
+                if (res != -1) {
+                    global.refreshWindow()
+                    if (global.refreshHistory) {
+                        global.refreshHistory()
+                    }
+                }
+                switch (res) {
+                    case 0:
+                        global.language = 'zh'
+                        Taro.setStorageSync('language', 'zh')
+                        i18n.changeLanguage('zh')
+                        setLanguageType('中文')
+
+                        break;
+                    case 1:
+                        global.language = 'en'
+                        Taro.setStorageSync('language', 'en')
+                        i18n.changeLanguage('en')
+                        setLanguageType('English')
+                        break;
+                    case 2:
+                        const isZh = Taro.getAppBaseInfo().language == 'zh_CN'
+                        global.language = isZh ? 'zh' : 'en'
+                        Taro.setStorageSync('language', 'wechat')
+                        i18n.changeLanguage(isZh ? 'zh' : 'en')
+                        setLanguageType('微信系统语言')
+                        break;
+                }
+            }
+        })
+        // 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 }}>
@@ -174,23 +234,23 @@ export default function Page() {
             }}>
                 <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 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'
-                
-            }}>
+            <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>
+                <Text className="h30" style={{ color: MainColorType.g01 }}>{languageType}</Text>
             </View>
         </Card>
         {

BIN
src/pages/account/share_01.jpg


+ 9 - 4
src/services/health.tsx

@@ -221,10 +221,11 @@ export const updateEventDuration = (id, duration) => {
     })
 }
 
-export const clockTimes = (params) => {
+export const clockTimes = (url,params) => {
+    debugger
     return new Promise((resolve, reject) => {
         request({
-            url: API_HEALTH_CLOCK, method: 'POST', data: { ...params }
+            url: API_HEALTH_CLOCK+url, method: 'POST', data: { ...params }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
@@ -360,23 +361,27 @@ export const setMoveSchedules = (params) => {
 }
 
 export const getEvents = (id,params) => {
-    return new Promise((resolve) => {
+    return new Promise((resolve,reject) => {
         request({
             url: API_HEALTH_EVENTS + '/' + id, method: 'GET', data: {...params}
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
+        }).catch(e=>{
+            reject(e)
         })
     })
 }
 
 export const getRecordDetail = (id, params) => {
-    return new Promise((resolve) => {
+    return new Promise((resolve,reject) => {
         request({
             url: API_HEALTH_RECORD + '/' + id, method: 'GET', data: { ...params }
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
+        }).catch(e=>{
+            reject(e)
         })
     })
 }

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

@@ -3,7 +3,7 @@ const online = process.env.TARO_ENV == 'weapp' ? false : false;
 import { WX_VERSION as _WX_VERSION, APP_VERSION as _APP_VERSION, ANDROID_VERSION as _ANDROID_VERSION } from "../../../config/env";
 
 // export const baseUrl = online ? 'https://api.fast.liveplus.fun' : 'https://api.fast.dev.liveplus.fun';
-export const baseUrl = online ? process.env.TARO_ENV == 'rn' ? 'https://api.app.fast.liveplus.fun' : 'https://api.fast.liveplus.fun' : 'https://api.fast.dev.liveplus.fun';
+export const baseUrl = online ? process.env.TARO_ENV == 'rn' ? 'https://api.app.fast.liveplus.fun' : 'https://api.fast.liveplus.fun' : 'https://api.fast.dev.liveplus.fun';//'https://api.pre.fast.liveplus.fun'//'https://api.fast.dev.liveplus.fun';
 
 export const APP_VERSION = _APP_VERSION
 export const WX_VERSION = _WX_VERSION
@@ -13,6 +13,8 @@ export let imgUrl = online
     ? 'https://api.fast.liveplus.fun/static/image/'
     : 'https://api.fast.dev.liveplus.fun/static/image/';
 
+export const SHARE_COVER_URL = 'https://background-pictures.oss-cn-beijing.aliyuncs.com/share_cover/'
+
 //common
 export const API_ADJUST_TIMES = `${baseUrl}/api/fast/adjust-times`
 // export const API_WX_PUB_FOLLOWED = `${baseUrl}/api/fast/user/wx-pub-followed`