xunji-wode-moban.vue
5.59 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<template>
<view class="container">
<!-- 页面头部 -->
<view class="header">
<u-icon name="arrow-left" size="32" color="#333" @click="back"></u-icon>
<text class="title">我的训练模板</text>
</view>
<!-- 筛选标签 + 加号按钮容器 -->
<view class="filter-wrapper">
<view class="filter-container">
<view class="filter-item" @click="toggleFilter('position')">
<text>部位</text>
<u-icon name="arrow-down" size="20" color="#999"></u-icon>
</view>
<view class="filter-item" @click="toggleFilter('scene')">
<text>场景</text>
<u-icon name="arrow-down" size="20" color="#999"></u-icon>
</view>
</view>
<view class="add-btn" @click="addTemplate">
<uni-icons type="plus" size="35" color="#333"></uni-icons>
</view>
</view>
<!-- 模板列表容器 -->
<view class="content">
<!-- 无数据状态 -->
<view v-if="templates.length === 0" class="empty-state">
<image src="https://fitness-hcxtec-bucket.oss-cn-shenzhen.aliyuncs.com/20260316/order-empty_1773628059920.png"
class="empty-image"></image>
<text class="empty-text">暂无该模板</text>
</view>
<!-- 模板卡片列表 -->
<view v-else class="template-list">
<view v-for="(item, index) in templates" :key="index" class="template-card">
<image src="https://fitness-hcxtec-bucket.oss-cn-shenzhen.aliyuncs.com/20260316/order-empty_1773628059920.png"
class="card-image"></image>
<view class="card-content">
<text class="card-title">{{ item.name }}</text>
<text class="card-desc">{{ item.desc }}</text>
<view class="card-footer">
<text class="footer-label">难度:</text>
<text class="footer-value">{{ item.difficulty }}</text>
<text class="footer-label">时长:</text>
<text class="footer-value">{{ item.duration }}分钟</text>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, onMounted } from 'vue';
// ====== 响应式数据 ======
const templates = ref([]);
const showPositionFilter = ref(false);
const showSceneFilter = ref(false);
// ====== 模拟接口:获取训练模板数据 ======
const fetchTemplates = () => {
const mockData = [
{
id: 1,
name: '全身燃脂训练',
desc: '高效燃脂,适合初学者',
difficulty: '初级',
duration: 30,
},
{
id: 2,
name: '核心力量训练',
desc: '强化腹部与腰部力量',
difficulty: '中级',
duration: 25,
},
{
id: 3,
name: '背部塑形训练',
desc: '改善体态,塑造完美背影',
difficulty: '高级',
duration: 40,
},
];
templates.value = mockData;
};
// ====== 方法 ======
const back = () => {
uni.navigateBack();
};
const addTemplate = () => {
uni.navigateTo({
url: '/pages/xunji/xunji-muban-xinzeng',
});
};
const toggleFilter = (type) => {
if (type === 'position') {
showPositionFilter.value = !showPositionFilter.value;
} else if (type === 'scene') {
showSceneFilter.value = !showSceneFilter.value;
}
};
// ====== 页面生命周期 ======
onMounted(() => {
fetchTemplates();
});
</script>
<style scoped lang="scss">
.container {
margin-top: 80rpx;
display: flex;
flex-direction: column;
min-height: 100vh;
background-color: #f5f5f5;
box-sizing: border-box;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx 20rpx;
padding-top: 60rpx;
background-color: #fff;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
z-index: 10;
}
.title {
font-size: 36rpx;
font-weight: bold;
color: #333;
flex: 1;
text-align: center;
}
.filter-wrapper {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 20rpx;
background-color: #fff;
}
.filter-container {
display: flex;
gap: 20rpx;
padding: 20rpx;
background-color: #fff;
}
.filter-item {
display: flex;
align-items: center;
justify-content: center;
gap: 8rpx;
padding: 12rpx 20rpx;
background-color: #f5f5f5;
border-radius: 20rpx;
font-size: 28rpx;
color: #333;
cursor: pointer;
}
.add-btn {
display: flex;
width: 60rpx;
height: 60rpx;
background-color: #fff;
color: #333;
align-items: center;
justify-content: center;
margin-left: 20rpx;
}
.content {
flex: 1;
padding: 20rpx;
overflow-y: auto;
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 500rpx;
}
.empty-image {
width: 180rpx;
height: 180rpx;
object-fit: contain;
margin-bottom: 30rpx;
}
.empty-text {
font-size: 28rpx;
color: #999;
text-align: center;
}
.template-list {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 20rpx;
}
.template-card {
background-color: #fff;
border-radius: 20rpx;
overflow: hidden;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
}
.card-image {
width: 100%;
height: 200rpx;
object-fit: cover;
}
.card-content {
padding: 20rpx;
}
.card-title {
font-size: 30rpx;
color: #333;
font-weight: 500;
margin-bottom: 10rpx;
}
.card-desc {
font-size: 24rpx;
color: #666;
line-height: 1.5;
margin-bottom: 15rpx;
}
.card-footer {
display: flex;
gap: 10rpx;
font-size: 24rpx;
color: #999;
}
.footer-label {
font-weight: 500;
}
.footer-value {
color: #333;
}
/* 防止内容溢出 */
.view {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
</style>