|
|
@@ -35,7 +35,6 @@ import { showModal } from '@/store/modal'
|
|
|
|
|
|
export default function IndexPage() {
|
|
|
const dispatch = useDispatch();
|
|
|
- const array: any[] = []
|
|
|
const [checkData, setCheckData] = useState(null)
|
|
|
const user = useSelector((state: any) => state.user);
|
|
|
const time = useSelector((state: any) => state.time);
|
|
|
@@ -45,14 +44,15 @@ export default function IndexPage() {
|
|
|
const [timerId, setTimerId] = useState(null)
|
|
|
const [needShowAddTip, setNeedShowAddTip] = useState(false)
|
|
|
|
|
|
+ const [swiperIndex, setSwiperIndex] = useState(0)
|
|
|
+ const [autoPlay, setAutoPlay] = useState(false)
|
|
|
+
|
|
|
const [showModal, setShowModal] = useState(false)
|
|
|
const [modalDetail, setModalDetail] = useState<any>({})
|
|
|
|
|
|
const [showModal2, setShowModal2] = useState(false)
|
|
|
const [modalDetail2, setModalDetail2] = useState<any>({})
|
|
|
|
|
|
- array.push(<Text>ffff</Text>)
|
|
|
- // array.push(<Rings radius={50}/>)
|
|
|
global.dispatch = dispatch;
|
|
|
useEffect(() => {
|
|
|
dispatch(staticResources() as any);
|
|
|
@@ -79,15 +79,11 @@ export default function IndexPage() {
|
|
|
checkAddToMini();
|
|
|
//检查session是否过期
|
|
|
checkSession()
|
|
|
+ getCheckData()
|
|
|
}
|
|
|
}, [user.isLogin])
|
|
|
|
|
|
function checkSession() {
|
|
|
- // Taro.login().then(res => {
|
|
|
- // // code = res.code;
|
|
|
- // uploadSessionKey({ type: 'WX_MP', code: res.code });
|
|
|
- // })
|
|
|
- // return
|
|
|
if (process.env.TARO_ENV === 'weapp') {
|
|
|
console.log('session request')
|
|
|
thirdPartRequest(RequestType.RequestTypeCheckSession).then(res => {
|
|
|
@@ -133,6 +129,11 @@ export default function IndexPage() {
|
|
|
|
|
|
const id = setInterval(() => {
|
|
|
setCounter((prevCounter) => prevCounter + 1);
|
|
|
+ //每天0点刷新一下打卡数据
|
|
|
+ var now = new Date()
|
|
|
+ if (now.getHours()==0 && now.getMinutes()==0){
|
|
|
+ getCheckData()
|
|
|
+ }
|
|
|
}, 1000);
|
|
|
|
|
|
setTimerId(id as any);
|
|
|
@@ -140,11 +141,9 @@ export default function IndexPage() {
|
|
|
|
|
|
|
|
|
useReady(async () => {
|
|
|
- // console.log('wwwwwwww')
|
|
|
const userData = await getStorage('userData');
|
|
|
if (userData) {
|
|
|
dispatch(getInfoSuccess(JSON.parse(userData as string)) as any);
|
|
|
- // return JSON.parse(userData as string) as UserState;
|
|
|
setTimeout(() => {
|
|
|
checkWXPubFollow()
|
|
|
getCheckData()
|
|
|
@@ -172,7 +171,7 @@ export default function IndexPage() {
|
|
|
global.updateTab(0)
|
|
|
if (user.isLogin) {
|
|
|
checkWXPubFollow()
|
|
|
- getCheckData();
|
|
|
+ // getCheckData();
|
|
|
}
|
|
|
clearTempScenarioCache()
|
|
|
})
|
|
|
@@ -185,67 +184,24 @@ export default function IndexPage() {
|
|
|
machine.context.checkData = res as any;
|
|
|
|
|
|
global.scenario = (res as any).current_record.scenario;
|
|
|
- // trackTimeService.send({ type: 'RESET' });
|
|
|
- // trackTimeService.send({ type: (res as any).current_record.scenario });
|
|
|
const currentState = trackTimeService.getSnapshot();
|
|
|
let json = {};
|
|
|
var key = (res as any).current_record.scenario
|
|
|
var status = (res as any).current_record.status
|
|
|
json[key] = status
|
|
|
currentState.value = json;
|
|
|
- // debugger
|
|
|
machine.context.currentStatus = `${key}.${status}`;//'mixed.ON_GOING2'
|
|
|
setCheckData(res as any)
|
|
|
- })
|
|
|
- return
|
|
|
- getChecks().then(res => {
|
|
|
- if ((res as any).scenario) {
|
|
|
- dispatch(setScenario((res as any).scenario));
|
|
|
- global.scenario = (res as any).scenario;
|
|
|
- // global.checkData = res;
|
|
|
- // console.log((res as any).scenario.name + ' ' + (res as any).status);
|
|
|
- // trackTimeService.send({type:(res as any).scenario.name});
|
|
|
- // setSpecifiedStatus('FAST_SLEEP', 'ON_GOING');
|
|
|
-
|
|
|
- // 初始化状态机
|
|
|
- // const initialState = machine.initialState;
|
|
|
-
|
|
|
- // 设置指定状态为 C->3
|
|
|
- // const nextState = machine.transition(initialState, 'SET_SPECIFIED_STATE');
|
|
|
- // const specifiedState = setSpecifiedState(nextState, 'FAST_SLEEP');
|
|
|
- // setSpecifiedState();
|
|
|
- // console.log('name:'+(res as any).scenario.name)
|
|
|
- // machine.reset();
|
|
|
- trackTimeService.send({ type: 'RESET' });
|
|
|
-
|
|
|
- trackTimeService.send({ type: (res as any).scenario.name });
|
|
|
-
|
|
|
- const currentState = trackTimeService.getSnapshot();
|
|
|
- let json = {};
|
|
|
- var key = (res as any).scenario.name
|
|
|
- json[key] = (res as any).status
|
|
|
- currentState.value = json;
|
|
|
- // debugger
|
|
|
- machine.context.currentStatus = `${key}.${(res as any).status}`;//'mixed.ON_GOING2'
|
|
|
- machine.context.checkData = res as any;
|
|
|
- // debugger
|
|
|
- // trackTimeService.send('APPLE');
|
|
|
- // machine.transition(`${key}.${(res as any).status}`,'' as any);
|
|
|
-
|
|
|
- // trackTimeService.send({type:'START_FAST'});
|
|
|
- // trackTimeService.send({type:'START_SLEEP'});
|
|
|
- // trackTimeService.send({type:'END_SLEEP'});
|
|
|
- // trackTimeService.send({type:'END_SLEEP'});
|
|
|
- // trackTimeService.send({type:'START_FAST'});
|
|
|
- // trackTimeService.send({type:'END_FAST'});
|
|
|
- // trackTimeService.send({type:'START_SLEEP'});
|
|
|
-
|
|
|
- // console.log(currentState.value);
|
|
|
- // debugger
|
|
|
- // trackTimeService.send('setCurrentStatus', {status:(res as any).status});
|
|
|
- // setCurrentStatus((res as any).status);
|
|
|
- // trackTimeService.send({type:'START_FAST'});
|
|
|
+
|
|
|
+ if ((res as any).current_record.status == 'ONGOING1') {
|
|
|
+ setSwiperIndex(1)
|
|
|
+ setAutoPlay(true)
|
|
|
}
|
|
|
+ else {
|
|
|
+ setSwiperIndex(0)
|
|
|
+ setAutoPlay(false)
|
|
|
+ }
|
|
|
+
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -255,26 +211,6 @@ export default function IndexPage() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- function followWxPub() {
|
|
|
- const resource = common.resources.filter((item: any) => {
|
|
|
- return item.code == 'follow_wx_pub'
|
|
|
- })
|
|
|
-
|
|
|
- Taro.showModal({
|
|
|
- title: '提示',
|
|
|
- content: '关注公众号后可接收提醒\n点击确定,前往关注',
|
|
|
- showCancel: true,
|
|
|
- success(result) {
|
|
|
- if (result.confirm) {
|
|
|
- Taro.navigateTo({
|
|
|
- url: '/pages/common/H5?title=fast16cc 关注服务号&url=' + resource[0].url,
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
async function getStorage(key: string) {
|
|
|
try {
|
|
|
const res = await Taro.getStorage({ key });
|
|
|
@@ -288,11 +224,7 @@ export default function IndexPage() {
|
|
|
if (!user.isLogin) {
|
|
|
return <View />
|
|
|
}
|
|
|
-
|
|
|
- // if ((checkData as any).current_record.scenario == 'FAST_SLEEP') {
|
|
|
return <Schedule data={(checkData as any).current_record} />
|
|
|
- // }
|
|
|
- // return <View />
|
|
|
}
|
|
|
|
|
|
function needSwiper() {
|
|
|
@@ -332,6 +264,15 @@ export default function IndexPage() {
|
|
|
{
|
|
|
needSwiper() ? <Swiper className='swiper' indicatorColor='#333'
|
|
|
indicatorActiveColor='#999'
|
|
|
+ current={swiperIndex}
|
|
|
+ autoplay={autoPlay}
|
|
|
+ duration={300}
|
|
|
+ interval={2000}
|
|
|
+ onChange={(e) => {
|
|
|
+ setSwiperIndex(e.detail.current)
|
|
|
+ if (e.detail.current == 0)
|
|
|
+ setAutoPlay(false)
|
|
|
+ }}
|
|
|
indicatorDots>
|
|
|
<SwiperItem className='swiperItem'>
|
|
|
<Console />
|
|
|
@@ -347,21 +288,13 @@ export default function IndexPage() {
|
|
|
}
|
|
|
|
|
|
{/* <Console /> */}
|
|
|
-
|
|
|
-
|
|
|
<More ref={global.moreRef} />
|
|
|
- {/* {
|
|
|
- !permission.wxPubFollow && user.isLogin && <Text style={{ textAlign: 'center', width: '100%' }} onClick={() => followWxPub()}>去关注公众号</Text>
|
|
|
- } */}
|
|
|
-
|
|
|
{
|
|
|
checkData && schedule()
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
{
|
|
|
- checkData && (checkData as any).latest_record && <RecordFastSleep type='latest' data={(checkData as any).latest_record} delSuccess={getCheckData} />
|
|
|
- // <Schedule type='latest' delSuccess={getCheckData} />
|
|
|
+ checkData && (checkData as any).latest_record &&
|
|
|
+ <RecordFastSleep type='latest' data={(checkData as any).latest_record} delSuccess={getCheckData} />
|
|
|
}
|
|
|
<View style={{ height: 100 }} />
|
|
|
</View>
|