@kengic/uni 0.3.2-beta.10

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 (166) hide show
  1. package/README.md +1 -0
  2. package/dist/index.css +1 -0
  3. package/dist/kengic-uni.js +5 -0
  4. package/dist/src/consts/i18n/en.d.ts +45 -0
  5. package/dist/src/consts/i18n/index.d.ts +90 -0
  6. package/dist/src/consts/i18n/zh_CN.d.ts +45 -0
  7. package/dist/src/consts/index.d.ts +1 -0
  8. package/dist/src/index.d.ts +2 -0
  9. package/dist/src/utils/index.d.ts +1 -0
  10. package/dist/src/utils/kg.util.d.ts +5 -0
  11. package/dist/uni-ui/index.ts +11 -0
  12. package/dist/uni-ui/uni-badge/uni-badge.vue +253 -0
  13. package/dist/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +41 -0
  14. package/dist/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +121 -0
  15. package/dist/uni-ui/uni-calendar/calendar.js +546 -0
  16. package/dist/uni-ui/uni-calendar/i18n/en.json +12 -0
  17. package/dist/uni-ui/uni-calendar/i18n/index.js +8 -0
  18. package/dist/uni-ui/uni-calendar/i18n/zh-Hans.json +12 -0
  19. package/dist/uni-ui/uni-calendar/i18n/zh-Hant.json +12 -0
  20. package/dist/uni-ui/uni-calendar/uni-calendar-item.vue +187 -0
  21. package/dist/uni-ui/uni-calendar/uni-calendar.vue +566 -0
  22. package/dist/uni-ui/uni-calendar/util.js +360 -0
  23. package/dist/uni-ui/uni-card/uni-card.vue +281 -0
  24. package/dist/uni-ui/uni-col/uni-col.vue +317 -0
  25. package/dist/uni-ui/uni-collapse/uni-collapse.vue +147 -0
  26. package/dist/uni-ui/uni-collapse-item/uni-collapse-item.vue +402 -0
  27. package/dist/uni-ui/uni-combox/uni-combox.vue +294 -0
  28. package/dist/uni-ui/uni-countdown/i18n/en.json +6 -0
  29. package/dist/uni-ui/uni-countdown/i18n/index.js +8 -0
  30. package/dist/uni-ui/uni-countdown/i18n/zh-Hans.json +6 -0
  31. package/dist/uni-ui/uni-countdown/i18n/zh-Hant.json +6 -0
  32. package/dist/uni-ui/uni-countdown/uni-countdown.vue +267 -0
  33. package/dist/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +821 -0
  34. package/dist/uni-ui/uni-data-picker/keypress.js +45 -0
  35. package/dist/uni-ui/uni-data-picker/uni-data-picker.vue +551 -0
  36. package/dist/uni-ui/uni-data-pickerview/uni-data-picker.js +622 -0
  37. package/dist/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +323 -0
  38. package/dist/uni-ui/uni-data-select/uni-data-select.vue +517 -0
  39. package/dist/uni-ui/uni-dateformat/date-format.js +200 -0
  40. package/dist/uni-ui/uni-dateformat/uni-dateformat.vue +88 -0
  41. package/dist/uni-ui/uni-datetime-picker/calendar-item.vue +177 -0
  42. package/dist/uni-ui/uni-datetime-picker/calendar.vue +928 -0
  43. package/dist/uni-ui/uni-datetime-picker/i18n/en.json +22 -0
  44. package/dist/uni-ui/uni-datetime-picker/i18n/index.js +8 -0
  45. package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +22 -0
  46. package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +22 -0
  47. package/dist/uni-ui/uni-datetime-picker/time-picker.vue +934 -0
  48. package/dist/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1026 -0
  49. package/dist/uni-ui/uni-datetime-picker/util.js +403 -0
  50. package/dist/uni-ui/uni-drawer/keypress.js +45 -0
  51. package/dist/uni-ui/uni-drawer/uni-drawer.vue +181 -0
  52. package/dist/uni-ui/uni-easyinput/common.js +56 -0
  53. package/dist/uni-ui/uni-easyinput/uni-easyinput.vue +660 -0
  54. package/dist/uni-ui/uni-fab/uni-fab.vue +491 -0
  55. package/dist/uni-ui/uni-fav/i18n/en.json +4 -0
  56. package/dist/uni-ui/uni-fav/i18n/index.js +8 -0
  57. package/dist/uni-ui/uni-fav/i18n/zh-Hans.json +4 -0
  58. package/dist/uni-ui/uni-fav/i18n/zh-Hant.json +4 -0
  59. package/dist/uni-ui/uni-fav/uni-fav.vue +161 -0
  60. package/dist/uni-ui/uni-file-picker/choose-and-upload-file.js +224 -0
  61. package/dist/uni-ui/uni-file-picker/uni-file-picker.vue +667 -0
  62. package/dist/uni-ui/uni-file-picker/upload-file.vue +325 -0
  63. package/dist/uni-ui/uni-file-picker/upload-image.vue +292 -0
  64. package/dist/uni-ui/uni-file-picker/utils.js +109 -0
  65. package/dist/uni-ui/uni-forms/uni-forms.vue +398 -0
  66. package/dist/uni-ui/uni-forms/utils.js +293 -0
  67. package/dist/uni-ui/uni-forms/validate.js +486 -0
  68. package/dist/uni-ui/uni-forms-item/uni-forms-item.vue +601 -0
  69. package/dist/uni-ui/uni-goods-nav/i18n/en.json +6 -0
  70. package/dist/uni-ui/uni-goods-nav/i18n/index.js +8 -0
  71. package/dist/uni-ui/uni-goods-nav/i18n/zh-Hans.json +6 -0
  72. package/dist/uni-ui/uni-goods-nav/i18n/zh-Hant.json +6 -0
  73. package/dist/uni-ui/uni-goods-nav/uni-goods-nav.vue +229 -0
  74. package/dist/uni-ui/uni-grid/uni-grid.vue +143 -0
  75. package/dist/uni-ui/uni-grid-item/uni-grid-item.vue +129 -0
  76. package/dist/uni-ui/uni-group/uni-group.vue +134 -0
  77. package/dist/uni-ui/uni-icons/icons.js +1169 -0
  78. package/dist/uni-ui/uni-icons/uni-icons.vue +96 -0
  79. package/dist/uni-ui/uni-icons/uniicons.css +663 -0
  80. package/dist/uni-ui/uni-icons/uniicons.ttf +0 -0
  81. package/dist/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +144 -0
  82. package/dist/uni-ui/uni-indexed-list/uni-indexed-list.vue +367 -0
  83. package/dist/uni-ui/uni-link/uni-link.vue +128 -0
  84. package/dist/uni-ui/uni-list/uni-list.vue +123 -0
  85. package/dist/uni-ui/uni-list/uni-refresh.vue +65 -0
  86. package/dist/uni-ui/uni-list/uni-refresh.wxs +87 -0
  87. package/dist/uni-ui/uni-list-ad/uni-list-ad.vue +107 -0
  88. package/dist/uni-ui/uni-list-chat/uni-list-chat.scss +58 -0
  89. package/dist/uni-ui/uni-list-chat/uni-list-chat.vue +593 -0
  90. package/dist/uni-ui/uni-list-item/uni-list-item.vue +534 -0
  91. package/dist/uni-ui/uni-load-more/i18n/en.json +5 -0
  92. package/dist/uni-ui/uni-load-more/i18n/index.js +8 -0
  93. package/dist/uni-ui/uni-load-more/i18n/zh-Hans.json +5 -0
  94. package/dist/uni-ui/uni-load-more/i18n/zh-Hant.json +5 -0
  95. package/dist/uni-ui/uni-load-more/uni-load-more.vue +399 -0
  96. package/dist/uni-ui/uni-nav-bar/uni-nav-bar.vue +357 -0
  97. package/dist/uni-ui/uni-nav-bar/uni-status-bar.vue +24 -0
  98. package/dist/uni-ui/uni-notice-bar/uni-notice-bar.vue +426 -0
  99. package/dist/uni-ui/uni-number-box/uni-number-box.vue +221 -0
  100. package/dist/uni-ui/uni-pagination/i18n/en.json +5 -0
  101. package/dist/uni-ui/uni-pagination/i18n/es.json +5 -0
  102. package/dist/uni-ui/uni-pagination/i18n/fr.json +5 -0
  103. package/dist/uni-ui/uni-pagination/i18n/index.js +12 -0
  104. package/dist/uni-ui/uni-pagination/i18n/zh-Hans.json +5 -0
  105. package/dist/uni-ui/uni-pagination/i18n/zh-Hant.json +5 -0
  106. package/dist/uni-ui/uni-pagination/uni-pagination.vue +465 -0
  107. package/dist/uni-ui/uni-popup/i18n/en.json +7 -0
  108. package/dist/uni-ui/uni-popup/i18n/index.js +9 -0
  109. package/dist/uni-ui/uni-popup/i18n/zh-Hans.json +7 -0
  110. package/dist/uni-ui/uni-popup/i18n/zh-Hant.json +7 -0
  111. package/dist/uni-ui/uni-popup/keypress.js +45 -0
  112. package/dist/uni-ui/uni-popup/popup.js +23 -0
  113. package/dist/uni-ui/uni-popup/uni-popup.vue +464 -0
  114. package/dist/uni-ui/uni-popup-dialog/keypress.js +45 -0
  115. package/dist/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +275 -0
  116. package/dist/uni-ui/uni-popup-message/uni-popup-message.vue +143 -0
  117. package/dist/uni-ui/uni-popup-share/uni-popup-share.vue +187 -0
  118. package/dist/uni-ui/uni-rate/uni-rate.vue +365 -0
  119. package/dist/uni-ui/uni-row/uni-row.vue +190 -0
  120. package/dist/uni-ui/uni-scss/changelog.md +8 -0
  121. package/dist/uni-ui/uni-scss/index.scss +1 -0
  122. package/dist/uni-ui/uni-scss/package.json +82 -0
  123. package/dist/uni-ui/uni-scss/readme.md +4 -0
  124. package/dist/uni-ui/uni-scss/styles/index.scss +7 -0
  125. package/dist/uni-ui/uni-scss/styles/setting/_border.scss +3 -0
  126. package/dist/uni-ui/uni-scss/styles/setting/_color.scss +66 -0
  127. package/dist/uni-ui/uni-scss/styles/setting/_radius.scss +55 -0
  128. package/dist/uni-ui/uni-scss/styles/setting/_space.scss +56 -0
  129. package/dist/uni-ui/uni-scss/styles/setting/_styles.scss +167 -0
  130. package/dist/uni-ui/uni-scss/styles/setting/_text.scss +24 -0
  131. package/dist/uni-ui/uni-scss/styles/setting/_variables.scss +146 -0
  132. package/dist/uni-ui/uni-scss/styles/tools/functions.scss +19 -0
  133. package/dist/uni-ui/uni-scss/theme.scss +31 -0
  134. package/dist/uni-ui/uni-scss/variables.scss +62 -0
  135. package/dist/uni-ui/uni-search-bar/i18n/en.json +4 -0
  136. package/dist/uni-ui/uni-search-bar/i18n/index.js +8 -0
  137. package/dist/uni-ui/uni-search-bar/i18n/zh-Hans.json +4 -0
  138. package/dist/uni-ui/uni-search-bar/i18n/zh-Hant.json +4 -0
  139. package/dist/uni-ui/uni-search-bar/uni-search-bar.vue +298 -0
  140. package/dist/uni-ui/uni-section/uni-section.vue +167 -0
  141. package/dist/uni-ui/uni-segmented-control/uni-segmented-control.vue +145 -0
  142. package/dist/uni-ui/uni-steps/uni-steps.vue +269 -0
  143. package/dist/uni-ui/uni-swipe-action/uni-swipe-action.vue +60 -0
  144. package/dist/uni-ui/uni-swipe-action-item/bindingx.js +302 -0
  145. package/dist/uni-ui/uni-swipe-action-item/isPC.js +12 -0
  146. package/dist/uni-ui/uni-swipe-action-item/mpalipay.js +195 -0
  147. package/dist/uni-ui/uni-swipe-action-item/mpother.js +260 -0
  148. package/dist/uni-ui/uni-swipe-action-item/mpwxs.js +84 -0
  149. package/dist/uni-ui/uni-swipe-action-item/render.js +270 -0
  150. package/dist/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +347 -0
  151. package/dist/uni-ui/uni-swipe-action-item/wx.wxs +341 -0
  152. package/dist/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +218 -0
  153. package/dist/uni-ui/uni-table/uni-table.vue +455 -0
  154. package/dist/uni-ui/uni-tag/uni-tag.vue +252 -0
  155. package/dist/uni-ui/uni-tbody/uni-tbody.vue +29 -0
  156. package/dist/uni-ui/uni-td/uni-td.vue +90 -0
  157. package/dist/uni-ui/uni-th/filter-dropdown.vue +511 -0
  158. package/dist/uni-ui/uni-th/uni-th.vue +285 -0
  159. package/dist/uni-ui/uni-thead/uni-thead.vue +129 -0
  160. package/dist/uni-ui/uni-title/uni-title.vue +171 -0
  161. package/dist/uni-ui/uni-tooltip/uni-tooltip.vue +68 -0
  162. package/dist/uni-ui/uni-tr/table-checkbox.vue +179 -0
  163. package/dist/uni-ui/uni-tr/uni-tr.vue +171 -0
  164. package/dist/uni-ui/uni-transition/createAnimation.js +131 -0
  165. package/dist/uni-ui/uni-transition/uni-transition.vue +281 -0
  166. package/package.json +90 -0
