sadais-piui 1.2.4-beta2 → 1.2.4-beta5
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/CHANGELOG.md +512 -512
- package/LICENSE +20 -20
- package/README.md +166 -166
- package/components/pi-action-sheet/index.vue +247 -247
- package/components/pi-badge/index.vue +136 -136
- package/components/pi-bottom-bar/index.vue +139 -139
- package/components/pi-button/index.vue +492 -492
- package/components/pi-calendar/index.vue +178 -178
- package/components/pi-calendar-panel/index.vue +436 -432
- package/components/pi-canvas/index.vue +400 -400
- package/components/pi-card/index.vue +127 -127
- package/components/pi-checkbox/index.vue +345 -345
- package/components/pi-checkbox-group/index.vue +215 -215
- package/components/pi-circle-progress/index.vue +224 -224
- package/components/pi-code-input/index.vue +262 -262
- package/components/pi-count-down/index.vue +245 -245
- package/components/pi-count-up/index.vue +209 -209
- package/components/pi-date-picker/index.vue +366 -366
- package/components/pi-divider/index.vue +109 -109
- package/components/pi-dropdown/components/dropdown-tab.vue +62 -62
- package/components/pi-dropdown/index.vue +316 -316
- package/components/pi-dropdown-item/index.vue +233 -233
- package/components/pi-form/index.vue +237 -237
- package/components/pi-form-item/index.vue +534 -534
- package/components/pi-gap/index.vue +72 -72
- package/components/pi-grid/index.vue +92 -92
- package/components/pi-grid-item/index.vue +220 -220
- package/components/pi-icon/index.vue +147 -147
- package/components/pi-img/index.vue +267 -267
- package/components/pi-img-cropper/canvas.js +112 -112
- package/components/pi-img-cropper/index.vue +357 -357
- package/components/pi-img-cropper/touch.js +163 -163
- package/components/pi-img-cropper/vector.js +34 -34
- package/components/pi-input/index.vue +299 -299
- package/components/pi-line/index.vue +78 -78
- package/components/pi-line-progress/index.vue +198 -198
- package/components/pi-list/index.vue +115 -115
- package/components/pi-list-item/index.vue +331 -331
- package/components/pi-loading/index.vue +188 -188
- package/components/pi-marquee/index.vue +281 -281
- package/components/pi-marquee-item/index.vue +47 -47
- package/components/pi-mask/index.vue +198 -198
- package/components/pi-modal/index.vue +303 -303
- package/components/pi-navbar/index.vue +421 -421
- package/components/pi-notify/index.vue +239 -239
- package/components/pi-number-keyboard/index.vue +189 -189
- package/components/pi-opentype-button/index.vue +501 -501
- package/components/pi-pagination/index.vue +277 -277
- package/components/pi-picker/index.vue +317 -317
- package/components/pi-popup/index.vue +353 -353
- package/components/pi-popup-select/index.vue +291 -291
- package/components/pi-radio/index.vue +387 -387
- package/components/pi-radio-group/index.vue +262 -262
- package/components/pi-rate/index.vue +212 -212
- package/components/pi-regions-select/index.vue +318 -318
- package/components/pi-search/index.vue +351 -351
- package/components/pi-section/index.vue +218 -218
- package/components/pi-select/index.vue +391 -391
- package/components/pi-skeleton/index.vue +280 -280
- package/components/pi-status-bar/index.vue +56 -56
- package/components/pi-stepper/index.vue +394 -394
- package/components/pi-steps/index.vue +299 -299
- package/components/pi-swiper/index.vue +344 -344
- package/components/pi-switch/index.vue +227 -227
- package/components/pi-tabs/index.vue +398 -398
- package/components/pi-upload-img/index.vue +508 -506
- package/components/pi-waterfall/index.vue +130 -130
- package/components/pi-webview/index.vue +82 -82
- package/config/actionSheet.js +25 -25
- package/config/badge.js +9 -9
- package/config/bottomBar.js +11 -11
- package/config/button.js +29 -29
- package/config/calendar.js +19 -19
- package/config/calendarPanel.js +24 -24
- package/config/card.js +8 -8
- package/config/checkbox.js +14 -14
- package/config/checkboxGroup.js +14 -14
- package/config/circleProgress.js +13 -13
- package/config/codeInput.js +12 -12
- package/config/countDown.js +12 -12
- package/config/countUp.js +13 -13
- package/config/datePicker.js +22 -22
- package/config/divider.js +10 -10
- package/config/dropdown.js +21 -21
- package/config/dropdownItem.js +26 -26
- package/config/form.js +27 -27
- package/config/formItem.js +25 -25
- package/config/gap.js +8 -8
- package/config/grid.js +9 -9
- package/config/gridItem.js +12 -12
- package/config/icon.js +11 -11
- package/config/img.js +21 -21
- package/config/imgCropper.js +26 -26
- package/config/index.js +28 -28
- package/config/input.js +25 -25
- package/config/line.js +8 -8
- package/config/lineProgress.js +14 -14
- package/config/list.js +12 -12
- package/config/listItem.js +25 -25
- package/config/loading.js +10 -10
- package/config/marquee.js +8 -8
- package/config/mask.js +12 -12
- package/config/modal.js +36 -36
- package/config/navbar.js +32 -32
- package/config/notify.js +13 -13
- package/config/numberKeyboard.js +21 -21
- package/config/pagination.js +10 -10
- package/config/picker.js +19 -19
- package/config/popup.js +23 -23
- package/config/popupSelect.js +35 -35
- package/config/radio.js +15 -15
- package/config/radioGroup.js +16 -16
- package/config/rate.js +15 -15
- package/config/regionsData.js +58 -58
- package/config/regionsSelect.js +18 -18
- package/config/search.js +27 -27
- package/config/section.js +23 -23
- package/config/select.js +28 -28
- package/config/skeleton.js +13 -13
- package/config/statusBar.js +5 -5
- package/config/stepper.js +19 -19
- package/config/steps.js +19 -19
- package/config/swiper.js +22 -22
- package/config/switch.js +13 -13
- package/config/tabs.js +23 -23
- package/config/uploadImg.js +63 -63
- package/config/waterfall.js +6 -6
- package/index.js +41 -41
- package/mixin/component-custom.js +24 -24
- package/mixin/emitter.js +45 -45
- package/mixin/props-sync.js +65 -65
- package/mixin/value-sync.js +32 -32
- package/mixin/wx-code.js +30 -30
- package/package.json +25 -25
- package/plugins/async-validator.js +1511 -1511
- package/scss/animation.scss +260 -260
- package/scss/icon/icon.scss +594 -594
- package/scss/index.scss +5 -5
- package/scss/mixin.scss +47 -47
- package/tools/index.js +11 -11
|
@@ -1,421 +1,421 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="navbar-wrap" :style="[{ zIndex }, customStyle]" :class="[customClass]">
|
|
3
|
-
<!-- 当导航栏为fixed时候,占位用 -->
|
|
4
|
-
<view
|
|
5
|
-
v-if="fixed && placeholder"
|
|
6
|
-
class="navbar-placeholder"
|
|
7
|
-
:style="[{ height: `calc(${height} + ${statusBarHeight})` }]"
|
|
8
|
-
/>
|
|
9
|
-
<view
|
|
10
|
-
:class="{ 'navbar-fixed': fixed, 'pi-solid-bottom-1': borderBottom }"
|
|
11
|
-
:style="[{ zIndex }]"
|
|
12
|
-
>
|
|
13
|
-
<!-- 内部状态栏占位用 -->
|
|
14
|
-
<pi-status-bar v-if="placeholder" :background="statusBarBackground" />
|
|
15
|
-
<!-- 真正渲染的navbar -->
|
|
16
|
-
<view class="pi-navbar pi-rela pi-w-100P pi-align-center" :style="[{ background, height }]">
|
|
17
|
-
<!-- 左侧 -->
|
|
18
|
-
<view
|
|
19
|
-
class="pi-align-center nav-icon"
|
|
20
|
-
:class="[
|
|
21
|
-
capsuleTheme,
|
|
22
|
-
{
|
|
23
|
-
'capsule pi-round': capsuleButton && isShowBack && showHome
|
|
24
|
-
}
|
|
25
|
-
]"
|
|
26
|
-
>
|
|
27
|
-
<!-- 定制导航栏左侧内容 -->
|
|
28
|
-
<slot name="left" />
|
|
29
|
-
<view v-if="isShowBack" class="pi-align-center back-wrap" @tap.stop="handleGoBack">
|
|
30
|
-
<view :class="'pi-icon-' + backIconName" :style="[backIconStyle]" />
|
|
31
|
-
<view v-if="backText" :style="[backTextStyle]">{{ backText }}</view>
|
|
32
|
-
</view>
|
|
33
|
-
<view v-if="showHome" class="pi-align-center home-wrap" @tap.stop="handleGoHome">
|
|
34
|
-
<view
|
|
35
|
-
:class="'pi-icon-' + homeIconName"
|
|
36
|
-
:style="[
|
|
37
|
-
{
|
|
38
|
-
color: homeIconColor,
|
|
39
|
-
padding: homeIconPadding,
|
|
40
|
-
fontSize: homeIconSize
|
|
41
|
-
}
|
|
42
|
-
]"
|
|
43
|
-
/>
|
|
44
|
-
</view>
|
|
45
|
-
</view>
|
|
46
|
-
<!-- 标题剩余空间 -->
|
|
47
|
-
<view :style="[navTitleStyle]" class="pi-flex-sub">
|
|
48
|
-
<!-- 定制导航栏标题 -->
|
|
49
|
-
<slot v-if="$slots.title" name="title" />
|
|
50
|
-
</view>
|
|
51
|
-
<!-- 贯穿标题 -->
|
|
52
|
-
<view :style="[navTitleStyle, throughTitleStyle]" class="through-space">
|
|
53
|
-
<!-- slot default -->
|
|
54
|
-
<slot v-if="$slots.default || $slots.$default" />
|
|
55
|
-
<template v-else-if="title">{{ title }}</template>
|
|
56
|
-
</view>
|
|
57
|
-
<!-- 右侧 -->
|
|
58
|
-
<view v-if="$slots.right" class="nav-icon">
|
|
59
|
-
<!-- 定制导航栏右侧区域 -->
|
|
60
|
-
<slot name="right" />
|
|
61
|
-
</view>
|
|
62
|
-
</view>
|
|
63
|
-
</view>
|
|
64
|
-
</view>
|
|
65
|
-
</template>
|
|
66
|
-
|
|
67
|
-
<script>
|
|
68
|
-
/**
|
|
69
|
-
* 返回按钮内部已经做了处理,如果当前打开页面不属于二级页面,则不显示,需要显示左侧内容,请使用 slot left
|
|
70
|
-
* slot left 和 backIcon homeIcon 冲突,两者只能取其一,默认以slot left为主
|
|
71
|
-
* slot right
|
|
72
|
-
* slot title 是除开icon的剩余空间
|
|
73
|
-
* slot 整个标题栏的插槽
|
|
74
|
-
*/
|
|
75
|
-
import { systemInfo } from '@sadais/piui-tool/tools/system'
|
|
76
|
-
import navi from '@sadais/piui-tool/tools/navi'
|
|
77
|
-
import { getConfig } from '../../config'
|
|
78
|
-
|
|
79
|
-
const TAG = 'PiNavbar'
|
|
80
|
-
const { navbar } = getConfig()
|
|
81
|
-
|
|
82
|
-
export default {
|
|
83
|
-
name: 'PiNavbar',
|
|
84
|
-
props: {
|
|
85
|
-
// 自定义样式 添加到组件的根节点上
|
|
86
|
-
customStyle: {
|
|
87
|
-
type: Object,
|
|
88
|
-
// {}
|
|
89
|
-
default() {
|
|
90
|
-
return navbar.customStyle
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
// 自定义样式类 添加到组件的根节点上
|
|
94
|
-
customClass: {
|
|
95
|
-
type: String,
|
|
96
|
-
// ''
|
|
97
|
-
default() {
|
|
98
|
-
return navbar.customClass
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
// 标题
|
|
102
|
-
title: {
|
|
103
|
-
type: String,
|
|
104
|
-
// ''
|
|
105
|
-
default: navbar.title
|
|
106
|
-
},
|
|
107
|
-
// 标题样式
|
|
108
|
-
titleStyle: {
|
|
109
|
-
type: Object,
|
|
110
|
-
// { fontSize: '36rpx', fontWeight: 500, color: '#333333' }
|
|
111
|
-
default() {
|
|
112
|
-
return navbar.titleStyle
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
// 导航栏高度
|
|
116
|
-
height: {
|
|
117
|
-
type: String,
|
|
118
|
-
// '44px'
|
|
119
|
-
default: navbar.height
|
|
120
|
-
},
|
|
121
|
-
// 贯穿布局title宽度,auto:自动撑开
|
|
122
|
-
throughTitleWidth: {
|
|
123
|
-
type: String,
|
|
124
|
-
// 'auto'
|
|
125
|
-
default: navbar.throughTitleWidth
|
|
126
|
-
},
|
|
127
|
-
// 导航栏是否固定在顶部
|
|
128
|
-
fixed: {
|
|
129
|
-
type: Boolean,
|
|
130
|
-
// true
|
|
131
|
-
default: navbar.fixed
|
|
132
|
-
},
|
|
133
|
-
// 固定在顶部时,是否生成一个与导航栏高度登高的占位容器
|
|
134
|
-
placeholder: {
|
|
135
|
-
type: Boolean,
|
|
136
|
-
// true
|
|
137
|
-
default: navbar.placeholder
|
|
138
|
-
},
|
|
139
|
-
// 是否显示导航栏的下边框
|
|
140
|
-
borderBottom: {
|
|
141
|
-
type: Boolean,
|
|
142
|
-
// true
|
|
143
|
-
default: navbar.borderBottom
|
|
144
|
-
},
|
|
145
|
-
// 状态栏的背景色
|
|
146
|
-
statusBarBackground: {
|
|
147
|
-
type: String,
|
|
148
|
-
// 'transparent'
|
|
149
|
-
default: navbar.statusBarBackground
|
|
150
|
-
},
|
|
151
|
-
// 背景颜色
|
|
152
|
-
background: {
|
|
153
|
-
type: String,
|
|
154
|
-
// '#ffffff'
|
|
155
|
-
default: navbar.background
|
|
156
|
-
},
|
|
157
|
-
// 是否显示后退按钮,默认不设置,根据当前页面堆栈自动判断
|
|
158
|
-
showBack: {
|
|
159
|
-
required: false,
|
|
160
|
-
type: [String, Boolean],
|
|
161
|
-
// ''
|
|
162
|
-
default: navbar.showBack
|
|
163
|
-
},
|
|
164
|
-
// 是否显示主页按钮
|
|
165
|
-
showHome: {
|
|
166
|
-
required: false,
|
|
167
|
-
type: Boolean,
|
|
168
|
-
// false
|
|
169
|
-
default: navbar.showHome
|
|
170
|
-
},
|
|
171
|
-
// 在微信小程序中,当showBack和showHome同时显示的时候,以胶囊按钮样式显示
|
|
172
|
-
capsuleButton: {
|
|
173
|
-
required: false,
|
|
174
|
-
type: Boolean,
|
|
175
|
-
// true
|
|
176
|
-
default: navbar.capsuleButton
|
|
177
|
-
},
|
|
178
|
-
// 胶囊按钮主题
|
|
179
|
-
capsuleTheme: {
|
|
180
|
-
// `'light'` `'dark'`
|
|
181
|
-
type: String,
|
|
182
|
-
// `'light'`
|
|
183
|
-
default: navbar.capsuleTheme,
|
|
184
|
-
validator: function(value) {
|
|
185
|
-
return ['light', 'dark'].includes(value)
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
// 返回箭头的颜色
|
|
189
|
-
backIconColor: {
|
|
190
|
-
type: String,
|
|
191
|
-
// '#333333'
|
|
192
|
-
default: navbar.backIconColor
|
|
193
|
-
},
|
|
194
|
-
// 左边返回的图标,自动拼接前缀pi-icon-
|
|
195
|
-
backIconName: {
|
|
196
|
-
type: String,
|
|
197
|
-
// 'back'
|
|
198
|
-
default: navbar.backIconName
|
|
199
|
-
},
|
|
200
|
-
// 左边返回图标的大小
|
|
201
|
-
backIconSize: {
|
|
202
|
-
type: String,
|
|
203
|
-
// '36rpx'
|
|
204
|
-
default: navbar.backIconSize
|
|
205
|
-
},
|
|
206
|
-
// 左边返回图标的padding
|
|
207
|
-
backIconPadding: {
|
|
208
|
-
type: String,
|
|
209
|
-
// '10rpx 24rpx'
|
|
210
|
-
default: navbar.backIconPadding
|
|
211
|
-
},
|
|
212
|
-
// 返回的文字提示
|
|
213
|
-
backText: {
|
|
214
|
-
type: String,
|
|
215
|
-
// ''
|
|
216
|
-
default: navbar.backText
|
|
217
|
-
},
|
|
218
|
-
// 返回的文字的样式
|
|
219
|
-
backTextStyle: {
|
|
220
|
-
type: Object,
|
|
221
|
-
// { color: '#333333' }
|
|
222
|
-
default() {
|
|
223
|
-
return navbar.backTextStyle
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
// 是否自定义返回函数
|
|
227
|
-
customBackFunc: {
|
|
228
|
-
type: Boolean,
|
|
229
|
-
default: navbar.customBackFunc
|
|
230
|
-
},
|
|
231
|
-
// 主页icon的颜色
|
|
232
|
-
homeIconColor: {
|
|
233
|
-
type: String,
|
|
234
|
-
// '#333333'
|
|
235
|
-
default: navbar.homeIconColor
|
|
236
|
-
},
|
|
237
|
-
// 主页icon的图标 自动拼接前缀pi-icon-
|
|
238
|
-
homeIconName: {
|
|
239
|
-
type: String,
|
|
240
|
-
// 'homefill'
|
|
241
|
-
default: navbar.homeIconName
|
|
242
|
-
},
|
|
243
|
-
// 主页icon图标的大小
|
|
244
|
-
homeIconSize: {
|
|
245
|
-
type: String,
|
|
246
|
-
// '36rpx'
|
|
247
|
-
default: navbar.homeIconSize
|
|
248
|
-
},
|
|
249
|
-
// 主页icon图标的padding
|
|
250
|
-
homeIconPadding: {
|
|
251
|
-
type: String,
|
|
252
|
-
// '10rpx 24rpx'
|
|
253
|
-
default: navbar.homeIconPadding
|
|
254
|
-
},
|
|
255
|
-
// 主页路径
|
|
256
|
-
homePage: {
|
|
257
|
-
type: String,
|
|
258
|
-
// ''
|
|
259
|
-
default: navbar.homePage
|
|
260
|
-
},
|
|
261
|
-
// 跳转主页方法
|
|
262
|
-
homePageMethod: {
|
|
263
|
-
// 'navigateTo'、'redirectTo'、'switchTab'、'reLaunch'
|
|
264
|
-
type: String,
|
|
265
|
-
// 'switchTab'
|
|
266
|
-
default: navbar.homePageMethod
|
|
267
|
-
},
|
|
268
|
-
// 是否自定义返回函数
|
|
269
|
-
customHomeFunc: {
|
|
270
|
-
type: Boolean,
|
|
271
|
-
default: navbar.customHomeFunc
|
|
272
|
-
},
|
|
273
|
-
// 元素 z-index
|
|
274
|
-
zIndex: {
|
|
275
|
-
type: [String, Number],
|
|
276
|
-
// 99
|
|
277
|
-
default: navbar.zIndex
|
|
278
|
-
}
|
|
279
|
-
},
|
|
280
|
-
data() {
|
|
281
|
-
return {
|
|
282
|
-
isShowBack: false
|
|
283
|
-
}
|
|
284
|
-
},
|
|
285
|
-
computed: {
|
|
286
|
-
// 状态栏高度
|
|
287
|
-
statusBarHeight() {
|
|
288
|
-
const statusBarHeight =
|
|
289
|
-
systemInfo && systemInfo.statusBarHeight ? systemInfo.statusBarHeight : 0
|
|
290
|
-
return `${statusBarHeight}px`
|
|
291
|
-
},
|
|
292
|
-
navTitleStyle() {
|
|
293
|
-
return this.$pi.lang.mergeDeep(navbar.titleStyle, this.titleStyle)
|
|
294
|
-
},
|
|
295
|
-
getThroughTitleWidth() {
|
|
296
|
-
return this.$pi.common.addUnit(this.throughTitleWidth)
|
|
297
|
-
},
|
|
298
|
-
throughTitleStyle() {
|
|
299
|
-
const style = {}
|
|
300
|
-
if (this.getThroughTitleWidth !== 'auto') {
|
|
301
|
-
style.width = this.getThroughTitleWidth
|
|
302
|
-
}
|
|
303
|
-
return style
|
|
304
|
-
},
|
|
305
|
-
backIconStyle() {
|
|
306
|
-
const style = {
|
|
307
|
-
color: this.backIconColor,
|
|
308
|
-
padding: this.backIconPadding,
|
|
309
|
-
fontSize: this.backIconSize
|
|
310
|
-
}
|
|
311
|
-
if (this.backText) {
|
|
312
|
-
style.paddingRight = '10rpx'
|
|
313
|
-
}
|
|
314
|
-
return style
|
|
315
|
-
}
|
|
316
|
-
},
|
|
317
|
-
created() {
|
|
318
|
-
this.syncPageRoute()
|
|
319
|
-
},
|
|
320
|
-
methods: {
|
|
321
|
-
syncPageRoute() {
|
|
322
|
-
if (this.showBack === null) {
|
|
323
|
-
/* eslint-disable */
|
|
324
|
-
const pages = getCurrentPages()
|
|
325
|
-
// 如果堆栈大于1表示打开了子页面,需要显示返回按钮
|
|
326
|
-
this.isShowBack = pages.length > 1
|
|
327
|
-
// #ifdef H5
|
|
328
|
-
if(!this.isShowBack) {
|
|
329
|
-
// H5端,如果isShowBack为false,继续尝试获取父节点的属性判断是否子页面
|
|
330
|
-
const page = this.$pi.parent(this, 'Page')
|
|
331
|
-
if(!page) return
|
|
332
|
-
this.isShowBack = !page.isQuit && !page.$route.meta.isQuit
|
|
333
|
-
}
|
|
334
|
-
// #endif
|
|
335
|
-
} else {
|
|
336
|
-
this.isShowBack = this.showBack
|
|
337
|
-
}
|
|
338
|
-
},
|
|
339
|
-
handleGoBack(){
|
|
340
|
-
if(!this.customBackFunc) {
|
|
341
|
-
if (getCurrentPages().length === 1) {
|
|
342
|
-
uni.reLaunch({
|
|
343
|
-
url: '/'
|
|
344
|
-
})
|
|
345
|
-
} else {
|
|
346
|
-
uni.navigateBack({
|
|
347
|
-
from: 'backbutton'
|
|
348
|
-
})
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
this.$emit('navigateToBack')
|
|
352
|
-
},
|
|
353
|
-
handleGoHome() {
|
|
354
|
-
!this.customHomeFunc && navi[this.homePageMethod](this.homePage)
|
|
355
|
-
this.$emit('navigateToHome')
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
</script>
|
|
360
|
-
|
|
361
|
-
<style lang="scss" scoped>
|
|
362
|
-
.navbar-wrap {
|
|
363
|
-
position: relative;
|
|
364
|
-
.navbar-fixed {
|
|
365
|
-
position: fixed;
|
|
366
|
-
top: 0;
|
|
367
|
-
right: 0;
|
|
368
|
-
left: 0;
|
|
369
|
-
}
|
|
370
|
-
.nav-icon {
|
|
371
|
-
position: relative;
|
|
372
|
-
z-index: 1;
|
|
373
|
-
|
|
374
|
-
// 小程序才开启胶囊效果
|
|
375
|
-
|
|
376
|
-
/* #ifdef MP */
|
|
377
|
-
&.capsule {
|
|
378
|
-
position: relative;
|
|
379
|
-
margin-left: 20rpx;
|
|
380
|
-
border: 1px solid rgba(0, 0, 0, 0.1);
|
|
381
|
-
&::before {
|
|
382
|
-
position: absolute;
|
|
383
|
-
top: 50%;
|
|
384
|
-
left: 50%;
|
|
385
|
-
width: 1px;
|
|
386
|
-
height: 60%;
|
|
387
|
-
content: '';
|
|
388
|
-
transform: scaleX(0.5) translate(-50%, -50%);
|
|
389
|
-
}
|
|
390
|
-
&.dark {
|
|
391
|
-
&::before {
|
|
392
|
-
background: #999999;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
background: rgba(0, 0, 0, 0.35);
|
|
396
|
-
}
|
|
397
|
-
&.light {
|
|
398
|
-
&::before {
|
|
399
|
-
background: #e5e5e5;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
background: rgba(252, 252, 252, 0.3);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/* #endif */
|
|
407
|
-
}
|
|
408
|
-
.through-space {
|
|
409
|
-
position: absolute;
|
|
410
|
-
top: 50%;
|
|
411
|
-
left: 50%;
|
|
412
|
-
z-index: 0;
|
|
413
|
-
overflow: hidden;
|
|
414
|
-
line-height: initial;
|
|
415
|
-
text-align: center;
|
|
416
|
-
text-overflow: ellipsis;
|
|
417
|
-
white-space: nowrap;
|
|
418
|
-
transform: translate(-50%, -50%);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<view class="navbar-wrap" :style="[{ zIndex }, customStyle]" :class="[customClass]">
|
|
3
|
+
<!-- 当导航栏为fixed时候,占位用 -->
|
|
4
|
+
<view
|
|
5
|
+
v-if="fixed && placeholder"
|
|
6
|
+
class="navbar-placeholder"
|
|
7
|
+
:style="[{ height: `calc(${height} + ${statusBarHeight})` }]"
|
|
8
|
+
/>
|
|
9
|
+
<view
|
|
10
|
+
:class="{ 'navbar-fixed': fixed, 'pi-solid-bottom-1': borderBottom }"
|
|
11
|
+
:style="[{ zIndex }]"
|
|
12
|
+
>
|
|
13
|
+
<!-- 内部状态栏占位用 -->
|
|
14
|
+
<pi-status-bar v-if="placeholder" :background="statusBarBackground" />
|
|
15
|
+
<!-- 真正渲染的navbar -->
|
|
16
|
+
<view class="pi-navbar pi-rela pi-w-100P pi-align-center" :style="[{ background, height }]">
|
|
17
|
+
<!-- 左侧 -->
|
|
18
|
+
<view
|
|
19
|
+
class="pi-align-center nav-icon"
|
|
20
|
+
:class="[
|
|
21
|
+
capsuleTheme,
|
|
22
|
+
{
|
|
23
|
+
'capsule pi-round': capsuleButton && isShowBack && showHome
|
|
24
|
+
}
|
|
25
|
+
]"
|
|
26
|
+
>
|
|
27
|
+
<!-- 定制导航栏左侧内容 -->
|
|
28
|
+
<slot name="left" />
|
|
29
|
+
<view v-if="isShowBack" class="pi-align-center back-wrap" @tap.stop="handleGoBack">
|
|
30
|
+
<view :class="'pi-icon-' + backIconName" :style="[backIconStyle]" />
|
|
31
|
+
<view v-if="backText" :style="[backTextStyle]">{{ backText }}</view>
|
|
32
|
+
</view>
|
|
33
|
+
<view v-if="showHome" class="pi-align-center home-wrap" @tap.stop="handleGoHome">
|
|
34
|
+
<view
|
|
35
|
+
:class="'pi-icon-' + homeIconName"
|
|
36
|
+
:style="[
|
|
37
|
+
{
|
|
38
|
+
color: homeIconColor,
|
|
39
|
+
padding: homeIconPadding,
|
|
40
|
+
fontSize: homeIconSize
|
|
41
|
+
}
|
|
42
|
+
]"
|
|
43
|
+
/>
|
|
44
|
+
</view>
|
|
45
|
+
</view>
|
|
46
|
+
<!-- 标题剩余空间 -->
|
|
47
|
+
<view :style="[navTitleStyle]" class="pi-flex-sub">
|
|
48
|
+
<!-- 定制导航栏标题 -->
|
|
49
|
+
<slot v-if="$slots.title" name="title" />
|
|
50
|
+
</view>
|
|
51
|
+
<!-- 贯穿标题 -->
|
|
52
|
+
<view :style="[navTitleStyle, throughTitleStyle]" class="through-space">
|
|
53
|
+
<!-- slot default -->
|
|
54
|
+
<slot v-if="$slots.default || $slots.$default" />
|
|
55
|
+
<template v-else-if="title">{{ title }}</template>
|
|
56
|
+
</view>
|
|
57
|
+
<!-- 右侧 -->
|
|
58
|
+
<view v-if="$slots.right" class="nav-icon">
|
|
59
|
+
<!-- 定制导航栏右侧区域 -->
|
|
60
|
+
<slot name="right" />
|
|
61
|
+
</view>
|
|
62
|
+
</view>
|
|
63
|
+
</view>
|
|
64
|
+
</view>
|
|
65
|
+
</template>
|
|
66
|
+
|
|
67
|
+
<script>
|
|
68
|
+
/**
|
|
69
|
+
* 返回按钮内部已经做了处理,如果当前打开页面不属于二级页面,则不显示,需要显示左侧内容,请使用 slot left
|
|
70
|
+
* slot left 和 backIcon homeIcon 冲突,两者只能取其一,默认以slot left为主
|
|
71
|
+
* slot right
|
|
72
|
+
* slot title 是除开icon的剩余空间
|
|
73
|
+
* slot 整个标题栏的插槽
|
|
74
|
+
*/
|
|
75
|
+
import { systemInfo } from '@sadais/piui-tool/tools/system'
|
|
76
|
+
import navi from '@sadais/piui-tool/tools/navi'
|
|
77
|
+
import { getConfig } from '../../config'
|
|
78
|
+
|
|
79
|
+
const TAG = 'PiNavbar'
|
|
80
|
+
const { navbar } = getConfig()
|
|
81
|
+
|
|
82
|
+
export default {
|
|
83
|
+
name: 'PiNavbar',
|
|
84
|
+
props: {
|
|
85
|
+
// 自定义样式 添加到组件的根节点上
|
|
86
|
+
customStyle: {
|
|
87
|
+
type: Object,
|
|
88
|
+
// {}
|
|
89
|
+
default() {
|
|
90
|
+
return navbar.customStyle
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
// 自定义样式类 添加到组件的根节点上
|
|
94
|
+
customClass: {
|
|
95
|
+
type: String,
|
|
96
|
+
// ''
|
|
97
|
+
default() {
|
|
98
|
+
return navbar.customClass
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
// 标题
|
|
102
|
+
title: {
|
|
103
|
+
type: String,
|
|
104
|
+
// ''
|
|
105
|
+
default: navbar.title
|
|
106
|
+
},
|
|
107
|
+
// 标题样式
|
|
108
|
+
titleStyle: {
|
|
109
|
+
type: Object,
|
|
110
|
+
// { fontSize: '36rpx', fontWeight: 500, color: '#333333' }
|
|
111
|
+
default() {
|
|
112
|
+
return navbar.titleStyle
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
// 导航栏高度
|
|
116
|
+
height: {
|
|
117
|
+
type: String,
|
|
118
|
+
// '44px'
|
|
119
|
+
default: navbar.height
|
|
120
|
+
},
|
|
121
|
+
// 贯穿布局title宽度,auto:自动撑开
|
|
122
|
+
throughTitleWidth: {
|
|
123
|
+
type: String,
|
|
124
|
+
// 'auto'
|
|
125
|
+
default: navbar.throughTitleWidth
|
|
126
|
+
},
|
|
127
|
+
// 导航栏是否固定在顶部
|
|
128
|
+
fixed: {
|
|
129
|
+
type: Boolean,
|
|
130
|
+
// true
|
|
131
|
+
default: navbar.fixed
|
|
132
|
+
},
|
|
133
|
+
// 固定在顶部时,是否生成一个与导航栏高度登高的占位容器
|
|
134
|
+
placeholder: {
|
|
135
|
+
type: Boolean,
|
|
136
|
+
// true
|
|
137
|
+
default: navbar.placeholder
|
|
138
|
+
},
|
|
139
|
+
// 是否显示导航栏的下边框
|
|
140
|
+
borderBottom: {
|
|
141
|
+
type: Boolean,
|
|
142
|
+
// true
|
|
143
|
+
default: navbar.borderBottom
|
|
144
|
+
},
|
|
145
|
+
// 状态栏的背景色
|
|
146
|
+
statusBarBackground: {
|
|
147
|
+
type: String,
|
|
148
|
+
// 'transparent'
|
|
149
|
+
default: navbar.statusBarBackground
|
|
150
|
+
},
|
|
151
|
+
// 背景颜色
|
|
152
|
+
background: {
|
|
153
|
+
type: String,
|
|
154
|
+
// '#ffffff'
|
|
155
|
+
default: navbar.background
|
|
156
|
+
},
|
|
157
|
+
// 是否显示后退按钮,默认不设置,根据当前页面堆栈自动判断
|
|
158
|
+
showBack: {
|
|
159
|
+
required: false,
|
|
160
|
+
type: [String, Boolean],
|
|
161
|
+
// ''
|
|
162
|
+
default: navbar.showBack
|
|
163
|
+
},
|
|
164
|
+
// 是否显示主页按钮
|
|
165
|
+
showHome: {
|
|
166
|
+
required: false,
|
|
167
|
+
type: Boolean,
|
|
168
|
+
// false
|
|
169
|
+
default: navbar.showHome
|
|
170
|
+
},
|
|
171
|
+
// 在微信小程序中,当showBack和showHome同时显示的时候,以胶囊按钮样式显示
|
|
172
|
+
capsuleButton: {
|
|
173
|
+
required: false,
|
|
174
|
+
type: Boolean,
|
|
175
|
+
// true
|
|
176
|
+
default: navbar.capsuleButton
|
|
177
|
+
},
|
|
178
|
+
// 胶囊按钮主题
|
|
179
|
+
capsuleTheme: {
|
|
180
|
+
// `'light'` `'dark'`
|
|
181
|
+
type: String,
|
|
182
|
+
// `'light'`
|
|
183
|
+
default: navbar.capsuleTheme,
|
|
184
|
+
validator: function(value) {
|
|
185
|
+
return ['light', 'dark'].includes(value)
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
// 返回箭头的颜色
|
|
189
|
+
backIconColor: {
|
|
190
|
+
type: String,
|
|
191
|
+
// '#333333'
|
|
192
|
+
default: navbar.backIconColor
|
|
193
|
+
},
|
|
194
|
+
// 左边返回的图标,自动拼接前缀pi-icon-
|
|
195
|
+
backIconName: {
|
|
196
|
+
type: String,
|
|
197
|
+
// 'back'
|
|
198
|
+
default: navbar.backIconName
|
|
199
|
+
},
|
|
200
|
+
// 左边返回图标的大小
|
|
201
|
+
backIconSize: {
|
|
202
|
+
type: String,
|
|
203
|
+
// '36rpx'
|
|
204
|
+
default: navbar.backIconSize
|
|
205
|
+
},
|
|
206
|
+
// 左边返回图标的padding
|
|
207
|
+
backIconPadding: {
|
|
208
|
+
type: String,
|
|
209
|
+
// '10rpx 24rpx'
|
|
210
|
+
default: navbar.backIconPadding
|
|
211
|
+
},
|
|
212
|
+
// 返回的文字提示
|
|
213
|
+
backText: {
|
|
214
|
+
type: String,
|
|
215
|
+
// ''
|
|
216
|
+
default: navbar.backText
|
|
217
|
+
},
|
|
218
|
+
// 返回的文字的样式
|
|
219
|
+
backTextStyle: {
|
|
220
|
+
type: Object,
|
|
221
|
+
// { color: '#333333' }
|
|
222
|
+
default() {
|
|
223
|
+
return navbar.backTextStyle
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
// 是否自定义返回函数
|
|
227
|
+
customBackFunc: {
|
|
228
|
+
type: Boolean,
|
|
229
|
+
default: navbar.customBackFunc
|
|
230
|
+
},
|
|
231
|
+
// 主页icon的颜色
|
|
232
|
+
homeIconColor: {
|
|
233
|
+
type: String,
|
|
234
|
+
// '#333333'
|
|
235
|
+
default: navbar.homeIconColor
|
|
236
|
+
},
|
|
237
|
+
// 主页icon的图标 自动拼接前缀pi-icon-
|
|
238
|
+
homeIconName: {
|
|
239
|
+
type: String,
|
|
240
|
+
// 'homefill'
|
|
241
|
+
default: navbar.homeIconName
|
|
242
|
+
},
|
|
243
|
+
// 主页icon图标的大小
|
|
244
|
+
homeIconSize: {
|
|
245
|
+
type: String,
|
|
246
|
+
// '36rpx'
|
|
247
|
+
default: navbar.homeIconSize
|
|
248
|
+
},
|
|
249
|
+
// 主页icon图标的padding
|
|
250
|
+
homeIconPadding: {
|
|
251
|
+
type: String,
|
|
252
|
+
// '10rpx 24rpx'
|
|
253
|
+
default: navbar.homeIconPadding
|
|
254
|
+
},
|
|
255
|
+
// 主页路径
|
|
256
|
+
homePage: {
|
|
257
|
+
type: String,
|
|
258
|
+
// ''
|
|
259
|
+
default: navbar.homePage
|
|
260
|
+
},
|
|
261
|
+
// 跳转主页方法
|
|
262
|
+
homePageMethod: {
|
|
263
|
+
// 'navigateTo'、'redirectTo'、'switchTab'、'reLaunch'
|
|
264
|
+
type: String,
|
|
265
|
+
// 'switchTab'
|
|
266
|
+
default: navbar.homePageMethod
|
|
267
|
+
},
|
|
268
|
+
// 是否自定义返回函数
|
|
269
|
+
customHomeFunc: {
|
|
270
|
+
type: Boolean,
|
|
271
|
+
default: navbar.customHomeFunc
|
|
272
|
+
},
|
|
273
|
+
// 元素 z-index
|
|
274
|
+
zIndex: {
|
|
275
|
+
type: [String, Number],
|
|
276
|
+
// 99
|
|
277
|
+
default: navbar.zIndex
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
data() {
|
|
281
|
+
return {
|
|
282
|
+
isShowBack: false
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
computed: {
|
|
286
|
+
// 状态栏高度
|
|
287
|
+
statusBarHeight() {
|
|
288
|
+
const statusBarHeight =
|
|
289
|
+
systemInfo && systemInfo.statusBarHeight ? systemInfo.statusBarHeight : 0
|
|
290
|
+
return `${statusBarHeight}px`
|
|
291
|
+
},
|
|
292
|
+
navTitleStyle() {
|
|
293
|
+
return this.$pi.lang.mergeDeep(navbar.titleStyle, this.titleStyle)
|
|
294
|
+
},
|
|
295
|
+
getThroughTitleWidth() {
|
|
296
|
+
return this.$pi.common.addUnit(this.throughTitleWidth)
|
|
297
|
+
},
|
|
298
|
+
throughTitleStyle() {
|
|
299
|
+
const style = {}
|
|
300
|
+
if (this.getThroughTitleWidth !== 'auto') {
|
|
301
|
+
style.width = this.getThroughTitleWidth
|
|
302
|
+
}
|
|
303
|
+
return style
|
|
304
|
+
},
|
|
305
|
+
backIconStyle() {
|
|
306
|
+
const style = {
|
|
307
|
+
color: this.backIconColor,
|
|
308
|
+
padding: this.backIconPadding,
|
|
309
|
+
fontSize: this.backIconSize
|
|
310
|
+
}
|
|
311
|
+
if (this.backText) {
|
|
312
|
+
style.paddingRight = '10rpx'
|
|
313
|
+
}
|
|
314
|
+
return style
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
created() {
|
|
318
|
+
this.syncPageRoute()
|
|
319
|
+
},
|
|
320
|
+
methods: {
|
|
321
|
+
syncPageRoute() {
|
|
322
|
+
if (this.showBack === null) {
|
|
323
|
+
/* eslint-disable */
|
|
324
|
+
const pages = getCurrentPages()
|
|
325
|
+
// 如果堆栈大于1表示打开了子页面,需要显示返回按钮
|
|
326
|
+
this.isShowBack = pages.length > 1
|
|
327
|
+
// #ifdef H5
|
|
328
|
+
if(!this.isShowBack) {
|
|
329
|
+
// H5端,如果isShowBack为false,继续尝试获取父节点的属性判断是否子页面
|
|
330
|
+
const page = this.$pi.parent(this, 'Page')
|
|
331
|
+
if(!page) return
|
|
332
|
+
this.isShowBack = !page.isQuit && !page.$route.meta.isQuit
|
|
333
|
+
}
|
|
334
|
+
// #endif
|
|
335
|
+
} else {
|
|
336
|
+
this.isShowBack = this.showBack
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
handleGoBack(){
|
|
340
|
+
if(!this.customBackFunc) {
|
|
341
|
+
if (getCurrentPages().length === 1) {
|
|
342
|
+
uni.reLaunch({
|
|
343
|
+
url: '/'
|
|
344
|
+
})
|
|
345
|
+
} else {
|
|
346
|
+
uni.navigateBack({
|
|
347
|
+
from: 'backbutton'
|
|
348
|
+
})
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
this.$emit('navigateToBack')
|
|
352
|
+
},
|
|
353
|
+
handleGoHome() {
|
|
354
|
+
!this.customHomeFunc && navi[this.homePageMethod](this.homePage)
|
|
355
|
+
this.$emit('navigateToHome')
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
</script>
|
|
360
|
+
|
|
361
|
+
<style lang="scss" scoped>
|
|
362
|
+
.navbar-wrap {
|
|
363
|
+
position: relative;
|
|
364
|
+
.navbar-fixed {
|
|
365
|
+
position: fixed;
|
|
366
|
+
top: 0;
|
|
367
|
+
right: 0;
|
|
368
|
+
left: 0;
|
|
369
|
+
}
|
|
370
|
+
.nav-icon {
|
|
371
|
+
position: relative;
|
|
372
|
+
z-index: 1;
|
|
373
|
+
|
|
374
|
+
// 小程序才开启胶囊效果
|
|
375
|
+
|
|
376
|
+
/* #ifdef MP */
|
|
377
|
+
&.capsule {
|
|
378
|
+
position: relative;
|
|
379
|
+
margin-left: 20rpx;
|
|
380
|
+
border: 1px solid rgba(0, 0, 0, 0.1);
|
|
381
|
+
&::before {
|
|
382
|
+
position: absolute;
|
|
383
|
+
top: 50%;
|
|
384
|
+
left: 50%;
|
|
385
|
+
width: 1px;
|
|
386
|
+
height: 60%;
|
|
387
|
+
content: '';
|
|
388
|
+
transform: scaleX(0.5) translate(-50%, -50%);
|
|
389
|
+
}
|
|
390
|
+
&.dark {
|
|
391
|
+
&::before {
|
|
392
|
+
background: #999999;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
background: rgba(0, 0, 0, 0.35);
|
|
396
|
+
}
|
|
397
|
+
&.light {
|
|
398
|
+
&::before {
|
|
399
|
+
background: #e5e5e5;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
background: rgba(252, 252, 252, 0.3);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/* #endif */
|
|
407
|
+
}
|
|
408
|
+
.through-space {
|
|
409
|
+
position: absolute;
|
|
410
|
+
top: 50%;
|
|
411
|
+
left: 50%;
|
|
412
|
+
z-index: 0;
|
|
413
|
+
overflow: hidden;
|
|
414
|
+
line-height: initial;
|
|
415
|
+
text-align: center;
|
|
416
|
+
text-overflow: ellipsis;
|
|
417
|
+
white-space: nowrap;
|
|
418
|
+
transform: translate(-50%, -50%);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
</style>
|