add-train-popup.vue
4.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
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
<template>
<!-- 添加自助训练底部弹窗 -->
<view v-if="visible" class="popup-overlay" @click="close">
<view class="popup-bottom" @click.stop>
<view class="popup-options">
<view class="popup-option" @click="handleAddFromPlan" v-if="planListCount > 0">
<view class=" icon-wrap">
<image src="/static/icons/plan.png" mode="aspectFit"></image>
</view>
<view class="text-wrap" @click="">
<text class="option-title">从训练计划中添加</text>
<text class="option-desc">从我的训练计划中添加</text>
</view>
</view>
<view class="popup-option" @click="handleAddFromTemplate">
<view class="icon-wrap">
<image src="/static/icons/template.png" mode="aspectFit"></image>
</view>
<view class="text-wrap">
<text class="option-title">使用训练模板</text>
<text class="option-desc">官方训练模板和自定义模板</text>
</view>
</view>
<view class="popup-option" @click="handleFreeTraining">
<view class="icon-wrap">
<image src="/static/icons/free.png" mode="aspectFit"></image>
</view>
<view class="text-wrap">
<text class="option-title">自由训练</text>
<text class="option-desc">新建空白训练</text>
</view>
</view>
</view>
<view class="close-btn" @click="close">
<text>×</text>
</view>
</view>
<WodeJihuaTianjiaTancuang v-model:visible="showPlanPopup" @get-plan-list-length="getPlanListLength" :isAdd="true" />
</view>
</template>
<script setup>
import { ref } from 'vue'
import WodeJihuaTianjiaTancuang from '@/pages/xunji/components/wode-jihua-tianjia-tancuang.vue'
// 控制训练计划弹窗显示
const showPlanPopup = ref(false)
const planListCount = ref(0)
const props = defineProps({
visible: {
type: Boolean,
default: false
}
})
const emit = defineEmits(['update:visible'])
// 关闭弹窗
const close = () => {
emit('update:visible', false)
}
// 三个逻辑全部放在子组件内部
const handleAddFromPlan = () => {
// close() // 关闭当前弹窗
showPlanPopup.value = true
}
const getPlanListLength = (len) => {
planListCount.value = len
}
const handleAddFromTemplate = () => {
uni.navigateTo({ url: '/pages4/pages/xunji/xunji-rili-tianjia-moban' })
close()
}
const handleFreeTraining = () => {
uni.navigateTo({ url: '/pages4/pages/xunji/xunji-dongzuo-lianxi' })
close()
}
</script>
<style lang="scss" scoped>
/* 半透明黑色遮罩层 —— 内容靠底部!! */
.popup-overlay {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: rgba(0, 0, 0, 0.8);
z-index: 9999;
display: flex;
flex-direction: column;
/* 核心:靠下 */
justify-content: flex-end;
align-items: center;
/* 距离底部一点距离,不贴着最底下 */
padding-bottom: 150rpx;
}
/* 弹窗主体容器 */
.popup-bottom {
width: 85%;
display: flex;
flex-direction: column;
align-items: center;
/* 选项和关闭按钮间距 */
gap: 70rpx;
}
/* 选项列表 */
.popup-options {
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 20rpx;
}
/* 单个选项项 */
.popup-option {
width: 100%;
// background: rgba(255, 255, 255, 0.1);
border-radius: 16rpx;
padding: 24rpx 30rpx;
display: flex;
align-items: center;
gap: 24rpx;
}
/* 黄色图标容器 */
.icon-wrap {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
background: #ffd60a;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
image {
width: 40rpx;
height: 40rpx;
}
}
/* 文字区域 */
.text-wrap {
display: flex;
flex-direction: column;
gap: 8rpx;
}
.option-title {
font-size: 32rpx;
color: #fff;
font-weight: 500;
}
.option-desc {
font-size: 26rpx;
color: rgba(255, 255, 255, 0.7);
}
/* 底部关闭按钮 */
.close-btn {
width: 88rpx;
height: 88rpx;
border-radius: 50%;
background: #fff;
display: flex;
align-items: center;
justify-content: center;
text {
font-size: 40rpx;
color: #000;
line-height: 1;
}
}
</style>