Clock.tsx 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. import { View, Text, Image, ScrollView, PageContainer, Swiper, SwiperItem, Switch } from "@tarojs/components";
  2. import Tabbar from "@/components/navigation/TabBar";
  3. import IndexItem from '@/features/trackTimeDuration/components/IndexItem';
  4. import Rings from "@/features/trackTimeDuration/components/Rings";
  5. import './Clock.scss'
  6. import { useDispatch, useSelector } from "react-redux";
  7. import { useDidHide, useDidShow, usePageScroll, useReady, useShareAppMessage } from "@tarojs/taro";
  8. import Taro from "@tarojs/taro";
  9. import { getInfoSuccess } from "@/store/user";
  10. import { clockHome, clockSummaryRecords, clockSummaryStats, getClockRecords, getClocks, getPlans } from "@/services/trackTimeDuration";
  11. import { updateScenario } from "@/store/time";
  12. import { setConfigs } from "@/store/common";
  13. import { setScenario, setStep } from "@/store/scenario";
  14. import { useEffect, useState } from "react";
  15. import { IconPlus, IconRadioCheck, IconRadioCross } from "@/components/basic/Icons";
  16. import { ColorType } from "@/context/themes/color";
  17. import { bigRingRadius, getBgRing, getCommon, getDot, getSchedule, ringWidth, smallRingRadius } from "@/features/trackTimeDuration/hooks/RingData";
  18. import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
  19. import IndexConsole from "@/features/trackTimeDuration/components/IndexConsole";
  20. import Modal from '@/components/layout/Modal'
  21. import { rpxToPx } from "@/utils/tools";
  22. import RecordFastSleep from "@/features/trackTimeDuration/components/RecordFastSleep";
  23. import DayLight from "@/features/trackTimeDuration/components/DayLight";
  24. import { getInfo, latestLocation } from "@/services/user";
  25. import { TimeFormatter } from "@/utils/time_format";
  26. import WeekCalendar from "@/features/trackTimeDuration/components/WeekCalendar";
  27. import { useTranslation } from "react-i18next";
  28. import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
  29. import Layout from "@/components/layout/layout";
  30. import { ModalType, NaviBarTitleShowType, TemplateType } from "@/utils/types";
  31. import TitleView from "@/features/trackTimeDuration/components/TitleView";
  32. import ClockHeader from "@/features/trackTimeDuration/components/ClockHeader";
  33. import DurationPicker from "@/features/trackTimeDuration/components/DurationPicker";
  34. import SegmentPop from "@/features/trackTimeDuration/components/SegmentPop";
  35. import Box from "@/components/layout/Box";
  36. import DayNightCard from "@/features/trackTimeDuration/components/DayNightCard";
  37. import StageSelector from "@/features/trackTimeDuration/components/StageSelector";
  38. import { ChooseScenarioBtn } from "@/features/common/SpecBtns";
  39. import { clearNightStore, showNight } from "@/store/night";
  40. import { showDay } from "@/store/day";
  41. import { clientInfo, staticResources } from "@/services/common";
  42. import { changeFastDuration, changeSleepDuration, setCurrentRecord, setSchedule } from "@/store/ring";
  43. import { checkAuthorized } from "@/utils/check_authorized";
  44. import NoData from "@/components/view/NoData";
  45. import { AtActivityIndicator } from "taro-ui";
  46. import Tooltip from "@/components/view/Tooltip";
  47. let GradientText
  48. let useNavigation;
  49. let timer
  50. let pauseTimer = false;
  51. let AppState;
  52. let needScroll = false;
  53. if (process.env.TARO_ENV == 'rn') {
  54. AppState = require("react-native").AppState
  55. GradientText = require('@/components/basic/GradientText').default
  56. useNavigation = require("@react-navigation/native").useNavigation
  57. }
  58. 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"}}]`
  59. export default function Page() {
  60. const dispatch = useDispatch();
  61. global.dispatch = dispatch;
  62. let navigation;
  63. if (useNavigation) {
  64. navigation = useNavigation()
  65. }
  66. const { t } = useTranslation()
  67. const user = useSelector((state: any) => state.user);
  68. const time = useSelector((state: any) => state.time);
  69. const [count, setCount] = useState(0)
  70. const [homeData, setHomeData] = useState(null)
  71. const [loaded, setLoaded] = useState(false)
  72. const [showErrorPage, setErrorPage] = useState(false)
  73. const [showModal, setShowModal] = useState(false)
  74. const [modalDetail, setModalDetail] = useState<any>(null)
  75. const [showModal2, setShowModal2] = useState(false)
  76. const [modalDetail2, setModalDetail2] = useState<any>(null)
  77. const [debugInfo, setDebugInfo] = useState(null)
  78. const [needShowAddTip, setNeedShowAddTip] = useState(false)
  79. const [showTip, setShowTip] = useState(false)
  80. const [records, setRecords] = useState([])
  81. const permission = useSelector((state: any) => state.permission);
  82. const common = useSelector((state: any) => state.common);
  83. const nightStore = useSelector((state: any) => state.night);
  84. if (process.env.TARO_ENV == 'weapp') {
  85. useShareAppMessage((e) => {
  86. return {
  87. title: t('feature.track_time_duration.common.share_title'),
  88. path: 'pages/clock/Clock'
  89. }
  90. })
  91. }
  92. useEffect(() => {
  93. dispatch(staticResources() as any);
  94. timer = setInterval(() => {
  95. if (global.pauseIndexTimer || pauseTimer) {
  96. return
  97. }
  98. setCount((prevCounter) => prevCounter + 1)
  99. }, 1000)
  100. }, [])
  101. useEffect(() => {
  102. if (process.env.TARO_ENV == 'weapp') {
  103. loadWXCache()
  104. }
  105. else {
  106. loadRNCache()
  107. }
  108. if (process.env.TARO_ENV == 'rn') {
  109. AppState.addEventListener('change', handleAppStateChange);
  110. }
  111. }, [])
  112. useEffect(() => {
  113. getCheckData()
  114. global.pauseIndexTimer = !user.isLogin
  115. if (user.isLogin) {
  116. uploadUserClient();
  117. checkAuthorized();
  118. //检查用户是否添加过小程序
  119. checkAddToMini();
  120. }
  121. else {
  122. dispatch(clearNightStore());
  123. }
  124. }, [user.isLogin, time.status])
  125. useReady(async () => {
  126. const userData = await getStorage('userData');
  127. if (userData) {
  128. dispatch(getInfoSuccess(JSON.parse(userData as string)) as any);
  129. getHistory()
  130. }
  131. // if (process.env.TARO_ENV == 'weapp') {
  132. // useShareAppMessage((e) => {
  133. // return {
  134. // title: t('feature.track_time_duration.common.share_title'),
  135. // path: 'pages/clock/Clock'
  136. // }
  137. // })
  138. // }
  139. })
  140. async function checkVersionUpdate() {
  141. if (!user.isLogin) {
  142. return
  143. }
  144. const showAlert = await getStorage('117alert') || false;
  145. if (!showAlert) {
  146. Taro.showModal({
  147. title: '版本更新提示',
  148. content: '【昼夜环】追踪每天日出日落时间;\n【周统计】查看每周断食和睡眠平均时长;\n【记录筛选】根据场景, 浏览历史记录',
  149. showCancel: false,
  150. confirmText: '我知道了'
  151. })
  152. }
  153. Taro.setStorage({ key: '117alert', data: true })
  154. }
  155. function checkAddToMini() {
  156. process.env.TARO_ENV == 'weapp' &&
  157. wx.checkIsAddedToMyMiniProgram({
  158. success: (res) => {
  159. if (!res.added) {
  160. setNeedShowAddTip(true)
  161. }
  162. },
  163. fail: (e) => {
  164. }
  165. });
  166. }
  167. useDidShow(() => {
  168. checkTimeZone()
  169. setCount(pre => pre + 1)
  170. //resume timer
  171. pauseTimer = false
  172. if (user.isLogin) {
  173. getInfo().then(res => {
  174. dispatch(getInfoSuccess(res))
  175. }).catch(e => {
  176. Taro.stopPullDownRefresh()
  177. })
  178. if (global.refreshRecent) {
  179. global.refreshRecent()
  180. }
  181. }
  182. setTimeout(() => {
  183. checkVersionUpdate();
  184. }, 1000)
  185. })
  186. usePageScroll((e) => {
  187. if (e.scrollTop > 70) {
  188. setShowTip(true)
  189. }
  190. else {
  191. setShowTip(false)
  192. }
  193. })
  194. useDidHide(() => {
  195. //pause timer
  196. pauseTimer = true
  197. })
  198. global.refreshIndex = () => {
  199. setCount((prevCounter) => prevCounter + 1)
  200. }
  201. const handleAppStateChange = (nextAppState) => {
  202. checkTimeZone()
  203. };
  204. function checkTimeZone() {
  205. var split = new Date().toString().split(' ');
  206. var timeZoneFormatted = split[split.length - 2];
  207. Taro.getStorage({
  208. key: 'last_tz',
  209. success: function (res) {
  210. if (res.data && res.data != timeZoneFormatted) {
  211. if (global.currentStatus != 'WAIT_FOR_START') {
  212. Taro.showModal({
  213. title: t('feature.track_time_duration.change_tz_alert.title'),
  214. content: t('feature.track_time_duration.change_tz_alert.content', { tz: timeZoneFormatted }),
  215. showCancel: false,
  216. confirmText: t('feature.track_time_duration.change_tz_alert.confirm'),
  217. })
  218. }
  219. }
  220. },
  221. complete: function () {
  222. Taro.setStorage({ key: 'last_tz', data: timeZoneFormatted })
  223. }
  224. })
  225. }
  226. function uploadUserClient() {
  227. var systemInfo = Taro.getSystemInfoSync();
  228. console.log(systemInfo)
  229. var split = new Date().toString().split(' ');
  230. var timeZoneFormatted = split[split.length - 2];
  231. clientInfo({
  232. client: {
  233. client_type: process.env.TARO_ENV == 'weapp' ? 'MP' : 'APP',
  234. client_version: process.env.TARO_ENV == 'weapp' ? Taro.getAccountInfoSync().miniProgram.version : '1.0',//'1.0'
  235. wx_version: process.env.TARO_ENV == 'weapp' ? systemInfo.version : '_'
  236. },
  237. meta: {
  238. language: systemInfo.language,
  239. time_zone: {
  240. id: Intl.DateTimeFormat().resolvedOptions().timeZone,
  241. name: timeZoneFormatted
  242. },
  243. },
  244. device: {
  245. brand: systemInfo.brand,
  246. model: systemInfo.model,
  247. platform: systemInfo.platform,
  248. system: systemInfo.system
  249. },
  250. perm: {
  251. wifi_enabled: systemInfo.wifiEnabled,
  252. location_authorized: systemInfo.locationAuthorized,
  253. location_enabled: systemInfo.locationEnabled
  254. }
  255. })
  256. }
  257. function loadWXCache() {
  258. var showDayRing = Taro.getStorageSync('showDayRing') || false;
  259. var showNightRing = Taro.getStorageSync('showNightRing') || false;
  260. dispatch(showDay(showDayRing))
  261. dispatch(showNight(showNightRing))
  262. var gps = Taro.getStorageSync('gps')
  263. if (gps) {
  264. global.locationDetail = JSON.parse(gps)
  265. }
  266. var userData = Taro.getStorageSync('userData')
  267. if (userData) {
  268. dispatch(getInfoSuccess(JSON.parse(userData)));
  269. }
  270. // getCheckData()
  271. }
  272. async function loadRNCache() {
  273. var showDayRing = await getStorage('showDayRing') || false;
  274. var showNightRing = await getStorage('showNightRing') || false;
  275. dispatch(showDay(showDayRing))
  276. dispatch(showNight(showNightRing))
  277. var gps = await getStorage('gps')
  278. if (gps) {
  279. global.locationDetail = JSON.parse(gps)
  280. }
  281. var userData = await getStorage('userData')
  282. if (userData) {
  283. dispatch(getInfoSuccess(JSON.parse(userData)));
  284. }
  285. // getCheckData()
  286. }
  287. function getCheckData() {
  288. Promise.all([getClocks(), getPlans()]).then((list) => {
  289. setErrorPage(false)
  290. setCheckData(list)
  291. if (needScroll) {
  292. needScroll = false
  293. setTimeout(() => {
  294. Taro.createSelectorQuery().select('#latest').boundingClientRect((rect) => {
  295. Taro.pageScrollTo({
  296. scrollTop: (rect as any).top,
  297. duration: 150
  298. })
  299. }).exec()
  300. }, 100)
  301. }
  302. }).catch((e) => {
  303. setErrorPage(true)
  304. var list = JSON.parse(defaultValue)
  305. setCheckData(list)
  306. needScroll = false
  307. })
  308. getHistory()
  309. }
  310. function setCheckData(list: any) {
  311. setHomeData(list[0])
  312. global.homeData = list[0]
  313. global.currentStatus = list[0].current_record.status;
  314. var array = list[1].scenarios
  315. var schedule = null
  316. array.map(item => {
  317. if (item.name == 'FAST_SLEEP') {
  318. schedule = item.schedule;
  319. }
  320. })
  321. if (user.isLogin) {
  322. dispatch(updateScenario(list[0].current_record))
  323. dispatch(setConfigs(list[0].time_input_schema));
  324. dispatch(setScenario(list[0].scenario));
  325. global.scenario = list[0].scenario.name;
  326. }
  327. dispatch(setCurrentRecord(list[0].current_record))
  328. dispatch(setSchedule(schedule))
  329. setLoaded(true)
  330. }
  331. function getHistory() {
  332. if (user.isLogin)
  333. getClockRecords({
  334. page: 1,
  335. limit: 1,
  336. part_completed: true
  337. // completed: true
  338. }).then(res => {
  339. setRecords((res as any).data)
  340. })
  341. }
  342. global.indexPageRefresh = () => {
  343. getCheckData()
  344. }
  345. global.showIndexModal = (isShow: boolean, detail: any, debugNode?: any) => {
  346. global.showModal = isShow
  347. setDebugInfo(debugNode)
  348. setShowModal(isShow)
  349. setModalDetail(detail)
  350. }
  351. global.showIndexModal2 = (isShow: boolean, detail: any) => {
  352. setDebugInfo(null)
  353. global.showModal = isShow
  354. setShowModal2(isShow)
  355. setModalDetail2(detail)
  356. }
  357. global.changeTargetDuration = (duration: number, isFast: boolean) => {
  358. var obj = JSON.parse(JSON.stringify(homeData))
  359. var record = obj.current_record
  360. if (isFast) {
  361. record.fast.target_end_time = record.fast.target_start_time + duration * 60 * 1000
  362. }
  363. else {
  364. record.sleep.target_end_time = record.sleep.target_start_time + duration * 60 * 1000
  365. }
  366. setHomeData(obj)
  367. }
  368. global.updateFastSleepData = (data: any) => {
  369. if (data.id == (homeData as any).current_record.id) {
  370. var obj = JSON.parse(JSON.stringify(homeData))
  371. obj.current_record = data
  372. setHomeData(obj)
  373. }
  374. switch (data.scenario) {
  375. case 'FAST':
  376. if (data.status == 'WAIT_FOR_START') {
  377. dispatch(changeFastDuration(data.fast.target_end_time - data.fast.target_start_time))
  378. }
  379. break;
  380. case 'SLEEP':
  381. if (data.status == 'WAIT_FOR_START') {
  382. dispatch(changeSleepDuration(data.sleep.target_end_time - data.sleep.target_start_time))
  383. }
  384. break;
  385. case 'FAST_SLEEP':
  386. if (data.status == 'WAIT_FOR_START') {
  387. dispatch(changeFastDuration(data.fast.target_end_time - data.fast.target_start_time))
  388. }
  389. else if (data.status == 'ONGOING1') {
  390. debugger
  391. dispatch(changeSleepDuration(data.sleep.target_end_time - data.sleep.target_start_time))
  392. }
  393. break;
  394. }
  395. }
  396. global.popScheduleAlert = (scenario, startTime) => {
  397. if (permission.wxPubFollow) {
  398. debugger
  399. Taro.showModal({
  400. title: t('feature.track_time_duration.reminders.schedule_title'),
  401. content: scenario.name == 'FAST' ?
  402. t('feature.track_time_duration.reminders.enable_schedule_fast_content', { time: startTime }) :
  403. t('feature.track_time_duration.reminders.enable_schedule_sleep_content', { time: startTime }),
  404. showCancel: false,
  405. confirmText: t('feature.track_time_duration.reminders.ok')
  406. })
  407. }
  408. else {
  409. debugger
  410. Taro.showModal({
  411. title: t('feature.track_time_duration.reminders.schedule_title'),
  412. content: scenario.name == 'FAST' ?
  413. t('feature.track_time_duration.reminders.schedule_fast_content', { time: startTime }) :
  414. t('feature.track_time_duration.reminders.schedule_sleep_content', { time: startTime }),
  415. cancelText: t('feature.track_time_duration.reminders.later'),
  416. confirmText: t('feature.track_time_duration.reminders.open'),
  417. success: function (res) {
  418. if (res.confirm) {
  419. followWxPub()
  420. } else if (res.cancel) {
  421. }
  422. }
  423. })
  424. }
  425. }
  426. global.popMixScheduleAlert = (time1, time2) => {
  427. if (permission.wxPubFollow) {
  428. Taro.showModal({
  429. title: t('feature.track_time_duration.reminders.schedule_title'),
  430. content: t('feature.track_time_duration.reminders.enable_schedule_mix_content', { time1: time1, time2: time2 }),
  431. showCancel: false,
  432. confirmText: t('feature.track_time_duration.reminders.ok')
  433. })
  434. }
  435. else {
  436. Taro.showModal({
  437. title: t('feature.track_time_duration.reminders.schedule_title'),
  438. content:
  439. t('feature.track_time_duration.reminders.schedule_mix_content'),
  440. cancelText: t('feature.track_time_duration.reminders.later'),
  441. confirmText: t('feature.track_time_duration.reminders.open'),
  442. success: function (res) {
  443. if (res.confirm) {
  444. followWxPub()
  445. } else if (res.cancel) {
  446. }
  447. }
  448. })
  449. }
  450. }
  451. function followWxPub() {
  452. const resource = common.resources.filter((item: any) => {
  453. return item.code == 'follow_wx_pub'
  454. })
  455. jumpPage('/pages/common/H5?title=fast16cc 关注服务号&url=' + resource[0].url)
  456. }
  457. function modalContent() {
  458. if (showModal || showModal2) {
  459. if (process.env.TARO_ENV == 'weapp') {
  460. return <Modal
  461. testInfo={debugInfo}
  462. dismiss={() => {
  463. setDebugInfo(null)
  464. setShowModal(false);
  465. setShowModal2(false);
  466. global.pauseIndexTimer = false
  467. }}
  468. confirm={() => { }}>
  469. {
  470. showModal ? modalDetail : modalDetail2
  471. }
  472. </Modal>
  473. }
  474. else if (process.env.TARO_ENV == 'rn') {
  475. return <PageContainer style={{ backgroundColor: '#1c1c1c' }}
  476. // overlayStyle='background-color:rgba(0,0,0,0.9)'
  477. // custom-style='background-color:#1c1c1c'
  478. overlayStyle={{ backgroundColor: 'rgba(0,0,0,0.9)' }}
  479. customStyle={{ backgroundColor: '#1c1c1c' }}
  480. closeOnSlideDown={false}
  481. onBeforeEnter={() => {
  482. Taro.hideTabBar();
  483. }}
  484. onBeforeLeave={() => {
  485. Taro.showTabBar();
  486. }}
  487. onClick={() => { alert('b') }}
  488. onClickOverlay={() => { alert('a') }}
  489. onAfterLeave={() => { setShowModal(false); setShowModal2(false); global.pauseIndexTimer = false }}
  490. show={showModal || showModal2} round={true} overlay={true} position='bottom'
  491. >
  492. {
  493. showModal ? modalDetail : modalDetail2
  494. }
  495. </PageContainer>
  496. }
  497. }
  498. return <View />
  499. }
  500. async function getStorage(key: string) {
  501. try {
  502. const res = await Taro.getStorage({ key });
  503. return res.data;
  504. } catch {
  505. return '';
  506. }
  507. }
  508. function more() {
  509. jumpPage('/pages/common/RecordsHistory?type=time&title=time', 'RecordsHistory', navigation, {
  510. type: 'time',
  511. title: 'time'
  512. })
  513. }
  514. function tapLogin() {
  515. if (!user.isLogin) {
  516. jumpPage('/pages/account/ChooseAuth', 'ChooseAuth')
  517. return
  518. }
  519. }
  520. function headerView() {
  521. return <ClockHeader homeData={homeData} />
  522. }
  523. global.scrollToLatest = () => {
  524. needScroll = true;
  525. }
  526. var timestamp = new Date().getTime()
  527. function render() {
  528. if (!loaded) {
  529. return <Layout type={TemplateType.customHeader} header={headerView()} title={t('page.clock.title')} titleShowStyle={NaviBarTitleShowType.scrollToShow}>
  530. <View style={{ width: rpxToPx(750), height: rpxToPx(900), display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
  531. <AtActivityIndicator size={40} color="#fff" />
  532. <Tabbar index={0} />
  533. </View>
  534. </Layout>
  535. }
  536. return <Layout type={TemplateType.customHeader} header={headerView()} title={t('page.clock.title')} titleShowStyle={NaviBarTitleShowType.scrollToShow}>
  537. <View className="index_container">
  538. {
  539. needShowAddTip && showTip && <Tooltip title="添加到我的小程序" closeTip={() => { setNeedShowAddTip(false) }} />
  540. }
  541. <Text className="count">{count}</Text>
  542. <Box>
  543. <View>
  544. <IndexItem type="FAST_SLEEP" data={homeData} time={timestamp} showStage={false} />
  545. {
  546. user.isLogin ? <IndexConsole record={homeData} /> : <StageSelector />
  547. }
  548. </View>
  549. </Box>
  550. <DayNightCard isNight={true} count={count} />
  551. {
  552. user.isLogin && records.length > 0 && <View style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', marginTop: rpxToPx(40), }}>
  553. {
  554. <Text className="discovery1" style={{ marginBottom: 0 }}>{t('feature.track_time_duration.record_fast_sleep.header.latest_record')}</Text>
  555. }
  556. {
  557. process.env.TARO_ENV == 'weapp' && <Text className="fast_sleep_more index_more" onClick={more}>{t('feature.track_time_duration.record_fast_sleep.header.btn_show_all')}</Text>
  558. }
  559. {
  560. process.env.TARO_ENV == 'rn' && <GradientText onClick={more} style={{ fontSize: rpxToPx(32), fontWeight: 'bold' }}>{t('feature.track_time_duration.record_fast_sleep.header.btn_show_all')}</GradientText>
  561. }
  562. </View>
  563. }
  564. {
  565. user.isLogin && records.length > 0 && <View id="latest" className="fast_sleep_item_bg">
  566. <RecordFastSleep data={records[0]} type='record' index={-20000} />
  567. </View>
  568. }
  569. {
  570. loaded && !user.isLogin && <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', marginTop: rpxToPx(36) }}>
  571. <ChooseScenarioBtn title={t('feature.auth.login.login_now')} background={ColorType.fast} onClick={tapLogin} />
  572. </View>
  573. }
  574. {
  575. showErrorPage && <NoData refresh={() => { getCheckData() }} />
  576. }
  577. {
  578. user.isLogin && !showErrorPage && <View style={{ marginTop: rpxToPx(60), display: 'flex', flexDirection: 'column' }}>
  579. <Text className="discovery1" >周统计</Text>
  580. <WeekCalendar />
  581. </View>
  582. }
  583. <View style={{ height: 100 }} />
  584. {
  585. modalContent()
  586. }
  587. {
  588. homeData && <SegmentPop data={homeData} />
  589. }
  590. {
  591. homeData && <DurationPicker record={(homeData as any).current_record} />
  592. }
  593. <Tabbar index={0} />
  594. </View>
  595. </Layout>
  596. }
  597. // if (process.env.TARO_ENV == 'rn') {
  598. // return <ScrollView>
  599. // {
  600. // render()
  601. // }
  602. // </ScrollView>
  603. // }
  604. return render()
  605. }