muzhiyu-ui 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +202 -0
- package/components/muzhiyu/mu-action-sheet/mu-action-sheet.vue +335 -0
- package/components/muzhiyu/mu-alert/mu-alert.vue +220 -0
- package/components/muzhiyu/mu-back-top/mu-back-top.vue +161 -0
- package/components/muzhiyu/mu-badge/mu-badge.vue +150 -0
- package/components/muzhiyu/mu-barcode/mu-barcode.vue +100 -0
- package/components/muzhiyu/mu-blank/mu-blank.vue +30 -0
- package/components/muzhiyu/mu-bottom-nav/mu-bottom-nav.vue +331 -0
- package/components/muzhiyu/mu-bubble/mu-bubble.vue +316 -0
- package/components/muzhiyu/mu-button/mu-button.vue +431 -0
- package/components/muzhiyu/mu-calendar/mu-calendar.vue +429 -0
- package/components/muzhiyu/mu-car-input/mu-car-input.vue +209 -0
- package/components/muzhiyu/mu-card/mu-card.vue +317 -0
- package/components/muzhiyu/mu-cascader/mu-cascader.vue +336 -0
- package/components/muzhiyu/mu-cell/mu-cell.vue +368 -0
- package/components/muzhiyu/mu-checkbox/mu-checkbox.vue +116 -0
- package/components/muzhiyu/mu-checkbox-group/mu-checkbox-group.vue +40 -0
- package/components/muzhiyu/mu-code-input/mu-code-input.vue +264 -0
- package/components/muzhiyu/mu-collapse/mu-collapse.vue +316 -0
- package/components/muzhiyu/mu-color-picker/mu-color-picker.vue +466 -0
- package/components/muzhiyu/mu-config/index.js +34 -0
- package/components/muzhiyu/mu-config/mu-config.vue +54 -0
- package/components/muzhiyu/mu-countdown/mu-countdown.vue +338 -0
- package/components/muzhiyu/mu-cropper/mu-cropper.vue +415 -0
- package/components/muzhiyu/mu-date-picker/mu-date-picker.vue +290 -0
- package/components/muzhiyu/mu-datetime/mu-datetime.vue +262 -0
- package/components/muzhiyu/mu-divider/mu-divider.vue +229 -0
- package/components/muzhiyu/mu-drawer/mu-drawer.vue +172 -0
- package/components/muzhiyu/mu-dropdown/mu-dropdown.vue +215 -0
- package/components/muzhiyu/mu-dropdown-top/mu-dropdown-top.vue +243 -0
- package/components/muzhiyu/mu-empty/mu-empty.vue +217 -0
- package/components/muzhiyu/mu-fab/mu-fab.vue +324 -0
- package/components/muzhiyu/mu-footer/mu-footer.vue +21 -0
- package/components/muzhiyu/mu-form/mu-form.vue +170 -0
- package/components/muzhiyu/mu-grid/mu-grid.vue +95 -0
- package/components/muzhiyu/mu-grid-item/mu-grid-item.vue +247 -0
- package/components/muzhiyu/mu-html/mu-html.vue +145 -0
- package/components/muzhiyu/mu-icon/mu-icon.vue +822 -0
- package/components/muzhiyu/mu-image-grid/mu-image-grid.vue +225 -0
- package/components/muzhiyu/mu-image-preview/mu-image-preview.vue +286 -0
- package/components/muzhiyu/mu-index-list/mu-index-list.vue +381 -0
- package/components/muzhiyu/mu-input/mu-input.vue +570 -0
- package/components/muzhiyu/mu-input-number/mu-input-number.vue +193 -0
- package/components/muzhiyu/mu-keyboard/mu-keyboard.vue +415 -0
- package/components/muzhiyu/mu-list/mu-list.vue +89 -0
- package/components/muzhiyu/mu-loading/mu-loading.vue +124 -0
- package/components/muzhiyu/mu-loading-page/mu-loading-page.vue +529 -0
- package/components/muzhiyu/mu-loadmore/mu-loadmore.vue +26 -0
- package/components/muzhiyu/mu-modal/mu-modal.vue +298 -0
- package/components/muzhiyu/mu-navbar/mu-navbar.vue +223 -0
- package/components/muzhiyu/mu-nomore/mu-nomore.vue +107 -0
- package/components/muzhiyu/mu-notice-bar/mu-notice-bar.vue +284 -0
- package/components/muzhiyu/mu-notify/mu-notify.vue +202 -0
- package/components/muzhiyu/mu-overlay/mu-overlay.vue +94 -0
- package/components/muzhiyu/mu-pagination/mu-pagination.vue +330 -0
- package/components/muzhiyu/mu-password-input/mu-password-input.vue +119 -0
- package/components/muzhiyu/mu-picker/mu-picker.vue +297 -0
- package/components/muzhiyu/mu-popup/mu-popup.vue +297 -0
- package/components/muzhiyu/mu-progress/mu-progress.vue +156 -0
- package/components/muzhiyu/mu-pull-refresh/mu-pull-refresh.vue +54 -0
- package/components/muzhiyu/mu-qrcode/mu-qrcode.vue +340 -0
- package/components/muzhiyu/mu-qrcode/qrcode.js +2237 -0
- package/components/muzhiyu/mu-radio/mu-radio.vue +125 -0
- package/components/muzhiyu/mu-radio-group/mu-radio-group.vue +37 -0
- package/components/muzhiyu/mu-rate/mu-rate.vue +103 -0
- package/components/muzhiyu/mu-search/mu-search.vue +320 -0
- package/components/muzhiyu/mu-section/mu-section.vue +206 -0
- package/components/muzhiyu/mu-select/mu-select.vue +440 -0
- package/components/muzhiyu/mu-share-sheet/mu-share-sheet.vue +269 -0
- package/components/muzhiyu/mu-sidebar/mu-sidebar.vue +304 -0
- package/components/muzhiyu/mu-signature/mu-signature.vue +449 -0
- package/components/muzhiyu/mu-skeleton/mu-skeleton.vue +225 -0
- package/components/muzhiyu/mu-slider/mu-slider.vue +228 -0
- package/components/muzhiyu/mu-space/mu-space.vue +84 -0
- package/components/muzhiyu/mu-steps/mu-steps.vue +311 -0
- package/components/muzhiyu/mu-sticky/mu-sticky.vue +57 -0
- package/components/muzhiyu/mu-swipe-cell/mu-swipe-cell.vue +281 -0
- package/components/muzhiyu/mu-swiper/mu-swiper.vue +107 -0
- package/components/muzhiyu/mu-switch/mu-switch.vue +99 -0
- package/components/muzhiyu/mu-tabbar/mu-tabbar.vue +382 -0
- package/components/muzhiyu/mu-table/mu-table.vue +420 -0
- package/components/muzhiyu/mu-tabs/mu-tabs.vue +339 -0
- package/components/muzhiyu/mu-tag/mu-tag.vue +65 -0
- package/components/muzhiyu/mu-text-ellipsis/mu-text-ellipsis.vue +54 -0
- package/components/muzhiyu/mu-timeline/mu-timeline.vue +166 -0
- package/components/muzhiyu/mu-tips/mu-tips.vue +36 -0
- package/components/muzhiyu/mu-toast/mu-toast.vue +151 -0
- package/components/muzhiyu/mu-transfer/mu-transfer.vue +114 -0
- package/components/muzhiyu/mu-tree/mu-tree.vue +263 -0
- package/components/muzhiyu/mu-upload/mu-upload.vue +415 -0
- package/components/muzhiyu/mu-waterfall/mu-waterfall.vue +321 -0
- package/components/muzhiyu/mu-watermark/mu-watermark.vue +60 -0
- package/index.js +83 -0
- package/package.json +38 -0
- package/utils/index.js +600 -0
- package/utils/request.js +265 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="mu-bottom-nav" :class="[fixed && 'mu-bottom-nav--fixed']" :style="{ background }">
|
|
3
|
+
<!-- 默认插槽:完全自定义底部栏内容 -->
|
|
4
|
+
<slot v-if="$slots.default || type === 'custom'"></slot>
|
|
5
|
+
|
|
6
|
+
<!-- 1. 电商 / 交易工具栏模式 (type="action") -->
|
|
7
|
+
<template v-else-if="type === 'action'">
|
|
8
|
+
<!-- 左侧小图标组 -->
|
|
9
|
+
<view class="mu-bottom-nav__icons">
|
|
10
|
+
<view
|
|
11
|
+
v-for="(item, index) in items"
|
|
12
|
+
:key="index"
|
|
13
|
+
class="mu-bottom-nav__icon-item mu-touchable-flat"
|
|
14
|
+
@tap="handleIconClick(index, item)"
|
|
15
|
+
>
|
|
16
|
+
<mu-badge :count="item.badge" :is-dot="item.dot">
|
|
17
|
+
<mu-icon v-if="item.icon" :name="item.icon" :size="20" :color="item.active ? (item.activeColor || '#171717') : '#64748B'" />
|
|
18
|
+
<image v-else-if="item.img" class="mu-bottom-nav__img" :src="item.img" mode="aspectFit" />
|
|
19
|
+
</mu-badge>
|
|
20
|
+
<text class="mu-bottom-nav__text" :style="{ color: item.active ? (item.activeColor || '#171717') : '#64748B' }">{{ item.text }}</text>
|
|
21
|
+
</view>
|
|
22
|
+
</view>
|
|
23
|
+
|
|
24
|
+
<!-- 右侧按钮组 -->
|
|
25
|
+
<view class="mu-bottom-nav__btns">
|
|
26
|
+
<view
|
|
27
|
+
v-for="(btn, bi) in buttons"
|
|
28
|
+
:key="bi"
|
|
29
|
+
class="mu-bottom-nav__btn mu-touchable-flat"
|
|
30
|
+
:class="[
|
|
31
|
+
btn.type && `mu-bottom-nav__btn--${btn.type}`,
|
|
32
|
+
buttons.length === 1 && 'mu-bottom-nav__btn--single'
|
|
33
|
+
]"
|
|
34
|
+
:style="getButtonStyle(btn, bi)"
|
|
35
|
+
@tap="handleButtonClick(bi, btn)"
|
|
36
|
+
>
|
|
37
|
+
<text class="mu-bottom-nav__btn-text">{{ btn.text }}</text>
|
|
38
|
+
</view>
|
|
39
|
+
</view>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<!-- 2. 社交 / 资讯互动模式 (type="bar") -->
|
|
43
|
+
<template v-else-if="type === 'bar'">
|
|
44
|
+
<view class="mu-bottom-nav__input-box mu-touchable-flat" @tap="handleInputTap">
|
|
45
|
+
<mu-icon name="edit" :size="14" color="#94A3B8" style="margin-right: 12rpx;" />
|
|
46
|
+
<text class="mu-bottom-nav__input-placeholder">{{ placeholder }}</text>
|
|
47
|
+
</view>
|
|
48
|
+
|
|
49
|
+
<view class="mu-bottom-nav__actions">
|
|
50
|
+
<view
|
|
51
|
+
v-for="(act, ai) in actions"
|
|
52
|
+
:key="ai"
|
|
53
|
+
class="mu-bottom-nav__action-item mu-touchable-flat"
|
|
54
|
+
@tap="handleActionClick(ai, act)"
|
|
55
|
+
>
|
|
56
|
+
<mu-badge :count="act.badge" :is-dot="act.dot">
|
|
57
|
+
<mu-icon :name="act.icon" :size="22" :color="act.active ? (act.activeColor || '#F43F5E') : '#64748B'" />
|
|
58
|
+
</mu-badge>
|
|
59
|
+
<text v-if="act.count !== undefined" class="mu-bottom-nav__action-count" :class="[act.active && 'mu-bottom-nav__action-count--active']">
|
|
60
|
+
{{ act.count }}
|
|
61
|
+
</text>
|
|
62
|
+
</view>
|
|
63
|
+
</view>
|
|
64
|
+
</template>
|
|
65
|
+
|
|
66
|
+
<!-- 3. 经典均匀导航栏模式 (type="nav") -->
|
|
67
|
+
<template v-else>
|
|
68
|
+
<view
|
|
69
|
+
v-for="(item, index) in items"
|
|
70
|
+
:key="index"
|
|
71
|
+
class="mu-bottom-nav__item mu-touchable-flat"
|
|
72
|
+
:class="[current === index && 'mu-bottom-nav__item--active']"
|
|
73
|
+
@tap="handleClick(index, item)"
|
|
74
|
+
>
|
|
75
|
+
<mu-badge :count="item.badge" :is-dot="item.dot">
|
|
76
|
+
<mu-icon v-if="item.icon" :name="item.icon" :size="22" :color="current === index ? '#171717' : '#94A3B8'" />
|
|
77
|
+
<image v-else-if="item.img" class="mu-bottom-nav__img" :src="item.img" mode="aspectFit" />
|
|
78
|
+
</mu-badge>
|
|
79
|
+
<text class="mu-bottom-nav__text" :class="{ 'mu-bottom-nav__text--active': current === index }">{{ item.text }}</text>
|
|
80
|
+
</view>
|
|
81
|
+
</template>
|
|
82
|
+
</view>
|
|
83
|
+
|
|
84
|
+
<!-- 安全区底部占位块 -->
|
|
85
|
+
<view v-if="fixed" class="mu-bottom-nav__placeholder"></view>
|
|
86
|
+
</template>
|
|
87
|
+
|
|
88
|
+
<script setup>
|
|
89
|
+
const props = defineProps({
|
|
90
|
+
type: { type: String, default: 'action' }, // action (电商交易工具栏) | bar (社交评论互动) | nav (均匀导航) | custom (自由自定义)
|
|
91
|
+
items: { type: Array, default: () => [] },
|
|
92
|
+
buttons: { type: Array, default: () => [] }, // type="action" 时的右侧大按钮
|
|
93
|
+
actions: { type: Array, default: () => [] }, // type="bar" 时的右侧互动图标组
|
|
94
|
+
placeholder: { type: String, default: '写下你的精彩评论...' },
|
|
95
|
+
current: { type: Number, default: 0 },
|
|
96
|
+
fixed: { type: Boolean, default: true },
|
|
97
|
+
background: { type: String, default: '' }
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
const emit = defineEmits(['change', 'click-icon', 'click-button', 'click-action', 'click-input'])
|
|
101
|
+
|
|
102
|
+
function getButtonStyle(btn, index) {
|
|
103
|
+
if (btn.color) return { background: btn.color }
|
|
104
|
+
|
|
105
|
+
// 默认双胶囊按钮优雅渐变配色
|
|
106
|
+
if (props.buttons.length === 2) {
|
|
107
|
+
if (index === 0) return { background: '#F59E0B' }
|
|
108
|
+
if (index === 1) return { background: '#171717' }
|
|
109
|
+
}
|
|
110
|
+
return { background: '#171717' }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function handleClick(index, item) {
|
|
114
|
+
emit('change', { index, item })
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function handleIconClick(index, item) {
|
|
118
|
+
emit('click-icon', { index, item })
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function handleButtonClick(index, btn) {
|
|
122
|
+
emit('click-button', { index, btn })
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function handleActionClick(index, act) {
|
|
126
|
+
emit('click-action', { index, act })
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function handleInputTap() {
|
|
130
|
+
emit('click-input')
|
|
131
|
+
}
|
|
132
|
+
</script>
|
|
133
|
+
|
|
134
|
+
<style lang="scss" scoped>
|
|
135
|
+
@import "@/uni.scss";
|
|
136
|
+
|
|
137
|
+
.mu-bottom-nav {
|
|
138
|
+
width: 100%;
|
|
139
|
+
height: 108rpx;
|
|
140
|
+
background: rgba(255, 255, 255, 0.92);
|
|
141
|
+
backdrop-filter: blur(20px);
|
|
142
|
+
border-top: 1rpx solid rgba(226, 232, 240, 0.8);
|
|
143
|
+
display: flex;
|
|
144
|
+
align-items: center;
|
|
145
|
+
padding: 0 24rpx;
|
|
146
|
+
box-sizing: border-box;
|
|
147
|
+
z-index: $mu-z-fixed;
|
|
148
|
+
|
|
149
|
+
&--fixed {
|
|
150
|
+
position: fixed;
|
|
151
|
+
bottom: 0;
|
|
152
|
+
left: 0;
|
|
153
|
+
right: 0;
|
|
154
|
+
padding-bottom: env(safe-area-inset-bottom, 0);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* ========== 1. type="action" 电商交易模式 ========== */
|
|
158
|
+
&__icons {
|
|
159
|
+
display: flex;
|
|
160
|
+
align-items: center;
|
|
161
|
+
margin-right: 24rpx;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
&__icon-item {
|
|
165
|
+
display: flex;
|
|
166
|
+
flex-direction: column;
|
|
167
|
+
align-items: center;
|
|
168
|
+
justify-content: center;
|
|
169
|
+
padding: 0 16rpx;
|
|
170
|
+
cursor: pointer;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
&__icon-wrap {
|
|
174
|
+
position: relative;
|
|
175
|
+
display: flex;
|
|
176
|
+
align-items: center;
|
|
177
|
+
justify-content: center;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
&__img {
|
|
181
|
+
width: 40rpx;
|
|
182
|
+
height: 40rpx;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
&__badge {
|
|
186
|
+
position: absolute;
|
|
187
|
+
top: -8rpx;
|
|
188
|
+
right: -16rpx;
|
|
189
|
+
min-width: 28rpx;
|
|
190
|
+
height: 28rpx;
|
|
191
|
+
border-radius: 999rpx;
|
|
192
|
+
background: #F43F5E;
|
|
193
|
+
display: flex;
|
|
194
|
+
align-items: center;
|
|
195
|
+
justify-content: center;
|
|
196
|
+
padding: 0 6rpx;
|
|
197
|
+
|
|
198
|
+
&-text {
|
|
199
|
+
font-size: 16rpx;
|
|
200
|
+
font-weight: 800;
|
|
201
|
+
color: #ffffff;
|
|
202
|
+
line-height: 1;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
&__text {
|
|
207
|
+
font-size: 20rpx;
|
|
208
|
+
color: #64748B;
|
|
209
|
+
font-weight: 600;
|
|
210
|
+
margin-top: 4rpx;
|
|
211
|
+
line-height: 1;
|
|
212
|
+
|
|
213
|
+
&--active {
|
|
214
|
+
color: #171717;
|
|
215
|
+
font-weight: 800;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
&__btns {
|
|
220
|
+
flex: 1;
|
|
221
|
+
display: flex;
|
|
222
|
+
align-items: center;
|
|
223
|
+
gap: 12rpx;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
&__btn {
|
|
227
|
+
flex: 1;
|
|
228
|
+
height: 76rpx;
|
|
229
|
+
border-radius: 38rpx;
|
|
230
|
+
display: flex;
|
|
231
|
+
align-items: center;
|
|
232
|
+
justify-content: center;
|
|
233
|
+
cursor: pointer;
|
|
234
|
+
box-shadow: 0 4rpx 14rpx rgba(15, 23, 42, 0.08);
|
|
235
|
+
|
|
236
|
+
&-text {
|
|
237
|
+
font-size: 26rpx;
|
|
238
|
+
font-weight: 800;
|
|
239
|
+
color: #ffffff;
|
|
240
|
+
letter-spacing: -0.5rpx;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
&--single {
|
|
244
|
+
width: 100%;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/* ========== 2. type="bar" 社交评论互动模式 ========== */
|
|
249
|
+
&__input-box {
|
|
250
|
+
flex: 1;
|
|
251
|
+
height: 72rpx;
|
|
252
|
+
border-radius: 36rpx;
|
|
253
|
+
background: #F1F5F9;
|
|
254
|
+
display: flex;
|
|
255
|
+
align-items: center;
|
|
256
|
+
padding: 0 24rpx;
|
|
257
|
+
margin-right: 20rpx;
|
|
258
|
+
cursor: pointer;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
&__input-placeholder {
|
|
262
|
+
font-size: 24rpx;
|
|
263
|
+
color: #94A3B8;
|
|
264
|
+
font-weight: 500;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
&__actions {
|
|
268
|
+
display: flex;
|
|
269
|
+
align-items: center;
|
|
270
|
+
gap: 28rpx;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
&__action-item {
|
|
274
|
+
display: flex;
|
|
275
|
+
align-items: center;
|
|
276
|
+
gap: 6rpx;
|
|
277
|
+
cursor: pointer;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
&__action-count {
|
|
281
|
+
font-size: 22rpx;
|
|
282
|
+
color: #64748B;
|
|
283
|
+
font-weight: 700;
|
|
284
|
+
|
|
285
|
+
&--active {
|
|
286
|
+
color: #F43F5E;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/* ========== 3. type="nav" 经典均匀导航模式 ========== */
|
|
291
|
+
&__item {
|
|
292
|
+
flex: 1;
|
|
293
|
+
display: flex;
|
|
294
|
+
flex-direction: column;
|
|
295
|
+
align-items: center;
|
|
296
|
+
justify-content: center;
|
|
297
|
+
height: 100%;
|
|
298
|
+
cursor: pointer;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
&__placeholder {
|
|
302
|
+
height: calc(108rpx + env(safe-area-inset-bottom, 0px));
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.mu-dark, page.mu-dark {
|
|
307
|
+
|
|
308
|
+
.mu-bottom-nav {
|
|
309
|
+
background: rgba(18, 18, 24, 0.95);
|
|
310
|
+
border-top-color: rgba(255, 255, 255, 0.08);
|
|
311
|
+
|
|
312
|
+
&__text { color: $mu-dark-text-secondary; }
|
|
313
|
+
&__input-box { background: rgba(255, 255, 255, 0.08); }
|
|
314
|
+
&__input-placeholder { color: rgba(255, 255, 255, 0.4); }
|
|
315
|
+
&__action-count { color: $mu-dark-text-secondary; }
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
@media (prefers-color-scheme: dark) {
|
|
320
|
+
|
|
321
|
+
.mu-bottom-nav {
|
|
322
|
+
background: rgba(18, 18, 24, 0.95);
|
|
323
|
+
border-top-color: rgba(255, 255, 255, 0.08);
|
|
324
|
+
|
|
325
|
+
&__text { color: $mu-dark-text-secondary; }
|
|
326
|
+
&__input-box { background: rgba(255, 255, 255, 0.08); }
|
|
327
|
+
&__input-placeholder { color: rgba(255, 255, 255, 0.4); }
|
|
328
|
+
&__action-count { color: $mu-dark-text-secondary; }
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
</style>
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="mu-bubble">
|
|
3
|
+
<!-- 触发节点插槽 -->
|
|
4
|
+
<view class="mu-bubble__trigger" @tap.stop="toggle">
|
|
5
|
+
<slot name="trigger">
|
|
6
|
+
<view class="mu-bubble__default-trigger">
|
|
7
|
+
<text class="mu-bubble__trigger-text">触发气泡</text>
|
|
8
|
+
</view>
|
|
9
|
+
</slot>
|
|
10
|
+
</view>
|
|
11
|
+
|
|
12
|
+
<!-- 气泡弹出主体 -->
|
|
13
|
+
<view
|
|
14
|
+
v-if="innerVisible"
|
|
15
|
+
class="mu-bubble__wrapper"
|
|
16
|
+
:class="[
|
|
17
|
+
`mu-bubble__wrapper--${placement}`,
|
|
18
|
+
`mu-bubble__wrapper--${theme}`,
|
|
19
|
+
animating && 'mu-bubble__wrapper--show'
|
|
20
|
+
]"
|
|
21
|
+
:style="wrapperStyle"
|
|
22
|
+
@tap.stop
|
|
23
|
+
>
|
|
24
|
+
<!-- 45度 旋转小尖角箭头 -->
|
|
25
|
+
<view
|
|
26
|
+
v-if="showArrow"
|
|
27
|
+
class="mu-bubble__arrow"
|
|
28
|
+
:class="[
|
|
29
|
+
`mu-bubble__arrow--${placement}`,
|
|
30
|
+
`mu-bubble__arrow--${theme}`
|
|
31
|
+
]"
|
|
32
|
+
></view>
|
|
33
|
+
|
|
34
|
+
<!-- 气泡内容容器 -->
|
|
35
|
+
<view class="mu-bubble__body" :class="[`mu-bubble__body--${theme}`]">
|
|
36
|
+
<slot>
|
|
37
|
+
<text class="mu-bubble__content-text">{{ content }}</text>
|
|
38
|
+
</slot>
|
|
39
|
+
</view>
|
|
40
|
+
</view>
|
|
41
|
+
</view>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script setup>
|
|
45
|
+
import { ref, computed, watch, onMounted, onUnmounted } from 'vue'
|
|
46
|
+
|
|
47
|
+
const props = defineProps({
|
|
48
|
+
visible: { type: Boolean, default: false },
|
|
49
|
+
placement: { type: String, default: 'top' }, // top | bottom | left | right
|
|
50
|
+
theme: { type: String, default: 'dark' }, // dark | light
|
|
51
|
+
content: { type: String, default: '' }, // 快捷提示文本
|
|
52
|
+
trigger: { type: String, default: 'click' },
|
|
53
|
+
showArrow: { type: Boolean, default: true }, // 是否显示箭头
|
|
54
|
+
width: { type: String, default: '' },
|
|
55
|
+
offset: { type: Array, default: () => [0, 0] }
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const emit = defineEmits(['update:visible', 'show', 'hide', 'change'])
|
|
59
|
+
|
|
60
|
+
const innerVisible = ref(false)
|
|
61
|
+
const animating = ref(false)
|
|
62
|
+
|
|
63
|
+
const wrapperStyle = computed(() => {
|
|
64
|
+
const style = {}
|
|
65
|
+
if (props.width) style.width = props.width
|
|
66
|
+
if (props.offset && props.offset.length === 2) {
|
|
67
|
+
if (props.offset[0]) style.marginTop = `${props.offset[0]}rpx`
|
|
68
|
+
if (props.offset[1]) style.marginLeft = `${props.offset[1]}rpx`
|
|
69
|
+
}
|
|
70
|
+
return style
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
function toggle(e) {
|
|
74
|
+
if (e && e.stopPropagation) e.stopPropagation()
|
|
75
|
+
if (props.trigger === 'click') {
|
|
76
|
+
if (innerVisible.value) hide()
|
|
77
|
+
else show()
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function show() {
|
|
82
|
+
innerVisible.value = true
|
|
83
|
+
setTimeout(() => {
|
|
84
|
+
animating.value = true
|
|
85
|
+
emit('update:visible', true)
|
|
86
|
+
emit('show')
|
|
87
|
+
emit('change', true)
|
|
88
|
+
}, 30)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function hide() {
|
|
92
|
+
animating.value = false
|
|
93
|
+
setTimeout(() => {
|
|
94
|
+
innerVisible.value = false
|
|
95
|
+
emit('update:visible', false)
|
|
96
|
+
emit('hide')
|
|
97
|
+
emit('change', false)
|
|
98
|
+
}, 200)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function handleClickOutside() {
|
|
102
|
+
if (innerVisible.value && props.trigger === 'click') {
|
|
103
|
+
hide()
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
watch(() => props.visible, (val) => {
|
|
108
|
+
if (val) show()
|
|
109
|
+
else hide()
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
onMounted(() => {
|
|
113
|
+
// #ifdef H5
|
|
114
|
+
setTimeout(() => {
|
|
115
|
+
document.addEventListener('click', handleClickOutside)
|
|
116
|
+
}, 100)
|
|
117
|
+
// #endif
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
onUnmounted(() => {
|
|
121
|
+
// #ifdef H5
|
|
122
|
+
document.removeEventListener('click', handleClickOutside)
|
|
123
|
+
// #endif
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
defineExpose({ show, hide, toggle })
|
|
127
|
+
</script>
|
|
128
|
+
|
|
129
|
+
<style lang="scss" scoped>
|
|
130
|
+
@import "@/uni.scss";
|
|
131
|
+
|
|
132
|
+
.mu-bubble {
|
|
133
|
+
position: relative;
|
|
134
|
+
display: inline-flex;
|
|
135
|
+
vertical-align: middle;
|
|
136
|
+
|
|
137
|
+
&__trigger {
|
|
138
|
+
display: inline-flex;
|
|
139
|
+
cursor: pointer;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
&__default-trigger {
|
|
143
|
+
padding: 12rpx 24rpx;
|
|
144
|
+
background: #F1F5F9;
|
|
145
|
+
border-radius: 12rpx;
|
|
146
|
+
display: inline-flex;
|
|
147
|
+
align-items: center;
|
|
148
|
+
|
|
149
|
+
&-text {
|
|
150
|
+
font-size: 24rpx;
|
|
151
|
+
color: #0F172A;
|
|
152
|
+
font-weight: 600;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
&__wrapper {
|
|
157
|
+
position: absolute;
|
|
158
|
+
z-index: $mu-z-popup;
|
|
159
|
+
opacity: 0;
|
|
160
|
+
transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
|
161
|
+
pointer-events: none;
|
|
162
|
+
white-space: nowrap;
|
|
163
|
+
|
|
164
|
+
&--show {
|
|
165
|
+
opacity: 1;
|
|
166
|
+
pointer-events: auto;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/* 4 向定位 */
|
|
170
|
+
&--top {
|
|
171
|
+
bottom: 100%;
|
|
172
|
+
left: 50%;
|
|
173
|
+
transform: translateX(-50%) scale(0.85);
|
|
174
|
+
margin-bottom: 16rpx;
|
|
175
|
+
&.mu-bubble__wrapper--show { transform: translateX(-50%) scale(1); }
|
|
176
|
+
}
|
|
177
|
+
&--bottom {
|
|
178
|
+
top: 100%;
|
|
179
|
+
left: 50%;
|
|
180
|
+
transform: translateX(-50%) scale(0.85);
|
|
181
|
+
margin-top: 16rpx;
|
|
182
|
+
&.mu-bubble__wrapper--show { transform: translateX(-50%) scale(1); }
|
|
183
|
+
}
|
|
184
|
+
&--left {
|
|
185
|
+
right: 100%;
|
|
186
|
+
top: 50%;
|
|
187
|
+
transform: translateY(-50%) scale(0.85);
|
|
188
|
+
margin-right: 16rpx;
|
|
189
|
+
&.mu-bubble__wrapper--show { transform: translateY(-50%) scale(1); }
|
|
190
|
+
}
|
|
191
|
+
&--right {
|
|
192
|
+
left: 100%;
|
|
193
|
+
top: 50%;
|
|
194
|
+
transform: translateY(-50%) scale(0.85);
|
|
195
|
+
margin-left: 16rpx;
|
|
196
|
+
&.mu-bubble__wrapper--show { transform: translateY(-50%) scale(1); }
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/* 尖角指示器 */
|
|
201
|
+
&__arrow {
|
|
202
|
+
position: absolute;
|
|
203
|
+
width: 14rpx;
|
|
204
|
+
height: 14rpx;
|
|
205
|
+
transform: rotate(45deg);
|
|
206
|
+
z-index: 2;
|
|
207
|
+
|
|
208
|
+
&--dark {
|
|
209
|
+
background: rgba(15, 23, 42, 0.92);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
&--light {
|
|
213
|
+
background: rgba(255, 255, 255, 0.95);
|
|
214
|
+
border: 1rpx solid rgba(226, 232, 240, 0.9);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
&--top {
|
|
218
|
+
bottom: -7rpx;
|
|
219
|
+
left: 50%;
|
|
220
|
+
margin-left: -7rpx;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
&--bottom {
|
|
224
|
+
top: -7rpx;
|
|
225
|
+
left: 50%;
|
|
226
|
+
margin-left: -7rpx;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
&--left {
|
|
230
|
+
right: -7rpx;
|
|
231
|
+
top: 50%;
|
|
232
|
+
margin-top: -7rpx;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
&--right {
|
|
236
|
+
left: -7rpx;
|
|
237
|
+
top: 50%;
|
|
238
|
+
margin-top: -7rpx;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
&__body {
|
|
243
|
+
padding: 16rpx 24rpx;
|
|
244
|
+
border-radius: 20rpx;
|
|
245
|
+
box-sizing: border-box;
|
|
246
|
+
white-space: nowrap;
|
|
247
|
+
position: relative;
|
|
248
|
+
z-index: 1;
|
|
249
|
+
display: inline-flex;
|
|
250
|
+
align-items: center;
|
|
251
|
+
justify-content: center;
|
|
252
|
+
|
|
253
|
+
&--dark {
|
|
254
|
+
background: rgba(15, 23, 42, 0.92);
|
|
255
|
+
backdrop-filter: blur(16px);
|
|
256
|
+
box-shadow: 0 12rpx 32rpx rgba(15, 23, 42, 0.25);
|
|
257
|
+
|
|
258
|
+
.mu-bubble__content-text {
|
|
259
|
+
color: #ffffff;
|
|
260
|
+
font-size: 24rpx;
|
|
261
|
+
font-weight: 600;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
&--light {
|
|
266
|
+
background: rgba(255, 255, 255, 0.95);
|
|
267
|
+
backdrop-filter: blur(16px);
|
|
268
|
+
border: 1rpx solid rgba(226, 232, 240, 0.9);
|
|
269
|
+
box-shadow: 0 12rpx 36rpx rgba(15, 23, 42, 0.1);
|
|
270
|
+
|
|
271
|
+
.mu-bubble__content-text {
|
|
272
|
+
color: #0F172A;
|
|
273
|
+
font-size: 24rpx;
|
|
274
|
+
font-weight: 600;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
&__content-text {
|
|
280
|
+
line-height: 1.4;
|
|
281
|
+
display: inline-block;
|
|
282
|
+
white-space: nowrap;
|
|
283
|
+
word-break: keep-all;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.mu-dark, page.mu-dark {
|
|
288
|
+
|
|
289
|
+
.mu-bubble {
|
|
290
|
+
&__body--light {
|
|
291
|
+
background: rgba(30, 41, 59, 0.95);
|
|
292
|
+
border-color: rgba(255, 255, 255, 0.1);
|
|
293
|
+
.mu-bubble__content-text { color: $mu-dark-text-primary; }
|
|
294
|
+
}
|
|
295
|
+
&__arrow--light {
|
|
296
|
+
background: rgba(30, 41, 59, 0.95);
|
|
297
|
+
border-color: rgba(255, 255, 255, 0.1);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
@media (prefers-color-scheme: dark) {
|
|
303
|
+
|
|
304
|
+
.mu-bubble {
|
|
305
|
+
&__body--light {
|
|
306
|
+
background: rgba(30, 41, 59, 0.95);
|
|
307
|
+
border-color: rgba(255, 255, 255, 0.1);
|
|
308
|
+
.mu-bubble__content-text { color: $mu-dark-text-primary; }
|
|
309
|
+
}
|
|
310
|
+
&__arrow--light {
|
|
311
|
+
background: rgba(30, 41, 59, 0.95);
|
|
312
|
+
border-color: rgba(255, 255, 255, 0.1);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
</style>
|