|
|
@@ -16,6 +16,9 @@ import { rpxToPx } from '@/utils/tools'
|
|
|
import { jumpPage } from '@/features/trackTimeDuration/hooks/Common'
|
|
|
import DayNightDetailPopup from './DayNightDetailPopup'
|
|
|
import { IconDay, IconInfo, IconNight } from '@/components/basic/Icons'
|
|
|
+import { getClocks } from '@/services/trackTimeDuration'
|
|
|
+import { request } from '@/services/http/request'
|
|
|
+import { API_USER_LOCATION } from '@/services/http/api'
|
|
|
|
|
|
let useNavigation;
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
@@ -174,9 +177,24 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
|
}, [user.test_user])
|
|
|
|
|
|
+ useDidShow(() => {
|
|
|
+ if (!user.isLogin) {
|
|
|
+ dispatch(showNight(false))
|
|
|
+ dispatch(showDay(false))
|
|
|
+ Taro.setStorage({
|
|
|
+ key: 'showNightRing',
|
|
|
+ data: false
|
|
|
+ })
|
|
|
+ Taro.setStorage({
|
|
|
+ key: 'showDayRing',
|
|
|
+ data: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
async function getGPSCache() {
|
|
|
var gps = await getStorage('gps')
|
|
|
- if (gps && gps.length>0) {
|
|
|
+ if (gps && gps.length > 0) {
|
|
|
locationDetail = JSON.parse(gps)
|
|
|
global.locationDetail = JSON.parse(gps)
|
|
|
}
|
|
|
@@ -344,16 +362,59 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
if (e && process.env.TARO_ENV == 'weapp') {
|
|
|
e.stopPropagation()
|
|
|
}
|
|
|
+ var today = new Date()
|
|
|
+ var yesterday = new Date(today.getTime() - 24 * 3600 * 1000)
|
|
|
+ var tomorrow = new Date(today.getTime() + 24 * 3600 * 1000 * 3)
|
|
|
+ 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 (process.env.TARO_ENV == 'rn') {
|
|
|
+ Taro.getLocation({
|
|
|
+ success(res) {
|
|
|
+ systemLocation({
|
|
|
+ lat: res.latitude,
|
|
|
+ lng: res.longitude,
|
|
|
+ // name: 'app test',
|
|
|
+ // address: 'app test',
|
|
|
+ date_start: strYesterday,
|
|
|
+ date_end: strTomorrow,
|
|
|
+ // coordinate_system_standard: 'GCJ-02'
|
|
|
+ }).then(data => {
|
|
|
+ updateDate(data);
|
|
|
+ locationDetail = data;
|
|
|
+ global.locationDetail = locationDetail
|
|
|
+ setAuthInfo(data as any)
|
|
|
+ setSunriseTime((data as any).daylights[0].sunrise)
|
|
|
+ setSunriseTmrTime((data as any).daylights[1].sunrise)
|
|
|
+ setSunsetTime((data as any).daylights[0].sunset)
|
|
|
+ Taro.setStorage({
|
|
|
+ key: 'gps',
|
|
|
+ data: JSON.stringify(data as any)
|
|
|
+ })
|
|
|
+ dispatch(updateMember({ isMember: isMember, gpsInfo: (data as any) }))
|
|
|
+ showRing()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail(res) {
|
|
|
+ if (res.errMsg=='Permissions denied!'){
|
|
|
+ alert('aaa')
|
|
|
+ }
|
|
|
+ console.log(res)
|
|
|
+ showRing()
|
|
|
+ },
|
|
|
+ complete(res) {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
joingMember = false;
|
|
|
Taro.chooseLocation({
|
|
|
latitude: authInfo && authInfo.lat ? authInfo.lat : undefined,
|
|
|
longitude: authInfo && authInfo.lat ? authInfo.lng : undefined,
|
|
|
success: function (res) {
|
|
|
- var today = new Date()
|
|
|
- var yesterday = new Date(today.getTime() - 24 * 3600 * 1000)
|
|
|
- var tomorrow = new Date(today.getTime() + 24 * 3600 * 1000 * 3)
|
|
|
- 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())}`
|
|
|
+
|
|
|
systemLocation({
|
|
|
lat: res.latitude,
|
|
|
lng: res.longitude,
|
|
|
@@ -374,6 +435,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
key: 'gps',
|
|
|
data: JSON.stringify(data as any)
|
|
|
})
|
|
|
+ showRing()
|
|
|
dispatch(updateMember({ isMember: isMember, gpsInfo: (data as any) }))
|
|
|
})
|
|
|
|
|
|
@@ -383,11 +445,28 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
title: '位置修改失败!\n请重新选择就近位置',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
+ showRing()
|
|
|
},
|
|
|
+ complete(res) {
|
|
|
+
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
+ function showRing() {
|
|
|
+ dispatch(showNight(true))
|
|
|
+ dispatch(showDay(true))
|
|
|
+ Taro.setStorage({
|
|
|
+ key: 'showNightRing',
|
|
|
+ data: true
|
|
|
+ })
|
|
|
+ Taro.setStorage({
|
|
|
+ key: 'showDayRing',
|
|
|
+ data: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
function getLocation() {
|
|
|
var city = ''
|
|
|
if ((authInfo as any).address.city.length > 0) {
|
|
|
@@ -683,6 +762,149 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ function tapShow() {
|
|
|
+ dispatch(showNight(true))
|
|
|
+ dispatch(showDay(true))
|
|
|
+ Taro.showModal({
|
|
|
+ title: 'Login Required',
|
|
|
+ content: 'desc',
|
|
|
+ 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() {
|
|
|
+ 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 = '夜间+有位置信息'
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ content = '夜间+无位置信息'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (authInfo && authInfo.lat) {
|
|
|
+ content = '白天+有位置信息'
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ content = '白天+无位置信息'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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('用户点击取消')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return <View>
|
|
|
+ {
|
|
|
+ !user.isLogin && <View style={{ color: '#fff' }} onClick={tapShow}>{props.isNight ? '显示当地夜晚时间' : '显示当地白天时间'}</View>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ user.isLogin && !dayStore.showDayRing && <View style={{ color: '#fff' }} onClick={auth}>{props.isNight ? '显示当地夜晚时间' : '显示当地白天时间'}</View>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ user.isLogin && dayStore.showDayRing && <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
+ <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>
|
|
|
+ {
|
|
|
+ authInfo && authInfo.lat ?
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'row', marginTop: rpxToPx(18) }} onClick={operate}>
|
|
|
+ <View className={props.isNight ? 'night_location_btn' : 'day_location_btn'}>{getLocation()}</View>
|
|
|
+ </View>
|
|
|
+ :
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'row', marginTop: rpxToPx(18) }} onClick={operate}>
|
|
|
+ <View className={props.isNight ? 'night_location_btn' : 'day_location_btn'} >
|
|
|
+ {props.isNight ? t('feature.day_night.get_local_time') : t('feature.day_night.get_local_time_sunrise')}
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+
|
|
|
+ /*
|
|
|
+
|
|
|
return <View style={{ color: '#fff' }} onLongPress={longClick}>
|
|
|
<Box onClick={tapCard}>
|
|
|
<View style={{ marginTop: -rpxToPx(14), marginBottom: -rpxToPx(14) }}>
|
|
|
@@ -703,14 +925,13 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
color={props.isNight ? ColorType.night : ColorType.day}
|
|
|
onClick={(e) => { e.stopPropagation() }}
|
|
|
onChange={(e) => {
|
|
|
- e.stopPropagation()
|
|
|
- // setExpand(e.detail.value)
|
|
|
- // if (props.isNight) {
|
|
|
+ if (process.env.TARO_ENV == 'weapp') {
|
|
|
+ e.stopPropagation()
|
|
|
+ }
|
|
|
+
|
|
|
dispatch(showNight(e.detail.value))
|
|
|
- // }
|
|
|
- // else {
|
|
|
+
|
|
|
dispatch(showDay(e.detail.value))
|
|
|
- // }
|
|
|
|
|
|
|
|
|
Taro.setStorage({
|
|
|
@@ -784,5 +1005,5 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
{
|
|
|
showDetailModal && modalContent2()
|
|
|
}
|
|
|
- </View >
|
|
|
+ </View >*/
|
|
|
}
|