training-float.vue
1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<template>
<view v-if="trainStore.trainingInfo.isMinimized" class="float-ball" @click="goBackTrain">
<text class="text">训练中</text>
<text class="time">{{ formatTime(trainStore.trainingInfo.totalSeconds) }}</text>
</view>
</template>
<script setup>
import useTrainingStore from '@/sheep/store/training';
const trainStore = useTrainingStore();
// 回到训练页
const goBackTrain = () => {
const info = trainStore.trainingInfo;
trainStore.restore();
uni.navigateTo({
url: `/pages4/pages/xunji/xunji-dongzuo-lianxi?id=${info.exerciseId}&unitType=${info.unitType}`,
});
};
// 时间格式化
const formatTime = (s) => {
const m = Math.floor(s / 60).toString().padStart(2, '0');
const sec = (s % 60).toString().padStart(2, '0');
return `${m}:${sec}`;
};
</script>
<style scoped>
.float-ball {
position: fixed;
bottom: 200rpx;
right: 40rpx;
width: 120rpx;
height: 120rpx;
background: #ffd700;
border-radius: 50%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
z-index: 99999;
}
.text {
font-size: 24rpx;
font-weight: bold;
}
.time {
font-size: 20rpx;
margin-top: 6rpx;
}
</style>