@@ -0,0 +1,491 @@
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>
41
+ <view class="fab-circle-h" :class="{'uni-fab__plus--active': isShow && content.length > 0}"></view> -->
42
+ </view>
43
+ </view>
44
+ </template>
45
+
46
+ <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
+ }
234
+ </script>
235
+
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
+ }
491
+ </style>
@@ -0,0 +1,4 @@
1
+ {
2
+ "uni-fav.collect": "collect",
3
+ "uni-fav.collected": "collected"
4
+ }
@@ -0,0 +1,8 @@
1
+ import en from './en.json'
2
+ import zhHans from './zh-Hans.json'
3
+ import zhHant from './zh-Hant.json'
4
+ export default {
5
+ en,
6
+ 'zh-Hans': zhHans,
7
+ 'zh-Hant': zhHant
8
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "uni-fav.collect": "收藏",
3
+ "uni-fav.collected": "已收藏"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "uni-fav.collect": "收藏",
3
+ "uni-fav.collected": "已收藏"
4
+ }
@@ -0,0 +1,161 @@
1
+ <template>
2
+ <view :class="[circle === true || circle === 'true' ? 'uni-fav--circle' : '']" :style="[{ backgroundColor: checked ? bgColorChecked : bgColor }]"
3
+ @click="onClick" class="uni-fav">
4
+ <!-- #ifdef MP-ALIPAY -->
5
+ <view class="uni-fav-star" v-if="!checked && (star === true || star === 'true')">
6
+ <uni-icons :color="fgColor" :style="{color: checked ? fgColorChecked : fgColor}" size="14" type="star-filled" />
7
+ </view>
8
+ <!-- #endif -->
9
+ <!-- #ifndef MP-ALIPAY -->
10
+ <uni-icons :color="fgColor" :style="{color: checked ? fgColorChecked : fgColor}" class="uni-fav-star" size="14" type="star-filled"
11
+ v-if="!checked && (star === true || star === 'true')" />
12
+ <!-- #endif -->
13
+ <text :style="{color: checked ? fgColorChecked : fgColor}" class="uni-fav-text">{{ checked ? contentFav : contentDefault }}</text>
14
+ </view>
15
+ </template>
16
+
17
+ <script>
18
+
19
+ /**
20
+ * Fav 收藏按钮
21
+ * @description 用于收藏功能,可点击切换选中、不选中的状态
22
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=864
23
+ * @property {Boolean} star = [true|false] 按钮是否带星星
24
+ * @property {String} bgColor 未收藏时的背景色
25
+ * @property {String} bgColorChecked 已收藏时的背景色
26
+ * @property {String} fgColor 未收藏时的文字颜色
27
+ * @property {String} fgColorChecked 已收藏时的文字颜色
28
+ * @property {Boolean} circle = [true|false] 是否为圆角
29
+ * @property {Boolean} checked = [true|false] 是否为已收藏
30
+ * @property {Object} contentText = [true|false] 收藏按钮文字
31
+ * @property {Boolean} stat 是否开启统计功能
32
+ * @event {Function} click 点击 fav按钮触发事件
33
+ * @example <uni-fav :checked="true"/>
34
+ */
35
+
36
+ import {
37
+ initVueI18n
38
+ } from '@dcloudio/uni-i18n'
39
+ import messages from './i18n'
40
+ const { t } = initVueI18n(messages)
41
+
42
+ export default {
43
+ name: "UniFav",
44
+ // TODO 兼容 vue3,需要注册事件
45
+ emits: ['click'],
46
+ props: {
47
+ star: {
48
+ type: [Boolean, String],
49
+ default: true
50
+ },
51
+ bgColor: {
52
+ type: String,
53
+ default: "#eeeeee"
54
+ },
55
+ fgColor: {
56
+ type: String,
57
+ default: "#666666"
58
+ },
59
+ bgColorChecked: {
60
+ type: String,
61
+ default: "#007aff"
62
+ },
63
+ fgColorChecked: {
64
+ type: String,
65
+ default: "#FFFFFF"
66
+ },
67
+ circle: {
68
+ type: [Boolean, String],
69
+ default: false
70
+ },
71
+ checked: {
72
+ type: Boolean,
73
+ default: false
74
+ },
75
+ contentText: {
76
+ type: Object,
77
+ default () {
78
+ return {
79
+ contentDefault: "",
80
+ contentFav: ""
81
+ };
82
+ }
83
+ },
84
+ stat:{
85
+ type: Boolean,
86
+ default: false
87
+ }
88
+ },
89
+ computed: {
90
+ contentDefault() {
91
+ return this.contentText.contentDefault || t("uni-fav.collect")
92
+ },
93
+ contentFav() {
94
+ return this.contentText.contentFav || t("uni-fav.collected")
95
+ },
96
+ },
97
+ watch: {
98
+ checked() {
99
+ if (uni.report && this.stat) {
100
+ if (this.checked) {
101
+ uni.report("收藏", "收藏");
102
+ } else {
103
+ uni.report("取消收藏", "取消收藏");
104
+ }
105
+ }
106
+ }
107
+ },
108
+ methods: {
109
+ onClick() {
110
+ this.$emit("click");
111
+ }
112
+ }
113
+ };
114
+ </script>
115
+
116
+ <style lang="scss" >
117
+ $fav-height: 25px;
118
+
119
+ .uni-fav {
120
+ /* #ifndef APP-NVUE */
121
+ display: flex;
122
+ /* #endif */
123
+ flex-direction: row;
124
+ align-items: center;
125
+ justify-content: center;
126
+ width: 60px;
127
+ height: $fav-height;
128
+ line-height: $fav-height;
129
+ text-align: center;
130
+ border-radius: 3px;
131
+ /* #ifdef H5 */
132
+ cursor: pointer;
133
+ /* #endif */
134
+ }
135
+
136
+ .uni-fav--circle {
137
+ border-radius: 30px;
138
+ }
139
+
140
+ .uni-fav-star {
141
+ /* #ifndef APP-NVUE */
142
+ display: flex;
143
+ /* #endif */
144
+ height: $fav-height;
145
+ line-height: 24px;
146
+ margin-right: 3px;
147
+ align-items: center;
148
+ justify-content: center;
149
+ }
150
+
151
+ .uni-fav-text {
152
+ /* #ifndef APP-NVUE */
153
+ display: flex;
154
+ /* #endif */
155
+ height: $fav-height;
156
+ line-height: $fav-height;
157
+ align-items: center;
158
+ justify-content: center;
159
+ font-size: 12px;
160
+ }
161
+ </style>