guide_full.tsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import { View, Text, Image } from "@tarojs/components";
  2. import './guide.scss'
  3. import '@/_health/pages/schedules.scss'
  4. import NewHeader, { NewHeaderType } from "../components/new_header";
  5. import { useEffect, useState } from "react";
  6. import { createSchedule, getSchedules } from "@/services/health";
  7. import { setSchedules } from "@/store/health";
  8. import { useDispatch, useSelector } from "react-redux";
  9. import Card from "../components/card";
  10. import { rpxToPx } from "@/utils/tools";
  11. import { getThemeColor } from "@/features/health/hooks/health_hooks";
  12. import Modal from "@/components/layout/Modal.weapp";
  13. import TimePicker from "@/features/common/TimePicker";
  14. import NewButton, { NewButtonType } from "../base/new_button";
  15. import { MainColorType } from "@/context/themes/color";
  16. import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
  17. import ScheduleItem from "../components/schedule_item";
  18. import { useTranslation } from "react-i18next";
  19. import CellFooter, { CellFooterType } from "../base/cell_footer";
  20. import CellFooterText from "../base/cell_footer_text";
  21. export default function GuideFull() {
  22. const health = useSelector((state: any) => state.health);
  23. const [errors, setErrors] = useState<any>([])
  24. const [selItem, setSelItem] = useState<any>(null)
  25. const {t} = useTranslation()
  26. const dispatch = useDispatch()
  27. const selMode = 'SLEEP'
  28. useEffect(() => {
  29. }, [])
  30. function commit(){
  31. createSchedule({
  32. schedules: health.schedules,
  33. op_page:'SCHEDULE_FINISH_SETUP'
  34. // only_check: true
  35. }).then(res => {
  36. const data={
  37. title:t('health.guide_done_title'),
  38. description:t('health.guide_done_desc'),
  39. current_window:(res as any).current_window
  40. }
  41. jumpPage('./post_result?type=schedule&data='+JSON.stringify(data))
  42. global.refreshWindow()
  43. })
  44. }
  45. function footerDesc() {
  46. if (health.footer) {
  47. return health.footer.summary.description
  48. }
  49. return ''
  50. }
  51. function items() {
  52. var array = JSON.parse(JSON.stringify(health.schedules))
  53. array.sort((a, b) => {
  54. return a.time.localeCompare(b.time);
  55. });
  56. return <Card>
  57. {
  58. array.map((obj, i) => {
  59. return <ScheduleItem
  60. key={i * 100}
  61. obj={obj}
  62. disable
  63. showLine={i < array.length - 1}
  64. errors={errors}
  65. selMode={selMode}
  66. />
  67. })
  68. }
  69. </Card>
  70. }
  71. return <View style={{ flex: 1, display: 'flex', flexDirection: 'column', height: '100vh' }}>
  72. <NewHeader type={NewHeaderType.center_subtitle} title={t('health.guide_end_title')} subtitle={t('health.guide_end_desc')} />
  73. {
  74. items()
  75. }
  76. <CellFooter type={CellFooterType.left}>
  77. <View style={{display:'flex',flexDirection:'column'}}>
  78. <CellFooterText text={footerDesc()} />
  79. </View>
  80. </CellFooter>
  81. <View style={{height:300,flexShrink:0}}/>
  82. <View style={{flex:1}}/>
  83. <View className="main_footer">
  84. <NewButton
  85. type={NewButtonType.fill}
  86. title="完成"
  87. color={MainColorType.fast}
  88. width={rpxToPx(646)}
  89. height={rpxToPx(96)}
  90. onClick={commit}
  91. />
  92. </View>
  93. </View>
  94. }