@kengic/uni 0.5.1 → 0.5.2-beta.1

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 (146) hide show
  1. package/dist/uni/uni-ui/uni-badge/uni-badge.vue +222 -219
  2. package/dist/uni/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +29 -29
  3. package/dist/uni/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +88 -88
  4. package/dist/uni/uni-ui/uni-calendar/calendar.js +936 -532
  5. package/dist/uni/uni-ui/uni-calendar/i18n/en.json +10 -10
  6. package/dist/uni/uni-ui/uni-calendar/i18n/index.js +8 -7
  7. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hans.json +10 -10
  8. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hant.json +10 -10
  9. package/dist/uni/uni-ui/uni-calendar/uni-calendar-item.vue +190 -168
  10. package/dist/uni/uni-ui/uni-calendar/uni-calendar.vue +459 -459
  11. package/dist/uni/uni-ui/uni-calendar/util.js +324 -340
  12. package/dist/uni/uni-ui/uni-card/uni-card.vue +8 -1
  13. package/dist/uni/uni-ui/uni-col/uni-col.vue +294 -287
  14. package/dist/uni/uni-ui/uni-collapse/uni-collapse.vue +139 -140
  15. package/dist/uni/uni-ui/uni-collapse-item/uni-collapse-item.vue +381 -378
  16. package/dist/uni/uni-ui/uni-combox/uni-combox.vue +280 -272
  17. package/dist/uni/uni-ui/uni-countdown/i18n/en.json +4 -4
  18. package/dist/uni/uni-ui/uni-countdown/i18n/index.js +8 -7
  19. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hans.json +4 -4
  20. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hant.json +4 -4
  21. package/dist/uni/uni-ui/uni-countdown/uni-countdown.vue +249 -257
  22. package/dist/uni/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +832 -813
  23. package/dist/uni/uni-ui/uni-data-picker/keypress.js +42 -42
  24. package/dist/uni/uni-ui/uni-data-picker/uni-data-picker.vue +535 -516
  25. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-picker.js +623 -618
  26. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +293 -288
  27. package/dist/uni/uni-ui/uni-data-select/uni-data-select.vue +495 -509
  28. package/dist/uni/uni-ui/uni-dateformat/date-format.js +181 -184
  29. package/dist/uni/uni-ui/uni-dateformat/uni-dateformat.vue +81 -82
  30. package/dist/uni/uni-ui/uni-datetime-picker/calendar-item.vue +176 -170
  31. package/dist/uni/uni-ui/uni-datetime-picker/calendar.vue +926 -920
  32. package/dist/uni/uni-ui/uni-datetime-picker/i18n/en.json +20 -20
  33. package/dist/uni/uni-ui/uni-datetime-picker/i18n/index.js +8 -7
  34. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +21 -21
  35. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +21 -21
  36. package/dist/uni/uni-ui/uni-datetime-picker/time-picker.vue +921 -926
  37. package/dist/uni/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1059 -1012
  38. package/dist/uni/uni-ui/uni-datetime-picker/util.js +366 -377
  39. package/dist/uni/uni-ui/uni-drawer/keypress.js +42 -42
  40. package/dist/uni/uni-ui/uni-drawer/uni-drawer.vue +176 -167
  41. package/dist/uni/uni-ui/uni-easyinput/common.js +40 -42
  42. package/dist/uni/uni-ui/uni-easyinput/uni-easyinput.vue +628 -547
  43. package/dist/uni/uni-ui/uni-fab/uni-fab.vue +507 -483
  44. package/dist/uni/uni-ui/uni-fav/i18n/en.json +2 -2
  45. package/dist/uni/uni-ui/uni-fav/i18n/index.js +8 -7
  46. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hans.json +2 -2
  47. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hant.json +2 -2
  48. package/dist/uni/uni-ui/uni-fav/uni-fav.vue +155 -147
  49. package/dist/uni/uni-ui/uni-file-picker/choose-and-upload-file.js +172 -198
  50. package/dist/uni/uni-ui/uni-file-picker/uni-file-picker.vue +636 -634
  51. package/dist/uni/uni-ui/uni-file-picker/upload-file.vue +294 -293
  52. package/dist/uni/uni-ui/uni-file-picker/upload-image.vue +267 -270
  53. package/dist/uni/uni-ui/uni-file-picker/utils.js +81 -82
  54. package/dist/uni/uni-ui/uni-forms/uni-forms.vue +360 -372
  55. package/dist/uni/uni-ui/uni-forms/utils.js +170 -174
  56. package/dist/uni/uni-ui/uni-forms/validate.js +447 -456
  57. package/dist/uni/uni-ui/uni-forms-item/uni-forms-item.vue +497 -497
  58. package/dist/uni/uni-ui/uni-goods-nav/i18n/en.json +4 -4
  59. package/dist/uni/uni-ui/uni-goods-nav/i18n/index.js +8 -7
  60. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hans.json +4 -4
  61. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hant.json +4 -4
  62. package/dist/uni/uni-ui/uni-goods-nav/uni-goods-nav.vue +238 -222
  63. package/dist/uni/uni-ui/uni-grid/uni-grid.vue +134 -134
  64. package/dist/uni/uni-ui/uni-grid-item/uni-grid-item.vue +121 -119
  65. package/dist/uni/uni-ui/uni-group/uni-group.vue +121 -121
  66. package/dist/uni/uni-ui/uni-icons/icons.js +1170 -1168
  67. package/dist/uni/uni-ui/uni-icons/uni-icons.vue +91 -86
  68. package/dist/uni/uni-ui/uni-icons/uniicons.css +166 -166
  69. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +129 -129
  70. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list.vue +352 -347
  71. package/dist/uni/uni-ui/uni-link/uni-link.vue +134 -119
  72. package/dist/uni/uni-ui/uni-list/uni-list.vue +119 -110
  73. package/dist/uni/uni-ui/uni-list/uni-refresh.vue +14 -14
  74. package/dist/uni/uni-ui/uni-list/uni-refresh.wxs +14 -14
  75. package/dist/uni/uni-ui/uni-list-ad/uni-list-ad.vue +101 -95
  76. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.scss +18 -18
  77. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.vue +602 -586
  78. package/dist/uni/uni-ui/uni-list-item/uni-list-item.vue +507 -503
  79. package/dist/uni/uni-ui/uni-load-more/i18n/en.json +3 -3
  80. package/dist/uni/uni-ui/uni-load-more/i18n/index.js +8 -7
  81. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hans.json +3 -3
  82. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hant.json +3 -3
  83. package/dist/uni/uni-ui/uni-load-more/uni-load-more.vue +402 -392
  84. package/dist/uni/uni-ui/uni-nav-bar/uni-nav-bar.vue +328 -330
  85. package/dist/uni/uni-ui/uni-nav-bar/uni-status-bar.vue +17 -17
  86. package/dist/uni/uni-ui/uni-notice-bar/uni-notice-bar.vue +422 -401
  87. package/dist/uni/uni-ui/uni-number-box/uni-number-box.vue +211 -205
  88. package/dist/uni/uni-ui/uni-pagination/i18n/en.json +3 -3
  89. package/dist/uni/uni-ui/uni-pagination/i18n/es.json +3 -3
  90. package/dist/uni/uni-ui/uni-pagination/i18n/fr.json +3 -3
  91. package/dist/uni/uni-ui/uni-pagination/i18n/index.js +12 -11
  92. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hans.json +3 -3
  93. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hant.json +3 -3
  94. package/dist/uni/uni-ui/uni-pagination/uni-pagination.vue +450 -433
  95. package/dist/uni/uni-ui/uni-popup/uni-popup.vue +404 -404
  96. package/dist/uni/uni-ui/uni-popup-dialog/keypress.js +42 -42
  97. package/dist/uni/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +1 -0
  98. package/dist/uni/uni-ui/uni-popup-message/uni-popup-message.vue +126 -125
  99. package/dist/uni/uni-ui/uni-popup-share/uni-popup-share.vue +172 -172
  100. package/dist/uni/uni-ui/uni-rate/uni-rate.vue +343 -347
  101. package/dist/uni/uni-ui/uni-row/uni-row.vue +180 -182
  102. package/dist/uni/uni-ui/uni-scss/changelog.md +11 -4
  103. package/dist/uni/uni-ui/uni-scss/package.json +73 -73
  104. package/dist/uni/uni-ui/uni-scss/readme.md +2 -1
  105. package/dist/uni/uni-ui/uni-scss/styles/setting/_border.scss +2 -2
  106. package/dist/uni/uni-ui/uni-scss/styles/setting/_color.scss +46 -47
  107. package/dist/uni/uni-ui/uni-scss/styles/setting/_radius.scss +49 -49
  108. package/dist/uni/uni-ui/uni-scss/styles/setting/_space.scss +52 -53
  109. package/dist/uni/uni-ui/uni-scss/styles/setting/_styles.scss +142 -147
  110. package/dist/uni/uni-ui/uni-scss/styles/setting/_text.scss +20 -20
  111. package/dist/uni/uni-ui/uni-scss/styles/setting/_variables.scss +111 -95
  112. package/dist/uni/uni-ui/uni-scss/styles/tools/functions.scss +28 -18
  113. package/dist/uni/uni-ui/uni-scss/theme.scss +10 -7
  114. package/dist/uni/uni-ui/uni-scss/variables.scss +42 -24
  115. package/dist/uni/uni-ui/uni-search-bar/i18n/en.json +3 -3
  116. package/dist/uni/uni-ui/uni-search-bar/i18n/index.js +8 -7
  117. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hans.json +2 -2
  118. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hant.json +2 -2
  119. package/dist/uni/uni-ui/uni-search-bar/uni-search-bar.vue +290 -281
  120. package/dist/uni/uni-ui/uni-section/uni-section.vue +149 -146
  121. package/dist/uni/uni-ui/uni-segmented-control/uni-segmented-control.vue +141 -131
  122. package/dist/uni/uni-ui/uni-steps/uni-steps.vue +255 -236
  123. package/dist/uni/uni-ui/uni-swipe-action/uni-swipe-action.vue +51 -51
  124. package/dist/uni/uni-ui/uni-swipe-action-item/bindingx.js +276 -282
  125. package/dist/uni/uni-ui/uni-swipe-action-item/isPC.js +10 -10
  126. package/dist/uni/uni-ui/uni-swipe-action-item/mpalipay.js +182 -187
  127. package/dist/uni/uni-ui/uni-swipe-action-item/mpother.js +235 -244
  128. package/dist/uni/uni-ui/uni-swipe-action-item/mpwxs.js +70 -75
  129. package/dist/uni/uni-ui/uni-swipe-action-item/render.js +238 -247
  130. package/dist/uni/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +387 -313
  131. package/dist/uni/uni-ui/uni-swipe-action-item/wx.wxs +206 -215
  132. package/dist/uni/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +241 -197
  133. package/dist/uni/uni-ui/uni-table/uni-table.vue +445 -447
  134. package/dist/uni/uni-ui/uni-tag/uni-tag.vue +234 -244
  135. package/dist/uni/uni-ui/uni-tbody/uni-tbody.vue +20 -23
  136. package/dist/uni/uni-ui/uni-td/uni-td.vue +79 -80
  137. package/dist/uni/uni-ui/uni-th/filter-dropdown.vue +510 -503
  138. package/dist/uni/uni-ui/uni-th/uni-th.vue +289 -273
  139. package/dist/uni/uni-ui/uni-thead/uni-thead.vue +115 -114
  140. package/dist/uni/uni-ui/uni-title/uni-title.vue +151 -154
  141. package/dist/uni/uni-ui/uni-tooltip/uni-tooltip.vue +55 -60
  142. package/dist/uni/uni-ui/uni-tr/table-checkbox.vue +162 -163
  143. package/dist/uni/uni-ui/uni-tr/uni-tr.vue +158 -157
  144. package/dist/uni/uni-ui/uni-transition/createAnimation.js +130 -113
  145. package/dist/uni/uni-ui/uni-transition/uni-transition.vue +274 -272
  146. package/package.json +1 -1
