|
@@ -14,6 +14,7 @@ import Taro from "@tarojs/taro";
|
|
|
import StickyDateList from "@/_health/components/sticky_date_list";
|
|
import StickyDateList from "@/_health/components/sticky_date_list";
|
|
|
import ListFooter from "@/_health/components/list_footer";
|
|
import ListFooter from "@/_health/components/list_footer";
|
|
|
import CoverList from "@/_health/components/cover_list";
|
|
import CoverList from "@/_health/components/cover_list";
|
|
|
|
|
+import { TimeFormatter } from "@/utils/time_format";
|
|
|
|
|
|
|
|
let myScrollTop = 0
|
|
let myScrollTop = 0
|
|
|
export default function Album() {
|
|
export default function Album() {
|
|
@@ -77,30 +78,30 @@ export default function Album() {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function historyMonth(index, preIndex) {
|
|
|
|
|
- var showDate = false;
|
|
|
|
|
- var dateStr = ''
|
|
|
|
|
- if (index == 0) {
|
|
|
|
|
- var currentDate = (medias[index].date + '').substring(0, 6)
|
|
|
|
|
- var now = dayjs().format('YYYYMM')
|
|
|
|
|
|
|
+ // function historyMonth(index, preIndex) {
|
|
|
|
|
+ // var showDate = false;
|
|
|
|
|
+ // var dateStr = ''
|
|
|
|
|
+ // if (index == 0) {
|
|
|
|
|
+ // var currentDate = (medias[index].date + '').substring(0, 6)
|
|
|
|
|
+ // var now = dayjs().format('YYYYMM')
|
|
|
|
|
|
|
|
- showDate = true
|
|
|
|
|
- dateStr = currentDate.substring(0, 4) + '年' + currentDate.substring(4, 6) + '月'
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- var currentDate = (medias[index].date + '').substring(0, 6)
|
|
|
|
|
- var now = (medias[index - 1].date + '').substring(0, 6)
|
|
|
|
|
- if (currentDate != now) {
|
|
|
|
|
- showDate = true
|
|
|
|
|
- // dateStr = currentDate
|
|
|
|
|
- dateStr = currentDate.substring(0, 4) + '年' + currentDate.substring(4, 6) + '月'
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (showDate) {
|
|
|
|
|
- return <View className="history_year_month h30 g01">{dateStr}</View>
|
|
|
|
|
- }
|
|
|
|
|
- return <View />
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // showDate = true
|
|
|
|
|
+ // dateStr = currentDate.substring(0, 4) + '年' + currentDate.substring(4, 6) + '月'
|
|
|
|
|
+ // }
|
|
|
|
|
+ // else {
|
|
|
|
|
+ // var currentDate = (medias[index].date + '').substring(0, 6)
|
|
|
|
|
+ // var now = (medias[index - 1].date + '').substring(0, 6)
|
|
|
|
|
+ // if (currentDate != now) {
|
|
|
|
|
+ // showDate = true
|
|
|
|
|
+ // // dateStr = currentDate
|
|
|
|
|
+ // dateStr = currentDate.substring(0, 4) + '年' + currentDate.substring(4, 6) + '月'
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // if (showDate) {
|
|
|
|
|
+ // return <View className="history_year_month h30 g01">{dateStr}</View>
|
|
|
|
|
+ // }
|
|
|
|
|
+ // return <View />
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
function measureItemLayouts() {
|
|
function measureItemLayouts() {
|
|
|
const query = Taro.createSelectorQuery()
|
|
const query = Taro.createSelectorQuery()
|
|
@@ -111,7 +112,7 @@ export default function Album() {
|
|
|
var layouts: any = []
|
|
var layouts: any = []
|
|
|
res.forEach((rect, index) => {
|
|
res.forEach((rect, index) => {
|
|
|
if (rect) {
|
|
if (rect) {
|
|
|
- layouts[index] = rect.top+myScrollTop
|
|
|
|
|
|
|
+ layouts[index] = rect.top + myScrollTop
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
setItemLayouts(layouts)
|
|
setItemLayouts(layouts)
|
|
@@ -142,6 +143,80 @@ export default function Album() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function historyYear(index) {
|
|
|
|
|
+ var showDate = false;
|
|
|
|
|
+ var dateStr2:any = ''
|
|
|
|
|
+ if (index == 0) {
|
|
|
|
|
+ var currentDate = global.language == 'en' ? dayjs(medias[index].timestamp).format('YYYY') : dayjs(medias[index].timestamp).format('YYYY年')
|
|
|
|
|
+ var now = global.language == 'en' ? dayjs().format('YYYY') : dayjs().format('YYYY年')
|
|
|
|
|
+
|
|
|
|
|
+ if (currentDate != now) {
|
|
|
|
|
+ showDate = true
|
|
|
|
|
+ dateStr2 = currentDate
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ var currentDate = global.language == 'en' ? dayjs(medias[index].timestamp).format('YYYY') : dayjs(medias[index].timestamp).format('YYYY年')
|
|
|
|
|
+ var now = global.language == 'en' ? dayjs().format('YYYY') : dayjs().format('YYYY年')
|
|
|
|
|
+ if (currentDate != now) {
|
|
|
|
|
+ showDate = true
|
|
|
|
|
+ dateStr2 = currentDate
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (showDate) {
|
|
|
|
|
+ return <View className="history_year_month h42 bold">{dateStr2}</View>
|
|
|
|
|
+ }
|
|
|
|
|
+ return <View />
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function historyDate(item, index) {
|
|
|
|
|
+ if (index == 0) {
|
|
|
|
|
+ if (global.language == 'zh' && TimeFormatter.isToday(item.timestamp)) {
|
|
|
|
|
+ return '今天'
|
|
|
|
|
+ }
|
|
|
|
|
+ if (global.language == 'zh' && TimeFormatter.isYesterday(item.timestamp)) {
|
|
|
|
|
+ return '昨天'
|
|
|
|
|
+ }
|
|
|
|
|
+ return dayjs(item.timestamp).format('DD')
|
|
|
|
|
+ }
|
|
|
|
|
+ if (dayjs(item.timestamp).format('MM-DD') ==
|
|
|
|
|
+ dayjs(medias[index - 1].timestamp).format('MM-DD')) {
|
|
|
|
|
+ return ''
|
|
|
|
|
+ }
|
|
|
|
|
+ if (global.language == 'zh' && TimeFormatter.isToday(item.timestamp)) {
|
|
|
|
|
+ return '今天'
|
|
|
|
|
+ }
|
|
|
|
|
+ if (global.language == 'zh' && TimeFormatter.isYesterday(item.timestamp)) {
|
|
|
|
|
+ return '昨天'
|
|
|
|
|
+ }
|
|
|
|
|
+ return dayjs(item.timestamp).format('DD')
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function historyMonth(item, index) {
|
|
|
|
|
+ if (index == 0) {
|
|
|
|
|
+ if (global.language == 'zh' && TimeFormatter.isToday(item.timestamp)) {
|
|
|
|
|
+ return ''
|
|
|
|
|
+ }
|
|
|
|
|
+ if (global.language == 'zh' && TimeFormatter.isYesterday(item.timestamp)) {
|
|
|
|
|
+ return ''
|
|
|
|
|
+ }
|
|
|
|
|
+ return dayjs(item.timestamp).format('MMM')
|
|
|
|
|
+ }
|
|
|
|
|
+ if (dayjs(item.timestamp).format('MM-DD') ==
|
|
|
|
|
+ dayjs(medias[index - 1].timestamp).format('MM-DD')) {
|
|
|
|
|
+ return ''
|
|
|
|
|
+ }
|
|
|
|
|
+ if (global.language == 'zh' && TimeFormatter.isToday(item.timestamp)) {
|
|
|
|
|
+ return ''
|
|
|
|
|
+ }
|
|
|
|
|
+ if (global.language == 'zh' && TimeFormatter.isYesterday(item.timestamp)) {
|
|
|
|
|
+ return ''
|
|
|
|
|
+ }
|
|
|
|
|
+ return dayjs(item.timestamp).format('MMM')
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return <StickyDateList onRefresherRefresh={() => {
|
|
return <StickyDateList onRefresherRefresh={() => {
|
|
|
setIsPulling(true)
|
|
setIsPulling(true)
|
|
|
setPage(1)
|
|
setPage(1)
|
|
@@ -199,13 +274,16 @@ export default function Album() {
|
|
|
</View>
|
|
</View>
|
|
|
{
|
|
{
|
|
|
medias.map((item, index) => {
|
|
medias.map((item, index) => {
|
|
|
- return <View key={index} id={`history-${index}`} style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
|
|
|
|
+ return <View key={index} id={`history-${index}`} style={{ display: 'flex', flexDirection: 'column', paddingTop: rpxToPx(6), backgroundColor: '#fff' }}>
|
|
|
{
|
|
{
|
|
|
- historyMonth(index, index - 1)
|
|
|
|
|
|
|
+ historyYear(index)
|
|
|
}
|
|
}
|
|
|
<View className="history_item2" >
|
|
<View className="history_item2" >
|
|
|
-
|
|
|
|
|
- <Text className="cell_date">{(item.date + '').substring(6, 9)}</Text>
|
|
|
|
|
|
|
+ <View className="cell_date" >
|
|
|
|
|
+ <View className="h42 bold" style={{ lineHeight: rpxToPx(60) + 'px' }}>{historyDate(item, index)}</View>
|
|
|
|
|
+ <View className="h24 bold" style={{ marginLeft: rpxToPx(6), marginTop: rpxToPx(11), lineHeight: rpxToPx(49) + 'px' }}>{historyMonth(item, index)}</View>
|
|
|
|
|
+ </View>
|
|
|
|
|
+ {/* <Text className="cell_date">{(item.date + '').substring(6, 9)}</Text> */}
|
|
|
<View style={{ display: 'flex', flex: 1 }}>
|
|
<View style={{ display: 'flex', flex: 1 }}>
|
|
|
<CoverList
|
|
<CoverList
|
|
|
imgs={item.images}
|
|
imgs={item.images}
|