sadais-piui 1.2.7-beta113 → 1.2.7-beta115

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.
Files changed (160) hide show
  1. package/.prettierrc +7 -7
  2. package/CHANGELOG.md +545 -545
  3. package/LICENSE +20 -20
  4. package/README.md +166 -166
  5. package/components/pi-action-sheet/index.vue +247 -247
  6. package/components/pi-badge/index.vue +146 -146
  7. package/components/pi-bottom-bar/index.vue +139 -139
  8. package/components/pi-bubble/index.vue +174 -174
  9. package/components/pi-button/index.vue +492 -492
  10. package/components/pi-calendar-input/index.vue +230 -230
  11. package/components/pi-calendar-panel/components/calendar-days/index.vue +410 -410
  12. package/components/pi-calendar-panel/index.vue +473 -473
  13. package/components/pi-canvas/index.vue +407 -407
  14. package/components/pi-card/index.vue +127 -127
  15. package/components/pi-cascader/index.vue +601 -601
  16. package/components/pi-checkbox/index.vue +363 -363
  17. package/components/pi-checkbox-group/index.vue +222 -222
  18. package/components/pi-circle-progress/index.vue +311 -311
  19. package/components/pi-code-input/index.vue +270 -270
  20. package/components/pi-collapse/index.vue +124 -124
  21. package/components/pi-collapse-item/index.vue +352 -352
  22. package/components/pi-count-down/index.vue +245 -245
  23. package/components/pi-count-up/index.vue +209 -209
  24. package/components/pi-date-picker-input/index.vue +219 -219
  25. package/components/pi-divider/index.vue +112 -112
  26. package/components/pi-dropdown/components/dropdown-tab.vue +71 -71
  27. package/components/pi-dropdown/index.vue +356 -356
  28. package/components/pi-dropdown-item/index.vue +252 -252
  29. package/components/pi-form/index.vue +273 -273
  30. package/components/pi-form-item/index.vue +603 -590
  31. package/components/pi-gap/index.vue +72 -72
  32. package/components/pi-grid/index.vue +92 -92
  33. package/components/pi-grid-item/index.vue +220 -220
  34. package/components/pi-icon/index.vue +147 -147
  35. package/components/pi-img/index.vue +266 -266
  36. package/components/pi-img-cropper/canvas.js +106 -106
  37. package/components/pi-img-cropper/index.vue +357 -357
  38. package/components/pi-img-cropper/touch.js +163 -163
  39. package/components/pi-img-cropper/vector.js +34 -34
  40. package/components/pi-input/index.vue +409 -401
  41. package/components/pi-line/index.vue +78 -78
  42. package/components/pi-line-progress/index.vue +198 -198
  43. package/components/pi-list/index.vue +115 -115
  44. package/components/pi-list-item/index.vue +335 -335
  45. package/components/pi-loading/index.vue +188 -188
  46. package/components/pi-marquee/index.vue +310 -310
  47. package/components/pi-marquee-item/index.vue +47 -47
  48. package/components/pi-mask/index.vue +198 -198
  49. package/components/pi-modal/index.vue +303 -303
  50. package/components/pi-navbar/index.vue +421 -421
  51. package/components/pi-notify/index.vue +239 -239
  52. package/components/pi-number-keyboard/index.vue +189 -189
  53. package/components/pi-opentype-button/index.vue +501 -501
  54. package/components/pi-pagination/index.vue +290 -290
  55. package/components/pi-picker/index.vue +317 -317
  56. package/components/pi-popup/index.vue +356 -356
  57. package/components/pi-popup-select/index.vue +300 -300
  58. package/components/pi-radio/index.vue +403 -403
  59. package/components/pi-radio-group/index.vue +300 -300
  60. package/components/pi-rate/index.vue +212 -212
  61. package/components/pi-regions-select/index.vue +349 -349
  62. package/components/pi-regions-select-input/index.vue +230 -230
  63. package/components/pi-search/index.vue +386 -386
  64. package/components/pi-section/index.vue +218 -218
  65. package/components/pi-select/index.vue +678 -678
  66. package/components/pi-select-input/index.vue +273 -273
  67. package/components/pi-skeleton/index.vue +280 -280
  68. package/components/pi-status-bar/index.vue +56 -56
  69. package/components/pi-stepper/index.vue +408 -408
  70. package/components/pi-steps/index.vue +378 -378
  71. package/components/pi-subsection/index.vue +403 -403
  72. package/components/pi-swiper/index.vue +344 -344
  73. package/components/pi-switch/index.vue +231 -231
  74. package/components/pi-table/index.vue +351 -351
  75. package/components/pi-tabs/index.vue +435 -435
  76. package/components/pi-tag/index.vue +488 -488
  77. package/components/pi-upload-img/index.vue +980 -980
  78. package/components/pi-waterfall/index.vue +130 -130
  79. package/config/actionSheet.js +24 -24
  80. package/config/badge.js +9 -9
  81. package/config/bottomBar.js +11 -11
  82. package/config/bubble.js +6 -6
  83. package/config/button.js +29 -29
  84. package/config/calendar.js +19 -19
  85. package/config/calendarInput.js +19 -19
  86. package/config/calendarPanel.js +27 -27
  87. package/config/card.js +8 -8
  88. package/config/cascader.js +22 -22
  89. package/config/checkbox.js +15 -15
  90. package/config/checkboxGroup.js +15 -15
  91. package/config/circleProgress.js +20 -20
  92. package/config/codeInput.js +13 -13
  93. package/config/collapse.js +7 -7
  94. package/config/collapseItem.js +11 -11
  95. package/config/countDown.js +12 -12
  96. package/config/countUp.js +13 -13
  97. package/config/datePickerInput.js +18 -18
  98. package/config/divider.js +10 -10
  99. package/config/dropdown.js +25 -25
  100. package/config/dropdownItem.js +26 -26
  101. package/config/form.js +29 -29
  102. package/config/formItem.js +27 -27
  103. package/config/gap.js +8 -8
  104. package/config/grid.js +9 -9
  105. package/config/gridItem.js +12 -12
  106. package/config/icon.js +11 -11
  107. package/config/img.js +21 -21
  108. package/config/imgCropper.js +26 -26
  109. package/config/index.js +28 -28
  110. package/config/input.js +37 -36
  111. package/config/line.js +8 -8
  112. package/config/lineProgress.js +14 -14
  113. package/config/list.js +12 -12
  114. package/config/listItem.js +25 -25
  115. package/config/loading.js +10 -10
  116. package/config/marquee.js +10 -10
  117. package/config/mask.js +12 -12
  118. package/config/modal.js +36 -36
  119. package/config/navbar.js +32 -32
  120. package/config/notify.js +13 -13
  121. package/config/numberKeyboard.js +21 -21
  122. package/config/pagination.js +10 -10
  123. package/config/picker.js +19 -19
  124. package/config/popup.js +23 -23
  125. package/config/popupSelect.js +35 -35
  126. package/config/radio.js +16 -16
  127. package/config/radioGroup.js +17 -17
  128. package/config/rate.js +15 -15
  129. package/config/regionsData.js +58 -58
  130. package/config/regionsSelect.js +19 -19
  131. package/config/regionsSelectInput.js +29 -29
  132. package/config/search.js +27 -27
  133. package/config/section.js +23 -23
  134. package/config/select.js +41 -41
  135. package/config/selectInput.js +29 -29
  136. package/config/skeleton.js +13 -13
  137. package/config/statusBar.js +5 -5
  138. package/config/stepper.js +19 -19
  139. package/config/steps.js +19 -19
  140. package/config/subsection.js +14 -14
  141. package/config/swiper.js +22 -22
  142. package/config/switch.js +13 -13
  143. package/config/table.js +8 -8
  144. package/config/tabs.js +23 -23
  145. package/config/tag.js +21 -21
  146. package/config/uploadImg.js +81 -81
  147. package/config/waterfall.js +6 -6
  148. package/index.js +41 -41
  149. package/mixin/component-custom.js +24 -24
  150. package/mixin/emitter.js +45 -45
  151. package/mixin/props-sync.js +65 -65
  152. package/mixin/value-sync.js +32 -32
  153. package/mixin/wx-code.js +30 -30
  154. package/package.json +28 -28
  155. package/plugins/async-validator.js +1511 -1511
  156. package/scss/animation.scss +260 -260
  157. package/scss/icon/icon.scss +595 -595
  158. package/scss/index.scss +5 -5
  159. package/scss/mixin.scss +47 -47
  160. package/tools/index.js +19 -19
@@ -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>