@@ -1,491 +1,515 @@
1
1
  <template>
2
- <view class="uni-cursor-point">
3
- <view v-if="popMenu && (leftBottom||rightBottom||leftTop||rightTop) && content.length > 0" :class="{
4
- 'uni-fab--leftBottom': leftBottom,
5
- 'uni-fab--rightBottom': rightBottom,
6
- 'uni-fab--leftTop': leftTop,
7
- 'uni-fab--rightTop': rightTop
8
- }" class="uni-fab"
9
- :style="nvueBottom"
10
- >
11
- <view :class="{
12
- 'uni-fab__content--left': horizontal === 'left',
13
- 'uni-fab__content--right': horizontal === 'right',
14
- 'uni-fab__content--flexDirection': direction === 'vertical',
15
- 'uni-fab__content--flexDirectionStart': flexDirectionStart,
16
- 'uni-fab__content--flexDirectionEnd': flexDirectionEnd,
17
- 'uni-fab__content--other-platform': !isAndroidNvue
18
- }" :style="{ width: boxWidth, height: boxHeight, backgroundColor: styles.backgroundColor }"
19
- class="uni-fab__content" elevation="5">
20
- <view v-if="flexDirectionStart || horizontalLeft" class="uni-fab__item uni-fab__item--first" />
21
- <view v-for="(item, index) in content" :key="index" :class="{ 'uni-fab__item--active': isShow }"
22
- class="uni-fab__item" @click="_onItemClick(index, item)">
23
- <image :src="item.active ? item.selectedIconPath : item.iconPath" class="uni-fab__item-image"
24
- mode="aspectFit" />
25
- <text class="uni-fab__item-text"
26
- :style="{ color: item.active ? styles.selectedColor : styles.color }">{{ item.text }}</text>
27
- </view>
28
- <view v-if="flexDirectionEnd || horizontalRight" class="uni-fab__item uni-fab__item--first" />
29
- </view>
30
- </view>
31
- <view :class="{
32
- 'uni-fab__circle--leftBottom': leftBottom,
33
- 'uni-fab__circle--rightBottom': rightBottom,
34
- 'uni-fab__circle--leftTop': leftTop,
35
- 'uni-fab__circle--rightTop': rightTop,
36
- 'uni-fab__content--other-platform': !isAndroidNvue
37
- }" class="uni-fab__circle uni-fab__plus" :style="{ 'background-color': styles.buttonColor, 'bottom': nvueBottom }" @click="_onClick">
38
- <uni-icons class="fab-circle-icon" :type="styles.icon" :color="styles.iconColor" size="32"
39
- :class="{'uni-fab__plus--active': isShow && content.length > 0}"></uni-icons>
40
- <!-- <view class="fab-circle-v" :class="{'uni-fab__plus--active': isShow && content.length > 0}"></view>
2
+ <view class="uni-cursor-point">
3
+ <view
4
+ v-if="popMenu && (leftBottom || rightBottom || leftTop || rightTop) && content.length > 0"
5
+ :class="{
6
+ 'uni-fab--leftBottom': leftBottom,
7
+ 'uni-fab--rightBottom': rightBottom,
8
+ 'uni-fab--leftTop': leftTop,
9
+ 'uni-fab--rightTop': rightTop,
10
+ }"
11
+ class="uni-fab"
12
+ :style="nvueBottom"
13
+ >
14
+ <view
15
+ :class="{
16
+ 'uni-fab__content--left': horizontal === 'left',
17
+ 'uni-fab__content--right': horizontal === 'right',
18
+ 'uni-fab__content--flexDirection': direction === 'vertical',
19
+ 'uni-fab__content--flexDirectionStart': flexDirectionStart,
20
+ 'uni-fab__content--flexDirectionEnd': flexDirectionEnd,
21
+ 'uni-fab__content--other-platform': !isAndroidNvue,
22
+ }"
23
+ :style="{ width: boxWidth, height: boxHeight, backgroundColor: styles.backgroundColor }"
24
+ class="uni-fab__content"
25
+ elevation="5"
26
+ >
27
+ <view v-if="flexDirectionStart || horizontalLeft" class="uni-fab__item uni-fab__item--first" />
28
+ <view
29
+ v-for="(item, index) in content"
30
+ :key="index"
31
+ :class="{ 'uni-fab__item--active': isShow }"
32
+ class="uni-fab__item"
33
+ @click="_onItemClick(index, item)"
34
+ >
35
+ <image :src="item.active ? item.selectedIconPath : item.iconPath" class="uni-fab__item-image" mode="aspectFit" />
36
+ <text class="uni-fab__item-text" :style="{ color: item.active ? styles.selectedColor : styles.color }">{{ item.text }}</text>
37
+ </view>
38
+ <view v-if="flexDirectionEnd || horizontalRight" class="uni-fab__item uni-fab__item--first" />
39
+ </view>
40
+ </view>
41
+ <view
42
+ :class="{
43
+ 'uni-fab__circle--leftBottom': leftBottom,
44
+ 'uni-fab__circle--rightBottom': rightBottom,
45
+ 'uni-fab__circle--leftTop': leftTop,
46
+ 'uni-fab__circle--rightTop': rightTop,
47
+ 'uni-fab__content--other-platform': !isAndroidNvue,
48
+ }"
49
+ class="uni-fab__circle uni-fab__plus"
50
+ :style="{ 'background-color': styles.buttonColor, bottom: nvueBottom }"
51
+ @click="_onClick"
52
+ >
53
+ <uni-icons
54
+ class="fab-circle-icon"
55
+ :type="styles.icon"
56
+ :color="styles.iconColor"
57
+ size="32"
58
+ :class="{ 'uni-fab__plus--active': isShow && content.length > 0 }"
59
+ ></uni-icons>
60
+ <!-- <view class="fab-circle-v" :class="{'uni-fab__plus--active': isShow && content.length > 0}"></view>
41
61
  <view class="fab-circle-h" :class="{'uni-fab__plus--active': isShow && content.length > 0}"></view> -->
