|
@@ -20,6 +20,7 @@ import Rings from "./Rings";
|
|
|
import { bigRingRadius, getBgRing, getCommon, getDot, ringWidth } from '../hooks/RingData'
|
|
import { bigRingRadius, getBgRing, getCommon, getDot, ringWidth } from '../hooks/RingData'
|
|
|
import '@/utils/ring_card.scss';
|
|
import '@/utils/ring_card.scss';
|
|
|
import { IconNight, IconSunrise, IconSunset } from '@/components/basic/Icons'
|
|
import { IconNight, IconSunrise, IconSunset } from '@/components/basic/Icons'
|
|
|
|
|
+import DayNightRing from './DayNightRing'
|
|
|
|
|
|
|
|
let useNavigation;
|
|
let useNavigation;
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
@@ -107,6 +108,20 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
setSunriseDate(sunriseA)
|
|
setSunriseDate(sunriseA)
|
|
|
setSunriseTmrDate(new Date(sunriseB.getTime() + 24 * 3600 * 1000))
|
|
setSunriseTmrDate(new Date(sunriseB.getTime() + 24 * 3600 * 1000))
|
|
|
setSunsetDate(sunsetA)
|
|
setSunsetDate(sunsetA)
|
|
|
|
|
+
|
|
|
|
|
+ dispatch(setDayRingData({
|
|
|
|
|
+ date: new Date().getTime(),
|
|
|
|
|
+ sunrise: '06:00',
|
|
|
|
|
+ sunset: '18:00'
|
|
|
|
|
+ }))
|
|
|
|
|
+ dispatch(setNightRingData({
|
|
|
|
|
+ date: new Date().getTime(),
|
|
|
|
|
+ sunrise: '06:00',
|
|
|
|
|
+ sunset: '18:00'
|
|
|
|
|
+ }))
|
|
|
|
|
+
|
|
|
|
|
+ setAuthInfo(null)
|
|
|
|
|
+ global.locationDetail = null
|
|
|
}
|
|
}
|
|
|
}, [user.isLogin])
|
|
}, [user.isLogin])
|
|
|
|
|
|
|
@@ -232,12 +247,14 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
function updateDate(data) {
|
|
function updateDate(data) {
|
|
|
|
|
|
|
|
var today = new Date()
|
|
var today = new Date()
|
|
|
|
|
+ if (authInfo && authInfo.timezone) {
|
|
|
|
|
+ today = localNow(today)
|
|
|
|
|
+ }
|
|
|
// var yesterday = new Date(today.getTime() - 24 * 3600 * 1000)
|
|
// var yesterday = new Date(today.getTime() - 24 * 3600 * 1000)
|
|
|
- var tomorrow = new Date(today.getTime() + 24 * 3600 * 1000)
|
|
|
|
|
|
|
+ // var tomorrow = new Date(today.getTime() + 24 * 3600 * 1000)
|
|
|
// var strYesterday = `${yesterday.getFullYear()}-${TimeFormatter.padZero(yesterday.getMonth() + 1)}-${TimeFormatter.padZero(yesterday.getDate())}`
|
|
// var strYesterday = `${yesterday.getFullYear()}-${TimeFormatter.padZero(yesterday.getMonth() + 1)}-${TimeFormatter.padZero(yesterday.getDate())}`
|
|
|
// var strTomorrow = `${tomorrow.getFullYear()}-${TimeFormatter.padZero(tomorrow.getMonth() + 1)}-${TimeFormatter.padZero(tomorrow.getDate())}`
|
|
// var strTomorrow = `${tomorrow.getFullYear()}-${TimeFormatter.padZero(tomorrow.getMonth() + 1)}-${TimeFormatter.padZero(tomorrow.getDate())}`
|
|
|
if (isMember && data && data.daylights && data.daylights.length > 0) {
|
|
if (isMember && data && data.daylights && data.daylights.length > 0) {
|
|
|
- debugger
|
|
|
|
|
var yesterdayDate = new Date(data.daylights[0].date + 'T' + data.daylights[0].sunset)
|
|
var yesterdayDate = new Date(data.daylights[0].date + 'T' + data.daylights[0].sunset)
|
|
|
var todaySunriseDate = new Date(data.daylights[1].date + 'T' + data.daylights[1].sunrise)
|
|
var todaySunriseDate = new Date(data.daylights[1].date + 'T' + data.daylights[1].sunrise)
|
|
|
var todaySunsetDate = new Date(data.daylights[1].date + 'T' + data.daylights[1].sunset)
|
|
var todaySunsetDate = new Date(data.daylights[1].date + 'T' + data.daylights[1].sunset)
|
|
@@ -325,7 +342,6 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
sunrise: '06:00',
|
|
sunrise: '06:00',
|
|
|
sunset: '18:00'
|
|
sunset: '18:00'
|
|
|
}))
|
|
}))
|
|
|
- debugger
|
|
|
|
|
dispatch(setNightRingData({
|
|
dispatch(setNightRingData({
|
|
|
date: sunsetDate,
|
|
date: sunsetDate,
|
|
|
sunrise: '06:00',
|
|
sunrise: '06:00',
|
|
@@ -336,11 +352,13 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function updateNightStore(date, sunrise, sunset) {
|
|
function updateNightStore(date, sunrise, sunset) {
|
|
|
- debugger
|
|
|
|
|
- if (lastNightInfo && lastNightInfo.date.getDate() == new Date(date).getDate() &&
|
|
|
|
|
- lastNightInfo.sunrise == sunrise &&
|
|
|
|
|
- lastNightInfo.sunset == sunset
|
|
|
|
|
- ) {
|
|
|
|
|
|
|
+ // if (lastNightInfo && lastNightInfo.date.getDate() == new Date(date).getDate() &&
|
|
|
|
|
+ // lastNightInfo.sunrise == sunrise &&
|
|
|
|
|
+ // lastNightInfo.sunset == sunset
|
|
|
|
|
+ // ) {
|
|
|
|
|
+ // return
|
|
|
|
|
+ // }
|
|
|
|
|
+ if (!user.isLogin) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
lastNightInfo = {
|
|
lastNightInfo = {
|
|
@@ -356,10 +374,13 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function updateDayStore(date, sunrise, sunset) {
|
|
function updateDayStore(date, sunrise, sunset) {
|
|
|
- if (lastDayInfo && lastDayInfo.date.getDate() == new Date(date).getDate() &&
|
|
|
|
|
- lastDayInfo.sunrise == sunrise &&
|
|
|
|
|
- lastDayInfo.sunset == sunset
|
|
|
|
|
- ) {
|
|
|
|
|
|
|
+ // if (lastDayInfo && lastDayInfo.date.getDate() == new Date(date).getDate() &&
|
|
|
|
|
+ // lastDayInfo.sunrise == sunrise &&
|
|
|
|
|
+ // lastDayInfo.sunset == sunset
|
|
|
|
|
+ // ) {
|
|
|
|
|
+ // return
|
|
|
|
|
+ // }
|
|
|
|
|
+ if (!user.isLogin) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
lastDayInfo = {
|
|
lastDayInfo = {
|
|
@@ -508,7 +529,17 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function getLocation() {
|
|
function getLocation() {
|
|
|
|
|
+ if (!authInfo) {
|
|
|
|
|
+ return ''
|
|
|
|
|
+ }
|
|
|
|
|
+ return `${getCity()} | ${Math.abs(parseInt(authInfo.lat))}°${parseInt(authInfo.lat) < 0 ? 'S' : 'N'} ${Math.abs(parseInt(authInfo.lng))}°${parseInt(authInfo.lng) < 0 ? 'W' : 'E'}`
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function getCity() {
|
|
|
var city = ''
|
|
var city = ''
|
|
|
|
|
+ if (!authInfo) {
|
|
|
|
|
+ return ''
|
|
|
|
|
+ }
|
|
|
if ((authInfo as any).address) {
|
|
if ((authInfo as any).address) {
|
|
|
if ((authInfo as any).address.city.length > 0) {
|
|
if ((authInfo as any).address.city.length > 0) {
|
|
|
city = (authInfo as any).address.city
|
|
city = (authInfo as any).address.city
|
|
@@ -526,8 +557,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
else {
|
|
else {
|
|
|
city = t('feature.track_time_duration.third_ring.unknown')
|
|
city = t('feature.track_time_duration.third_ring.unknown')
|
|
|
}
|
|
}
|
|
|
- // return city +' | '+parseInt(authInfo.lat)+'°'+ ' '+parseInt(authInfo.lng)
|
|
|
|
|
- return `${city} | ${Math.abs(parseInt(authInfo.lat))}°${parseInt(authInfo.lat) < 0 ? 'S' : 'N'} ${Math.abs(parseInt(authInfo.lng))}°${parseInt(authInfo.lng) < 0 ? 'W' : 'E'}`
|
|
|
|
|
|
|
+ return city
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function clearData() {
|
|
function clearData() {
|
|
@@ -545,6 +575,9 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
}
|
|
|
lastNightInfo = null
|
|
lastNightInfo = null
|
|
|
lastDayInfo = null
|
|
lastDayInfo = null
|
|
|
|
|
+
|
|
|
|
|
+ setAuthInfo(null)
|
|
|
|
|
+ global.locationDetail = null
|
|
|
})
|
|
})
|
|
|
} else if (res.cancel) {
|
|
} else if (res.cancel) {
|
|
|
console.log('用户点击取消')
|
|
console.log('用户点击取消')
|
|
@@ -566,6 +599,10 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
setSunsetTime('18:00')
|
|
setSunsetTime('18:00')
|
|
|
dispatch(updateMember({ isMember: isMember, gpsInfo: null }))
|
|
dispatch(updateMember({ isMember: isMember, gpsInfo: null }))
|
|
|
|
|
|
|
|
|
|
+ setSunriseDate(sunriseA)
|
|
|
|
|
+ setSunriseTmrDate(new Date(sunriseB.getTime() + 24 * 3600 * 1000))
|
|
|
|
|
+ setSunsetDate(sunsetA)
|
|
|
|
|
+
|
|
|
|
|
|
|
|
dispatch(setDayRingData({
|
|
dispatch(setDayRingData({
|
|
|
date: new Date().getTime(),
|
|
date: new Date().getTime(),
|
|
@@ -734,68 +771,6 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- function getSunsetTime() {
|
|
|
|
|
- if (props.isNight) {
|
|
|
|
|
- if (!authInfo || !(authInfo as any).lat) {
|
|
|
|
|
- if (new Date().getHours() >= 6) {
|
|
|
|
|
- return `${sunsetTime}`
|
|
|
|
|
- }
|
|
|
|
|
- return `${sunsetTime}`
|
|
|
|
|
- // return `Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
|
|
|
|
|
- }
|
|
|
|
|
- if (nightDate.getDate() == new Date().getDate()) {
|
|
|
|
|
- return `${sunsetTime.substring(0, 5)}`
|
|
|
|
|
- }
|
|
|
|
|
- return `${sunsetTime.substring(0, 5)}`
|
|
|
|
|
- }
|
|
|
|
|
- if (!authInfo || !(authInfo as any).lat) {
|
|
|
|
|
- if (new Date().getHours() >= 18) {
|
|
|
|
|
- return `${sunsetTime}`
|
|
|
|
|
-
|
|
|
|
|
- // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
|
|
|
|
|
- }
|
|
|
|
|
- return `${sunsetTime}`
|
|
|
|
|
- // return `Today ${sunriseTime} - ${sunsetTime}`
|
|
|
|
|
- }
|
|
|
|
|
- if (dayDate.getDate() == new Date().getDate()) {
|
|
|
|
|
- return `${sunsetTime.substring(0, 5)}`
|
|
|
|
|
- // return `Today ${sunriseTime} - ${sunsetTime}`
|
|
|
|
|
- }
|
|
|
|
|
- return `${sunsetTime.substring(0, 5)}`
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function getSunriseTime() {
|
|
|
|
|
- if (props.isNight) {
|
|
|
|
|
- if (!authInfo || !(authInfo as any).lat) {
|
|
|
|
|
- if (new Date().getHours() >= 6) {
|
|
|
|
|
- return `${sunriseTmrTime}`
|
|
|
|
|
- }
|
|
|
|
|
- return `${sunriseTmrTime}`
|
|
|
|
|
- // return `Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
|
|
|
|
|
- }
|
|
|
|
|
- if (nightDate.getDate() == new Date().getDate()) {
|
|
|
|
|
- return `${sunriseTmrTime.substring(0, 5)}`
|
|
|
|
|
- }
|
|
|
|
|
- return `${sunriseTmrTime.substring(0, 5)}`
|
|
|
|
|
- }
|
|
|
|
|
- if (!authInfo || !(authInfo as any).lat) {
|
|
|
|
|
- if (new Date().getHours() >= 18) {
|
|
|
|
|
- return `${sunriseTime}`
|
|
|
|
|
-
|
|
|
|
|
- // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
|
|
|
|
|
- }
|
|
|
|
|
- return `${sunriseTime}`
|
|
|
|
|
- // return `Today ${sunriseTime} - ${sunsetTime}`
|
|
|
|
|
- }
|
|
|
|
|
- if (dayDate.getDate() == new Date().getDate()) {
|
|
|
|
|
- return `${sunriseTime.substring(0, 5)}`
|
|
|
|
|
- // return `Today ${sunriseTime} - ${sunsetTime}`
|
|
|
|
|
- }
|
|
|
|
|
- return `${sunriseTime.substring(0, 5)}`
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
function longClick() {
|
|
function longClick() {
|
|
|
if (user.isLogin && user.test_user && authInfo)
|
|
if (user.isLogin && user.test_user && authInfo)
|
|
|
setShowDetailModal(true)
|
|
setShowDetailModal(true)
|
|
@@ -806,220 +781,100 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
e.stopPropagation()
|
|
e.stopPropagation()
|
|
|
}
|
|
}
|
|
|
tapCard(e)
|
|
tapCard(e)
|
|
|
- // if (isMember && authInfo && authInfo.lat) {
|
|
|
|
|
- // tapCard(e)
|
|
|
|
|
- // return
|
|
|
|
|
- // }
|
|
|
|
|
- // setShowDetailPopup(true)
|
|
|
|
|
- // Taro.showModal({
|
|
|
|
|
- // title: props.isNight ? t('feature.day_night.alert_required_night') : t('feature.day_night.alert_required_day'),
|
|
|
|
|
- // content: props.isNight ? t('feature.day_night.alert_night_content') : t('feature.day_night.alert_day_content'),
|
|
|
|
|
- // confirmText: t('feature.day_night.choose_location'),
|
|
|
|
|
- // cancelText: t('feature.day_night.view_more'),
|
|
|
|
|
- // success: function (res) {
|
|
|
|
|
- // if (res.confirm) {
|
|
|
|
|
- // auth()
|
|
|
|
|
- // // console.log('用户点击确定')
|
|
|
|
|
- // } else if (res.cancel) {
|
|
|
|
|
- // setShowDetailPopup(true)
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // })
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function tapShow() {
|
|
|
|
|
- dispatch(showNight(true))
|
|
|
|
|
- dispatch(showDay(true))
|
|
|
|
|
- Taro.showModal({
|
|
|
|
|
- title: 'Login Required',
|
|
|
|
|
- content: props.isNight ? 'Log in to see your daily local nighttime from sunset to sunrise.' : 'Log in to see your daily local daytime from sunrise to sunset.',
|
|
|
|
|
- cancelText: 'Later',
|
|
|
|
|
- confirmText: 'Login',
|
|
|
|
|
- success: function (res) {
|
|
|
|
|
- if (res.confirm) {
|
|
|
|
|
- Taro.setStorage({
|
|
|
|
|
- key: 'showNightRing',
|
|
|
|
|
- data: true
|
|
|
|
|
- })
|
|
|
|
|
- Taro.setStorage({
|
|
|
|
|
- key: 'showDayRing',
|
|
|
|
|
- data: true
|
|
|
|
|
- })
|
|
|
|
|
- if (!user.isLogin) {
|
|
|
|
|
- jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- } else if (res.cancel) {
|
|
|
|
|
- dispatch(showNight(false))
|
|
|
|
|
- dispatch(showDay(false))
|
|
|
|
|
- Taro.setStorage({
|
|
|
|
|
- key: 'showNightRing',
|
|
|
|
|
- data: false
|
|
|
|
|
- })
|
|
|
|
|
- Taro.setStorage({
|
|
|
|
|
- key: 'showDayRing',
|
|
|
|
|
- data: false
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function operate(e) {
|
|
|
|
|
- if (process.env.TARO_ENV == 'weapp') {
|
|
|
|
|
- e.stopPropagation()
|
|
|
|
|
- }
|
|
|
|
|
- Taro.showActionSheet({
|
|
|
|
|
- itemList: ['选择位置', '重置'],
|
|
|
|
|
- success: function (res) {
|
|
|
|
|
- switch (res.tapIndex) {
|
|
|
|
|
- case 0:
|
|
|
|
|
- auth()
|
|
|
|
|
- break;
|
|
|
|
|
- case 1:
|
|
|
|
|
- reset()
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- fail: function (res) {
|
|
|
|
|
- console.log(res.errMsg)
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function reset() {
|
|
|
|
|
- var content = ''
|
|
|
|
|
- if (props.isNight) {
|
|
|
|
|
- if (authInfo && authInfo.lat) {
|
|
|
|
|
- content = 'Local times for sunset and sunrise, together with the nighttime ring will turn off, and your location data will be cleared. '
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- content = 'Sunset and sunrise times, together with the nighttime ring will turn off.'
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- if (authInfo && authInfo.lat) {
|
|
|
|
|
- content = 'Local times for sunrise and sunset, together with the daytime ring will turn off, and your location data will be cleared. '
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- content = 'Sunrise and sunset times, together with the daytime ring will turn off.'
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- Taro.showModal({
|
|
|
|
|
- title: 'Reset Alert',
|
|
|
|
|
- content: content,
|
|
|
|
|
- success: function (res) {
|
|
|
|
|
- if (res.confirm) {
|
|
|
|
|
- if (user.isLogin) {
|
|
|
|
|
- uploadPerm({ show_ring: false })
|
|
|
|
|
- }
|
|
|
|
|
- clearLocation().then(res => {
|
|
|
|
|
- if (global.clearNightLocation) {
|
|
|
|
|
- global.clearNightLocation()
|
|
|
|
|
- }
|
|
|
|
|
- if (global.clearDayLocation) {
|
|
|
|
|
- global.clearDayLocation()
|
|
|
|
|
- }
|
|
|
|
|
- lastNightInfo = null
|
|
|
|
|
- lastDayInfo = null
|
|
|
|
|
-
|
|
|
|
|
- dispatch(showNight(false))
|
|
|
|
|
- dispatch(showDay(false))
|
|
|
|
|
- Taro.setStorage({
|
|
|
|
|
- key: 'showNightRing',
|
|
|
|
|
- data: false
|
|
|
|
|
- })
|
|
|
|
|
- Taro.setStorage({
|
|
|
|
|
- key: 'showDayRing',
|
|
|
|
|
- data: false
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- } else if (res.cancel) {
|
|
|
|
|
- console.log('用户点击取消')
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function nightRing() {
|
|
function nightRing() {
|
|
|
- var common = getCommon(null, true)
|
|
|
|
|
- common.radius = bigRingRadius;
|
|
|
|
|
- common.lineWidth = ringWidth;
|
|
|
|
|
- var bgRing = getBgRing()
|
|
|
|
|
-
|
|
|
|
|
- let realRingBig: RealRing = {
|
|
|
|
|
- color: ColorType.night + '66',
|
|
|
|
|
- startArc: 0,
|
|
|
|
|
- durationArc: 2
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- var now1 = new Date().getTime()
|
|
|
|
|
- if (authInfo && authInfo.timezone) {
|
|
|
|
|
- now1 = TimeFormatter.transferTimestamp(now1, authInfo.timezone)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return <DayNightRing
|
|
|
|
|
+ isNight={true}
|
|
|
|
|
+ isThirdRing={false}
|
|
|
|
|
+ canvasId={'day_night_card_night_ring'}
|
|
|
|
|
+ authInfo={authInfo}
|
|
|
|
|
+ currentStatus={currentStatus()}
|
|
|
|
|
+ />
|
|
|
|
|
+ // var common = getCommon(null, true)
|
|
|
|
|
+ // common.radius = bigRingRadius;
|
|
|
|
|
+ // common.lineWidth = ringWidth;
|
|
|
|
|
+ // var bgRing = getBgRing()
|
|
|
|
|
+
|
|
|
|
|
+ // let realRingBig: RealRing = {
|
|
|
|
|
+ // color: ColorType.night + '66',
|
|
|
|
|
+ // startArc: 0,
|
|
|
|
|
+ // durationArc: 2
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
|
|
|
|
|
- if (authInfo && authInfo.night_completed && now1 > authInfo.night_completed.sunrise_ts) {
|
|
|
|
|
- realRingBig.color = ColorType.night
|
|
|
|
|
- var duration = (authInfo.night_completed.sunrise_ts - authInfo.night_completed.sunset_ts) / 1000
|
|
|
|
|
- // var start = new Date(authInfo.night_completed.sunset_ts)
|
|
|
|
|
- var newT = TimeFormatter.transferTimestamp(authInfo.night_completed.sunset_ts, authInfo.timezone)
|
|
|
|
|
- var start = new Date(newT)
|
|
|
|
|
- realRingBig.startArc = (start.getHours() * 3600 + start.getMinutes() * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
|
|
|
|
|
- realRingBig.durationArc = (duration) / (24 * 3600) * 2 * Math.PI;
|
|
|
|
|
- return <Rings common={common} bgRing={bgRing} targetRing={realRingBig} canvasId={'ddddsss' + 'index_day'} />
|
|
|
|
|
|
|
+ // var now1 = new Date().getTime()
|
|
|
|
|
+ // if (authInfo && authInfo.timezone) {
|
|
|
|
|
+ // now1 = TimeFormatter.transferTimestamp(now1, authInfo.timezone)
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if (authInfo && authInfo.night_completed && new Date().getTime() > authInfo.night_completed.sunrise_ts) {
|
|
|
|
|
+ // realRingBig.color = ColorType.night
|
|
|
|
|
+ // var duration = (authInfo.night_completed.sunrise_ts - authInfo.night_completed.sunset_ts) / 1000
|
|
|
|
|
+ // // var start = new Date(authInfo.night_completed.sunset_ts)
|
|
|
|
|
+ // var newT = TimeFormatter.transferTimestamp(authInfo.night_completed.sunset_ts, authInfo.timezone)
|
|
|
|
|
+ // var start = new Date(newT)
|
|
|
|
|
+ // realRingBig.startArc = (start.getHours() * 3600 + start.getMinutes() * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
|
|
|
|
|
+ // realRingBig.durationArc = (duration) / (24 * 3600) * 2 * Math.PI;
|
|
|
|
|
+
|
|
|
|
|
+ // var currentDot = getDot(null, false)
|
|
|
|
|
+ // currentDot.color = ColorType.night
|
|
|
|
|
+ // currentDot.offset = (authInfo && authInfo.timezone) ? TimeFormatter.timeZoneOffset(authInfo.timezone) : 0;
|
|
|
|
|
+ // //已结束未更新暂停时,显示current_dot
|
|
|
|
|
+ // if (currentStatus() == t('feature.day_night.update_paused')){
|
|
|
|
|
+ // currentDot = null
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
- var sunRise = 24 * 60 + 6 * 60
|
|
|
|
|
- var sunSet = 18 * 60
|
|
|
|
|
|
|
+ // return <Rings common={common} bgRing={bgRing} targetRing={realRingBig} currentDot={currentDot} canvasId={'ddddsss' + 'index_day'} />
|
|
|
|
|
|
|
|
- var sunRiseObj = nightStore.nightRingSunrise
|
|
|
|
|
- var sunSetObj = nightStore.nightRingSunset
|
|
|
|
|
- sunRise = 24 * 60 + parseInt(sunRiseObj.split(':')[0]) * 60 + parseInt(sunRiseObj.split(':')[1])
|
|
|
|
|
- sunSet = parseInt(sunSetObj.split(':')[0]) * 60 + parseInt(sunSetObj.split(':')[1])
|
|
|
|
|
- if (sunSetObj.indexOf('PM') != -1) {
|
|
|
|
|
- sunSet += 12 * 60
|
|
|
|
|
- }
|
|
|
|
|
// }
|
|
// }
|
|
|
- var duration = sunRise - sunSet
|
|
|
|
|
- realRingBig.startArc = (sunSet * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
|
|
|
|
|
- realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
|
|
|
|
|
-
|
|
|
|
|
- var currentDot = getDot(null, false)
|
|
|
|
|
- currentDot.color = ColorType.night
|
|
|
|
|
- currentDot.offset = (authInfo && authInfo.timezone) ? TimeFormatter.timeZoneOffset(authInfo.timezone) : 0
|
|
|
|
|
|
|
|
|
|
- var now = new Date()
|
|
|
|
|
- now = localNow(now)
|
|
|
|
|
|
|
+ // var sunRise = 24 * 60 + 6 * 60
|
|
|
|
|
+ // var sunSet = 18 * 60
|
|
|
|
|
|
|
|
- var t = now.getHours() * 60 + now.getMinutes()
|
|
|
|
|
- var duration2 = t - sunSet
|
|
|
|
|
- if (duration2 < 0) {
|
|
|
|
|
- duration2 += 24 * 60
|
|
|
|
|
- }
|
|
|
|
|
- let realRing: RealRing = {
|
|
|
|
|
- color: ColorType.night,
|
|
|
|
|
- startArc: (sunSet * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0,
|
|
|
|
|
- durationArc: (duration2 * 60) / (24 * 3600) * 2 * Math.PI
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // var sunRiseObj = user.isLogin ? nightStore.nightRingSunrise : '06:00:00'
|
|
|
|
|
+ // var sunSetObj = user.isLogin ? nightStore.nightRingSunset : '18:00:00'
|
|
|
|
|
+ // sunRise = 24 * 60 + parseInt(sunRiseObj.split(':')[0]) * 60 + parseInt(sunRiseObj.split(':')[1])
|
|
|
|
|
+ // sunSet = parseInt(sunSetObj.split(':')[0]) * 60 + parseInt(sunSetObj.split(':')[1])
|
|
|
|
|
+ // if (sunSetObj.indexOf('PM') != -1) {
|
|
|
|
|
+ // sunSet += 12 * 60
|
|
|
|
|
+ // }
|
|
|
|
|
+ // // }
|
|
|
|
|
+ // var duration = sunRise - sunSet
|
|
|
|
|
+ // realRingBig.startArc = (sunSet * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
|
|
|
|
|
+ // realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
|
|
|
|
|
+
|
|
|
|
|
+ // var currentDot = getDot(null, false)
|
|
|
|
|
+ // currentDot.color = ColorType.night
|
|
|
|
|
+ // currentDot.offset = (authInfo && authInfo.timezone) ? TimeFormatter.timeZoneOffset(authInfo.timezone) : 0
|
|
|
|
|
+
|
|
|
|
|
+ // var now = new Date()
|
|
|
|
|
+ // now = localNow(now)
|
|
|
|
|
+
|
|
|
|
|
+ // var t1 = now.getHours() * 60 + now.getMinutes()
|
|
|
|
|
+ // var duration2 = t1 - sunSet
|
|
|
|
|
+ // if (duration2 < 0) {
|
|
|
|
|
+ // duration2 += 24 * 60
|
|
|
|
|
+ // }
|
|
|
|
|
+ // let realRing: RealRing = {
|
|
|
|
|
+ // color: ColorType.night,
|
|
|
|
|
+ // startArc: (sunSet * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0,
|
|
|
|
|
+ // durationArc: (duration2 * 60) / (24 * 3600) * 2 * Math.PI
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
- if (nightStore.nightRingDate) {
|
|
|
|
|
- if (new Date(nightStore.nightRingDate).getDate() == new Date().getDate() && new Date().getHours() < 12) {
|
|
|
|
|
- realRing = null;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if (nightStore.nightRingDate) {
|
|
|
|
|
+ // if (new Date(nightStore.nightRingDate).getDate() == now.getDate() && now.getHours() < 12) {
|
|
|
|
|
+ // realRing = null;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
- if (!user.isLogin) {
|
|
|
|
|
- currentDot = null;
|
|
|
|
|
- realRing = null;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // // if (!user.isLogin) {
|
|
|
|
|
+ // // currentDot = null;
|
|
|
|
|
+ // // realRing = null;
|
|
|
|
|
+ // // }
|
|
|
|
|
|
|
|
|
|
|
|
|
- return <Rings common={common} bgRing={bgRing} targetRing={realRingBig} realRing={duration2 > duration ? null : realRing} currentDot={currentDot} canvasId={'dddd' + 'index_day'} />
|
|
|
|
|
|
|
+ // return <Rings common={common} bgRing={bgRing} targetRing={realRingBig} realRing={duration2 > duration ? null : realRing} currentDot={currentDot} canvasId={'dddd' + 'index_day'} />
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1031,88 +886,101 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function dayRing() {
|
|
function dayRing() {
|
|
|
- var common = getCommon(null, true)
|
|
|
|
|
- common.radius = bigRingRadius;
|
|
|
|
|
- common.lineWidth = ringWidth;
|
|
|
|
|
- var bgRing = getBgRing()
|
|
|
|
|
-
|
|
|
|
|
- const realRingBig: RealRing = {
|
|
|
|
|
- color: ColorType.day + '66',
|
|
|
|
|
- startArc: 0,
|
|
|
|
|
- durationArc: 2
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- var now1 = new Date().getTime()
|
|
|
|
|
- if (authInfo && authInfo.timezone) {
|
|
|
|
|
- now1 = TimeFormatter.transferTimestamp(now1, authInfo.timezone)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return <DayNightRing
|
|
|
|
|
+ isNight={false}
|
|
|
|
|
+ isThirdRing={false}
|
|
|
|
|
+ canvasId={'day_night_card_big_day'}
|
|
|
|
|
+ authInfo={authInfo}
|
|
|
|
|
+ />
|
|
|
|
|
+
|
|
|
|
|
+ // var common = getCommon(null, true)
|
|
|
|
|
+ // common.radius = bigRingRadius;
|
|
|
|
|
+ // common.lineWidth = ringWidth;
|
|
|
|
|
+ // var bgRing = getBgRing()
|
|
|
|
|
+
|
|
|
|
|
+ // const realRingBig: RealRing = {
|
|
|
|
|
+ // color: ColorType.day + '66',
|
|
|
|
|
+ // startArc: 0,
|
|
|
|
|
+ // durationArc: 2
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
- if (authInfo && authInfo.day_completed && now1 > authInfo.day_completed.sunset_ts) {
|
|
|
|
|
- realRingBig.color = ColorType.day
|
|
|
|
|
- var duration = (authInfo.day_completed.sunset_ts - authInfo.day_completed.sunrise_ts) / 1000
|
|
|
|
|
- // var start = new Date(authInfo.day_completed.sunrise_ts)
|
|
|
|
|
- // var start = new Date(authInfo.night_completed.sunset_ts)
|
|
|
|
|
- var newT = TimeFormatter.transferTimestamp(authInfo.day_completed.sunrise_ts, authInfo.timezone)
|
|
|
|
|
- var start = new Date(newT)
|
|
|
|
|
- realRingBig.startArc = (start.getHours() * 3600 + start.getMinutes() * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
|
|
|
|
|
- realRingBig.durationArc = (duration) / (24 * 3600) * 2 * Math.PI;
|
|
|
|
|
- return <Rings common={common} bgRing={bgRing} targetRing={realRingBig} canvasId={'ddddsss_day' + 'index_day'} />
|
|
|
|
|
|
|
+ // var now1 = new Date().getTime()
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- var sunRise = 6 * 60
|
|
|
|
|
- var sunSet = 18 * 60
|
|
|
|
|
|
|
+ // if (authInfo && authInfo.day_completed && now1 > authInfo.day_completed.sunset_ts) {
|
|
|
|
|
+ // realRingBig.color = ColorType.day
|
|
|
|
|
+ // var duration = (authInfo.day_completed.sunset_ts - authInfo.day_completed.sunrise_ts) / 1000
|
|
|
|
|
+ // // var start = new Date(authInfo.day_completed.sunrise_ts)
|
|
|
|
|
+ // // var start = new Date(authInfo.night_completed.sunset_ts)
|
|
|
|
|
+ // var newT = TimeFormatter.transferTimestamp(authInfo.day_completed.sunrise_ts, authInfo.timezone)
|
|
|
|
|
+ // var start = new Date(newT)
|
|
|
|
|
+ // realRingBig.startArc = (start.getHours() * 3600 + start.getMinutes() * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
|
|
|
|
|
+ // realRingBig.durationArc = (duration) / (24 * 3600) * 2 * Math.PI;
|
|
|
|
|
+ // return <Rings common={common} bgRing={bgRing} targetRing={realRingBig} canvasId={'ddddsss_day' + 'index_day'} />
|
|
|
|
|
|
|
|
- var sunRiseObj = dayStore.dayRingSunrise
|
|
|
|
|
- var sunSetObj = dayStore.dayRingSunset
|
|
|
|
|
- sunRise = parseInt(sunRiseObj.split(':')[0]) * 60 + parseInt(sunRiseObj.split(':')[1])
|
|
|
|
|
- sunSet = parseInt(sunSetObj.split(':')[0]) * 60 + parseInt(sunSetObj.split(':')[1])
|
|
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
|
|
+ // if (authInfo && authInfo.timezone) {
|
|
|
|
|
+ // now1 = TimeFormatter.transferTimestamp(now1, authInfo.timezone)
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
- var duration = sunSet - sunRise
|
|
|
|
|
|
|
|
|
|
- realRingBig.startArc = (sunRise * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
|
|
|
|
|
- realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
|
|
|
|
|
|
|
+ // var sunRise = 6 * 60
|
|
|
|
|
+ // var sunSet = 18 * 60
|
|
|
|
|
|
|
|
- var currentDot = getDot(null, false)
|
|
|
|
|
- currentDot.offset = (authInfo && authInfo.timezone) ? TimeFormatter.timeZoneOffset(authInfo.timezone) : 0
|
|
|
|
|
- var date = new Date()
|
|
|
|
|
- var minutes = date.getHours() * 60 + date.getMinutes()
|
|
|
|
|
- if (minutes < sunRise) {
|
|
|
|
|
- minutes += 1440
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // var sunRiseObj = user.isLogin ? dayStore.dayRingSunrise : '06:00:00'
|
|
|
|
|
+ // var sunSetObj = user.isLogin ? dayStore.dayRingSunset : '18:00:00'
|
|
|
|
|
+ // sunRise = parseInt(sunRiseObj.split(':')[0]) * 60 + parseInt(sunRiseObj.split(':')[1])
|
|
|
|
|
+ // sunSet = parseInt(sunSetObj.split(':')[0]) * 60 + parseInt(sunSetObj.split(':')[1])
|
|
|
|
|
|
|
|
- currentDot.color = ColorType.day
|
|
|
|
|
|
|
|
|
|
|
|
+ // var duration = sunSet - sunRise
|
|
|
|
|
|
|
|
- var now = new Date()
|
|
|
|
|
- var t = now.getHours() * 60 + now.getMinutes()
|
|
|
|
|
- var duration2 = t - sunRise
|
|
|
|
|
- if (duration2 < 0) {
|
|
|
|
|
- duration2 += 24 * 60
|
|
|
|
|
- }
|
|
|
|
|
- var realRing: RealRing = {
|
|
|
|
|
- color: ColorType.day,
|
|
|
|
|
- startArc: (sunRise * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0,
|
|
|
|
|
- durationArc: (duration2 * 60) / (24 * 3600) * 2 * Math.PI
|
|
|
|
|
- }
|
|
|
|
|
- if (dayStore.dayRingDate) {
|
|
|
|
|
- if (new Date(dayStore.dayRingDate).getDate() != new Date().getDate()) {
|
|
|
|
|
- realRing = null;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // realRingBig.startArc = (sunRise * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
|
|
|
|
|
+ // realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
|
|
|
|
|
|
|
|
- if (!user.isLogin) {
|
|
|
|
|
- currentDot = null
|
|
|
|
|
- realRing = null
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // var currentDot = getDot(null, false)
|
|
|
|
|
+ // currentDot.offset = (authInfo && authInfo.timezone) ? TimeFormatter.timeZoneOffset(authInfo.timezone) : 0
|
|
|
|
|
+ // var date = new Date()
|
|
|
|
|
+ // var minutes = date.getHours() * 60 + date.getMinutes()
|
|
|
|
|
+ // if (minutes < sunRise) {
|
|
|
|
|
+ // minutes += 1440
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
- return <Rings common={common} bgRing={bgRing} targetRing={realRingBig} realRing={duration2 <= duration ? realRing : null} currentDot={currentDot} canvasId={'day_day2'} />
|
|
|
|
|
|
|
+ // currentDot.color = ColorType.day
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // var now = new Date()
|
|
|
|
|
+ // now = localNow(now)
|
|
|
|
|
+ // var t = now.getHours() * 60 + now.getMinutes()
|
|
|
|
|
+ // var duration2 = t - sunRise
|
|
|
|
|
+ // if (duration2 < 0) {
|
|
|
|
|
+ // duration2 += 24 * 60
|
|
|
|
|
+ // }
|
|
|
|
|
+ // var realRing: RealRing = {
|
|
|
|
|
+ // color: ColorType.day,
|
|
|
|
|
+ // startArc: (sunRise * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0,
|
|
|
|
|
+ // durationArc: (duration2 * 60) / (24 * 3600) * 2 * Math.PI
|
|
|
|
|
+ // }
|
|
|
|
|
+ // if (dayStore.dayRingDate) {
|
|
|
|
|
+ // if (new Date(dayStore.dayRingDate).getDate() != now.getDate()) {
|
|
|
|
|
+ // realRing = null;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // // if (!user.isLogin) {
|
|
|
|
|
+ // // currentDot = null
|
|
|
|
|
+ // // realRing = null
|
|
|
|
|
+ // // }
|
|
|
|
|
+
|
|
|
|
|
+ // return <Rings common={common} bgRing={bgRing} targetRing={realRingBig} realRing={duration2 <= duration ? realRing : null} currentDot={currentDot} canvasId={'day_day2'} />
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function getSunsetDuration() {
|
|
function getSunsetDuration() {
|
|
|
|
|
+
|
|
|
if (authInfo && authInfo.night_completed && new Date().getTime() > authInfo.night_completed.sunrise_ts) {
|
|
if (authInfo && authInfo.night_completed && new Date().getTime() > authInfo.night_completed.sunrise_ts) {
|
|
|
global.sunsetDuration = TimeFormatter.durationFormate(authInfo.night_completed.sunrise_ts, authInfo.night_completed.sunset_ts)
|
|
global.sunsetDuration = TimeFormatter.durationFormate(authInfo.night_completed.sunrise_ts, authInfo.night_completed.sunset_ts)
|
|
|
return TimeFormatter.durationFormate(authInfo.night_completed.sunrise_ts, authInfo.night_completed.sunset_ts)
|
|
return TimeFormatter.durationFormate(authInfo.night_completed.sunrise_ts, authInfo.night_completed.sunset_ts)
|
|
@@ -1121,7 +989,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
var now = new Date()
|
|
var now = new Date()
|
|
|
now = localNow(now)
|
|
now = localNow(now)
|
|
|
if (props.isNight && sunsetDate) {
|
|
if (props.isNight && sunsetDate) {
|
|
|
- if (now.getTime() > sunsetDate.getTime()) {
|
|
|
|
|
|
|
+ if (new Date().getTime() > sunsetDate.getTime()) {
|
|
|
global.sunsetDuration = TimeFormatter.countdown(sunsetDate.getTime(), now.getTime())
|
|
global.sunsetDuration = TimeFormatter.countdown(sunsetDate.getTime(), now.getTime())
|
|
|
return TimeFormatter.countdown(sunsetDate.getTime(), now.getTime())
|
|
return TimeFormatter.countdown(sunsetDate.getTime(), now.getTime())
|
|
|
}
|
|
}
|
|
@@ -1138,8 +1006,8 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var duration = (sunRise - sunSet) * 60 * 1000
|
|
var duration = (sunRise - sunSet) * 60 * 1000
|
|
|
- global.sunsetDuration = TimeFormatter.calculateTimeDifference(new Date().getTime(), new Date().getTime() + duration);
|
|
|
|
|
- return TimeFormatter.calculateTimeDifference(new Date().getTime(), new Date().getTime() + duration);
|
|
|
|
|
|
|
+ global.sunsetDuration = TimeFormatter.calculateTimeDifference(now.getTime(), now.getTime() + duration);
|
|
|
|
|
+ return TimeFormatter.calculateTimeDifference(now.getTime(), now.getTime() + duration);
|
|
|
|
|
|
|
|
// //COMPLETED
|
|
// //COMPLETED
|
|
|
// if (time.last_real_check_time && time.status != 'WAIT_FOR_START' && time.status != 'COMPLETED') {
|
|
// if (time.last_real_check_time && time.status != 'WAIT_FOR_START' && time.status != 'COMPLETED') {
|
|
@@ -1168,11 +1036,11 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var now = new Date()
|
|
var now = new Date()
|
|
|
- debugger
|
|
|
|
|
|
|
+ now = localNow(now)
|
|
|
if (!props.isNight && sunriseDate) {
|
|
if (!props.isNight && sunriseDate) {
|
|
|
if (now.getTime() > sunriseDate.getTime()) {
|
|
if (now.getTime() > sunriseDate.getTime()) {
|
|
|
global.sunriseDuration = TimeFormatter.countdown(sunriseDate.getTime())
|
|
global.sunriseDuration = TimeFormatter.countdown(sunriseDate.getTime())
|
|
|
- return TimeFormatter.countdown(sunriseDate.getTime())
|
|
|
|
|
|
|
+ return TimeFormatter.countdown(sunriseDate.getTime(), now.getTime())
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1186,19 +1054,25 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var duration = (sunSet - sunRise) * 60 * 1000
|
|
var duration = (sunSet - sunRise) * 60 * 1000
|
|
|
- global.sunriseDuration = TimeFormatter.calculateTimeDifference(new Date().getTime(), new Date().getTime() + duration);
|
|
|
|
|
- return TimeFormatter.calculateTimeDifference(new Date().getTime(), new Date().getTime() + duration);
|
|
|
|
|
|
|
+ global.sunriseDuration = TimeFormatter.calculateTimeDifference(now.getTime(), now.getTime() + duration);
|
|
|
|
|
+ return TimeFormatter.calculateTimeDifference(now.getTime(), now.getTime() + duration);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function completedDate() {
|
|
function completedDate() {
|
|
|
if (props.isNight) {
|
|
if (props.isNight) {
|
|
|
if (authInfo && authInfo.night_completed && new Date().getTime() > authInfo.night_completed.sunrise_ts) {
|
|
if (authInfo && authInfo.night_completed && new Date().getTime() > authInfo.night_completed.sunrise_ts) {
|
|
|
- return TimeFormatter.dateDescription(authInfo.night_completed.sunset_ts)
|
|
|
|
|
|
|
+ if (localNow(new Date()).getTime() != new Date().getTime()) {
|
|
|
|
|
+ return TimeFormatter.getMonthAndDayByTimestamp(authInfo.night_completed.sunrise_ts, true)
|
|
|
|
|
+ }
|
|
|
|
|
+ return TimeFormatter.dateDescription(authInfo.night_completed.sunrise_ts, true)
|
|
|
}
|
|
}
|
|
|
return ''
|
|
return ''
|
|
|
}
|
|
}
|
|
|
if (authInfo && authInfo.day_completed && new Date().getTime() > authInfo.day_completed.sunset_ts) {
|
|
if (authInfo && authInfo.day_completed && new Date().getTime() > authInfo.day_completed.sunset_ts) {
|
|
|
- return TimeFormatter.dateDescription(authInfo.day_completed.sunrise_ts)
|
|
|
|
|
|
|
+ if (localNow(new Date()).getTime() != new Date().getTime()) {
|
|
|
|
|
+ return TimeFormatter.getMonthAndDayByTimestamp(authInfo.day_completed.sunset_ts, true)
|
|
|
|
|
+ }
|
|
|
|
|
+ return TimeFormatter.dateDescription(authInfo.day_completed.sunset_ts, true)
|
|
|
}
|
|
}
|
|
|
return ''
|
|
return ''
|
|
|
}
|
|
}
|
|
@@ -1220,14 +1094,14 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
if (showArrow()) {
|
|
if (showArrow()) {
|
|
|
if (props.isNight) {
|
|
if (props.isNight) {
|
|
|
if (authInfo.day_completed && new Date().getTime() > authInfo.day_completed.sunset_ts) {
|
|
if (authInfo.day_completed && new Date().getTime() > authInfo.day_completed.sunset_ts) {
|
|
|
- return '更新暂停'
|
|
|
|
|
|
|
+ return t('feature.day_night.update_paused')
|
|
|
}
|
|
}
|
|
|
- return '已结束'
|
|
|
|
|
|
|
+ return t('feature.day_night.ended')
|
|
|
}
|
|
}
|
|
|
- return '更新暂停'
|
|
|
|
|
|
|
+ return t('feature.day_night.update_paused')
|
|
|
}
|
|
}
|
|
|
var strTime = props.isNight ? getSunsetDuration() : getSunriseDuration()
|
|
var strTime = props.isNight ? getSunsetDuration() : getSunriseDuration()
|
|
|
- return (strTime.indexOf('小时') != -1 || strTime.indexOf('分钟') != -1) ? '即将到来' : '正在进行'
|
|
|
|
|
|
|
+ return (strTime.indexOf('小时') != -1 || strTime.indexOf('分钟') != -1) ? t('feature.day_night.upcoming') : t('feature.day_night.in_real_time')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function footerDesc() {
|
|
function footerDesc() {
|
|
@@ -1255,18 +1129,51 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
var now = new Date()
|
|
var now = new Date()
|
|
|
if (props.isNight) {
|
|
if (props.isNight) {
|
|
|
if (now.getTime() < sunsetDate.getTime()) {
|
|
if (now.getTime() < sunsetDate.getTime()) {
|
|
|
- return <IconSunset color={ColorType.night + '66'} width={14} />
|
|
|
|
|
|
|
+ return <IconSunset color={ColorType.night + '66'} width={rpxToPx(28)} />
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- return <IconSunrise color={ColorType.night + '66'} width={14} />
|
|
|
|
|
|
|
+ return <IconSunrise color={ColorType.night + '66'} width={rpxToPx(28)} />
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (now.getTime() > sunriseDate.getTime() && now.getTime() < sunsetDate.getTime()) {
|
|
if (now.getTime() > sunriseDate.getTime() && now.getTime() < sunsetDate.getTime()) {
|
|
|
|
|
|
|
|
- return <IconSunset color={ColorType.day + '66'} width={14} />
|
|
|
|
|
|
|
+ return <IconSunset color={ColorType.day + '66'} width={rpxToPx(28)} />
|
|
|
|
|
+ }
|
|
|
|
|
+ return <IconSunrise color={ColorType.day + '66'} width={rpxToPx(28)} />
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function currentTime() {
|
|
|
|
|
+ var now = new Date()
|
|
|
|
|
+ var now2 = localNow(now)
|
|
|
|
|
+ if (now.getTime() == now2.getTime()) {
|
|
|
|
|
+ return ''
|
|
|
|
|
+ }
|
|
|
|
|
+ var offset = TimeFormatter.timeZoneOffset(authInfo.timezone);
|
|
|
|
|
+ var hour = Math.floor(Math.abs(offset) / 60)
|
|
|
|
|
+ var minute = Math.abs(offset) % 60
|
|
|
|
|
+ var time = ''
|
|
|
|
|
+ if (global.language == 'en') {
|
|
|
|
|
+ time = `${hour} h`
|
|
|
|
|
+ if (minute > 0) {
|
|
|
|
|
+ time += ` ${minute} m`
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ time = `${hour}小时`
|
|
|
|
|
+ if (minute > 0) {
|
|
|
|
|
+ time += `${minute}分钟`
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- return <IconSunrise color={ColorType.day + '66'} width={14} />
|
|
|
|
|
|
|
+ return <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
|
|
|
|
+ <Text className='ring_city'>{getCity()}</Text>
|
|
|
|
|
+ <Text className='ring_clock' style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{TimeFormatter.padZero(now2.getHours()) + ':' + TimeFormatter.padZero(now2.getMinutes())}</Text>
|
|
|
|
|
+ <Text className='ring_timezone'>{
|
|
|
|
|
+ offset > 0 ? t('feature.day_night.ahead_desc', { time: time }) : t('feature.day_night.behind_desc', { time: time })
|
|
|
|
|
+ }</Text>
|
|
|
|
|
+ </View>
|
|
|
|
|
|
|
|
|
|
+ // return (now.getMonth() + 1) + '.' + now.getDate() + ' ' + TimeFormatter.padZero(now.getHours()) + ':' + TimeFormatter.padZero(now.getMinutes())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return <Box><View style={{ position: 'relative' }}>
|
|
return <Box><View style={{ position: 'relative' }}>
|
|
@@ -1283,9 +1190,12 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
padding: 0,
|
|
padding: 0,
|
|
|
alignItems: 'center'
|
|
alignItems: 'center'
|
|
|
}}>
|
|
}}>
|
|
|
- {
|
|
|
|
|
- props.isNight ? nightRing() : dayRing()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ <View style={{ display: 'flex', position: 'relative' }}>
|
|
|
|
|
+ {
|
|
|
|
|
+ props.isNight ? nightRing() : dayRing()
|
|
|
|
|
+ }
|
|
|
|
|
+ <View style={{ color: '#fff', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center', display: 'flex' }}>{currentTime()}</View>
|
|
|
|
|
+ </View>
|
|
|
<View style={{ display: 'flex', flexDirection: 'column', flexShrink: 0, flex: 1, marginLeft: rpxToPx(52) }}>
|
|
<View style={{ display: 'flex', flexDirection: 'column', flexShrink: 0, flex: 1, marginLeft: rpxToPx(52) }}>
|
|
|
<Text className='ring_card_duration_title'>{props.isNight ? t('feature.common.overnight') : t('feature.common.day')}</Text>
|
|
<Text className='ring_card_duration_title'>{props.isNight ? t('feature.common.overnight') : t('feature.common.day')}</Text>
|
|
|
<Text className='ring_card_duration_value' style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{props.isNight ? getSunsetDuration() : getSunriseDuration()}</Text>
|
|
<Text className='ring_card_duration_value' style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{props.isNight ? getSunsetDuration() : getSunriseDuration()}</Text>
|
|
@@ -1293,6 +1203,9 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
{/* <Text className='duration_value22' style={{ color: !props.isNight ? ColorType.night : ColorType.day }}>{!props.isNight ? getSunsetTime() : getSunriseTime()}</Text> */}
|
|
{/* <Text className='duration_value22' style={{ color: !props.isNight ? ColorType.night : ColorType.day }}>{!props.isNight ? getSunsetTime() : getSunriseTime()}</Text> */}
|
|
|
|
|
|
|
|
</View>
|
|
</View>
|
|
|
|
|
+ {
|
|
|
|
|
+ !showArrow() && <Image className="card_arrow2" src={require('@/assets/images/arrow3.png')} />
|
|
|
|
|
+ }
|
|
|
{/* <View style={{ position: 'absolute', right: -rpxToPx(20), top: -rpxToPx(20) }}>
|
|
{/* <View style={{ position: 'absolute', right: -rpxToPx(20), top: -rpxToPx(20) }}>
|
|
|
{
|
|
{
|
|
|
authInfo && authInfo.lat ?
|
|
authInfo && authInfo.lat ?
|
|
@@ -1308,9 +1221,25 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
}
|
|
|
</View> */}
|
|
</View> */}
|
|
|
<View className='day_card_header'>
|
|
<View className='day_card_header'>
|
|
|
- <View className='free' style={{ backgroundColor: props.isNight ? ColorType.night : ColorType.day, color: props.isNight ? '#fff' : '#1C1C1C' }}>{currentStatus()}</View>
|
|
|
|
|
|
|
+ <View className='free' style={{ backgroundColor: props.isNight ? ColorType.night + '33' : ColorType.day + '33', color: props.isNight ? ColorType.night : ColorType.day }}>{currentStatus()}</View>
|
|
|
</View>
|
|
</View>
|
|
|
- <View className='day_card_footer'>
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ showArrow() ? <View className='day_card_footer'>
|
|
|
|
|
+ <Text className='day_card_footer_date'>{t('feature.day_night.update_paused') == currentStatus() ? t('feature.day_night.last_updated') : ''}
|
|
|
|
|
+ {
|
|
|
|
|
+ completedDate()
|
|
|
|
|
+ }
|
|
|
|
|
+ </Text>
|
|
|
|
|
+ <Image className="card_arrow" src={require('@/assets/images/arrow3.png')} />
|
|
|
|
|
+ </View> :
|
|
|
|
|
+ <View className='day_card_footer2'>
|
|
|
|
|
+ {
|
|
|
|
|
+ footerIcon()
|
|
|
|
|
+ }
|
|
|
|
|
+ <Text className='footer_desc_text' style={{ color: props.isNight ? ColorType.night : ColorType.day, opacity: 0.4 }}>{footerDesc()}</Text>
|
|
|
|
|
+ </View>
|
|
|
|
|
+ }
|
|
|
|
|
+ {/* <View className='day_card_footer'>
|
|
|
<Text className='day_card_footer_date'>
|
|
<Text className='day_card_footer_date'>
|
|
|
{
|
|
{
|
|
|
completedDate()
|
|
completedDate()
|
|
@@ -1326,7 +1255,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
{
|
|
{
|
|
|
!showArrow() && <Text className='footer_desc_text' style={{ color: props.isNight ? ColorType.night : ColorType.day, opacity: 0.4 }}>{footerDesc()}</Text>
|
|
!showArrow() && <Text className='footer_desc_text' style={{ color: props.isNight ? ColorType.night : ColorType.day, opacity: 0.4 }}>{footerDesc()}</Text>
|
|
|
}
|
|
}
|
|
|
- </View>
|
|
|
|
|
|
|
+ </View> */}
|
|
|
</View>
|
|
</View>
|
|
|
</View>
|
|
</View>
|
|
|
</View>
|
|
</View>
|