|
@@ -1,7 +1,7 @@
|
|
|
import { View, Text } from "@tarojs/components";
|
|
import { View, Text } from "@tarojs/components";
|
|
|
import trackTimeService, { machine } from "@/store/trackTimeMachine"
|
|
import trackTimeService, { machine } from "@/store/trackTimeMachine"
|
|
|
import { useEffect, useState } from "react";
|
|
import { useEffect, useState } from "react";
|
|
|
-import Taro from "@tarojs/taro";
|
|
|
|
|
|
|
+import Taro, { useReady } from "@tarojs/taro";
|
|
|
import Box from "@/components/layout/Box";
|
|
import Box from "@/components/layout/Box";
|
|
|
import './Schedule.scss'
|
|
import './Schedule.scss'
|
|
|
import { useTranslation } from "react-i18next";
|
|
import { useTranslation } from "react-i18next";
|
|
@@ -20,6 +20,10 @@ import { ColorType } from "@/context/themes/color";
|
|
|
import { getThemeColor, jumpPage } from "../hooks/Common";
|
|
import { getThemeColor, jumpPage } from "../hooks/Common";
|
|
|
import TableCell from "@/components/layout/TableCell";
|
|
import TableCell from "@/components/layout/TableCell";
|
|
|
import TimelineStage from "./TimelineStage";
|
|
import TimelineStage from "./TimelineStage";
|
|
|
|
|
+import { useFocusEffect } from "@react-navigation/native";
|
|
|
|
|
+import React from "react";
|
|
|
|
|
+import { AppState } from "react-native";
|
|
|
|
|
+import JPush from 'jpush-react-native';
|
|
|
|
|
|
|
|
|
|
|
|
|
export default function Component(props: { type?: string, data?: any, delSuccess?: Function }) {
|
|
export default function Component(props: { type?: string, data?: any, delSuccess?: Function }) {
|
|
@@ -28,8 +32,45 @@ export default function Component(props: { type?: string, data?: any, delSuccess
|
|
|
const common = useSelector((state: any) => state.common);
|
|
const common = useSelector((state: any) => state.common);
|
|
|
const time = useSelector((state: any) => state.time);
|
|
const time = useSelector((state: any) => state.time);
|
|
|
const [showModal, setShowModal] = useState(false)
|
|
const [showModal, setShowModal] = useState(false)
|
|
|
|
|
+ const [pushEnable, setPushEnable] = useState(true)
|
|
|
const dispatch = useDispatch();
|
|
const dispatch = useDispatch();
|
|
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ console.log('push', global.pushEnable)
|
|
|
|
|
+ }, [global.pushEnable])
|
|
|
|
|
+
|
|
|
|
|
+ const handleAppStateChange = (nextAppState) => {
|
|
|
|
|
+ checkPushStatus()
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ AppState.addEventListener('change', handleAppStateChange);
|
|
|
|
|
+
|
|
|
|
|
+ return () => {
|
|
|
|
|
+ AppState.removeEventListener('change', handleAppStateChange);
|
|
|
|
|
+ };
|
|
|
|
|
+ }, []);
|
|
|
|
|
+
|
|
|
|
|
+ // useReady(() => {
|
|
|
|
|
+ // alert('sss')
|
|
|
|
|
+ // if (process.env.TARO_ENV == 'rn') {
|
|
|
|
|
+ // const JPush = require('jpush-react-native')
|
|
|
|
|
+ // JPush.isNotificationEnabled(obj => {
|
|
|
|
|
+ // alert(obj)
|
|
|
|
|
+ // })
|
|
|
|
|
+ // }
|
|
|
|
|
+ // })
|
|
|
|
|
+
|
|
|
|
|
+ useFocusEffect(React.useCallback(() => {
|
|
|
|
|
+ checkPushStatus()
|
|
|
|
|
+ }, []))
|
|
|
|
|
+
|
|
|
|
|
+ function checkPushStatus() {
|
|
|
|
|
+ JPush.isNotificationEnabled(obj => {
|
|
|
|
|
+ setPushEnable(obj)
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function all() {
|
|
function all() {
|
|
|
if (props.type == 'latest') {
|
|
if (props.type == 'latest') {
|
|
|
jumpPage('/pages/common/RecordsHistory?type=time&title=Time')
|
|
jumpPage('/pages/common/RecordsHistory?type=time&title=Time')
|
|
@@ -48,8 +89,8 @@ export default function Component(props: { type?: string, data?: any, delSuccess
|
|
|
return item.code == 'follow_wx_pub'
|
|
return item.code == 'follow_wx_pub'
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- const title = permission.wxPubFollow ?t('feature.track_time_duration.follow_wx_pub.h5_followed_title'):
|
|
|
|
|
- t('feature.track_time_duration.follow_wx_pub.h5_unfollowed_title')
|
|
|
|
|
|
|
+ const title = permission.wxPubFollow ? t('feature.track_time_duration.follow_wx_pub.h5_followed_title') :
|
|
|
|
|
+ t('feature.track_time_duration.follow_wx_pub.h5_unfollowed_title')
|
|
|
|
|
|
|
|
Taro.showModal({
|
|
Taro.showModal({
|
|
|
title: permission.wxPubFollow ? t('feature.track_time_duration.follow_wx_pub.modal_followed_title') :
|
|
title: permission.wxPubFollow ? t('feature.track_time_duration.follow_wx_pub.modal_followed_title') :
|
|
@@ -232,6 +273,11 @@ export default function Component(props: { type?: string, data?: any, delSuccess
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function getSetting() {
|
|
|
|
|
+ // const RNBridge = require('tarojs/plugin-rn-bridge');
|
|
|
|
|
+ // RNBridge.NativeModules.RNBridgeModule.jumpToNotificationSettings();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// if (!permission.wxPubFollow) {
|
|
// if (!permission.wxPubFollow) {
|
|
|
// return <View className="schedule_box">
|
|
// return <View className="schedule_box">
|
|
|
// <Text className="box_title">{t('feature.track_time_duration.schedule.section_title')}</Text>
|
|
// <Text className="box_title">{t('feature.track_time_duration.schedule.section_title')}</Text>
|
|
@@ -274,7 +320,11 @@ export default function Component(props: { type?: string, data?: any, delSuccess
|
|
|
return <View className="schedule_box">
|
|
return <View className="schedule_box">
|
|
|
<View className="box_header" style={{ marginRight: 20, backgroundColor: global.isDebug ? 'red' : 'transparent' }}>
|
|
<View className="box_header" style={{ marginRight: 20, backgroundColor: global.isDebug ? 'red' : 'transparent' }}>
|
|
|
<Text className="box_title">{t('feature.track_time_duration.schedule.section_title')}</Text>
|
|
<Text className="box_title">{t('feature.track_time_duration.schedule.section_title')}</Text>
|
|
|
- <Switch isOn={permission.wxPubFollow} onClick={() => followWxPub()} />
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ process.env.TARO_ENV == 'weapp' ? <Switch isOn={permission.wxPubFollow} onClick={() => followWxPub()} /> :
|
|
|
|
|
+ <Switch isOn={!pushEnable} onClick={() => getSetting()} />
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
</View>
|
|
</View>
|
|
|
|
|
|