time_record.tsx 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. import { View, Image } from "@tarojs/components";
  2. import './time_record.scss'
  3. import Taro from "@tarojs/taro";
  4. import { rpxToPx } from "@/utils/tools";
  5. import { MainColorType } from "@/context/themes/color";
  6. import NewButton, { NewButtonType } from "@/_health/base/new_button";
  7. import { useEffect, useState } from "react";
  8. import NewDateTimePicker from "@/_health/base/new_date_time_picker";
  9. import dayjs from "dayjs";
  10. import RingProgress from "../components/ring_progress";
  11. import NewDurationPicker, { DurationPickerType } from "@/_health/base/new_durationpicker";
  12. import { IconArrow } from "@/components/basic/Icons";
  13. let timer
  14. export default function TimeRecord() {
  15. const systemInfo: any = Taro.getWindowInfo ? Taro.getWindowInfo() : Taro.getSystemInfoSync();
  16. const navigationBarHeight = systemInfo.statusBarHeight + 44;
  17. const [enterTime] = useState(new Date().getTime())
  18. const [showDatePicker, setShowDatePicker] = useState(false)
  19. const [showDurationPicker, setShowDurationPicker] = useState(false)
  20. const [count, setCount] = useState(0)
  21. useEffect(() => {
  22. timer = setInterval(() => { setCount(count => count + 1) }, 1000)
  23. return () => {
  24. clearInterval(timer)
  25. }
  26. }, [])
  27. function tapStart() {
  28. setShowDatePicker(true)
  29. }
  30. function tapGoal() {
  31. setShowDurationPicker(true)
  32. }
  33. return <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
  34. <View className="navi_bar" style={{ height: navigationBarHeight }}>
  35. <View style={{
  36. position: 'absolute',
  37. left: 0,
  38. right: 0,
  39. bottom: 0,
  40. height: 44,
  41. display: 'flex',
  42. alignItems: 'center',
  43. justifyContent: 'center'
  44. }}>
  45. <Image src={require('@assets/_health/navi_back.png')} style={{
  46. position: 'absolute',
  47. width: rpxToPx(92),
  48. height: rpxToPx(64),
  49. left: 0,
  50. top: 22 - rpxToPx(32)
  51. }}
  52. onClick={() => {
  53. Taro.navigateBack()
  54. }}
  55. />
  56. <View className="h36 bold">upcoming fast</View>
  57. </View>
  58. </View>
  59. <View style={{ height: navigationBarHeight }} />
  60. <View className="progress_card">
  61. <View onClick={() => {
  62. setShowDurationPicker(true)
  63. }}>
  64. <RingProgress width={400} height={320}
  65. radius={125} canvasId="helloworld"
  66. //scale={0.75}
  67. count={count}
  68. bgRing={{
  69. color: 'rgba(255,255,255,0.25)',
  70. width: 35
  71. }}
  72. target={{
  73. color: 'rgba(255,255,255,0.5)',
  74. width: 35,
  75. start: 0,
  76. duration: 3 / 4 * Math.PI
  77. }}
  78. real={{
  79. color: MainColorType.orange,
  80. width: 35,
  81. start: 0,
  82. duration: 2 / 4 * Math.PI
  83. }}
  84. extra={{
  85. header: 'GOAL',
  86. value: dayjs().format('HH:mm:ss'),
  87. footer: 'Edit',
  88. color: MainColorType.orange
  89. }}
  90. />
  91. </View>
  92. <View className="operate_content">
  93. <View className="operate_item">
  94. <View className="g02 h24">STARTED</View>
  95. <View className="h44 bold" style={{ marginTop: rpxToPx(8), marginBottom: rpxToPx(8) }}>今天 13:54</View>
  96. <View className="h30 bold" style={{ color: MainColorType.orange }}>Edit Start</View>
  97. </View>
  98. <View className="operate_item">
  99. <View className="g02 h24">STARTED</View>
  100. <View className="h44 bold" style={{ marginTop: rpxToPx(8), marginBottom: rpxToPx(8) }}>今天 13:54</View>
  101. <View className="h30 bold" style={{ color: MainColorType.orange }}>Edit Start</View>
  102. </View>
  103. </View>
  104. <NewButton
  105. type={NewButtonType.fill}
  106. title="Start fasting"
  107. width={rpxToPx(490)}
  108. height={rpxToPx(96)}
  109. color={MainColorType.orange}
  110. />
  111. </View>
  112. <View className="eat_card" onClick={() => {
  113. Taro.redirectTo({
  114. url: './log_record'
  115. })
  116. }}>
  117. <View className="h30 bold">Or share your meals</View>
  118. <View className="h24 g02" style={{ marginTop: rpxToPx(12) }}>if you haven't started fasting yet</View>
  119. <View className="eat_card_arrow">
  120. <IconArrow width={rpxToPx(34)} color={MainColorType.g02} />
  121. </View>
  122. </View>
  123. <View className="eat_card" style={{height:rpxToPx(120)}} onClick={() => {
  124. Taro.redirectTo({
  125. url: './log_record'
  126. })
  127. }}>
  128. <View className="h24 g02" style={{ marginTop: rpxToPx(12) }}>How are you feeling?</View>
  129. <View className="eat_card_arrow">
  130. <IconArrow width={rpxToPx(34)} color={MainColorType.g02} />
  131. </View>
  132. </View>
  133. <View className="time_card_bg">
  134. <View className="time_card" onClick={tapStart}>
  135. <View className="h30" style={{ opacity: 0.4 }}>Start</View>
  136. <View className="h44 bold" style={{ marginTop: rpxToPx(12) }}>10:00</View>
  137. </View>
  138. <View className="time_card" onClick={tapGoal}>
  139. <View className="h30" style={{ opacity: 0.4 }}>Goal</View>
  140. <View className="h44 bold" style={{ marginTop: rpxToPx(12) }}>10:00</View>
  141. </View>
  142. </View>
  143. <NewButton
  144. onClick={() => { }}
  145. type={NewButtonType.fill}
  146. color={MainColorType.orange}
  147. width={rpxToPx(669)}
  148. height={rpxToPx(96)}
  149. title="开始断食"
  150. />
  151. {
  152. showDatePicker && <NewDateTimePicker date={dayjs().format('YYYY-MM-DD')} count={1} time={dayjs().format('HH:mm')}
  153. minTimestamp={new Date().getTime() - 24 * 3600 * 1000}
  154. maxTimestamp={new Date().getTime()}
  155. onChange={(e) => {
  156. // if (props.dateChange)
  157. // props.dateChange(e[0])
  158. // if (props.timeChange)
  159. // props.timeChange(e[1])
  160. // props.change(e)
  161. }} color={MainColorType.orange} />
  162. }
  163. {
  164. showDurationPicker && <NewDurationPicker type={DurationPickerType.normal} />
  165. }
  166. </View>
  167. }