|
@@ -144,7 +144,6 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
}, [health.mode])
|
|
}, [health.mode])
|
|
|
|
|
|
|
|
function measureItemLayouts() {
|
|
function measureItemLayouts() {
|
|
|
- console.log(new Date().getTime())
|
|
|
|
|
const query = Taro.createSelectorQuery()
|
|
const query = Taro.createSelectorQuery()
|
|
|
list.forEach((item, index) => {
|
|
list.forEach((item, index) => {
|
|
|
query.select(`#history-${index}`).boundingClientRect()
|
|
query.select(`#history-${index}`).boundingClientRect()
|
|
@@ -160,12 +159,29 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
});
|
|
});
|
|
|
setItemLayouts(layouts)
|
|
setItemLayouts(layouts)
|
|
|
setItemHeights(heights)
|
|
setItemHeights(heights)
|
|
|
- debugger
|
|
|
|
|
-
|
|
|
|
|
- console.log(new Date().getTime())
|
|
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function isTimestampInThisWeek(timestamp) {
|
|
|
|
|
+ const date = new Date(timestamp);
|
|
|
|
|
+
|
|
|
|
|
+ // 获取当前日期
|
|
|
|
|
+ const now = new Date();
|
|
|
|
|
+
|
|
|
|
|
+ // 获取本周的第一天(周一)
|
|
|
|
|
+ const startOfWeek = new Date(now);
|
|
|
|
|
+ startOfWeek.setDate(now.getDate() - now.getDay() + 1); // 计算本周周一
|
|
|
|
|
+ startOfWeek.setHours(0, 0, 0, 0); // 设置为当天的开始时间
|
|
|
|
|
+
|
|
|
|
|
+ // 获取本周的最后一天(周日)
|
|
|
|
|
+ const endOfWeek = new Date(startOfWeek);
|
|
|
|
|
+ endOfWeek.setDate(startOfWeek.getDate() + 6); // 计算本周周日
|
|
|
|
|
+ endOfWeek.setHours(23, 59, 59, 999); // 设置为当天的结束时间
|
|
|
|
|
+
|
|
|
|
|
+ // 判断时间戳是否在本周范围内
|
|
|
|
|
+ return date >= startOfWeek && date <= endOfWeek;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function onScroll(e) {
|
|
function onScroll(e) {
|
|
|
// var top = e.detail.scrollTop
|
|
// var top = e.detail.scrollTop
|
|
|
// myScrollTop = top
|
|
// myScrollTop = top
|
|
@@ -180,7 +196,18 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
list.forEach((item, index) => {
|
|
list.forEach((item, index) => {
|
|
|
if (top >= itemLayouts[index] - 50) {
|
|
if (top >= itemLayouts[index] - 50) {
|
|
|
i = index
|
|
i = index
|
|
|
- date = dayjs(item.window_range.start_timestamp).format('YYYY年M月')
|
|
|
|
|
|
|
+ if (isTimestampInThisWeek(item.window_range.start_timestamp)) {
|
|
|
|
|
+ date = t('health.this_week')
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (dayjs(item.window_range.start_timestamp).format('YYYY') == dayjs().format('YYYY')) {
|
|
|
|
|
+ date = global.language == 'en' ? dayjs(item.window_range.start_timestamp).format('MMMM') : dayjs(item.window_range.start_timestamp).format('MMMM')
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ date = global.language == 'en' ? dayjs(item.window_range.start_timestamp).format('MMMM YYYY') : dayjs(item.window_range.start_timestamp).format('YYYY年M月')
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
if (props.updateDate) {
|
|
if (props.updateDate) {
|
|
@@ -202,6 +229,7 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function refresh() {
|
|
function refresh() {
|
|
|
|
|
+
|
|
|
loadData(1)
|
|
loadData(1)
|
|
|
setPage(1)
|
|
setPage(1)
|
|
|
}
|
|
}
|
|
@@ -332,6 +360,13 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
|
|
|
|
|
|
|
|
|
|
function loadData(index: number) {
|
|
function loadData(index: number) {
|
|
|
|
|
+ // console.log('load data, page',index)
|
|
|
|
|
+ if (index == 1) {
|
|
|
|
|
+ Taro.setStorage({
|
|
|
|
|
+ key: 'lastRefresh',
|
|
|
|
|
+ data: new Date().getTime() + ''
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
var params: any = {
|
|
var params: any = {
|
|
|
window: props.type ? props.type : health.mode,
|
|
window: props.type ? props.type : health.mode,
|
|
|
limit: 10,
|
|
limit: 10,
|
|
@@ -579,12 +614,12 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
var data = list[0]
|
|
var data = list[0]
|
|
|
jumpPage(`/_health/pages/timeline_detail?window_id=${data.window_id}&type=recent&isfastsleep=0×tamp=${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 => {
|
|
|
|
|
|
|
+ // getLatestJournal(false, {
|
|
|
|
|
+ // id: health.mode == 'EAT' ? global.eatTipId : global.activeTipId,
|
|
|
|
|
+ // user_confirmed: true
|
|
|
|
|
+ // }).then(res => {
|
|
|
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ // })
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
if (health.mode == 'EAT') {
|
|
if (health.mode == 'EAT') {
|
|
|
dispatch(setEatTip(false))
|
|
dispatch(setEatTip(false))
|
|
@@ -752,7 +787,7 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
list.length > 0 && <View style={{ minHeight: rpxToPx(464), backgroundColor: '#fff', paddingTop: rpxToPx(60) }}>
|
|
list.length > 0 && <View style={{ minHeight: rpxToPx(464), backgroundColor: '#fff', paddingTop: rpxToPx(60) }}>
|
|
|
{
|
|
{
|
|
|
list.map((item, index) => {
|
|
list.map((item, index) => {
|
|
|
- if (itemLayouts.length >= index + 1 && index>5) {
|
|
|
|
|
|
|
+ if (itemLayouts.length >= index + 1 && index > 5) {
|
|
|
if (Math.abs(itemLayouts[index] - pageTop) > 2500) {
|
|
if (Math.abs(itemLayouts[index] - pageTop) > 2500) {
|
|
|
return <View style={{ height: itemHeights[index] }} id={`history-${index}`} key={index}>
|
|
return <View style={{ height: itemHeights[index] }} id={`history-${index}`} key={index}>
|
|
|
{
|
|
{
|