|
@@ -67,6 +67,7 @@ let needScroll = false;
|
|
|
let showUpdate = false;
|
|
let showUpdate = false;
|
|
|
let Linking;
|
|
let Linking;
|
|
|
let JPush;
|
|
let JPush;
|
|
|
|
|
+let checkNotification, uploadPermissions;
|
|
|
|
|
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
JPush = require('jpush-react-native').default;
|
|
JPush = require('jpush-react-native').default;
|
|
@@ -74,6 +75,8 @@ if (process.env.TARO_ENV == 'rn') {
|
|
|
AppState = require("react-native").AppState
|
|
AppState = require("react-native").AppState
|
|
|
GradientText = require('@/components/basic/GradientText').default
|
|
GradientText = require('@/components/basic/GradientText').default
|
|
|
useNavigation = require("@react-navigation/native").useNavigation
|
|
useNavigation = require("@react-navigation/native").useNavigation
|
|
|
|
|
+ checkNotification = require('@/utils/native_permission_check').checkNotification;
|
|
|
|
|
+ uploadPermissions = require('@/utils/native_permission_check').uploadPermissions;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const defaultValue = `[{"scenario":{"name":"FAST_SLEEP","count":0,"schedule":{"fast":{"start_time":"15:00","end_time":"08:00"},"sleep":{"start_time":"22:00","end_time":"07:00"}}},"current_record":{"scenario":"FAST_SLEEP","status":"WAIT_FOR_START","fast":{"status":"WAIT_FOR_START","target_start_time":1710514800000,"target_end_time":1710576000000},"sleep":{"status":"WAIT_FOR_START","target_start_time":1710540000000,"target_end_time":1710572400000}},"wx_pub_followed":false,"time_input_schema":{"min":60,"max":1380,"step":5},"theme_color":{"fast":"#00FFFF","sleep":"#8183FF"}},{"scenarios":[{"name":"FAST","count":0,"schedule":{"fast":{"start_time":"15:00","end_time":"08:00"}}},{"name":"SLEEP","count":0,"schedule":{"sleep":{"start_time":"22:00","end_time":"07:00"}}},{"name":"FAST_SLEEP","count":0,"schedule":{"fast":{"start_time":"15:00","end_time":"08:00"},"sleep":{"start_time":"22:00","end_time":"07:00"}}}],"select_count":0,"theme_color":{"fast":"#00FFFF","sleep":"#8183FF"}}]`
|
|
const defaultValue = `[{"scenario":{"name":"FAST_SLEEP","count":0,"schedule":{"fast":{"start_time":"15:00","end_time":"08:00"},"sleep":{"start_time":"22:00","end_time":"07:00"}}},"current_record":{"scenario":"FAST_SLEEP","status":"WAIT_FOR_START","fast":{"status":"WAIT_FOR_START","target_start_time":1710514800000,"target_end_time":1710576000000},"sleep":{"status":"WAIT_FOR_START","target_start_time":1710540000000,"target_end_time":1710572400000}},"wx_pub_followed":false,"time_input_schema":{"min":60,"max":1380,"step":5},"theme_color":{"fast":"#00FFFF","sleep":"#8183FF"}},{"scenarios":[{"name":"FAST","count":0,"schedule":{"fast":{"start_time":"15:00","end_time":"08:00"}}},{"name":"SLEEP","count":0,"schedule":{"sleep":{"start_time":"22:00","end_time":"07:00"}}},{"name":"FAST_SLEEP","count":0,"schedule":{"fast":{"start_time":"15:00","end_time":"08:00"},"sleep":{"start_time":"22:00","end_time":"07:00"}}}],"select_count":0,"theme_color":{"fast":"#00FFFF","sleep":"#8183FF"}}]`
|
|
@@ -137,14 +140,28 @@ export default function Page() {
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
|
|
+
|
|
|
if (process.env.TARO_ENV == 'weapp') {
|
|
if (process.env.TARO_ENV == 'weapp') {
|
|
|
loadWXCache()
|
|
loadWXCache()
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
loadRNCache()
|
|
loadRNCache()
|
|
|
|
|
+ // const test = require('@/utils/push').default
|
|
|
|
|
+ // test()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
|
|
+ JPush.setBadge({
|
|
|
|
|
+ badge: 0,
|
|
|
|
|
+ appBadge: 0
|
|
|
|
|
+ })
|
|
|
|
|
+ JPush.isNotificationEnabled((res) => {
|
|
|
|
|
+ if (res) {
|
|
|
|
|
+ const test = require('@/utils/push').default
|
|
|
|
|
+ test()
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
AppState.addEventListener('change', handleAppStateChange);
|
|
AppState.addEventListener('change', handleAppStateChange);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -154,6 +171,8 @@ export default function Page() {
|
|
|
getCheckData()
|
|
getCheckData()
|
|
|
// global.pauseIndexTimer = !user.isLogin
|
|
// global.pauseIndexTimer = !user.isLogin
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
if (user.isLogin) {
|
|
if (user.isLogin) {
|
|
|
uploadUserClient();
|
|
uploadUserClient();
|
|
|
checkAuthorized();
|
|
checkAuthorized();
|
|
@@ -161,6 +180,7 @@ export default function Page() {
|
|
|
checkAddToMini();
|
|
checkAddToMini();
|
|
|
|
|
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
|
|
+ uploadPermissions()
|
|
|
JPush.isNotificationEnabled((res) => {
|
|
JPush.isNotificationEnabled((res) => {
|
|
|
if (res) {
|
|
if (res) {
|
|
|
const test = require('@/utils/push').default
|
|
const test = require('@/utils/push').default
|
|
@@ -293,7 +313,22 @@ export default function Page() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const handleAppStateChange = (nextAppState) => {
|
|
const handleAppStateChange = (nextAppState) => {
|
|
|
|
|
+ console.log(nextAppState)
|
|
|
|
|
+ if (nextAppState!='active'){
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
checkTimeZone()
|
|
checkTimeZone()
|
|
|
|
|
+
|
|
|
|
|
+ if (user.isLogin) {
|
|
|
|
|
+ uploadPermissions()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (process.env.TARO_ENV == 'rn') {
|
|
|
|
|
+ JPush.setBadge({
|
|
|
|
|
+ badge: 0,
|
|
|
|
|
+ appBadge: 0
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
function checkTimeZone() {
|
|
function checkTimeZone() {
|
|
@@ -317,7 +352,7 @@ export default function Page() {
|
|
|
// global.refreshDay()
|
|
// global.refreshDay()
|
|
|
// }
|
|
// }
|
|
|
if (global.currentStatus != 'WAIT_FOR_START') {
|
|
if (global.currentStatus != 'WAIT_FOR_START') {
|
|
|
- Taro.showModal({
|
|
|
|
|
|
|
+ showAlert({
|
|
|
title: t('feature.track_time_duration.change_tz_alert.title'),
|
|
title: t('feature.track_time_duration.change_tz_alert.title'),
|
|
|
content: t('feature.track_time_duration.change_tz_alert.content', { tz: timeZoneFormatted }),
|
|
content: t('feature.track_time_duration.change_tz_alert.content', { tz: timeZoneFormatted }),
|
|
|
showCancel: false,
|
|
showCancel: false,
|
|
@@ -543,60 +578,118 @@ export default function Page() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
global.popScheduleAlert = (scenario, startTime) => {
|
|
global.popScheduleAlert = (scenario, startTime) => {
|
|
|
- if (permission.wxPubFollow) {
|
|
|
|
|
- Taro.showModal({
|
|
|
|
|
- title: t('feature.track_time_duration.reminders.schedule_title'),
|
|
|
|
|
- content: scenario.name == 'FAST' ?
|
|
|
|
|
- t('feature.track_time_duration.reminders.enable_schedule_fast_content', { time: startTime }) :
|
|
|
|
|
- t('feature.track_time_duration.reminders.enable_schedule_sleep_content', { time: startTime }),
|
|
|
|
|
- showCancel: false,
|
|
|
|
|
- confirmText: t('feature.track_time_duration.reminders.ok')
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- Taro.showModal({
|
|
|
|
|
- title: t('feature.track_time_duration.reminders.schedule_title'),
|
|
|
|
|
- content: scenario.name == 'FAST' ?
|
|
|
|
|
- t('feature.track_time_duration.reminders.schedule_fast_content', { time: startTime }) :
|
|
|
|
|
- t('feature.track_time_duration.reminders.schedule_sleep_content', { time: startTime }),
|
|
|
|
|
- cancelText: t('feature.track_time_duration.reminders.later'),
|
|
|
|
|
- confirmText: t('feature.track_time_duration.reminders.open'),
|
|
|
|
|
- success: function (res) {
|
|
|
|
|
- if (res.confirm) {
|
|
|
|
|
|
|
+ if (process.env.TARO_ENV == 'weapp') {
|
|
|
|
|
+ if (permission.wxPubFollow) {
|
|
|
|
|
+ showAlert({
|
|
|
|
|
+ title: t('feature.track_time_duration.reminders.schedule_title'),
|
|
|
|
|
+ content: scenario.name == 'FAST' ?
|
|
|
|
|
+ t('feature.track_time_duration.reminders.enable_schedule_fast_content', { time: startTime }) :
|
|
|
|
|
+ t('feature.track_time_duration.reminders.enable_schedule_sleep_content', { time: startTime }),
|
|
|
|
|
+ showCancel: false,
|
|
|
|
|
+ confirmText: t('feature.track_time_duration.reminders.ok')
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ showAlert({
|
|
|
|
|
+ title: t('feature.track_time_duration.reminders.schedule_title'),
|
|
|
|
|
+ content: scenario.name == 'FAST' ?
|
|
|
|
|
+ t('feature.track_time_duration.reminders.schedule_fast_content', { time: startTime }) :
|
|
|
|
|
+ t('feature.track_time_duration.reminders.schedule_sleep_content', { time: startTime }),
|
|
|
|
|
+ cancelText: t('feature.track_time_duration.reminders.later'),
|
|
|
|
|
+ confirmText: t('feature.track_time_duration.reminders.open'),
|
|
|
|
|
+ showCancel: true,
|
|
|
|
|
+ confirm: () => {
|
|
|
followWxPub()
|
|
followWxPub()
|
|
|
- } else if (res.cancel) {
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ JPush.isNotificationEnabled((res) => {
|
|
|
|
|
+ if (res) {
|
|
|
|
|
+ showAlert({
|
|
|
|
|
+ title: t('feature.track_time_duration.reminders.schedule_title'),
|
|
|
|
|
+ content: scenario.name == 'FAST' ?
|
|
|
|
|
+ t('feature.track_time_duration.reminders.enable_schedule_fast_content', { time: startTime }) :
|
|
|
|
|
+ t('feature.track_time_duration.reminders.enable_schedule_sleep_content', { time: startTime }),
|
|
|
|
|
+ showCancel: false,
|
|
|
|
|
+ confirmText: t('feature.track_time_duration.reminders.ok')
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ showAlert({
|
|
|
|
|
+ title: t('feature.track_time_duration.reminders.schedule_title'),
|
|
|
|
|
+ content: scenario.name == 'FAST' ?
|
|
|
|
|
+ t('feature.track_time_duration.reminders.schedule_fast_content', { time: startTime }) :
|
|
|
|
|
+ t('feature.track_time_duration.reminders.schedule_sleep_content', { time: startTime }),
|
|
|
|
|
+ cancelText: t('feature.track_time_duration.reminders.later'),
|
|
|
|
|
+ confirmText: t('feature.track_time_duration.reminders.open'),
|
|
|
|
|
+ showCancel: true,
|
|
|
|
|
+ confirm: () => {
|
|
|
|
|
+ checkNotification()
|
|
|
|
|
+ // Linking.openURL('app-settings:notifications')
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
global.popMixScheduleAlert = (time1, time2) => {
|
|
global.popMixScheduleAlert = (time1, time2) => {
|
|
|
- if (permission.wxPubFollow) {
|
|
|
|
|
- Taro.showModal({
|
|
|
|
|
- title: t('feature.track_time_duration.reminders.schedule_title'),
|
|
|
|
|
- content: t('feature.track_time_duration.reminders.enable_schedule_mix_content', { time1: time1, time2: time2 }),
|
|
|
|
|
- showCancel: false,
|
|
|
|
|
- confirmText: t('feature.track_time_duration.reminders.ok')
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- Taro.showModal({
|
|
|
|
|
- title: t('feature.track_time_duration.reminders.schedule_title'),
|
|
|
|
|
- content:
|
|
|
|
|
- t('feature.track_time_duration.reminders.schedule_mix_content'),
|
|
|
|
|
- cancelText: t('feature.track_time_duration.reminders.later'),
|
|
|
|
|
- confirmText: t('feature.track_time_duration.reminders.open'),
|
|
|
|
|
- success: function (res) {
|
|
|
|
|
- if (res.confirm) {
|
|
|
|
|
|
|
+ if (process.env.TARO_ENV == 'weapp') {
|
|
|
|
|
+ if (permission.wxPubFollow) {
|
|
|
|
|
+ showAlert({
|
|
|
|
|
+ title: t('feature.track_time_duration.reminders.schedule_title'),
|
|
|
|
|
+ content: t('feature.track_time_duration.reminders.enable_schedule_mix_content', { time1: time1, time2: time2 }),
|
|
|
|
|
+ showCancel: false,
|
|
|
|
|
+ confirmText: t('feature.track_time_duration.reminders.ok')
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ showAlert({
|
|
|
|
|
+ title: t('feature.track_time_duration.reminders.schedule_title'),
|
|
|
|
|
+ content:
|
|
|
|
|
+ t('feature.track_time_duration.reminders.schedule_mix_content'),
|
|
|
|
|
+ cancelText: t('feature.track_time_duration.reminders.later'),
|
|
|
|
|
+ confirmText: t('feature.track_time_duration.reminders.open'),
|
|
|
|
|
+ showCancel: true,
|
|
|
|
|
+ confirm: () => {
|
|
|
followWxPub()
|
|
followWxPub()
|
|
|
- } else if (res.cancel) {
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ JPush.isNotificationEnabled((res) => {
|
|
|
|
|
+ if (res) {
|
|
|
|
|
+ showAlert({
|
|
|
|
|
+ title: t('feature.track_time_duration.reminders.schedule_title'),
|
|
|
|
|
+ content: t('feature.track_time_duration.reminders.enable_schedule_mix_content', { time1: time1, time2: time2 }),
|
|
|
|
|
+ showCancel: false,
|
|
|
|
|
+ confirmText: t('feature.track_time_duration.reminders.ok')
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
|
|
+ else {
|
|
|
|
|
+ showAlert({
|
|
|
|
|
+ title: t('feature.track_time_duration.reminders.schedule_title'),
|
|
|
|
|
+ content:
|
|
|
|
|
+ t('feature.track_time_duration.reminders.schedule_mix_content'),
|
|
|
|
|
+ cancelText: t('feature.track_time_duration.reminders.later'),
|
|
|
|
|
+ confirmText: t('feature.track_time_duration.reminders.open'),
|
|
|
|
|
+ showCancel: true,
|
|
|
|
|
+ confirm: () => {
|
|
|
|
|
+ checkNotification()
|
|
|
|
|
+ // Linking.openURL('app-settings:notifications')
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function followWxPub() {
|
|
function followWxPub() {
|
|
@@ -674,9 +767,11 @@ export default function Page() {
|
|
|
function render() {
|
|
function render() {
|
|
|
if (!loaded) {
|
|
if (!loaded) {
|
|
|
return <Layout type={TemplateType.customHeader} header={headerView()} title={t('page.clock.title')} titleShowStyle={NaviBarTitleShowType.scrollToShow}>
|
|
return <Layout type={TemplateType.customHeader} header={headerView()} title={t('page.clock.title')} titleShowStyle={NaviBarTitleShowType.scrollToShow}>
|
|
|
- <View style={{ width: rpxToPx(750), height: rpxToPx(900), display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
|
|
|
|
|
+ <View style={{ width: rpxToPx(750), height: rpxToPx(900), display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}>
|
|
|
<AtActivityIndicator size={40} color="#fff" />
|
|
<AtActivityIndicator size={40} color="#fff" />
|
|
|
- <Tabbar index={0} />
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ process.env.TARO_ENV == 'weapp' && <Tabbar index={0} />
|
|
|
|
|
+ }
|
|
|
</View>
|
|
</View>
|
|
|
</Layout>
|
|
</Layout>
|
|
|
}
|
|
}
|
|
@@ -760,7 +855,7 @@ export default function Page() {
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- user.isLogin && <Streaks />
|
|
|
|
|
|
|
+ user.isLogin && <Streaks count={count} />
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{
|
|
{
|