|
|
@@ -2,7 +2,7 @@ import { View, Text, Image } from "@tarojs/components";
|
|
|
import './index_time.scss';
|
|
|
import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
|
|
|
import { getCommon, getDot } from "@/features/trackTimeDuration/hooks/RingData";
|
|
|
-import Rings, { RingCommon, BgRing,TargetRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
|
|
|
+import Rings, { RingCommon, BgRing, TargetRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
|
|
|
import { useEffect, useState } from "react";
|
|
|
import DeviceInfo from 'react-native-device-info';
|
|
|
import dayjs from "dayjs";
|
|
|
@@ -13,6 +13,7 @@ import Taro from "@tarojs/taro";
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
import 'dayjs/locale/zh-cn';
|
|
|
import 'dayjs/locale/en';
|
|
|
+// import 'moment/locale/en';
|
|
|
|
|
|
|
|
|
|
|
|
@@ -46,12 +47,17 @@ export default function IndexTimePage() {
|
|
|
}, [])
|
|
|
|
|
|
async function getLanguage() {
|
|
|
+ var strLocation = await getStorage('lastLocation')
|
|
|
+ if (strLocation) {
|
|
|
+ setCurrent(JSON.parse(strLocation))
|
|
|
+ }
|
|
|
+
|
|
|
var language = await getStorage('language') || 'en'
|
|
|
global.language = language;
|
|
|
i18n.changeLanguage(language)
|
|
|
setIsEn(language == 'en')
|
|
|
dayjs.locale(language == 'en' ? 'en' : 'zh-cn');
|
|
|
- moment.locale(language == 'en' ? 'en' : 'zh-cn');
|
|
|
+ // moment.locale(language == 'en' ? 'en' : 'zh-cn');
|
|
|
}
|
|
|
|
|
|
async function getStorage(key: string) {
|
|
|
@@ -70,7 +76,7 @@ export default function IndexTimePage() {
|
|
|
Taro.setStorage({ key: 'language', data: isEnglish ? 'en' : 'zh' })
|
|
|
setShowLanguage(false)
|
|
|
dayjs.locale(isEnglish ? 'en' : 'zh-cn');
|
|
|
- moment.locale(isEnglish ? 'en' : 'zh-cn');
|
|
|
+ // moment.locale(isEnglish ? 'en' : 'zh-cn');
|
|
|
|
|
|
if (current) {
|
|
|
chooseLocation({
|
|
|
@@ -89,7 +95,19 @@ export default function IndexTimePage() {
|
|
|
}
|
|
|
|
|
|
function goMap() {
|
|
|
- jumpPage('', 'map', navigation, { source: 'time_of_day', chooseLocation: chooseLocation })
|
|
|
+ jumpPage('', 'map', navigation, {
|
|
|
+ source: 'time_of_day',
|
|
|
+ lat: current ? current.geo.lat : null,
|
|
|
+ lng: current ? current.geo.lng : null,
|
|
|
+ chooseLocation: chooseLocation
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ function goRecords() {
|
|
|
+ if (!current) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ jumpPage('','MyPlaces',navigation)
|
|
|
}
|
|
|
|
|
|
function chooseLocation(res: any) {
|
|
|
@@ -103,7 +121,7 @@ export default function IndexTimePage() {
|
|
|
}
|
|
|
|
|
|
function saveLocation(location: any) {
|
|
|
-
|
|
|
+ Taro.setStorage({ key: 'lastLocation', data: JSON.stringify(location) })
|
|
|
}
|
|
|
|
|
|
function getLocation() {
|
|
|
@@ -137,7 +155,7 @@ export default function IndexTimePage() {
|
|
|
color: '#EAE9E9'
|
|
|
}
|
|
|
|
|
|
- function getArc(){
|
|
|
+ function getArc() {
|
|
|
var hour = new Date().getHours()
|
|
|
var minute = new Date().getMinutes()
|
|
|
var second = new Date().getSeconds()
|
|
|
@@ -150,23 +168,38 @@ export default function IndexTimePage() {
|
|
|
second = parseInt(strSecond)
|
|
|
}
|
|
|
|
|
|
- return (hour*3600+minute*60+second)/(24*3600)*2*Math.PI
|
|
|
+ return (hour * 3600 + minute * 60 + second) / (24 * 3600) * 2 * Math.PI
|
|
|
}
|
|
|
|
|
|
function ring() {
|
|
|
+ var offset = 0
|
|
|
+
|
|
|
+ var hour = new Date().getHours()
|
|
|
+ var minute = new Date().getMinutes()
|
|
|
+ if (current) {
|
|
|
+ var strHour = moment().tz(current.time.timezone.id).format('H')
|
|
|
+ hour = parseInt(strHour)
|
|
|
+ var strMin = moment().tz(current.time.timezone.id).format('m')
|
|
|
+ minute = parseInt(strMin)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (hour != new Date().getHours() || minute != new Date().getMinutes()) {
|
|
|
+ offset = hour * 60 + minute - new Date().getHours() * 60 - new Date().getMinutes()
|
|
|
+ }
|
|
|
+
|
|
|
const currentDot: CurrentDot = {
|
|
|
color: '#CACACA',
|
|
|
lineWidth: 10,
|
|
|
borderColor: '#ffffff',
|
|
|
- offset: 0
|
|
|
+ offset: offset
|
|
|
}
|
|
|
const targetRing: TargetRing = {
|
|
|
color: '#CACACA',
|
|
|
- startArc: -Math.PI/2,
|
|
|
+ startArc: -Math.PI / 2,
|
|
|
durationArc: getArc()
|
|
|
}
|
|
|
|
|
|
- return <Rings common={common} bgRing={bgRing} targetRing={targetRing} currentDot={currentDot} canvasId={'smal11l'} />
|
|
|
+ return <Rings common={common} bgRing={bgRing} targetRing={targetRing} currentDot={currentDot} canvasId={'smal11l'} />
|
|
|
}
|
|
|
|
|
|
function languageModalContent() {
|
|
|
@@ -194,9 +227,9 @@ export default function IndexTimePage() {
|
|
|
// var moment = require('moment-timezone');
|
|
|
if (current) {
|
|
|
if (timestamp) {
|
|
|
- return dayjs(timestamp).tz(current.time.timezone.id).format(format)
|
|
|
+ return moment(timestamp).tz(current.time.timezone.id).format(format)
|
|
|
}
|
|
|
- return dayjs().tz(current.time.timezone.id).format(format)
|
|
|
+ return moment().tz(current.time.timezone.id).format(format)
|
|
|
}
|
|
|
|
|
|
return dayjs().format(format)
|
|
|
@@ -222,14 +255,6 @@ export default function IndexTimePage() {
|
|
|
return t('time_of_day.index.winter_starts')
|
|
|
}
|
|
|
|
|
|
- function dstNote(item: any) {
|
|
|
- var str = moment(item.timestamp).tz(current.time.timezone.id).format('YYYY-MM-DDTHH:mm:ss')
|
|
|
- var str2 = moment(item.timestamp - 1).tz(current.time.timezone.id).format('YYYY-MM-DDTHH:mm:ss')
|
|
|
- console.log(str, str2)
|
|
|
- debugger
|
|
|
- return 'Time was set forward 1 hour from 02:00 to 03:00.\nTime zone changed to UTC-7, Pacific Daylight Time (PDT).'
|
|
|
- }
|
|
|
-
|
|
|
function isNight() {
|
|
|
var hour = new Date().getHours()
|
|
|
if (current) {
|
|
|
@@ -258,8 +283,13 @@ export default function IndexTimePage() {
|
|
|
</View>
|
|
|
<View style={{ flex: 1 }}>
|
|
|
<Text className="dst_title">{dstTitle(index)}</Text>
|
|
|
- <Text className="dst_desc">{dstDesc(item, index)}</Text>
|
|
|
- <Text className="dst_note">{dstNote(item)}</Text>
|
|
|
+ <Text className="dst_desc" style={{ marginBottom: 10 }}>{dstDesc(item, index)}</Text>
|
|
|
+ {
|
|
|
+ item.descriptions.map((desc, j) => {
|
|
|
+ return <Text className="dst_note" key={j * 100}>· {desc}</Text>
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
</View>
|
|
|
</View>
|
|
|
})
|
|
|
@@ -298,9 +328,12 @@ export default function IndexTimePage() {
|
|
|
</View>
|
|
|
|
|
|
|
|
|
- <View className="btn_bg" onClick={goMap}>
|
|
|
+ <View className="btn_bg" onClick={goMap} onLongClick={goRecords}>
|
|
|
<Text className="btn_text">{t('time_of_day.index.pick_location')}</Text>
|
|
|
- <Image className="more" src={require('@assets/index_time/more.png')} />
|
|
|
+ {
|
|
|
+ current && <Image className="more" onClick={goRecords} src={require('@assets/index_time/more.png')} />
|
|
|
+ }
|
|
|
+
|
|
|
</View>
|
|
|
<View className="footer" onClick={() => setShowLanguage(true)}>
|
|
|
<Text className="footer_text">{isEn ? 'English' : '中文'}</Text>
|