guide_full.tsx 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. export default function GuideFull() {
  18. const health = useSelector((state: any) => state.health);
  19. const [errors, setErrors] = useState<any>([])
  20. const [selItem, setSelItem] = useState<any>(null)
  21. const [selIndex, setSelIndex] = useState(-1)
  22. const [showTimePicker, setShowTimePicker] = useState(false)
  23. const dispatch = useDispatch()
  24. const selMode = 'SLEEP'
  25. useEffect(() => {
  26. }, [])
  27. function itemStyle(obj) {
  28. if (obj.is_conflict) {
  29. return {
  30. backgroundColor: '#FF00001A',
  31. color: '#FF0000'
  32. }
  33. }
  34. if (errors.length > 0) {
  35. return {
  36. backgroundColor: '#B2B2B21A',
  37. color: '#000'
  38. }
  39. }
  40. return {
  41. backgroundColor: obj.window == selMode ? getThemeColor(selMode) + '1A' : '#B2B2B21A',
  42. color: obj.window == selMode ? getThemeColor(selMode) : '#000'
  43. }
  44. }
  45. function modalContent() {
  46. const strTime = selItem.time
  47. var title = selItem.title
  48. var color = getThemeColor(selItem.window)
  49. return <TimePicker time={strTime}
  50. color={color}
  51. title={title}
  52. confirm={(e) => {
  53. // selItem.time = e
  54. setSelItem(selItem)
  55. setShowTimePicker(false)
  56. var array = JSON.parse(JSON.stringify(health.schedules))
  57. array.map(item => {
  58. if (item.id == selItem.id) {
  59. item.time = e
  60. }
  61. })
  62. dispatch(setSchedules(array))
  63. // var array = JSON.parse(JSON.stringify(list))
  64. // array[selIndex].time = e
  65. // setList(array)
  66. // checkData(array)
  67. }}
  68. cancel={() => {
  69. setShowTimePicker(false)
  70. }} />
  71. }
  72. function commit(){
  73. createSchedule({
  74. schedules: health.schedules
  75. // only_check: true
  76. }).then(res => {
  77. const data={
  78. title:'一切就绪!',
  79. description:'你的日程已启动',
  80. current_window:(res as any).current_window
  81. }
  82. jumpPage('./post_result?type=schedule&data='+JSON.stringify(data))
  83. })
  84. }
  85. function items() {
  86. return <Card>
  87. {
  88. health.schedules.map((obj, i) => {
  89. return <View className='schedule_item' key={i} style={{
  90. width: rpxToPx(700),
  91. boxSizing: 'border-box',
  92. backgroundColor: '#fff'
  93. }}>
  94. <View className='item_left2'>
  95. <View className='item_index'>
  96. <View className="index_point" style={{ backgroundColor: getThemeColor(obj.window) }} />
  97. </View>
  98. <Text className='item_name'>{obj.title}</Text>
  99. <View style={{ flex: 1 }} />
  100. {
  101. obj.is_conflict && <Text className="conflict_tip">时间冲突,请调整</Text>
  102. }
  103. {/* {
  104. !obj.is_all_day && !obj.reminder && <Image src={require('@assets/images/notification_off.png')} className='notification_icon' />
  105. } */}
  106. {
  107. !obj.is_all_day && <View className='edit_item_time' style={{backgroundColor:'transparent'}}>{obj.time}</View>
  108. }
  109. {
  110. i < items.length - 1 && <View className='item_line' />
  111. }
  112. </View>
  113. </View>
  114. })
  115. }
  116. </Card>
  117. }
  118. return <View style={{ flex: 1, display: 'flex', flexDirection: 'column', height: '100vh' }}>
  119. <NewHeader type={NewHeaderType.center_subtitle} title="即将完成!" subtitle="查看我的日程" />
  120. {
  121. items()
  122. }
  123. <View style={{ flex: 1 }} />
  124. <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', marginBottom: rpxToPx(128) }}>
  125. <NewButton
  126. type={NewButtonType.fill}
  127. title="完成"
  128. color={MainColorType.fast}
  129. width={rpxToPx(646)}
  130. height={rpxToPx(96)}
  131. onClick={commit}
  132. />
  133. </View>
  134. {
  135. showTimePicker && <Modal
  136. testInfo={null}
  137. dismiss={() => {
  138. setShowTimePicker(false)
  139. }}
  140. confirm={() => {
  141. }}>
  142. {
  143. modalContent()
  144. }
  145. </Modal>
  146. }
  147. </View>
  148. }