|
@@ -1,4 +1,4 @@
|
|
|
-import { View, Text, Switch, ScrollView } from "@tarojs/components";
|
|
|
|
|
|
|
+import { View, Text, ScrollView } from "@tarojs/components";
|
|
|
import Metric from "@/features/trackSomething/components/Metric";
|
|
import Metric from "@/features/trackSomething/components/Metric";
|
|
|
import { useDidShow, usePullDownRefresh, useShareAppMessage } from "@tarojs/taro";
|
|
import { useDidShow, usePullDownRefresh, useShareAppMessage } from "@tarojs/taro";
|
|
|
import { useTranslation } from "react-i18next";
|
|
import { useTranslation } from "react-i18next";
|
|
@@ -12,11 +12,13 @@ import { getLocalPush } from "@/features/trackTimeDuration/actions/TrackTimeActi
|
|
|
import { useSelector } from "react-redux";
|
|
import { useSelector } from "react-redux";
|
|
|
import ProductList from "../store/product_list";
|
|
import ProductList from "../store/product_list";
|
|
|
import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
|
|
import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
|
|
|
|
|
+import { userAccess } from "@/services/user";
|
|
|
|
|
|
|
|
let useNavigation;
|
|
let useNavigation;
|
|
|
-let AppState;
|
|
|
|
|
|
|
+let AppState, Switch;
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
AppState = require("react-native").AppState
|
|
AppState = require("react-native").AppState
|
|
|
|
|
+ Switch = require("react-native").Switch
|
|
|
useNavigation = require("@react-navigation/native").useNavigation
|
|
useNavigation = require("@react-navigation/native").useNavigation
|
|
|
}
|
|
}
|
|
|
export default function Page() {
|
|
export default function Page() {
|
|
@@ -32,6 +34,7 @@ export default function Page() {
|
|
|
const [systemFast, setSystemFast] = useState(true)
|
|
const [systemFast, setSystemFast] = useState(true)
|
|
|
const [systemExtra, setSystemExtra] = useState(true)
|
|
const [systemExtra, setSystemExtra] = useState(true)
|
|
|
const [systemSun, setSystemSun] = useState(true)
|
|
const [systemSun, setSystemSun] = useState(true)
|
|
|
|
|
+ const [access, setAccess] = useState<any>(null)
|
|
|
const user = useSelector((state: any) => state.user);
|
|
const user = useSelector((state: any) => state.user);
|
|
|
|
|
|
|
|
let navigation;
|
|
let navigation;
|
|
@@ -40,12 +43,13 @@ export default function Page() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// useEffect(() => {
|
|
// useEffect(() => {
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// }, [])
|
|
// }, [])
|
|
|
|
|
|
|
|
- useEffect(()=>{
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
checkSetting()
|
|
checkSetting()
|
|
|
getSettings()
|
|
getSettings()
|
|
|
|
|
+ getMemberStatus()
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
AppState.addEventListener('change', handleAppStateChange);
|
|
AppState.addEventListener('change', handleAppStateChange);
|
|
|
// AppState.addEventListener('change', handleAppStateChange);
|
|
// AppState.addEventListener('change', handleAppStateChange);
|
|
@@ -59,7 +63,19 @@ export default function Page() {
|
|
|
// });
|
|
// });
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- },[user.isLogin])
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (process.env.TARO_ENV == 'rn') {
|
|
|
|
|
+ // AppState.addEventListener('change', handleAppStateChange);
|
|
|
|
|
+ navigation.addListener('focus', () => {
|
|
|
|
|
+ getMemberStatus()
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 当页面即将消失时执行
|
|
|
|
|
+ navigation.addListener('blur', () => {
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [user.isLogin])
|
|
|
|
|
|
|
|
const handleAppStateChange = (nextAppState) => {
|
|
const handleAppStateChange = (nextAppState) => {
|
|
|
console.log(nextAppState)
|
|
console.log(nextAppState)
|
|
@@ -68,10 +84,39 @@ export default function Page() {
|
|
|
}
|
|
}
|
|
|
if (nextAppState == 'active') {
|
|
if (nextAppState == 'active') {
|
|
|
checkSetting()
|
|
checkSetting()
|
|
|
|
|
+ getMemberStatus()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ function getMemberStatus() {
|
|
|
|
|
+ userAccess().then(res => {
|
|
|
|
|
+ setAccess(res)
|
|
|
|
|
+ if ((res as any).member.status == 'NON_MEMBER') {
|
|
|
|
|
+ postNotifySettings({
|
|
|
|
|
+ notification: {
|
|
|
|
|
+ follow_sun: {
|
|
|
|
|
+ sunrise: {
|
|
|
|
|
+ in_app: 'OFF'
|
|
|
|
|
+ },
|
|
|
|
|
+ sunset: {
|
|
|
|
|
+ in_app: 'OFF'
|
|
|
|
|
+ },
|
|
|
|
|
+ solar_noon: {
|
|
|
|
|
+ in_app: 'OFF'
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }).then(res => {
|
|
|
|
|
+ setIsSolarNoon(false)
|
|
|
|
|
+ setIsSunset(false)
|
|
|
|
|
+ setIsSunrise(false)
|
|
|
|
|
+ global.swiperDayNightRefresh()
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
useDidShow(() => {
|
|
useDidShow(() => {
|
|
|
console.log('notfication setting user did show')
|
|
console.log('notfication setting user did show')
|
|
|
})
|
|
})
|
|
@@ -84,6 +129,7 @@ export default function Page() {
|
|
|
setIsSunrise(dt.follow_sun.sunrise.in_app == 'ON')
|
|
setIsSunrise(dt.follow_sun.sunrise.in_app == 'ON')
|
|
|
setIsSunset(dt.follow_sun.sunset.in_app == 'ON')
|
|
setIsSunset(dt.follow_sun.sunset.in_app == 'ON')
|
|
|
setIsSolarNoon(dt.follow_sun.solar_noon.in_app == 'ON')
|
|
setIsSolarNoon(dt.follow_sun.solar_noon.in_app == 'ON')
|
|
|
|
|
+
|
|
|
setLoaded(true)
|
|
setLoaded(true)
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -168,8 +214,8 @@ export default function Page() {
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function iap(){
|
|
|
|
|
- jumpPage('','ProductList',navigation)
|
|
|
|
|
|
|
+ function iap() {
|
|
|
|
|
+ jumpPage('', 'ProductList', navigation)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function pro() {
|
|
function pro() {
|
|
@@ -189,18 +235,20 @@ export default function Page() {
|
|
|
<Text className="setting_header">Extra Reminders</Text>
|
|
<Text className="setting_header">Extra Reminders</Text>
|
|
|
<View className="setting_cell">
|
|
<View className="setting_cell">
|
|
|
<Text className="setting_cell_title" style={{ flex: 1 }}>If I missed previous action</Text>
|
|
<Text className="setting_cell_title" style={{ flex: 1 }}>If I missed previous action</Text>
|
|
|
- <Switch className="myswitch" checked={isExtra} color={ColorType.fast} onChange={(e) => {
|
|
|
|
|
- // setIsMulti(e.detail.value)
|
|
|
|
|
|
|
+ <Switch className="myswitch" value={isExtra} color={ColorType.fast} trackColor={{ true: ColorType.fast }} onChange={(e) => {
|
|
|
|
|
+ debugger
|
|
|
|
|
+ // setIsMulti(e.nativeEvent.value)
|
|
|
|
|
+ const value = e.nativeEvent.value
|
|
|
postNotifySettings({
|
|
postNotifySettings({
|
|
|
notification: {
|
|
notification: {
|
|
|
fast_sleep: {
|
|
fast_sleep: {
|
|
|
extra_reminders: {
|
|
extra_reminders: {
|
|
|
- in_app: e.detail.value ? 'ON' : 'OFF'
|
|
|
|
|
|
|
+ in_app: value ? 'ON' : 'OFF'
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}).then(res => {
|
|
}).then(res => {
|
|
|
- setIsExtra(e.detail.value)
|
|
|
|
|
|
|
+ setIsExtra(value)
|
|
|
getLocalPush()
|
|
getLocalPush()
|
|
|
})
|
|
})
|
|
|
}} />
|
|
}} />
|
|
@@ -214,17 +262,30 @@ export default function Page() {
|
|
|
<View className="setting_cell_group_item">
|
|
<View className="setting_cell_group_item">
|
|
|
<Text className="setting_cell_title" style={{ flex: 1 }}>Sunrise</Text>
|
|
<Text className="setting_cell_title" style={{ flex: 1 }}>Sunrise</Text>
|
|
|
<Switch className="myswitch" checked={isSunrise} color={ColorType.fast} onChange={(e) => {
|
|
<Switch className="myswitch" checked={isSunrise} color={ColorType.fast} onChange={(e) => {
|
|
|
- // setIsMulti(e.detail.value)
|
|
|
|
|
|
|
+ // setIsMulti(e.nativeEvent.value)
|
|
|
|
|
+ const value = e.nativeEvent.value
|
|
|
|
|
+ if (e.nativeEvent.value) {
|
|
|
|
|
+ if (access.member.status == 'NON_MEMBER') {
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ setIsSunrise(false)
|
|
|
|
|
+ }, 1000)
|
|
|
|
|
+
|
|
|
|
|
+ jumpPage('', 'ProductList', navigation)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
postNotifySettings({
|
|
postNotifySettings({
|
|
|
notification: {
|
|
notification: {
|
|
|
follow_sun: {
|
|
follow_sun: {
|
|
|
sunrise: {
|
|
sunrise: {
|
|
|
- in_app: e.detail.value ? 'ON' : 'OFF'
|
|
|
|
|
|
|
+ in_app: value ? 'ON' : 'OFF'
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}).then(res => {
|
|
}).then(res => {
|
|
|
- setIsSunrise(e.detail.value)
|
|
|
|
|
|
|
+ setIsExtra(value)
|
|
|
|
|
+ // setIsSunrise(e.nativeEvent.value)
|
|
|
global.swiperDayNightRefresh()
|
|
global.swiperDayNightRefresh()
|
|
|
})
|
|
})
|
|
|
}} />
|
|
}} />
|
|
@@ -232,17 +293,28 @@ export default function Page() {
|
|
|
<View className="setting_cell_group_item">
|
|
<View className="setting_cell_group_item">
|
|
|
<Text className="setting_cell_title" style={{ flex: 1 }}>Sunset</Text>
|
|
<Text className="setting_cell_title" style={{ flex: 1 }}>Sunset</Text>
|
|
|
<Switch className="myswitch" checked={isSunset} color={ColorType.fast} onChange={(e) => {
|
|
<Switch className="myswitch" checked={isSunset} color={ColorType.fast} onChange={(e) => {
|
|
|
- // setIsMulti(e.detail.value)
|
|
|
|
|
|
|
+ // setIsMulti(e.nativeEvent.value)
|
|
|
|
|
+ if (e.nativeEvent.value) {
|
|
|
|
|
+ if (access.member.status == 'NON_MEMBER') {
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ setIsSunset(false)
|
|
|
|
|
+ }, 1000)
|
|
|
|
|
+
|
|
|
|
|
+ jumpPage('', 'ProductList', navigation)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
postNotifySettings({
|
|
postNotifySettings({
|
|
|
notification: {
|
|
notification: {
|
|
|
follow_sun: {
|
|
follow_sun: {
|
|
|
sunset: {
|
|
sunset: {
|
|
|
- in_app: e.detail.value ? 'ON' : 'OFF'
|
|
|
|
|
|
|
+ in_app: e.nativeEvent.value ? 'ON' : 'OFF'
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}).then(res => {
|
|
}).then(res => {
|
|
|
- setIsSunset(e.detail.value)
|
|
|
|
|
|
|
+ setIsSunset(e.nativeEvent.value)
|
|
|
global.swiperDayNightRefresh()
|
|
global.swiperDayNightRefresh()
|
|
|
})
|
|
})
|
|
|
}} />
|
|
}} />
|
|
@@ -250,17 +322,28 @@ export default function Page() {
|
|
|
<View className="setting_cell_group_item">
|
|
<View className="setting_cell_group_item">
|
|
|
<Text className="setting_cell_title" style={{ flex: 1 }}>Solar Noon</Text>
|
|
<Text className="setting_cell_title" style={{ flex: 1 }}>Solar Noon</Text>
|
|
|
<Switch className="myswitch" checked={isSolarNoon} color={ColorType.fast} onChange={(e) => {
|
|
<Switch className="myswitch" checked={isSolarNoon} color={ColorType.fast} onChange={(e) => {
|
|
|
- // setIsMulti(e.detail.value)
|
|
|
|
|
|
|
+ // setIsMulti(e.nativeEvent.value)
|
|
|
|
|
+ if (e.nativeEvent.value) {
|
|
|
|
|
+ if (access.member.status == 'NON_MEMBER') {
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ setIsSolarNoon(false)
|
|
|
|
|
+ }, 1000)
|
|
|
|
|
+
|
|
|
|
|
+ jumpPage('', 'ProductList', navigation)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
postNotifySettings({
|
|
postNotifySettings({
|
|
|
notification: {
|
|
notification: {
|
|
|
follow_sun: {
|
|
follow_sun: {
|
|
|
solar_noon: {
|
|
solar_noon: {
|
|
|
- in_app: e.detail.value ? 'ON' : 'OFF'
|
|
|
|
|
|
|
+ in_app: e.nativeEvent.value ? 'ON' : 'OFF'
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}).then(res => {
|
|
}).then(res => {
|
|
|
- setIsSolarNoon(e.detail.value)
|
|
|
|
|
|
|
+ setIsSolarNoon(e.nativeEvent.value)
|
|
|
global.swiperDayNightRefresh()
|
|
global.swiperDayNightRefresh()
|
|
|
})
|
|
})
|
|
|
}} />
|
|
}} />
|