|
@@ -1,8 +1,9 @@
|
|
|
-import { View, Text } from "@tarojs/components";
|
|
|
|
|
|
|
+import { View, Text, Input } from "@tarojs/components";
|
|
|
import './move_setting_time.scss'
|
|
import './move_setting_time.scss'
|
|
|
import Cell from "../base/cell";
|
|
import Cell from "../base/cell";
|
|
|
import { useEffect, useState } from "react";
|
|
import { useEffect, useState } from "react";
|
|
|
-import { getMoveSchedules } from "@/services/health";
|
|
|
|
|
|
|
+import { createSchedule, getMoveSchedules } from "@/services/health";
|
|
|
|
|
+import { rpxToPx } from "@/utils/tools";
|
|
|
|
|
|
|
|
export default function MoveSettingTime() {
|
|
export default function MoveSettingTime() {
|
|
|
const [selIndex, setSelIndex] = useState(-1)
|
|
const [selIndex, setSelIndex] = useState(-1)
|
|
@@ -11,12 +12,16 @@ export default function MoveSettingTime() {
|
|
|
const [detail, setDetail] = useState<any>(null)
|
|
const [detail, setDetail] = useState<any>(null)
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
|
|
+ getDatas()
|
|
|
|
|
+ }, [])
|
|
|
|
|
+
|
|
|
|
|
+ function getDatas() {
|
|
|
getMoveSchedules().then(res => {
|
|
getMoveSchedules().then(res => {
|
|
|
setDetail(res)
|
|
setDetail(res)
|
|
|
setHours((res as any).goal.hour)
|
|
setHours((res as any).goal.hour)
|
|
|
setTotal((res as any).goal.day)
|
|
setTotal((res as any).goal.day)
|
|
|
})
|
|
})
|
|
|
- }, [])
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (!detail) return <View />
|
|
if (!detail) return <View />
|
|
|
|
|
|
|
@@ -27,13 +32,47 @@ export default function MoveSettingTime() {
|
|
|
detail.schedules.map((item, index) => {
|
|
detail.schedules.map((item, index) => {
|
|
|
return <View key={index}>
|
|
return <View key={index}>
|
|
|
<Cell className='demoCell' disable>
|
|
<Cell className='demoCell' disable>
|
|
|
- <View style={{display:'flex',flexDirection:'column'}}>
|
|
|
|
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'column', paddingLeft: 20, paddingRight: 20, width: rpxToPx(750), boxSizing: 'border-box' }}>
|
|
|
<Text>{item.time}-{item.end_time}</Text>
|
|
<Text>{item.time}-{item.end_time}</Text>
|
|
|
- <View>
|
|
|
|
|
- <Text style={{flex:1}}>200<Text>Steps</Text></Text>
|
|
|
|
|
- <Text onClick={()=>{
|
|
|
|
|
- setSelIndex(index)
|
|
|
|
|
- }}>更改目标</Text>
|
|
|
|
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
|
|
|
+ {
|
|
|
|
|
+ selIndex == index ? <Input className='item_name' style={{ flex: 1 }}
|
|
|
|
|
+ value={item.goal}
|
|
|
|
|
+ autoFocus={true}
|
|
|
|
|
+ focus={true}
|
|
|
|
|
+ onBlur={() => {
|
|
|
|
|
+ setSelIndex(-1)
|
|
|
|
|
+ createSchedule({
|
|
|
|
|
+ schedules: [{
|
|
|
|
|
+ id: item.id,
|
|
|
|
|
+ goal: item.goal
|
|
|
|
|
+ }],
|
|
|
|
|
+ }).then(res => {
|
|
|
|
|
+ if (global.refreshWindow) {
|
|
|
|
|
+ global.refreshWindow()
|
|
|
|
|
+ }
|
|
|
|
|
+ if (global.refreshSchedules) {
|
|
|
|
|
+ global.refreshSchedules()
|
|
|
|
|
+ }
|
|
|
|
|
+ if (global.updateMove) {
|
|
|
|
|
+ global.updateMove()
|
|
|
|
|
+ }
|
|
|
|
|
+ getDatas()
|
|
|
|
|
+ })
|
|
|
|
|
+ }}
|
|
|
|
|
+ onInput={(e) => {
|
|
|
|
|
+ // item.goal = e.detail.value
|
|
|
|
|
+ var obj = JSON.parse(JSON.stringify(detail))
|
|
|
|
|
+ obj.schedules[index].goal = e.detail.value
|
|
|
|
|
+ setDetail(obj)
|
|
|
|
|
+ }} /> : <Text style={{ flex: 1 }}>{item.goal}<Text>Steps</Text></Text>
|
|
|
|
|
+ }
|
|
|
|
|
+ {
|
|
|
|
|
+ selIndex != index && <Text onClick={() => {
|
|
|
|
|
+ setSelIndex(index)
|
|
|
|
|
+ }}>更改目标</Text>
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
</View>
|
|
</View>
|
|
|
</View>
|
|
</View>
|
|
|
</Cell>
|
|
</Cell>
|