|
|
@@ -14,6 +14,7 @@ import { setNightRingData, showNight, updateMember } from '@/store/night'
|
|
|
import Modal from '@/components/layout/Modal.weapp'
|
|
|
import { rpxToPx } from '@/utils/tools'
|
|
|
import { jumpPage } from '@/features/trackTimeDuration/hooks/Common'
|
|
|
+import DayNightDetailPopup from './DayNightDetailPopup'
|
|
|
|
|
|
let useNavigation;
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
@@ -41,6 +42,7 @@ sunriseB.setMilliseconds(0)
|
|
|
|
|
|
let lastDayInfo: any = null;
|
|
|
let lastNightInfo: any = null;
|
|
|
+let joingMember = false
|
|
|
export default function DayNightCard(props: { isNight: boolean, count: number }) {
|
|
|
const user = useSelector((state: any) => state.user);
|
|
|
const dayStore = useSelector((state: any) => state.day);
|
|
|
@@ -56,7 +58,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
|
|
|
|
|
|
const [showDetailModal, setShowDetailModal] = useState(false)
|
|
|
- const [showStageDetail, setShowStageDetail] = useState(false)
|
|
|
+ const [showDetailPopup, setShowDetailPopup] = useState(false)
|
|
|
// const [locationDetail, setLocationDetail] = useState(null)
|
|
|
|
|
|
const [nightDate, setNightDate] = useState(new Date())
|
|
|
@@ -105,6 +107,11 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
|
}, [user.isLogin])
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ locationDetail = global.locationDetail
|
|
|
+ setAuthInfo(locationDetail)
|
|
|
+ }, [global.locationDetail])
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
if (locationDetail)
|
|
|
updateDate(locationDetail)
|
|
|
@@ -134,6 +141,41 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
|
}, [props.count])
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ if (user.test_user && joingMember) {
|
|
|
+ auth()
|
|
|
+ }
|
|
|
+ if (!user.test_user) {
|
|
|
+ lastNightInfo = null
|
|
|
+ lastDayInfo = null
|
|
|
+ locationDetail = null
|
|
|
+ setAuthInfo(null)
|
|
|
+ setSunriseTime('06:00')
|
|
|
+ setSunriseTmrTime('06:00')
|
|
|
+ setSunsetTime('18:00')
|
|
|
+ dispatch(updateMember({ isMember: user.test_user, gpsInfo: null }))
|
|
|
+
|
|
|
+
|
|
|
+ dispatch(setDayRingData({
|
|
|
+ date: new Date().getTime(),
|
|
|
+ sunrise: '06:00',
|
|
|
+ sunset: '18:00'
|
|
|
+ }))
|
|
|
+ dispatch(setNightRingData({
|
|
|
+ date: new Date().getTime(),
|
|
|
+ sunrise: '06:00',
|
|
|
+ sunset: '18:00'
|
|
|
+ }))
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ var gps = Taro.getStorageSync('gps')
|
|
|
+ if (gps) {
|
|
|
+ locationDetail = JSON.parse(gps)
|
|
|
+ global.locationDetail = JSON.parse(gps)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, [user.test_user])
|
|
|
+
|
|
|
function updateDate(data) {
|
|
|
|
|
|
var today = new Date()
|
|
|
@@ -141,7 +183,8 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
var tomorrow = new Date(today.getTime() + 24 * 3600 * 1000)
|
|
|
// 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())}`
|
|
|
- if (data && data.daylights && data.daylights.length > 0) {
|
|
|
+ if (user.test_user && data && data.daylights && data.daylights.length > 0) {
|
|
|
+ debugger
|
|
|
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 todaySunsetDate = new Date(data.daylights[1].date + 'T' + data.daylights[1].sunset)
|
|
|
@@ -209,6 +252,24 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
+ locationDetail = null
|
|
|
+ setAuthInfo(null)
|
|
|
+ setSunriseTime('06:00')
|
|
|
+ setSunriseTmrTime('06:00')
|
|
|
+ setSunsetTime('18:00')
|
|
|
+ dispatch(updateMember({ isMember: user.test_user, gpsInfo: null }))
|
|
|
+
|
|
|
+
|
|
|
+ dispatch(setDayRingData({
|
|
|
+ date: new Date().getTime(),
|
|
|
+ sunrise: '06:00',
|
|
|
+ sunset: '18:00'
|
|
|
+ }))
|
|
|
+ dispatch(setNightRingData({
|
|
|
+ date: new Date().getTime(),
|
|
|
+ sunrise: '06:00',
|
|
|
+ sunset: '18:00'
|
|
|
+ }))
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -220,6 +281,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
) {
|
|
|
return
|
|
|
}
|
|
|
+ debugger
|
|
|
lastNightInfo = {
|
|
|
date,
|
|
|
sunrise,
|
|
|
@@ -260,7 +322,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function footer() {
|
|
|
+ function footer(e) {
|
|
|
return <View className='day_night_card_footer' onClick={tapFooter}>
|
|
|
<Text style={{ color: '#9E9E9E', fontSize: rpxToPx(20) }}>{
|
|
|
// !isMember ? t('feature.track_time_duration.third_ring.member_desc') :
|
|
|
@@ -270,7 +332,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
{
|
|
|
authInfo && (authInfo as any).lat && <Text style={{ color: '#9E9E9E', fontSize: rpxToPx(20) }} onClick={(e) => {
|
|
|
e.stopPropagation()
|
|
|
- auth()
|
|
|
+ auth(e)
|
|
|
}}>Edit Location</Text>
|
|
|
}
|
|
|
</View>
|
|
|
@@ -310,19 +372,24 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
|
|
|
|
function tapCard(e) {
|
|
|
- if (process.env.TARO_ENV == 'weapp') {
|
|
|
- e.stopPropagation()
|
|
|
- }
|
|
|
+ // if (process.env.TARO_ENV == 'weapp') {
|
|
|
+ // e.stopPropagation()
|
|
|
+ // }
|
|
|
if (!user.isLogin) {
|
|
|
jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
|
|
|
return
|
|
|
}
|
|
|
- if (props.isNight && !nightStore.showNightRing || !props.isNight && !dayStore.showDayRing) {
|
|
|
+ if (!dayStore.showDayRing) {
|
|
|
return
|
|
|
}
|
|
|
+ setShowDetailPopup(true)
|
|
|
}
|
|
|
|
|
|
- function auth() {
|
|
|
+ function auth(e?: any) {
|
|
|
+ if (e && process.env.TARO_ENV == 'weapp') {
|
|
|
+ e.stopPropagation()
|
|
|
+ }
|
|
|
+ joingMember = false;
|
|
|
Taro.chooseLocation({
|
|
|
success: function (res) {
|
|
|
var today = new Date()
|
|
|
@@ -518,6 +585,8 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
if (global.clearDayLocation) {
|
|
|
global.clearDayLocation()
|
|
|
}
|
|
|
+ lastNightInfo = null
|
|
|
+ lastDayInfo = null
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
console.log('用户点击取消')
|
|
|
@@ -560,7 +629,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
<Text>暂无位置信息</Text>
|
|
|
</View>
|
|
|
}
|
|
|
- return <View>
|
|
|
+ return <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
{
|
|
|
<View className="cell_bg">
|
|
|
{
|
|
|
@@ -600,11 +669,17 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
|
|
|
|
|
|
</View>
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+ <Text onClick={() => {
|
|
|
+ clearData()
|
|
|
+ setShowDetailModal(false)
|
|
|
+ }} style={{ width: '100%', textAlign: 'center', marginBottom: 50, color: '#fff', marginTop: 20 }}>清除位置</Text>
|
|
|
</View>
|
|
|
}
|
|
|
|
|
|
- function modalContent() {
|
|
|
+ function modalContent2() {
|
|
|
if (process.env.TARO_ENV == 'weapp') {
|
|
|
return <Modal
|
|
|
testInfo={null}
|
|
|
@@ -641,6 +716,64 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function modalContent() {
|
|
|
+ if (process.env.TARO_ENV == 'weapp') {
|
|
|
+ return <Modal
|
|
|
+ testInfo={null}
|
|
|
+ dismiss={() => {
|
|
|
+ setShowDetailPopup(false)
|
|
|
+ }}
|
|
|
+ confirm={() => { }}>
|
|
|
+ <DayNightDetailPopup
|
|
|
+ sunsetDate={sunsetDate}
|
|
|
+ sunriseDate={sunriseDate}
|
|
|
+ sunriseTmrDate={sunriseTmrDate}
|
|
|
+ sunsetTime={sunsetTime}
|
|
|
+ sunriseTime={sunriseTime}
|
|
|
+ sunriseTmrTime={sunriseTmrTime}
|
|
|
+ isNight={props.isNight}
|
|
|
+ authInfo={authInfo}
|
|
|
+ nightDate={nightDate}
|
|
|
+ dayDate={dayDate}
|
|
|
+ onClose={() => { setShowDetailPopup(false) }}
|
|
|
+ />
|
|
|
+ </Modal>
|
|
|
+ }
|
|
|
+ else if (process.env.TARO_ENV == 'rn') {
|
|
|
+ return <PageContainer style={{ backgroundColor: '#1c1c1c' }}
|
|
|
+ // overlayStyle='background-color:rgba(0,0,0,0.9)'
|
|
|
+ // custom-style='background-color:#1c1c1c'
|
|
|
+ overlayStyle={{ backgroundColor: 'rgba(0,0,0,0.9)' }}
|
|
|
+ customStyle={{ backgroundColor: '#1c1c1c' }}
|
|
|
+ closeOnSlideDown={false}
|
|
|
+ onBeforeEnter={() => {
|
|
|
+
|
|
|
+ }}
|
|
|
+ onBeforeLeave={() => {
|
|
|
+ }}
|
|
|
+ onClick={() => { alert('b') }}
|
|
|
+ onClickOverlay={() => { alert('a') }}
|
|
|
+ onAfterLeave={() => { setShowDetailPopup(false) }}
|
|
|
+ show={showDetailModal} round={true} overlay={true} position='bottom'
|
|
|
+ >
|
|
|
+ <DayNightDetailPopup
|
|
|
+ sunsetDate={sunsetDate}
|
|
|
+ sunriseDate={sunriseDate}
|
|
|
+ sunriseTmrDate={sunriseTmrDate}
|
|
|
+ sunsetTime={sunsetTime}
|
|
|
+ sunriseTime={sunriseTime}
|
|
|
+ sunriseTmrTime={sunriseTmrTime}
|
|
|
+ isNight={props.isNight}
|
|
|
+ authInfo={authInfo}
|
|
|
+ nightDate={nightDate}
|
|
|
+ dayDate={dayDate}
|
|
|
+ onClose={() => { setShowDetailPopup(false) }}
|
|
|
+ />
|
|
|
+ </PageContainer>
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
function nightDurationDesc() {
|
|
|
if (!authInfo || !(authInfo as any).lat) {
|
|
|
if (new Date().getHours() >= 6) {
|
|
|
@@ -674,13 +807,181 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
// return `Tomorrow ${sunriseTime} - ${sunsetTime}`
|
|
|
}
|
|
|
|
|
|
+ function nightDuration() {
|
|
|
+ if (!authInfo || !(authInfo as any).lat) {
|
|
|
+ if (new Date().getHours() >= 6) {
|
|
|
+ return `${sunsetTime} - ${sunriseTmrTime}`
|
|
|
+ }
|
|
|
+ return `${sunsetTime} - ${sunriseTmrTime}`
|
|
|
+ // return `Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
|
|
|
+ }
|
|
|
+ if (nightDate.getDate() == new Date().getDate()) {
|
|
|
+ return `${sunsetTime} - ${sunriseTmrTime}`
|
|
|
+ }
|
|
|
+ return `${sunsetTime} - ${sunriseTmrTime}`
|
|
|
+ //`Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
|
|
|
+ }
|
|
|
+
|
|
|
+ function dayDuration() {
|
|
|
+ if (!authInfo || !(authInfo as any).lat) {
|
|
|
+ if (new Date().getHours() >= 18) {
|
|
|
+ return `${sunriseTime} - ${sunsetTime}`
|
|
|
+
|
|
|
+ // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
|
|
|
+ }
|
|
|
+ return `${sunriseTime} - ${sunsetTime}`
|
|
|
+ // return `Today ${sunriseTime} - ${sunsetTime}`
|
|
|
+ }
|
|
|
+ if (dayDate.getDate() == new Date().getDate()) {
|
|
|
+ return `${sunriseTime} - ${sunsetTime}`
|
|
|
+ // return `Today ${sunriseTime} - ${sunsetTime}`
|
|
|
+ }
|
|
|
+ return `${sunriseTime} - ${sunsetTime}`
|
|
|
+ // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
|
|
|
+ }
|
|
|
+
|
|
|
+ function nightDurationDesc1() {
|
|
|
+ if (!authInfo || !(authInfo as any).lat) {
|
|
|
+ if (new Date().getHours() >= 6) {
|
|
|
+ return `${t('feature.day_night.tonight')}${t('feature.day_night.to')}${t('feature.day_night.tomorrow_morning')}`
|
|
|
+ }
|
|
|
+ return `${t('feature.day_night.last_night')}${t('feature.day_night.to')}${t('feature.day_night.this_morning')}`
|
|
|
+ // return `Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
|
|
|
+ }
|
|
|
+ if (nightDate.getDate() == new Date().getDate()) {
|
|
|
+ return `${t('feature.day_night.tonight')}${t('feature.day_night.to')}${t('feature.day_night.tomorrow_morning')}`
|
|
|
+ }
|
|
|
+ return `${t('feature.day_night.last_night')}${t('feature.day_night.to')}${t('feature.day_night.this_morning')}`
|
|
|
+ //`Yesterday ${sunsetTime} - Today ${sunriseTmrTime}`
|
|
|
+ }
|
|
|
+
|
|
|
+ function dayDurationDesc1() {
|
|
|
+ if (!authInfo || !(authInfo as any).lat) {
|
|
|
+ if (new Date().getHours() >= 18) {
|
|
|
+ return `${t('feature.day_night.tomorrow')}`
|
|
|
+
|
|
|
+ // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
|
|
|
+ }
|
|
|
+ return `${t('feature.day_night.today')}`
|
|
|
+ // return `Today ${sunriseTime} - ${sunsetTime}`
|
|
|
+ }
|
|
|
+ if (dayDate.getDate() == new Date().getDate()) {
|
|
|
+ return `${t('feature.day_night.today')}`
|
|
|
+ // return `Today ${sunriseTime} - ${sunsetTime}`
|
|
|
+ }
|
|
|
+ return `${t('feature.day_night.tomorrow')}`
|
|
|
+ // return `Tomorrow ${sunriseTime} - ${sunsetTime}`
|
|
|
+ }
|
|
|
+
|
|
|
+ function buy(e) {
|
|
|
+ if (process.env.TARO_ENV == 'weapp') {
|
|
|
+ e.stopPropagation()
|
|
|
+ }
|
|
|
+ joingMember = true
|
|
|
+ Taro.navigateTo({
|
|
|
+ url: '/pages/account/Member'
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ function longClick() {
|
|
|
+ if (user.isLogin && authInfo)
|
|
|
+ setShowDetailModal(true)
|
|
|
+ }
|
|
|
|
|
|
+ return <View style={{ color: '#fff' }} onLongPress={longClick}>
|
|
|
+ <Box onClick={tapCard}>
|
|
|
+ <View style={{marginTop:-rpxToPx(16)}}>
|
|
|
+ <View className='day_night_top'>
|
|
|
+ {
|
|
|
+ user.isLogin ? <Text className='day_night_title'>{props.isNight ? t('feature.day_night.night_ring_login') : t('feature.day_night.day_ring_login')}</Text> :
|
|
|
+ <Text className='day_night_title'>{props.isNight ? t('feature.day_night.night_ring') : t('feature.day_night.day_ring')}</Text>
|
|
|
+ }
|
|
|
|
|
|
+ {
|
|
|
+ user.isLogin && <View className='free' style={{ backgroundColor: props.isNight ? ColorType.night : ColorType.day, color: props.isNight ? '#fff' : '#1C1C1C' }}>{t('feature.day_night.limited_free')}</View>
|
|
|
+ }
|
|
|
+
|
|
|
+ <View style={{ flex: 1 }} />
|
|
|
+ <Switch checked={props.isNight ? dayStore.showDayRing : dayStore.showDayRing}
|
|
|
+ color={props.isNight ? ColorType.night : ColorType.day}
|
|
|
+ onClick={(e) => { e.stopPropagation() }}
|
|
|
+ onChange={(e) => {
|
|
|
+ e.stopPropagation()
|
|
|
+ // setExpand(e.detail.value)
|
|
|
+ // if (props.isNight) {
|
|
|
+ dispatch(showNight(e.detail.value))
|
|
|
+ // }
|
|
|
+ // else {
|
|
|
+ dispatch(showDay(e.detail.value))
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+ Taro.setStorage({
|
|
|
+ key: 'showNightRing',
|
|
|
+ data: e.detail.value
|
|
|
+ })
|
|
|
+ Taro.setStorage({
|
|
|
+ key: 'showDayRing',
|
|
|
+ data: e.detail.value
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ if (user.isLogin) {
|
|
|
+ uploadPerm({ show_ring: e.detail.value })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ {
|
|
|
+ user.isLogin && dayStore.showDayRing && <View style={{ marginTop:rpxToPx(40) }}>
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
|
|
+ <Text className='day_night_value' style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{props.isNight ? nightDuration() : dayDuration()}</Text>
|
|
|
+ <Text className='day_night_desc'>{props.isNight ? nightDurationDesc1() : dayDurationDesc1()}</Text>
|
|
|
+
|
|
|
+ </View>
|
|
|
+
|
|
|
+ <View style={{marginTop:rpxToPx(40),marginBottom:rpxToPx(20)}}>
|
|
|
+ {
|
|
|
+ !user.test_user ? <View className={props.isNight ? 'day_night_card_btn buy_night' : 'day_night_card_btn buy_day'} onClick={buy}>{
|
|
|
+ props.isNight ? t('feature.day_night.get_local_time') : t('feature.day_night.get_local_time_sunrise')
|
|
|
+ }</View> :
|
|
|
+ authInfo && authInfo.lat ?
|
|
|
+ <View style={{display:'flex',alignItems:'center',justifyContent:'center'}}>
|
|
|
+ <View className={props.isNight ? 'night_location_btn' : 'day_location_btn'} onClick={auth}>{getLocation()}</View>
|
|
|
+ </View>
|
|
|
+ :
|
|
|
+ <View className='day_night_card_btn' style={{ backgroundColor: props.isNight ? ColorType.night : ColorType.day }} onClick={auth}>{
|
|
|
+ props.isNight ? t('feature.day_night.get_local_time') : t('feature.day_night.get_local_time_sunrise')
|
|
|
+ }</View>
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+
|
|
|
+ </View>
|
|
|
+ </Box >
|
|
|
+ {
|
|
|
+ showDetailPopup && modalContent()
|
|
|
+ }
|
|
|
+ {
|
|
|
+ showDetailModal && modalContent2()
|
|
|
+ }
|
|
|
+ </View >
|
|
|
+
|
|
|
+ /*
|
|
|
return <View style={{ color: '#fff' }}>
|
|
|
<Box onClick={tapCard}>
|
|
|
<View>
|
|
|
<View className='day_night_top'>
|
|
|
- <Text className='day_night_title'>{props.isNight ? t('feature.day_night.night_ring') : t('feature.day_night.day_ring')}</Text>
|
|
|
+ {
|
|
|
+ user.isLogin?<Text className='day_night_title'>{props.isNight ? t('feature.day_night.night_ring_login') : t('feature.day_night.day_ring_login')}</Text>:
|
|
|
+ <Text className='day_night_title'>{props.isNight ? t('feature.day_night.night_ring') : t('feature.day_night.day_ring')}</Text>
|
|
|
+ }
|
|
|
+
|
|
|
{
|
|
|
user.isLogin && <View className='free' style={{ backgroundColor: props.isNight ? ColorType.night : ColorType.day, color: props.isNight ? '#fff' : '#1C1C1C' }}>{t('feature.day_night.limited_free')}</View>
|
|
|
}
|
|
|
@@ -754,5 +1055,5 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
{
|
|
|
showDetailModal && modalContent()
|
|
|
}
|
|
|
- </View>
|
|
|
+ </View>*/
|
|
|
}
|