|
@@ -20,6 +20,7 @@ import { IconRadioCross, IconX } from "@/components/basic/Icons";
|
|
|
|
|
|
|
|
var timer
|
|
var timer
|
|
|
var lastStrTime
|
|
var lastStrTime
|
|
|
|
|
+var lastTimestamp
|
|
|
export default function Component(props: { targetCount: any, end: Function }) {
|
|
export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
|
|
|
|
|
@@ -153,7 +154,7 @@ export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
return strDuration.length == 0 ? '1秒' : strDuration
|
|
return strDuration.length == 0 ? '1秒' : strDuration
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function twoTimeFormateList(start,end){
|
|
|
|
|
|
|
+ function twoTimeFormateList(start, end) {
|
|
|
var time = Math.floor((end - start) / 1000);
|
|
var time = Math.floor((end - start) / 1000);
|
|
|
debugger
|
|
debugger
|
|
|
return TimeFormatter.workoutTimeAndUnitList(time)
|
|
return TimeFormatter.workoutTimeAndUnitList(time)
|
|
@@ -243,15 +244,6 @@ export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
var count = 0
|
|
var count = 0
|
|
|
var schema = workout.item.schemas[0]
|
|
var schema = workout.item.schemas[0]
|
|
|
if (schema.format == 'TIME_SECONDS') {
|
|
if (schema.format == 'TIME_SECONDS') {
|
|
|
- // for (var i=0;i<groups.length;i++){
|
|
|
|
|
- // var obj = groups[i]
|
|
|
|
|
- // if (obj.type=='REST'){
|
|
|
|
|
- // count+= Math.floor((obj.time-groups[i-1].time)/1000)
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- debugger
|
|
|
|
|
-
|
|
|
|
|
groups.map(item => {
|
|
groups.map(item => {
|
|
|
if (item.type == 'WORK') {
|
|
if (item.type == 'WORK') {
|
|
|
var t = Math.floor((item.end - item.start) / 1000)
|
|
var t = Math.floor((item.end - item.start) / 1000)
|
|
@@ -390,15 +382,11 @@ export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
}
|
|
}
|
|
|
]
|
|
]
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
uploadWorkout(params).then(res => {
|
|
uploadWorkout(params).then(res => {
|
|
|
clearCache()
|
|
clearCache()
|
|
|
dispatch(endSuccess())
|
|
dispatch(endSuccess())
|
|
|
|
|
|
|
|
- // var item = workout.item
|
|
|
|
|
- // Taro.redirectTo({
|
|
|
|
|
- // url: '/pages/common/RecordsHistory?type=workout&refreshList=getCards&title=' + item.name + '&code=' + item.code + '&themeColor=' + item.theme_color
|
|
|
|
|
- // })
|
|
|
|
|
-
|
|
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
Taro.redirectTo({
|
|
Taro.redirectTo({
|
|
|
url: '/pages/workout/WorkoutDetail?detail=' + JSON.stringify((res as any).latest_record) + '&title=' + workout.item.name + '&themeColor=' + workout.item.theme_color
|
|
url: '/pages/workout/WorkoutDetail?detail=' + JSON.stringify((res as any).latest_record) + '&title=' + workout.item.name + '&themeColor=' + workout.item.theme_color
|
|
@@ -410,6 +398,7 @@ export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
global.refreshWorkout()
|
|
global.refreshWorkout()
|
|
|
}).catch(e => {
|
|
}).catch(e => {
|
|
|
setIsPosting(false)
|
|
setIsPosting(false)
|
|
|
|
|
+ resume()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -429,6 +418,7 @@ export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
clearInterval(timer)
|
|
clearInterval(timer)
|
|
|
var tempTimestamp = new Date().getTime()
|
|
var tempTimestamp = new Date().getTime()
|
|
|
setTempTime(tempTimestamp)
|
|
setTempTime(tempTimestamp)
|
|
|
|
|
+ lastTimestamp = tempTimestamp
|
|
|
Taro.showModal({
|
|
Taro.showModal({
|
|
|
title: '提示',
|
|
title: '提示',
|
|
|
content: '确认结束?',
|
|
content: '确认结束?',
|
|
@@ -465,6 +455,7 @@ export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
function numChange(e) {
|
|
function numChange(e) {
|
|
|
setPickerValue(e)
|
|
setPickerValue(e)
|
|
|
setShowModal(false)
|
|
setShowModal(false)
|
|
|
|
|
+
|
|
|
var array = groups;
|
|
var array = groups;
|
|
|
array.push({
|
|
array.push({
|
|
|
index: index,
|
|
index: index,
|
|
@@ -474,11 +465,12 @@ export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
value3: e.length > 2 ? pickerItems[2][e[2]] : null,
|
|
value3: e.length > 2 ? pickerItems[2][e[2]] : null,
|
|
|
type: 'REST'
|
|
type: 'REST'
|
|
|
})
|
|
})
|
|
|
- setIsDoing(false)
|
|
|
|
|
if (needTerminal) {
|
|
if (needTerminal) {
|
|
|
postData()
|
|
postData()
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ setIsDoing(false)
|
|
|
|
|
+
|
|
|
|
|
|
|
|
saveCache(array)
|
|
saveCache(array)
|
|
|
setStartTime(tempTime)
|
|
setStartTime(tempTime)
|
|
@@ -486,61 +478,6 @@ export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
resume()
|
|
resume()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function total() {
|
|
|
|
|
- var schema = workout.item.schemas[0]
|
|
|
|
|
- if (schema.format == 'TIME_SECONDS') {
|
|
|
|
|
- var count = 0
|
|
|
|
|
- // groups.map(item => {
|
|
|
|
|
- // if (item.type == 'REST') {
|
|
|
|
|
- // count += parseInt(item.value) * 3600 + parseInt(item.value2) * 60 + parseInt(item.value3)
|
|
|
|
|
- // }
|
|
|
|
|
- // })
|
|
|
|
|
-
|
|
|
|
|
- for (var i = 0; i < groups.length; i++) {
|
|
|
|
|
- var obj = groups[i]
|
|
|
|
|
- if (obj.type == 'REST') {
|
|
|
|
|
- count += Math.floor((obj.time - groups[i - 1].time) / 1000)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (!count) {
|
|
|
|
|
- return '0小时0分钟0秒'
|
|
|
|
|
- }
|
|
|
|
|
- return TimeFormatter.workoutTime(count)
|
|
|
|
|
- }
|
|
|
|
|
- var count = 0
|
|
|
|
|
- for (var i = 0; i < groups.length; i++) {
|
|
|
|
|
- var obj = groups[i]
|
|
|
|
|
- if (obj.type == 'REST') {
|
|
|
|
|
- var temp = 0
|
|
|
|
|
- if (obj.value) {
|
|
|
|
|
- temp = parseInt(obj.value + '')
|
|
|
|
|
- }
|
|
|
|
|
- if (obj.value2) {
|
|
|
|
|
- temp *= parseInt(obj.value2 + '')
|
|
|
|
|
- }
|
|
|
|
|
- if (obj.value3) {
|
|
|
|
|
- temp *= parseInt(obj.value3 + '')
|
|
|
|
|
- }
|
|
|
|
|
- count += temp
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- var unit = ''
|
|
|
|
|
- var array = workout.item.schemas[0].values
|
|
|
|
|
-
|
|
|
|
|
- for (var i = 0; i < array.length; i++) {
|
|
|
|
|
- unit += array[i].unit + '·'
|
|
|
|
|
- }
|
|
|
|
|
- return count + unit.substring(0, unit.length - 1)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function getGroupValue(item) {
|
|
|
|
|
- var schema = workout.item.schemas[0]
|
|
|
|
|
- if (schema.format == 'TIME_SECONDS') {
|
|
|
|
|
- return ''
|
|
|
|
|
- return item.value + item.value2 + item.value3
|
|
|
|
|
- }
|
|
|
|
|
- return item.value + (item.value2 ? 'x' + item.value2 : '') + (item.value3 ? 'x' + item.value3 : '')
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
function needShowPicker() {
|
|
function needShowPicker() {
|
|
|
var schema = workout.item.schemas[0]
|
|
var schema = workout.item.schemas[0]
|
|
@@ -631,7 +568,7 @@ export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return <View style={{ color: workout.item.theme_color, flexDirection: 'column', display: 'flex' }}>
|
|
return <View style={{ color: workout.item.theme_color, flexDirection: 'column', display: 'flex' }}>
|
|
|
- <Text className="working_title" style={{fontSize:rpxToPx(56)}}>{workout.item.name}</Text>
|
|
|
|
|
|
|
+ <Text className="working_title" style={{ fontSize: rpxToPx(56) }}>{workout.item.name}</Text>
|
|
|
<Text className="working_subtitle">计时训练</Text>
|
|
<Text className="working_subtitle">计时训练</Text>
|
|
|
{
|
|
{
|
|
|
groups.length > 1 && groups.map((item, index) => {
|
|
groups.length > 1 && groups.map((item, index) => {
|
|
@@ -642,7 +579,7 @@ export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
<Box key={index} >
|
|
<Box key={index} >
|
|
|
<View>
|
|
<View>
|
|
|
<Text className="working_index">{item.type == 'REST' ? `第${item.index}组` : '组间休息'}</Text>
|
|
<Text className="working_index">{item.type == 'REST' ? `第${item.index}组` : '组间休息'}</Text>
|
|
|
- <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', marginTop: item.type == 'REST' ? rpxToPx(60) : 0, marginBottom: item.type == 'REST' ? rpxToPx(0) : 0 }}>
|
|
|
|
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', marginTop: item.type == 'REST' ? rpxToPx(60) : 0, marginBottom: item.type == 'REST' ? rpxToPx(0) : 0 }}>
|
|
|
{item.type == 'REST' && workout.item.schemas[0].format != 'TIME_SECONDS' &&
|
|
{item.type == 'REST' && workout.item.schemas[0].format != 'TIME_SECONDS' &&
|
|
|
<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
|
<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
|
|
{
|
|
{
|
|
@@ -652,7 +589,7 @@ export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
item.value2 && <IconX width={rpxToPx(32)} color={workout.item.theme_color} />
|
|
item.value2 && <IconX width={rpxToPx(32)} color={workout.item.theme_color} />
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- item.value2 && <View style={{width:1}} />
|
|
|
|
|
|
|
+ item.value2 && <View style={{ width: 1 }} />
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
item.value2 && <MultiText values={[parseInt(item.value2)]} units={[workout.item.schemas[0].values[1].unit]} color={workout.item.theme_color} valueSize={rpxToPx(48)} unitSize={rpxToPx(32)} />
|
|
item.value2 && <MultiText values={[parseInt(item.value2)]} units={[workout.item.schemas[0].values[1].unit]} color={workout.item.theme_color} valueSize={rpxToPx(48)} unitSize={rpxToPx(32)} />
|
|
@@ -665,7 +602,7 @@ export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
item.type == 'REST' && workout.item.schemas[0].format == 'TIME_SECONDS' &&
|
|
item.type == 'REST' && workout.item.schemas[0].format == 'TIME_SECONDS' &&
|
|
|
- <MultiText values={twoTimeFormateList(groups[index - 1].time,item.time).values} units={twoTimeFormateList(groups[index - 1].time,item.time).units} color={workout.item.theme_color} valueSize={rpxToPx(48)} unitSize={rpxToPx(32)} />
|
|
|
|
|
|
|
+ <MultiText values={twoTimeFormateList(groups[index - 1].time, item.time).values} units={twoTimeFormateList(groups[index - 1].time, item.time).units} color={workout.item.theme_color} valueSize={rpxToPx(48)} unitSize={rpxToPx(32)} />
|
|
|
}
|
|
}
|
|
|
<View style={{ flex: 1 }} />
|
|
<View style={{ flex: 1 }} />
|
|
|
|
|
|
|
@@ -710,39 +647,16 @@ export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
totalSummary()
|
|
totalSummary()
|
|
|
}
|
|
}
|
|
|
{/* <Text className="train_summary_value" style={{ color: workout.item.theme_color }}></Text> */}
|
|
{/* <Text className="train_summary_value" style={{ color: workout.item.theme_color }}></Text> */}
|
|
|
- <Text className="train_summary_title">用时</Text>
|
|
|
|
|
- <Text className="train_summary_value" style={{ color: workout.item.theme_color }}>{groups.length > 0 && TimeFormatter.formateTimeNow(groups[0].time)}</Text>
|
|
|
|
|
|
|
+ <Text className="train_summary_title">已进行</Text>
|
|
|
|
|
+ <Text className="train_summary_value" style={{ color: workout.item.theme_color }}>{groups.length > 0 &&
|
|
|
|
|
+ (isPosting ? TimeFormatter.formateTimeNow(groups[0].time,lastTimestamp) :
|
|
|
|
|
+ TimeFormatter.formateTimeNow(groups[0].time))}</Text>
|
|
|
<Text className="train_summary_title">{groups.length > 0 && new Date().getTime() > groups[0].time + props.targetCount * 1000 ? '已超时' : '距结束'}</Text>
|
|
<Text className="train_summary_title">{groups.length > 0 && new Date().getTime() > groups[0].time + props.targetCount * 1000 ? '已超时' : '距结束'}</Text>
|
|
|
- <Text className="train_summary_value" style={{ color: workout.item.theme_color }}>{groups.length > 0 && TimeFormatter.countdown(groups[0].time + props.targetCount * 1000)}</Text>
|
|
|
|
|
|
|
+ <Text className="train_summary_value" style={{ color: workout.item.theme_color }}>{groups.length > 0 &&
|
|
|
|
|
+ (isPosting ? TimeFormatter.countdown(groups[0].time + props.targetCount * 1000,lastTimestamp) :
|
|
|
|
|
+ TimeFormatter.countdown(groups[0].time + props.targetCount * 1000))}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- {/* {
|
|
|
|
|
- !router.params.content_only && <View style={{ display: 'flex', flexDirection: 'column', color: '#fff', marginLeft: rpxToPx(46) }}>
|
|
|
|
|
- <Text style={{ fontSize: rpxToPx(40), fontWeight: 'bold' }}>实时训练统计</Text>
|
|
|
|
|
- <Text style={{ opacity: 0.8, fontSize: rpxToPx(32), fontWeight: 'bold' }}>总量</Text>
|
|
|
|
|
- <Text style={{ fontSize: rpxToPx(48), fontWeight: 'bold', marginTop: rpxToPx(10) }}>{total()}</Text>
|
|
|
|
|
- <Text style={{ marginTop: 20 }}>计时</Text>
|
|
|
|
|
- <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(40) }}>{planTime()}</Text>
|
|
|
|
|
- </View>
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- {
|
|
|
|
|
- !router.params.content_only && <View style={{ display: 'flex', flexDirection: 'row', color: '#fff', marginLeft: rpxToPx(46), marginBottom: 100, marginTop: rpxToPx(20) }}>
|
|
|
|
|
- <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
|
|
|
|
-
|
|
|
|
|
- <Text style={{ color: workout.item.theme_color, fontSize: rpxToPx(36), fontWeight: 'bold' }}>{groups.length > 0 && TimeFormatter.formateTimeNow(groups[0].time)}</Text>
|
|
|
|
|
- <Text style={{ fontSize: rpxToPx(20), color: '#fff', opacity: 0.4 }}>已进行</Text>
|
|
|
|
|
- </View>
|
|
|
|
|
- <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', marginLeft: rpxToPx(80) }}>
|
|
|
|
|
-
|
|
|
|
|
- <Text style={{ color: workout.item.theme_color, fontSize: rpxToPx(36), fontWeight: 'bold' }}>{groups.length > 0 && TimeFormatter.countdown(groups[0].time + props.targetCount * 1000)}</Text>
|
|
|
|
|
- <Text style={{ fontSize: rpxToPx(20), color: '#fff', opacity: 0.4 }}>{groups.length > 0 && new Date().getTime() > groups[0].time + props.targetCount * 1000 ? '已超时' : '距结束'}</Text>
|
|
|
|
|
- </View>
|
|
|
|
|
- </View>
|
|
|
|
|
- } */}
|
|
|
|
|
-
|
|
|
|
|
{
|
|
{
|
|
|
showModal && <Modal dismiss={() => {
|
|
showModal && <Modal dismiss={() => {
|
|
|
setShowModal(false)
|
|
setShowModal(false)
|