42
- </view>
43
- </view>
62
+ </view>
63
+ </view>
44
64
  </template>
45
65
 
46
66
  <script>
47
- let platform = 'other'
48
- // #ifdef APP-NVUE
49
- platform = uni.getSystemInfoSync().platform
50
- // #endif
51
-
52
- /**
53
- * Fab 悬浮按钮
54
- * @description 点击可展开一个图形按钮菜单
55
- * @tutorial https://ext.dcloud.net.cn/plugin?id=144
56
- * @property {Object} pattern 可选样式配置项
57
- * @property {Object} horizontal = [left | right] 水平对齐方式
58
- * @value left 左对齐
59
- * @value right 右对齐
60
- * @property {Object} vertical = [bottom | top] 垂直对齐方式
61
- * @value bottom 下对齐
62
- * @value top 上对齐
63
- * @property {Object} direction = [horizontal | vertical] 展开菜单显示方式
64
- * @value horizontal 水平显示
65
- * @value vertical 垂直显示
66
- * @property {Array} content 展开菜单内容配置项
67
- * @property {Boolean} popMenu 是否使用弹出菜单
68
- * @event {Function} trigger 展开菜单点击事件,返回点击信息
69
- * @event {Function} fabClick 悬浮按钮点击事件
70
- */
71
- export default {
72
- name: 'UniFab',
73
- emits: ['fabClick', 'trigger'],
74
- props: {
75
- pattern: {
76
- type: Object,
77
- default () {
78
- return {}
79
- }
80
- },
81
- horizontal: {
82
- type: String,
83
- default: 'left'
84
- },
85
- vertical: {
86
- type: String,
87
- default: 'bottom'
88
- },
89
- direction: {
90
- type: String,
91
- default: 'horizontal'
92
- },
93
- content: {
94
- type: Array,
95
- default () {
96
- return []
97
- }
98
- },
99
- show: {
100
- type: Boolean,
101
- default: false
102
- },
103
- popMenu: {
104
- type: Boolean,
105
- default: true
106
- }
107
- },
108
- data() {
109
- return {
110
- fabShow: false,
111
- isShow: false,
112
- isAndroidNvue: platform === 'android',
113
- styles: {
114
- color: '#3c3e49',
115
- selectedColor: '#007AFF',
116
- backgroundColor: '#fff',
117
- buttonColor: '#007AFF',
118
- iconColor: '#fff',
119
- icon: 'plusempty'
120
- }
121
- }
122
- },
123
- computed: {
124
- contentWidth(e) {
125
- return (this.content.length + 1) * 55 + 15 + 'px'
126
- },
127
- contentWidthMin() {
128
- return '55px'
129
- },
130
- // 动态计算宽度
131
- boxWidth() {
132
- return this.getPosition(3, 'horizontal')
133
- },
134
- // 动态计算高度
135
- boxHeight() {
136
- return this.getPosition(3, 'vertical')
137
- },
138
- // 计算左下位置
139
- leftBottom() {
140
- return this.getPosition(0, 'left', 'bottom')
141
- },
142
- // 计算右下位置
143
- rightBottom() {
144
- return this.getPosition(0, 'right', 'bottom')
145
- },
146
- // 计算左上位置
147
- leftTop() {
148
- return this.getPosition(0, 'left', 'top')
149
- },
150
- rightTop() {
151
- return this.getPosition(0, 'right', 'top')
152
- },
153
- flexDirectionStart() {
154
- return this.getPosition(1, 'vertical', 'top')
155
- },
156
- flexDirectionEnd() {
157
- return this.getPosition(1, 'vertical', 'bottom')
158
- },
159
- horizontalLeft() {
160
- return this.getPosition(2, 'horizontal', 'left')
161
- },
162
- horizontalRight() {
163
- return this.getPosition(2, 'horizontal', 'right')
164
- },
165
- // 计算 nvue bottom
166
- nvueBottom() {
167
- const safeBottom = uni.getSystemInfoSync().windowBottom;
168
- // #ifdef APP-NVUE
169
- return 30 + safeBottom
170
- // #endif
171
- // #ifndef APP-NVUE
172
- return 30
173
- // #endif
174
- }
175
- },
176
- watch: {
177
- pattern: {
178
- handler(val, oldVal) {
179
- this.styles = Object.assign({}, this.styles, val)
180
- },
181
- deep: true
182
- }
183
- },
184
- created() {
185
- this.isShow = this.show
186
- if (this.top === 0) {
187
- this.fabShow = true
188
- }
189
- // 初始化样式
190
- this.styles = Object.assign({}, this.styles, this.pattern)
191
- },
192
- methods: {
193
- _onClick() {
194
- this.$emit('fabClick')
195
- if (!this.popMenu) {
196
- return
197
- }
198
- this.isShow = !this.isShow
199
- },
200
- open() {
201
- this.isShow = true
202
- },
203
- close() {
204
- this.isShow = false
205
- },
206
- /**
207
- * 按钮点击事件
208
- */
209
- _onItemClick(index, item) {
210
- if (!this.isShow) {
211
- return
212
- }
213
- this.$emit('trigger', {
214
- index,
215
- item
216
- })
217
- },
218
- /**
219
- * 获取 位置信息
220
- */
221
- getPosition(types, paramA, paramB) {
222
- if (types === 0) {
223
- return this.horizontal === paramA && this.vertical === paramB
224
- } else if (types === 1) {
225
- return this.direction === paramA && this.vertical === paramB
226
- } else if (types === 2) {
227
- return this.direction === paramA && this.horizontal === paramB
228
- } else {
229
- return this.isShow && this.direction === paramA ? this.contentWidth : this.contentWidthMin
230
- }
231
- }
232
- }
233
- }
67
+ let platform = 'other';
68
+ // #ifdef APP-NVUE
69
+ platform = uni.getSystemInfoSync().platform;
70
+ // #endif
71
+
72
+ /**
73
+ * Fab 悬浮按钮
74
+ * @description 点击可展开一个图形按钮菜单
75
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=144
76
+ * @property {Object} pattern 可选样式配置项
77
+ * @property {Object} horizontal = [left | right] 水平对齐方式
78
+ * @value left 左对齐
79
+ * @value right 右对齐
80
+ * @property {Object} vertical = [bottom | top] 垂直对齐方式
81
+ * @value bottom 下对齐
82
+ * @value top 上对齐
83
+ * @property {Object} direction = [horizontal | vertical] 展开菜单显示方式
84
+ * @value horizontal 水平显示
85
+ * @value vertical 垂直显示
86
+ * @property {Array} content 展开菜单内容配置项
87
+ * @property {Boolean} popMenu 是否使用弹出菜单
88
+ * @event {Function} trigger 展开菜单点击事件,返回点击信息
89
+ * @event {Function} fabClick 悬浮按钮点击事件
90
+ */
91
+ export default {
92
+ name: 'UniFab',
93
+ emits: ['fabClick', 'trigger'],
94
+ props: {
95
+ pattern: {
96
+ type: Object,
97
+ default() {
98
+ return {};
99
+ },
100
+ },
101
+ horizontal: {
102
+ type: String,
103
+ default: 'left',
104
+ },
105
+ vertical: {
106
+ type: String,
107
+ default: 'bottom',
108
+ },
109
+ direction: {
110
+ type: String,
111
+ default: 'horizontal',
112
+ },
113
+ content: {
114
+ type: Array,
115
+ default() {
116
+ return [];
117
+ },
118
+ },
119
+ show: {
120
+ type: Boolean,
121
+ default: false,
122
+ },
123
+ popMenu: {
124
+ type: Boolean,
125
+ default: true,
126
+ },
127
+ },
128
+ data() {
129
+ return {
130
+ fabShow: false,
131
+ isShow: false,
132
+ isAndroidNvue: platform === 'android',
133
+ styles: {
134
+ color: '#3c3e49',
135
+ selectedColor: '#007AFF',
136
+ backgroundColor: '#fff',
137
+ buttonColor: '#007AFF',
138
+ iconColor: '#fff',
139
+ icon: 'plusempty',
140
+ },
141
+ };
142
+ },
143
+ computed: {
144
+ contentWidth(e) {
145
+ return (this.content.length + 1) * 55 + 15 + 'px';
146
+ },
147
+ contentWidthMin() {
148
+ return '55px';
149
+ },
150
+ // 动态计算宽度
151
+ boxWidth() {
152
+ return this.getPosition(3, 'horizontal');
153
+ },
154
+ // 动态计算高度
155
+ boxHeight() {
156
+ return this.getPosition(3, 'vertical');
157
+ },
158
+ // 计算左下位置
159
+ leftBottom() {
160
+ return this.getPosition(0, 'left', 'bottom');
161
+ },
162
+ // 计算右下位置
163
+ rightBottom() {
164
+ return this.getPosition(0, 'right', 'bottom');
165
+ },
166
+ // 计算左上位置
167
+ leftTop() {
168
+ return this.getPosition(0, 'left', 'top');
169
+ },
170
+ rightTop() {
171
+ return this.getPosition(0, 'right', 'top');
172
+ },
173
+ flexDirectionStart() {
174
+ return this.getPosition(1, 'vertical', 'top');
175
+ },
176
+ flexDirectionEnd() {
177
+ return this.getPosition(1, 'vertical', 'bottom');
178
+ },
179
+ horizontalLeft() {
180
+ return this.getPosition(2, 'horizontal', 'left');
181
+ },
182
+ horizontalRight() {
183
+ return this.getPosition(2, 'horizontal', 'right');
184
+ },
185
+ // 计算 nvue bottom
186
+ nvueBottom() {
187
+ const safeBottom = uni.getSystemInfoSync().windowBottom;
188
+ // #ifdef APP-NVUE
189
+ return 30 + safeBottom;
190
+ // #endif
191
+ // #ifndef APP-NVUE
192
+ return 30;
193
+ // #endif
194
+ },
195
+ },
196
+ watch: {
197
+ pattern: {
198
+ handler(val, oldVal) {
199
+ this.styles = Object.assign({}, this.styles, val);
200
+ },
201
+ deep: true,
202
+ },
203
+ },
204
+ created() {
205
+ this.isShow = this.show;
206
+ if (this.top === 0) {
207
+ this.fabShow = true;
208
+ }
209
+ // 初始化样式
210
+ this.styles = Object.assign({}, this.styles, this.pattern);
211
+ },
212
+ methods: {
213
+ _onClick() {
214
+ this.$emit('fabClick');
215
+ if (!this.popMenu) {
216
+ return;
217
+ }
218
+ this.isShow = !this.isShow;
219
+ },
220
+ open() {
221
+ this.isShow = true;
222
+ },
223
+ close() {
224
+ this.isShow = false;
225
+ },
226
+ /**
227
+ * 按钮点击事件
228
+ */
229
+ _onItemClick(index, item) {
230
+ if (!this.isShow) {
231
+ return;
232
+ }
233
+ this.$emit('trigger', {
234
+ index,
235
+ item,
236
+ });
237
+ },
238
+ /**
239
+ * 获取 位置信息
240
+ */
241
+ getPosition(types, paramA, paramB) {
242
+ if (types === 0) {
243
+ return this.horizontal === paramA && this.vertical === paramB;
244
+ } else if (types === 1) {
245
+ return this.direction === paramA && this.vertical === paramB;
246
+ } else if (types === 2) {
247
+ return this.direction === paramA && this.horizontal === paramB;
248
+ } else {
249
+ return this.isShow && this.direction === paramA ? this.contentWidth : this.contentWidthMin;
250
+ }
251
+ },
252
+ },
253
+ };
234
254
  </script>
