|
@@ -10,7 +10,7 @@ import PickerViews from "@/components/input/PickerViews";
|
|
|
|
|
|
|
|
var timer
|
|
var timer
|
|
|
var lastStrTime
|
|
var lastStrTime
|
|
|
-export default function Component(props: { targetCount: number, type: WorkoutType }) {
|
|
|
|
|
|
|
+export default function Component(props: { targetCount: any, type: WorkoutType,end:Function }) {
|
|
|
const [index, setIndex] = useState(1)
|
|
const [index, setIndex] = useState(1)
|
|
|
const [count, setCount] = useState(0)
|
|
const [count, setCount] = useState(0)
|
|
|
const [startTime, setStartTime] = useState(new Date().getTime())
|
|
const [startTime, setStartTime] = useState(new Date().getTime())
|
|
@@ -19,6 +19,7 @@ export default function Component(props: { targetCount: number, type: WorkoutTyp
|
|
|
const [groups, setGroups] = useState<any[]>([])
|
|
const [groups, setGroups] = useState<any[]>([])
|
|
|
const [isDoing, setIsDoing] = useState(true)
|
|
const [isDoing, setIsDoing] = useState(true)
|
|
|
const [showModal, setShowModal] = useState(false)
|
|
const [showModal, setShowModal] = useState(false)
|
|
|
|
|
+ const [needTerminal, setNeedTerminal] = useState(false)
|
|
|
|
|
|
|
|
const items = [[1, 2, 3, 4, 5, 6]]
|
|
const items = [[1, 2, 3, 4, 5, 6]]
|
|
|
const [selIndex, setSelIndex] = useState([1])
|
|
const [selIndex, setSelIndex] = useState([1])
|
|
@@ -107,12 +108,29 @@ export default function Component(props: { targetCount: number, type: WorkoutTyp
|
|
|
setGroups(array)
|
|
setGroups(array)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function checkEnd() {
|
|
|
|
|
+ if (groups[groups.length - 1].type == 'end') {
|
|
|
|
|
+ Taro.redirectTo({
|
|
|
|
|
+ url: '/pages/workout/WorkoutDetail?detail=' + JSON.stringify(groups)
|
|
|
|
|
+ })
|
|
|
|
|
+ props.end()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ setNeedTerminal(true)
|
|
|
|
|
+ setShowModal(true)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function terminal() {
|
|
function terminal() {
|
|
|
|
|
+ clearInterval(timer)
|
|
|
Taro.showModal({
|
|
Taro.showModal({
|
|
|
title: '提示',
|
|
title: '提示',
|
|
|
content: '确认结束?',
|
|
content: '确认结束?',
|
|
|
success: function (res) {
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
if (res.confirm) {
|
|
|
|
|
+ if (props.type != WorkoutType.normal) {
|
|
|
|
|
+ checkEnd()
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
var array = groups;
|
|
var array = groups;
|
|
|
var time = new Date().getTime()
|
|
var time = new Date().getTime()
|
|
|
array.push({
|
|
array.push({
|
|
@@ -123,10 +141,12 @@ export default function Component(props: { targetCount: number, type: WorkoutTyp
|
|
|
setIsDoing(false)
|
|
setIsDoing(false)
|
|
|
setGroups(array)
|
|
setGroups(array)
|
|
|
|
|
|
|
|
- Taro.navigateTo({
|
|
|
|
|
|
|
+ Taro.redirectTo({
|
|
|
url: '/pages/workout/WorkoutDetail?detail=' + JSON.stringify(array)
|
|
url: '/pages/workout/WorkoutDetail?detail=' + JSON.stringify(array)
|
|
|
})
|
|
})
|
|
|
|
|
+ props.end()
|
|
|
} else if (res.cancel) {
|
|
} else if (res.cancel) {
|
|
|
|
|
+ resume()
|
|
|
console.log('用户点击取消')
|
|
console.log('用户点击取消')
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -141,11 +161,20 @@ export default function Component(props: { targetCount: number, type: WorkoutTyp
|
|
|
array.push({
|
|
array.push({
|
|
|
index: index,
|
|
index: index,
|
|
|
time: tempTime,
|
|
time: tempTime,
|
|
|
- value: e.length>0?multiItems[0][e[0]]:items[e[0]],
|
|
|
|
|
- value2:e.length>0?multiItems[1][e[1]]:null,
|
|
|
|
|
|
|
+ value: e.length > 0 ? multiItems[0][e[0]] : items[e[0]],
|
|
|
|
|
+ value2: e.length > 0 ? multiItems[1][e[1]] : null,
|
|
|
type: 'end'
|
|
type: 'end'
|
|
|
})
|
|
})
|
|
|
setIsDoing(false)
|
|
setIsDoing(false)
|
|
|
|
|
+ if (needTerminal) {
|
|
|
|
|
+ Taro.redirectTo({
|
|
|
|
|
+ url: '/pages/workout/WorkoutDetail?detail=' + JSON.stringify(groups)
|
|
|
|
|
+ })
|
|
|
|
|
+ props.end()
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
setStartTime(tempTime)
|
|
setStartTime(tempTime)
|
|
|
setGroups(array)
|
|
setGroups(array)
|
|
|
resume()
|
|
resume()
|