|
|
@@ -1,6 +1,6 @@
|
|
|
import { View, ScrollView, Text } from "@tarojs/components";
|
|
|
import './WeekCalendar.scss'
|
|
|
-import { useEffect, useState, useMemo, memo } from "react";
|
|
|
+import { useEffect, useState, useMemo, memo, useRef } from "react";
|
|
|
import { ColorType } from "@/context/themes/color";
|
|
|
import WeekCalendarItem from "./WeekCalendarItem";
|
|
|
import { rpxToPx } from "@/utils/tools";
|
|
|
@@ -24,6 +24,7 @@ const WeekCalendar = memo(() => {
|
|
|
const [left, setLeft] = useState(0)
|
|
|
const [isLoading, setIsLoading] = useState(false)
|
|
|
const { t } = useTranslation()
|
|
|
+ const ref = useRef(null)
|
|
|
const pageSize = 34
|
|
|
|
|
|
useEffect(() => {
|
|
|
@@ -82,7 +83,12 @@ const WeekCalendar = memo(() => {
|
|
|
setCalendarData(list[list.length - 1])
|
|
|
setMinTime((res as any).extra.real_start_time_min)
|
|
|
setLeft((list.length - 1) * parseInt(rpxToPx(658) + ''))
|
|
|
- setIsLoading(false)
|
|
|
+ setIsLoading(false);
|
|
|
+ if (ref.current) {
|
|
|
+ (ref.current as any).scrollTo({
|
|
|
+ x: (list.length - 1) * parseInt(rpxToPx(658) + ''), y: 0, animated: false
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
var array = list.concat(calendars)
|
|
|
@@ -102,6 +108,7 @@ const WeekCalendar = memo(() => {
|
|
|
setSummary(array[current + list.length].summary_stats ? array[current + list.length].summary_stats : null)
|
|
|
setCalendarData(array[current + list.length])
|
|
|
setLeft((current + list.length - 1) * parseInt(rpxToPx(658) + ''))
|
|
|
+ console.log('sssssss')
|
|
|
setIsLoading(false)
|
|
|
clearInterval(timer);
|
|
|
timer = null;
|
|
|
@@ -118,7 +125,7 @@ const WeekCalendar = memo(() => {
|
|
|
}
|
|
|
|
|
|
function onScroll(e) {
|
|
|
- if (!fingerDrag) return
|
|
|
+ if (!fingerDrag && process.env.TARO_ENV == 'weapp') return
|
|
|
isScrolling = true
|
|
|
var x = e.detail.scrollLeft + 5
|
|
|
// var page = parseInt(x / parseInt(rpxToPx(658) + '') + '')
|
|
|
@@ -172,33 +179,35 @@ const WeekCalendar = memo(() => {
|
|
|
bottom: parseInt(rpxToPx(60) + ''),
|
|
|
width: parseInt(rpxToPx(658) + ''),
|
|
|
}} />
|
|
|
- <ScrollView
|
|
|
- // className="chart_scroll"
|
|
|
- style={{
|
|
|
- marginLeft: parseInt(rpxToPx(46) + ''),
|
|
|
- width: parseInt(rpxToPx(658) + ''),
|
|
|
- height: parseInt(rpxToPx(520) + ''),
|
|
|
- flexDirection: 'row', display: 'flex',
|
|
|
- }}
|
|
|
- onScroll={onScroll}
|
|
|
- onDragEnd={dragEnd}
|
|
|
- onDragStart={dragStart}
|
|
|
- scrollLeft={left}
|
|
|
- scrollX pagingEnabled={true}
|
|
|
- enableFlex enhanced>
|
|
|
- {
|
|
|
- calendars.map((item, index) => {
|
|
|
- // return <View style={{width: parseInt(rpxToPx(658) + ''),
|
|
|
- // height: parseInt(rpxToPx(520) + ''),backgroundColor:'red',flexShrink:0}}><Text style={{color:'#fff'}}>{index}</Text></View>
|
|
|
-
|
|
|
- // //
|
|
|
- if (index == current || index == current - 1 || index == current + 1)
|
|
|
- return <WeekCalendarItem data={item} key={index} isCurrentWeek={index == calendars.length - 1} />
|
|
|
- return <View style={{ width: parseInt(rpxToPx(658) + ''), flexShrink: 0 }} />
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- </ScrollView>
|
|
|
+ <View>
|
|
|
+ <ScrollView
|
|
|
+ style={{
|
|
|
+ marginLeft: parseInt(rpxToPx(46) + ''),
|
|
|
+ width: parseInt(rpxToPx(658) + ''),
|
|
|
+ height: parseInt(rpxToPx(520) + ''),
|
|
|
+ flexDirection: 'row', display: 'flex',
|
|
|
+
|
|
|
+ }}
|
|
|
+ ref={ref}
|
|
|
+ showScrollbar={false}
|
|
|
+ onScroll={onScroll}
|
|
|
+ onDragEnd={dragEnd}
|
|
|
+ onDragStart={dragStart}
|
|
|
+ scrollLeft={left}
|
|
|
+ scrollX pagingEnabled={true}
|
|
|
+ showsHorizontalScrollIndicator={false}
|
|
|
+ enableFlex enhanced>
|
|
|
+ {
|
|
|
+ calendars.map((item, index) => {
|
|
|
+
|
|
|
+ if (index == current || index == current - 1 || index == current + 1)
|
|
|
+ return <WeekCalendarItem data={item} key={index} isCurrentWeek={index == calendars.length - 1} />
|
|
|
+ return <View style={{ width: parseInt(rpxToPx(658) + ''), flexShrink: 0 }} />
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ </ScrollView>
|
|
|
+ </View>
|
|
|
<View className="chart_times" style={{ marginTop: parseInt(rpxToPx(60) + ''), marginBottom: parseInt(rpxToPx(60) + '') }}>
|
|
|
<Text className="chart_times_txt" style={{ left: 0, top: 0 }}>12:00</Text>
|
|
|
<Text className="chart_times_txt" style={{ left: 0, top: parseInt(rpxToPx(100 - 7) + '') }}>18:00</Text>
|