235
255
 
236
- <style lang="scss" >
237
- $uni-shadow-base:0 1px 5px 2px rgba($color: #000000, $alpha: 0.3) !default;
238
-
239
- .uni-fab {
240
- position: fixed;
241
- /* #ifndef APP-NVUE */
242
- display: flex;
243
- /* #endif */
244
- justify-content: center;
245
- align-items: center;
246
- z-index: 10;
247
- border-radius: 45px;
248
- box-shadow: $uni-shadow-base;
249
- }
250
-
251
- .uni-cursor-point {
252
- /* #ifdef H5 */
253
- cursor: pointer;
254
- /* #endif */
255
- }
256
-
257
- .uni-fab--active {
258
- opacity: 1;
259
- }
260
-
261
- .uni-fab--leftBottom {
262
- left: 15px;
263
- bottom: 30px;
264
- /* #ifdef H5 */
265
- left: calc(15px + var(--window-left));
266
- bottom: calc(30px + var(--window-bottom));
267
- /* #endif */
268
- // padding: 10px;
269
- }
270
-
271
- .uni-fab--leftTop {
272
- left: 15px;
273
- top: 30px;
274
- /* #ifdef H5 */
275
- left: calc(15px + var(--window-left));
276
- top: calc(30px + var(--window-top));
277
- /* #endif */
278
- // padding: 10px;
279
- }
280
-
281
- .uni-fab--rightBottom {
282
- right: 15px;
283
- bottom: 30px;
284
- /* #ifdef H5 */
285
- right: calc(15px + var(--window-right));
286
- bottom: calc(30px + var(--window-bottom));
287
- /* #endif */
288
- // padding: 10px;
289
- }
290
-
291
- .uni-fab--rightTop {
292
- right: 15px;
293
- top: 30px;
294
- /* #ifdef H5 */
295
- right: calc(15px + var(--window-right));
296
- top: calc(30px + var(--window-top));
297
- /* #endif */
298
- // padding: 10px;
299
- }
300
-
301
- .uni-fab__circle {
302
- position: fixed;
303
- /* #ifndef APP-NVUE */
304
- display: flex;
305
- /* #endif */
306
- justify-content: center;
307
- align-items: center;
308
- width: 55px;
309
- height: 55px;
310
- background-color: #3c3e49;
311
- border-radius: 45px;
312
- z-index: 11;
313
- // box-shadow: $uni-shadow-base;
314
- }
315
-
316
- .uni-fab__circle--leftBottom {
317
- left: 15px;
318
- bottom: 30px;
319
- /* #ifdef H5 */
320
- left: calc(15px + var(--window-left));
321
- bottom: calc(30px + var(--window-bottom));
322
- /* #endif */
323
- }
324
-
325
- .uni-fab__circle--leftTop {
326
- left: 15px;
327
- top: 30px;
328
- /* #ifdef H5 */
329
- left: calc(15px + var(--window-left));
330
- top: calc(30px + var(--window-top));
331
- /* #endif */
332
- }
333
-
334
- .uni-fab__circle--rightBottom {
335
- right: 15px;
336
- bottom: 30px;
337
- /* #ifdef H5 */
338
- right: calc(15px + var(--window-right));
339
- bottom: calc(30px + var(--window-bottom));
340
- /* #endif */
341
- }
342
-
343
- .uni-fab__circle--rightTop {
344
- right: 15px;
345
- top: 30px;
346
- /* #ifdef H5 */
347
- right: calc(15px + var(--window-right));
348
- top: calc(30px + var(--window-top));
349
- /* #endif */
350
- }
351
-
352
- .uni-fab__circle--left {
353
- left: 0;
354
- }
355
-
356
- .uni-fab__circle--right {
357
- right: 0;
358
- }
359
-
360
- .uni-fab__circle--top {
361
- top: 0;
362
- }
363
-
364
- .uni-fab__circle--bottom {
365
- bottom: 0;
366
- }
367
-
368
- .uni-fab__plus {
369
- font-weight: bold;
370
- }
371
-
372
- // .fab-circle-v {
373
- // position: absolute;
374
- // width: 2px;
375
- // height: 24px;
376
- // left: 0;
377
- // top: 0;
378
- // right: 0;
379
- // bottom: 0;
380
- // /* #ifndef APP-NVUE */
381
- // margin: auto;
382
- // /* #endif */
383
- // background-color: white;
384
- // transform: rotate(0deg);
385
- // transition: transform 0.3s;
386
- // }
387
-
388
- // .fab-circle-h {
389
- // position: absolute;
390
- // width: 24px;
391
- // height: 2px;
392
- // left: 0;
393
- // top: 0;
394
- // right: 0;
395
- // bottom: 0;
396
- // /* #ifndef APP-NVUE */
397
- // margin: auto;
398
- // /* #endif */
399
- // background-color: white;
400
- // transform: rotate(0deg);
401
- // transition: transform 0.3s;
402
- // }
403
-
404
- .fab-circle-icon {
405
- transform: rotate(0deg);
406
- transition: transform 0.3s;
407
- font-weight: 200;
408
- }
409
-
410
- .uni-fab__plus--active {
411
- transform: rotate(135deg);
412
- }
413
-
414
- .uni-fab__content {
415
- /* #ifndef APP-NVUE */
416
- box-sizing: border-box;
417
- display: flex;
418
- /* #endif */
419
- flex-direction: row;
420
- border-radius: 55px;
421
- overflow: hidden;
422
- transition-property: width, height;
423
- transition-duration: 0.2s;
424
- width: 55px;
425
- border-color: #DDDDDD;
426
- border-width: 1rpx;
427
- border-style: solid;
428
- }
429
-
430
- .uni-fab__content--other-platform {
431
- border-width: 0px;
432
- box-shadow: $uni-shadow-base;
433
- }
434
-
435
- .uni-fab__content--left {
436
- justify-content: flex-start;
437
- }
438
-
439
- .uni-fab__content--right {
440
- justify-content: flex-end;
441
- }
442
-
443
- .uni-fab__content--flexDirection {
444
- flex-direction: column;
445
- justify-content: flex-end;
446
- }
447
-
448
- .uni-fab__content--flexDirectionStart {
449
- flex-direction: column;
450
- justify-content: flex-start;
451
- }
452
-
453
- .uni-fab__content--flexDirectionEnd {
454
- flex-direction: column;
455
- justify-content: flex-end;
456
- }
457
-
458
- .uni-fab__item {
459
- /* #ifndef APP-NVUE */
460
- display: flex;
461
- /* #endif */
462
- flex-direction: column;
463
- justify-content: center;
464
- align-items: center;
465
- width: 55px;
466
- height: 55px;
467
- opacity: 0;
468
- transition: opacity 0.2s;
469
- }
470
-
471
- .uni-fab__item--active {
472
- opacity: 1;
473
- }
474
-
475
- .uni-fab__item-image {
476
- width: 20px;
477
- height: 20px;
478
- margin-bottom: 4px;
479
- }
480
-
481
- .uni-fab__item-text {
482
- color: #FFFFFF;
483
- font-size: 12px;
484
- line-height: 12px;
485
- margin-top: 2px;
486
- }
487
-
488
- .uni-fab__item--first {
489
- width: 55px;
490
- }
256
+ <style lang="scss">
257
+ $uni-shadow-base: 0 1px 5px 2px
258
+ rgba(
259
+ $color: #000000,
260
+ $alpha: 0.3,
261
+ ) !default;
262
+
263
+ .uni-fab {
264
+ position: fixed;
265
+ /* #ifndef APP-NVUE */
266
+ display: flex;
267
+ /* #endif */
268
+ justify-content: center;
269
+ align-items: center;
270
+ z-index: 10;
271
+ border-radius: 45px;
272
+ box-shadow: $uni-shadow-base;
273
+ }
274
+
275
+ .uni-cursor-point {
276
+ /* #ifdef H5 */
277
+ cursor: pointer;
278
+ /* #endif */
279
+ }
280
+
281
+ .uni-fab--active {
282
+ opacity: 1;
283
+ }
284
+
285
+ .uni-fab--leftBottom {
286
+ left: 15px;
287
+ bottom: 30px;
288
+ /* #ifdef H5 */
289
+ left: calc(15px + var(--window-left));
290
+ bottom: calc(30px + var(--window-bottom));
291
+ /* #endif */
292
+ // padding: 10px;
293
+ }
294
+
295
+ .uni-fab--leftTop {
296
+ left: 15px;
297
+ top: 30px;
298
+ /* #ifdef H5 */
299
+ left: calc(15px + var(--window-left));
300
+ top: calc(30px + var(--window-top));
301
+ /* #endif */
302
+ // padding: 10px;
303
+ }
304
+
305
+ .uni-fab--rightBottom {
306
+ right: 15px;
307
+ bottom: 30px;
308
+ /* #ifdef H5 */
309
+ right: calc(15px + var(--window-right));
310
+ bottom: calc(30px + var(--window-bottom));
311
+ /* #endif */
312
+ // padding: 10px;
313
+ }
314
+
315
+ .uni-fab--rightTop {
316
+ right: 15px;
317
+ top: 30px;
318
+ /* #ifdef H5 */
319
+ right: calc(15px + var(--window-right));
320
+ top: calc(30px + var(--window-top));
321
+ /* #endif */
322
+ // padding: 10px;
323
+ }
324
+
325
+ .uni-fab__circle {
326
+ position: fixed;
327
+ /* #ifndef APP-NVUE */
328
+ display: flex;
329
+ /* #endif */
330
+ justify-content: center;
331
+ align-items: center;
332
+ width: 55px;
333
+ height: 55px;
334
+ background-color: #3c3e49;
335
+ border-radius: 45px;
336
+ z-index: 11;
337
+ // box-shadow: $uni-shadow-base;
338
+ }
339
+
340
+ .uni-fab__circle--leftBottom {
341
+ left: 15px;
342
+ bottom: 30px;
343
+ /* #ifdef H5 */
344
+ left: calc(15px + var(--window-left));
345
+ bottom: calc(30px + var(--window-bottom));
346
+ /* #endif */
347
+ }
348
+
349
+ .uni-fab__circle--leftTop {
350
+ left: 15px;
351
+ top: 30px;
352
+ /* #ifdef H5 */
353
+ left: calc(15px + var(--window-left));
354
+ top: calc(30px + var(--window-top));
355
+ /* #endif */
356
+ }
357
+
358
+ .uni-fab__circle--rightBottom {
359
+ right: 15px;
360
+ bottom: 30px;
361
+ /* #ifdef H5 */
362
+ right: calc(15px + var(--window-right));
363
+ bottom: calc(30px + var(--window-bottom));
364
+ /* #endif */
365
+ }
366
+
367
+ .uni-fab__circle--rightTop {
368
+ right: 15px;
369
+ top: 30px;
370
+ /* #ifdef H5 */
371
+ right: calc(15px + var(--window-right));
372
+ top: calc(30px + var(--window-top));
373
+ /* #endif */
374
+ }
375
+
376
+ .uni-fab__circle--left {
377
+ left: 0;
378
+ }
379
+
380
+ .uni-fab__circle--right {
381
+ right: 0;
382
+ }
383
+
384
+ .uni-fab__circle--top {
385
+ top: 0;
386
+ }
387
+
388
+ .uni-fab__circle--bottom {
389
+ bottom: 0;
390
+ }
391
+
392
+ .uni-fab__plus {
393
+ font-weight: bold;
394
+ }
395
+
396
+ // .fab-circle-v {
397
+ // position: absolute;
398
+ // width: 2px;
399
+ // height: 24px;
400
+ // left: 0;
401
+ // top: 0;
402
+ // right: 0;
403
+ // bottom: 0;
404
+ // /* #ifndef APP-NVUE */
405
+ // margin: auto;
406
+ // /* #endif */
407
+ // background-color: white;
408
+ // transform: rotate(0deg);
409
+ // transition: transform 0.3s;
410
+ // }
411
+
412
+ // .fab-circle-h {
413
+ // position: absolute;
414
+ // width: 24px;
415
+ // height: 2px;
416
+ // left: 0;
417
+ // top: 0;
418
+ // right: 0;
419
+ // bottom: 0;
420
+ // /* #ifndef APP-NVUE */
421
+ // margin: auto;
422
+ // /* #endif */
423
+ // background-color: white;
424
+ // transform: rotate(0deg);
425
+ // transition: transform 0.3s;
426
+ // }
427
+
428
+ .fab-circle-icon {
429
+ transform: rotate(0deg);
430
+ transition: transform 0.3s;
431
+ font-weight: 200;
432
+ }
433
+
434
+ .uni-fab__plus--active {
435
+ transform: rotate(135deg);
436
+ }
437
+
438
+ .uni-fab__content {
439
+ /* #ifndef APP-NVUE */
440
+ box-sizing: border-box;
441
+ display: flex;
442
+ /* #endif */
443
+ flex-direction: row;
444
+ border-radius: 55px;
445
+ overflow: hidden;
446
+ transition-property: width, height;
447
+ transition-duration: 0.2s;
448
+ width: 55px;
449
+ border-color: #dddddd;
450
+ border-width: 1rpx;
451
+ border-style: solid;
452
+ }
453
+
454
+ .uni-fab__content--other-platform {
455
+ border-width: 0px;
456
+ box-shadow: $uni-shadow-base;
457
+ }
458
+
459
+ .uni-fab__content--left {
460
+ justify-content: flex-start;
461
+ }
462
+
463
+ .uni-fab__content--right {
464
+ justify-content: flex-end;
465
+ }
466
+
467
+ .uni-fab__content--flexDirection {
468
+ flex-direction: column;
469
+ justify-content: flex-end;
470
+ }
471
+
472
+ .uni-fab__content--flexDirectionStart {
473
+ flex-direction: column;
474
+ justify-content: flex-start;
475
+ }
476
+
477
+ .uni-fab__content--flexDirectionEnd {
478
+ flex-direction: column;
479
+ justify-content: flex-end;
480
+ }
481
+
482
+ .uni-fab__item {
483
+ /* #ifndef APP-NVUE */
484
+ display: flex;
485
+ /* #endif */
486
+ flex-direction: column;
487
+ justify-content: center;
488
+ align-items: center;
489
+ width: 55px;
490
+ height: 55px;
491
+ opacity: 0;
492
+ transition: opacity 0.2s;
493
+ }
494
+
495
+ .uni-fab__item--active {
496
+ opacity: 1;
497
+ }
498
+
499
+ .uni-fab__item-image {
500
+ width: 20px;
501
+ height: 20px;
502
+ margin-bottom: 4px;
503
+ }
504
+
505
+ .uni-fab__item-text {
506
+ color: #ffffff;
507
+ font-size: 12px;
508
+ line-height: 12px;
509
+ margin-top: 2px;
510
+ }
511
+
512
+ .uni-fab__item--first {
513
+ width: 55px;
514
+ }
491
515
  </style>