|
|
@@ -1,6 +1,6 @@
|
|
|
import { View, Text, Image } from "@tarojs/components";
|
|
|
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
|
-import { records } from "@/services/health";
|
|
|
+import { getLatestJournal, records } from "@/services/health";
|
|
|
import './History.scss'
|
|
|
import Calendar from "./calendar";
|
|
|
import { useDispatch, useSelector } from "react-redux";
|
|
|
@@ -17,6 +17,7 @@ import NoRecord from "@/_health/components/no_record";
|
|
|
import ListFooter from "@/_health/components/list_footer";
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
import { setActiveTip, setEatTip, setFirstActiveId, setFirstEatId } from "@/store/health";
|
|
|
+import RightArrowRow from "@/_health/components/right_arrow_row";
|
|
|
|
|
|
let lastMode = ''
|
|
|
let myScrollTop = 0
|
|
|
@@ -64,6 +65,9 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
|
|
|
global.refreshHistory = () => {
|
|
|
refresh()
|
|
|
+
|
|
|
+ refreshEat()
|
|
|
+ refreshActive()
|
|
|
}
|
|
|
|
|
|
useEffect(() => {
|
|
|
@@ -174,6 +178,210 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
loadData(index)
|
|
|
}
|
|
|
|
|
|
+ function refreshEat() {
|
|
|
+ var params: any = {
|
|
|
+ window: 'EAT',
|
|
|
+ limit: 10,
|
|
|
+ page: 1
|
|
|
+ }
|
|
|
+
|
|
|
+ records(params).then(res => {
|
|
|
+ var array = (res as any).data
|
|
|
+
|
|
|
+ array.map(item => {
|
|
|
+ var temps: any = []
|
|
|
+ var lastType = ''
|
|
|
+ var lastTextArray: any = []
|
|
|
+ var lastImageArray: any = []
|
|
|
+ item.events.map(event => {
|
|
|
+ event.moments && event.moments.map(moment => {
|
|
|
+ switch (moment.type) {
|
|
|
+ case 'TEXT':
|
|
|
+ {
|
|
|
+ lastTextArray.push({
|
|
|
+ title: moment.title,
|
|
|
+ description: moment.description,
|
|
|
+ event_id: event.id
|
|
|
+ })
|
|
|
+ if (lastType == 'PIC') {
|
|
|
+ temps.push({
|
|
|
+ type: 'PIC',
|
|
|
+ data: JSON.parse(JSON.stringify(lastImageArray))
|
|
|
+ })
|
|
|
+ lastImageArray = []
|
|
|
+ }
|
|
|
+ lastType = 'TEXT'
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'PIC':
|
|
|
+ {
|
|
|
+ lastImageArray.push(moment.media[0].url)
|
|
|
+ if (lastType == 'TEXT') {
|
|
|
+ temps.push({
|
|
|
+ type: 'TEXT',
|
|
|
+ data: JSON.parse(JSON.stringify(lastTextArray))
|
|
|
+ })
|
|
|
+ lastTextArray = []
|
|
|
+ }
|
|
|
+ lastType = 'PIC'
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'PIC_TEXT':
|
|
|
+ if (lastType == 'PIC') {
|
|
|
+ temps.push({
|
|
|
+ type: 'PIC',
|
|
|
+ data: JSON.parse(JSON.stringify(lastImageArray))
|
|
|
+ })
|
|
|
+ lastImageArray = []
|
|
|
+ }
|
|
|
+ if (lastType == 'TEXT') {
|
|
|
+ temps.push({
|
|
|
+ type: 'TEXT',
|
|
|
+ data: JSON.parse(JSON.stringify(lastTextArray))
|
|
|
+ })
|
|
|
+ lastTextArray = []
|
|
|
+ }
|
|
|
+ temps.push({
|
|
|
+ type: 'PIC_TEXT',
|
|
|
+ data: [
|
|
|
+ {
|
|
|
+ title: moment.title,
|
|
|
+ description: moment.description,
|
|
|
+ url: moment.media[0].url,
|
|
|
+ event_id: event.id
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ })
|
|
|
+ lastType = 'PIC_TEXT'
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ if (lastType == 'PIC') {
|
|
|
+ temps.push({
|
|
|
+ type: 'PIC',
|
|
|
+ data: JSON.parse(JSON.stringify(lastImageArray))
|
|
|
+ })
|
|
|
+ lastImageArray = []
|
|
|
+ }
|
|
|
+ if (lastType == 'TEXT') {
|
|
|
+ temps.push({
|
|
|
+ type: 'TEXT',
|
|
|
+ data: JSON.parse(JSON.stringify(lastTextArray))
|
|
|
+ })
|
|
|
+ lastTextArray = []
|
|
|
+ }
|
|
|
+
|
|
|
+ item.dataArray = temps;
|
|
|
+ })
|
|
|
+
|
|
|
+ setEatList(array)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ function refreshActive() {
|
|
|
+ var params: any = {
|
|
|
+ window: 'ACTIVE',
|
|
|
+ limit: 10,
|
|
|
+ page: 1
|
|
|
+ }
|
|
|
+
|
|
|
+ records(params).then(res => {
|
|
|
+ var array = (res as any).data
|
|
|
+
|
|
|
+ array.map(item => {
|
|
|
+ var temps: any = []
|
|
|
+ var lastType = ''
|
|
|
+ var lastTextArray: any = []
|
|
|
+ var lastImageArray: any = []
|
|
|
+ item.events.map(event => {
|
|
|
+ event.moments && event.moments.map(moment => {
|
|
|
+ switch (moment.type) {
|
|
|
+ case 'TEXT':
|
|
|
+ {
|
|
|
+ lastTextArray.push({
|
|
|
+ title: moment.title,
|
|
|
+ description: moment.description,
|
|
|
+ event_id: event.id
|
|
|
+ })
|
|
|
+ if (lastType == 'PIC') {
|
|
|
+ temps.push({
|
|
|
+ type: 'PIC',
|
|
|
+ data: JSON.parse(JSON.stringify(lastImageArray))
|
|
|
+ })
|
|
|
+ lastImageArray = []
|
|
|
+ }
|
|
|
+ lastType = 'TEXT'
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'PIC':
|
|
|
+ {
|
|
|
+ lastImageArray.push(moment.media[0].url)
|
|
|
+ if (lastType == 'TEXT') {
|
|
|
+ temps.push({
|
|
|
+ type: 'TEXT',
|
|
|
+ data: JSON.parse(JSON.stringify(lastTextArray))
|
|
|
+ })
|
|
|
+ lastTextArray = []
|
|
|
+ }
|
|
|
+ lastType = 'PIC'
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'PIC_TEXT':
|
|
|
+ if (lastType == 'PIC') {
|
|
|
+ temps.push({
|
|
|
+ type: 'PIC',
|
|
|
+ data: JSON.parse(JSON.stringify(lastImageArray))
|
|
|
+ })
|
|
|
+ lastImageArray = []
|
|
|
+ }
|
|
|
+ if (lastType == 'TEXT') {
|
|
|
+ temps.push({
|
|
|
+ type: 'TEXT',
|
|
|
+ data: JSON.parse(JSON.stringify(lastTextArray))
|
|
|
+ })
|
|
|
+ lastTextArray = []
|
|
|
+ }
|
|
|
+ temps.push({
|
|
|
+ type: 'PIC_TEXT',
|
|
|
+ data: [
|
|
|
+ {
|
|
|
+ title: moment.title,
|
|
|
+ description: moment.description,
|
|
|
+ url: moment.media[0].url,
|
|
|
+ event_id: event.id
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ })
|
|
|
+ lastType = 'PIC_TEXT'
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ if (lastType == 'PIC') {
|
|
|
+ temps.push({
|
|
|
+ type: 'PIC',
|
|
|
+ data: JSON.parse(JSON.stringify(lastImageArray))
|
|
|
+ })
|
|
|
+ lastImageArray = []
|
|
|
+ }
|
|
|
+ if (lastType == 'TEXT') {
|
|
|
+ temps.push({
|
|
|
+ type: 'TEXT',
|
|
|
+ data: JSON.parse(JSON.stringify(lastTextArray))
|
|
|
+ })
|
|
|
+ lastTextArray = []
|
|
|
+ }
|
|
|
+
|
|
|
+ item.dataArray = temps;
|
|
|
+ })
|
|
|
+
|
|
|
+ setActiveList(array)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
function loadData(index: number) {
|
|
|
var params: any = {
|
|
|
window: props.type ? props.type : health.mode,
|
|
|
@@ -284,22 +492,22 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
if (!props.type && array.length > 0) {
|
|
|
if (health.mode == 'EAT') {
|
|
|
setEatList(array)
|
|
|
- dispatch(setFirstEatId(array[0].window_id))
|
|
|
- if (health.first_eat_id.length > 0 && health.first_eat_id != array[0].window_id) {
|
|
|
- dispatch(setEatTip(true))
|
|
|
- }
|
|
|
+ // dispatch(setFirstEatId(array[0].window_id))
|
|
|
+ // if (health.first_eat_id.length > 0 && health.first_eat_id != array[0].window_id) {
|
|
|
+ // dispatch(setEatTip(true))
|
|
|
+ // }
|
|
|
}
|
|
|
else if (health.mode == 'ACTIVE') {
|
|
|
setActiveList(array)
|
|
|
- dispatch(setFirstActiveId(array[0].window_id))
|
|
|
- if (health.first_active_id.length > 0 && health.first_active_id != array[0].window_id) {
|
|
|
- dispatch(setActiveTip(true))
|
|
|
- }
|
|
|
+ // dispatch(setFirstActiveId(array[0].window_id))
|
|
|
+ // if (health.first_active_id.length > 0 && health.first_active_id != array[0].window_id) {
|
|
|
+ // dispatch(setActiveTip(true))
|
|
|
+ // }
|
|
|
}
|
|
|
- else if (health.mode == 'FAST'){
|
|
|
+ else if (health.mode == 'FAST') {
|
|
|
setFastList(array)
|
|
|
}
|
|
|
- else if (health.mode == 'SLEEP'){
|
|
|
+ else if (health.mode == 'SLEEP') {
|
|
|
setSleepList(array)
|
|
|
}
|
|
|
}
|
|
|
@@ -350,7 +558,7 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
}
|
|
|
else {
|
|
|
var currentDate = global.language == 'en' ? dayjs(list[index].window_range.start_timestamp).format('YYYY') : dayjs(list[index].window_range.start_timestamp).format('YYYY年')
|
|
|
- var now = global.language == 'en' ? dayjs(list[index-1].window_range.start_timestamp).format('YYYY') : dayjs(list[index-1].window_range.start_timestamp).format('YYYY年')
|
|
|
+ var now = global.language == 'en' ? dayjs(list[index - 1].window_range.start_timestamp).format('YYYY') : dayjs(list[index - 1].window_range.start_timestamp).format('YYYY年')
|
|
|
if (currentDate != now) {
|
|
|
showDate = true
|
|
|
dateStr = currentDate
|
|
|
@@ -411,7 +619,7 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
return <Image src={item} key={index} className="archived_img" mode="aspectFill" />
|
|
|
})
|
|
|
}
|
|
|
- <IconArrow color={MainColorType.g03} width={rpxToPx(34)} />
|
|
|
+ <IconArrow color={MainColorType.g02} width={rpxToPx(34)} />
|
|
|
</View>
|
|
|
<View className="border_footer_line" />
|
|
|
</View>
|
|
|
@@ -422,13 +630,13 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
|
|
|
if (!user.isLogin) return <View />
|
|
|
|
|
|
- function showTipF(){
|
|
|
+ function showTipF() {
|
|
|
var showTip = false
|
|
|
- if (getScenario(health.windows,health.mode).status == 'OG'){
|
|
|
- if (health.mode == 'EAT'){
|
|
|
+ if (getScenario(health.windows, health.mode).status == 'OG') {
|
|
|
+ if (health.mode == 'EAT') {
|
|
|
showTip = !global.hideEatArchiveTip
|
|
|
}
|
|
|
- else if (health.mode == 'ACTIVE'){
|
|
|
+ else if (health.mode == 'ACTIVE') {
|
|
|
showTip = !global.hideActiveArchiveTip
|
|
|
}
|
|
|
}
|
|
|
@@ -438,15 +646,15 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
function newJournalTip() {
|
|
|
if (!props.type) {
|
|
|
var show = false
|
|
|
-
|
|
|
+
|
|
|
if (health.mode == 'EAT' && health.eat_journal_tip) {
|
|
|
show = true
|
|
|
}
|
|
|
else if (health.mode == 'ACTIVE' && health.active_journal_tip) {
|
|
|
show = true
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
if (show) {
|
|
|
return <View style={{
|
|
|
@@ -461,9 +669,14 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
<View className="archived_bg" onClick={() => {
|
|
|
// jumpPage('/_health/pages/archive')
|
|
|
var data = list[0]
|
|
|
- jumpPage(`/_health/pages/timeline_detail?window_id=${data.window_id}&type=recent&isfastsleep=0&
|
|
|
-
|
|
|
- timestamp=${data.publish.timestamp}`)
|
|
|
+ jumpPage(`/_health/pages/timeline_detail?window_id=${data.window_id}&type=recent&isfastsleep=0×tamp=${data.publish.timestamp}`)
|
|
|
+
|
|
|
+ getLatestJournal(false, {
|
|
|
+ id: health.mode == 'EAT' ? global.eatTipId : global.activeTipId,
|
|
|
+ user_confirmed: true
|
|
|
+ }).then(res => {
|
|
|
+
|
|
|
+ })
|
|
|
setTimeout(() => {
|
|
|
if (health.mode == 'EAT') {
|
|
|
dispatch(setEatTip(false))
|
|
|
@@ -480,7 +693,7 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
return <Image src={item} key={index} className="archived_img" mode="aspectFill" />
|
|
|
})
|
|
|
} */}
|
|
|
- <IconArrow color={MainColorType.g03} width={rpxToPx(34)} />
|
|
|
+ <IconArrow color={MainColorType.g02} width={rpxToPx(34)} />
|
|
|
</View>
|
|
|
<View className="border_footer_line" />
|
|
|
</View>
|
|
|
@@ -510,14 +723,14 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
return <View />
|
|
|
}
|
|
|
|
|
|
- return <View style={{ width: rpxToPx(750), marginTop: rpxToPx(36) }}>
|
|
|
+ return <View style={{ width: rpxToPx(750), marginTop: rpxToPx(60) }}>
|
|
|
|
|
|
{
|
|
|
- (list.length >= 0 || health.mode == 'EAT') && <View className="recent">
|
|
|
- <Text className="h42 bold" >{t('health.recents')}</Text>
|
|
|
+ (list.length >= 0 || health.mode == 'EAT') && <View className="new_header_bg">
|
|
|
+ <Text className="h50 bold">{t('health.recents')}</Text>
|
|
|
{
|
|
|
- (health.mode == 'EAT' || health.mode == 'ACTIVE') && <View onClick={() => {
|
|
|
- jumpPage('/pages/account/Journal?type=' + health.mode+`&show_tip=${showTipF()?'1':'0'}`)
|
|
|
+ false && (health.mode == 'EAT' || health.mode == 'ACTIVE') && <View onClick={() => {
|
|
|
+ jumpPage('/pages/account/Journal?type=' + health.mode + `&show_tip=${showTipF() ? '1' : '0'}`)
|
|
|
setTimeout(() => {
|
|
|
health.mode == 'EAT' ? setShowEatArchive(false) : setShowActiveArchive(false)
|
|
|
}, 1000)
|
|
|
@@ -546,6 +759,36 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
{
|
|
|
newJournalTip()
|
|
|
}
|
|
|
+ {
|
|
|
+ (health.mode == 'EAT' || health.mode == 'ACTIVE') && <RightArrowRow title={health.mode == 'ACTIVE' ? t('health.title_active_journal') : t('health.title_food_journal')}
|
|
|
+ showBadge={(health.mode == 'EAT' && health.eat_journal_tip) ||
|
|
|
+ (health.mode == 'ACTIVE' && health.active_journal_tip)}
|
|
|
+ onClick={() => {
|
|
|
+ if ((health.mode == 'EAT' && health.eat_journal_tip) ||
|
|
|
+ (health.mode == 'ACTIVE' && health.active_journal_tip)) {
|
|
|
+ getLatestJournal(false, {
|
|
|
+ id: health.mode == 'EAT' ? global.eatTipId : global.activeTipId,
|
|
|
+ user_confirmed: true
|
|
|
+ }).then(res => {
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ if (health.mode == 'EAT') {
|
|
|
+ dispatch(setEatTip(false))
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ dispatch(setActiveTip(false))
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+
|
|
|
+ var showBadge = (health.mode == 'EAT' && health.eat_journal_tip) ||
|
|
|
+ (health.mode == 'ACTIVE' && health.active_journal_tip)
|
|
|
+ jumpPage('/pages/account/Journal?type=' + health.mode + `&show_tip=${showTipF() ? '1' : '0'}&show_badge=${showBadge ? 1 : 0}`)
|
|
|
+ }} />
|
|
|
+ }
|
|
|
{
|
|
|
list.length == 0 && <NoRecord />
|
|
|
}
|