wedux-ui 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +184 -0
  3. package/miniprogram_dist/behaviors/formField.js +35 -0
  4. package/miniprogram_dist/components/avatar/avatar.js +70 -0
  5. package/miniprogram_dist/components/avatar/avatar.json +4 -0
  6. package/miniprogram_dist/components/avatar/avatar.scss +68 -0
  7. package/miniprogram_dist/components/avatar/avatar.wxml +15 -0
  8. package/miniprogram_dist/components/avatar-group/avatar-group.js +45 -0
  9. package/miniprogram_dist/components/avatar-group/avatar-group.json +7 -0
  10. package/miniprogram_dist/components/avatar-group/avatar-group.scss +4 -0
  11. package/miniprogram_dist/components/avatar-group/avatar-group.wxml +3 -0
  12. package/miniprogram_dist/components/back-top/back-top.js +68 -0
  13. package/miniprogram_dist/components/back-top/back-top.json +4 -0
  14. package/miniprogram_dist/components/back-top/back-top.scss +43 -0
  15. package/miniprogram_dist/components/back-top/back-top.wxml +10 -0
  16. package/miniprogram_dist/components/badge/badge.js +100 -0
  17. package/miniprogram_dist/components/badge/badge.json +4 -0
  18. package/miniprogram_dist/components/badge/badge.scss +98 -0
  19. package/miniprogram_dist/components/badge/badge.wxml +11 -0
  20. package/miniprogram_dist/components/button/button.js +152 -0
  21. package/miniprogram_dist/components/button/button.json +4 -0
  22. package/miniprogram_dist/components/button/button.scss +499 -0
  23. package/miniprogram_dist/components/button/button.wxml +21 -0
  24. package/miniprogram_dist/components/button-group/button-group.js +51 -0
  25. package/miniprogram_dist/components/button-group/button-group.json +4 -0
  26. package/miniprogram_dist/components/button-group/button-group.scss +8 -0
  27. package/miniprogram_dist/components/button-group/button-group.wxml +3 -0
  28. package/miniprogram_dist/components/calendar/calendar.js +308 -0
  29. package/miniprogram_dist/components/calendar/calendar.json +4 -0
  30. package/miniprogram_dist/components/calendar/calendar.scss +141 -0
  31. package/miniprogram_dist/components/calendar/calendar.wxml +47 -0
  32. package/miniprogram_dist/components/card/card.js +44 -0
  33. package/miniprogram_dist/components/card/card.json +4 -0
  34. package/miniprogram_dist/components/card/card.scss +143 -0
  35. package/miniprogram_dist/components/card/card.wxml +31 -0
  36. package/miniprogram_dist/components/checkbox/checkbox.js +43 -0
  37. package/miniprogram_dist/components/checkbox/checkbox.json +4 -0
  38. package/miniprogram_dist/components/checkbox/checkbox.scss +77 -0
  39. package/miniprogram_dist/components/checkbox/checkbox.wxml +13 -0
  40. package/miniprogram_dist/components/checkbox-button/checkbox-button.js +43 -0
  41. package/miniprogram_dist/components/checkbox-button/checkbox-button.json +4 -0
  42. package/miniprogram_dist/components/checkbox-button/checkbox-button.scss +39 -0
  43. package/miniprogram_dist/components/checkbox-button/checkbox-button.wxml +8 -0
  44. package/miniprogram_dist/components/checkbox-group/checkbox-group.js +84 -0
  45. package/miniprogram_dist/components/checkbox-group/checkbox-group.json +4 -0
  46. package/miniprogram_dist/components/checkbox-group/checkbox-group.scss +9 -0
  47. package/miniprogram_dist/components/checkbox-group/checkbox-group.wxml +3 -0
  48. package/miniprogram_dist/components/color-picker/color-picker.js +348 -0
  49. package/miniprogram_dist/components/color-picker/color-picker.json +7 -0
  50. package/miniprogram_dist/components/color-picker/color-picker.scss +383 -0
  51. package/miniprogram_dist/components/color-picker/color-picker.wxml +232 -0
  52. package/miniprogram_dist/components/date-picker/date-picker.js +1289 -0
  53. package/miniprogram_dist/components/date-picker/date-picker.json +7 -0
  54. package/miniprogram_dist/components/date-picker/date-picker.scss +468 -0
  55. package/miniprogram_dist/components/date-picker/date-picker.wxml +214 -0
  56. package/miniprogram_dist/components/divider/divider.js +34 -0
  57. package/miniprogram_dist/components/divider/divider.json +4 -0
  58. package/miniprogram_dist/components/divider/divider.scss +75 -0
  59. package/miniprogram_dist/components/divider/divider.wxml +8 -0
  60. package/miniprogram_dist/components/drawer/drawer.js +104 -0
  61. package/miniprogram_dist/components/drawer/drawer.json +4 -0
  62. package/miniprogram_dist/components/drawer/drawer.scss +171 -0
  63. package/miniprogram_dist/components/drawer/drawer.wxml +22 -0
  64. package/miniprogram_dist/components/ellipsis/ellipsis.js +38 -0
  65. package/miniprogram_dist/components/ellipsis/ellipsis.json +4 -0
  66. package/miniprogram_dist/components/ellipsis/ellipsis.scss +22 -0
  67. package/miniprogram_dist/components/ellipsis/ellipsis.wxml +7 -0
  68. package/miniprogram_dist/components/flex/flex.js +81 -0
  69. package/miniprogram_dist/components/flex/flex.json +4 -0
  70. package/miniprogram_dist/components/flex/flex.scss +4 -0
  71. package/miniprogram_dist/components/flex/flex.wxml +3 -0
  72. package/miniprogram_dist/components/float-button/float-button.js +78 -0
  73. package/miniprogram_dist/components/float-button/float-button.json +4 -0
  74. package/miniprogram_dist/components/float-button/float-button.scss +54 -0
  75. package/miniprogram_dist/components/float-button/float-button.wxml +9 -0
  76. package/miniprogram_dist/components/form/form.js +142 -0
  77. package/miniprogram_dist/components/form/form.json +4 -0
  78. package/miniprogram_dist/components/form/form.scss +11 -0
  79. package/miniprogram_dist/components/form/form.wxml +3 -0
  80. package/miniprogram_dist/components/form/validator.js +220 -0
  81. package/miniprogram_dist/components/form-item/form-item.js +240 -0
  82. package/miniprogram_dist/components/form-item/form-item.json +4 -0
  83. package/miniprogram_dist/components/form-item/form-item.scss +59 -0
  84. package/miniprogram_dist/components/form-item/form-item.wxml +33 -0
  85. package/miniprogram_dist/components/gradient-text/gradient-text.js +54 -0
  86. package/miniprogram_dist/components/gradient-text/gradient-text.json +4 -0
  87. package/miniprogram_dist/components/gradient-text/gradient-text.scss +7 -0
  88. package/miniprogram_dist/components/gradient-text/gradient-text.wxml +1 -0
  89. package/miniprogram_dist/components/h/h.js +60 -0
  90. package/miniprogram_dist/components/h/h.json +4 -0
  91. package/miniprogram_dist/components/h/h.scss +53 -0
  92. package/miniprogram_dist/components/h/h.wxml +1 -0
  93. package/miniprogram_dist/components/highlight/highlight.js +77 -0
  94. package/miniprogram_dist/components/highlight/highlight.json +4 -0
  95. package/miniprogram_dist/components/highlight/highlight.scss +8 -0
  96. package/miniprogram_dist/components/highlight/highlight.wxml +12 -0
  97. package/miniprogram_dist/components/infinite-scroll/infinite-scroll.js +31 -0
  98. package/miniprogram_dist/components/infinite-scroll/infinite-scroll.json +4 -0
  99. package/miniprogram_dist/components/infinite-scroll/infinite-scroll.scss +31 -0
  100. package/miniprogram_dist/components/infinite-scroll/infinite-scroll.wxml +12 -0
  101. package/miniprogram_dist/components/input/input.js +59 -0
  102. package/miniprogram_dist/components/input/input.json +4 -0
  103. package/miniprogram_dist/components/input/input.scss +96 -0
  104. package/miniprogram_dist/components/input/input.wxml +34 -0
  105. package/miniprogram_dist/components/input-otp/input-otp.js +106 -0
  106. package/miniprogram_dist/components/input-otp/input-otp.json +4 -0
  107. package/miniprogram_dist/components/input-otp/input-otp.scss +122 -0
  108. package/miniprogram_dist/components/input-otp/input-otp.wxml +38 -0
  109. package/miniprogram_dist/components/layout/layout.js +50 -0
  110. package/miniprogram_dist/components/layout/layout.json +4 -0
  111. package/miniprogram_dist/components/layout/layout.scss +10 -0
  112. package/miniprogram_dist/components/layout/layout.wxml +3 -0
  113. package/miniprogram_dist/components/layout-content/layout-content.js +47 -0
  114. package/miniprogram_dist/components/layout-content/layout-content.json +4 -0
  115. package/miniprogram_dist/components/layout-content/layout-content.scss +5 -0
  116. package/miniprogram_dist/components/layout-content/layout-content.wxml +13 -0
  117. package/miniprogram_dist/components/layout-footer/layout-footer.js +59 -0
  118. package/miniprogram_dist/components/layout-footer/layout-footer.json +4 -0
  119. package/miniprogram_dist/components/layout-footer/layout-footer.scss +23 -0
  120. package/miniprogram_dist/components/layout-footer/layout-footer.wxml +16 -0
  121. package/miniprogram_dist/components/layout-header/layout-header.js +59 -0
  122. package/miniprogram_dist/components/layout-header/layout-header.json +4 -0
  123. package/miniprogram_dist/components/layout-header/layout-header.scss +23 -0
  124. package/miniprogram_dist/components/layout-header/layout-header.wxml +16 -0
  125. package/miniprogram_dist/components/layout-sider/layout-sider.js +48 -0
  126. package/miniprogram_dist/components/layout-sider/layout-sider.json +4 -0
  127. package/miniprogram_dist/components/layout-sider/layout-sider.scss +13 -0
  128. package/miniprogram_dist/components/layout-sider/layout-sider.wxml +5 -0
  129. package/miniprogram_dist/components/list/list.js +55 -0
  130. package/miniprogram_dist/components/list/list.json +4 -0
  131. package/miniprogram_dist/components/list/list.scss +51 -0
  132. package/miniprogram_dist/components/list/list.wxml +9 -0
  133. package/miniprogram_dist/components/list-item/list-item.js +24 -0
  134. package/miniprogram_dist/components/list-item/list-item.json +4 -0
  135. package/miniprogram_dist/components/list-item/list-item.scss +51 -0
  136. package/miniprogram_dist/components/list-item/list-item.wxml +14 -0
  137. package/miniprogram_dist/components/navigation-bar/navigation-bar.js +77 -0
  138. package/miniprogram_dist/components/navigation-bar/navigation-bar.json +4 -0
  139. package/miniprogram_dist/components/navigation-bar/navigation-bar.scss +63 -0
  140. package/miniprogram_dist/components/navigation-bar/navigation-bar.wxml +35 -0
  141. package/miniprogram_dist/components/number-animation/number-animation.js +124 -0
  142. package/miniprogram_dist/components/number-animation/number-animation.json +4 -0
  143. package/miniprogram_dist/components/number-animation/number-animation.scss +3 -0
  144. package/miniprogram_dist/components/number-animation/number-animation.wxml +1 -0
  145. package/miniprogram_dist/components/popover/popover.js +183 -0
  146. package/miniprogram_dist/components/popover/popover.json +4 -0
  147. package/miniprogram_dist/components/popover/popover.scss +69 -0
  148. package/miniprogram_dist/components/popover/popover.wxml +19 -0
  149. package/miniprogram_dist/components/qr-code/qr-code.js +216 -0
  150. package/miniprogram_dist/components/qr-code/qr-code.json +4 -0
  151. package/miniprogram_dist/components/qr-code/qr-code.scss +8 -0
  152. package/miniprogram_dist/components/qr-code/qr-code.wxml +16 -0
  153. package/miniprogram_dist/components/radio/radio.js +38 -0
  154. package/miniprogram_dist/components/radio/radio.json +4 -0
  155. package/miniprogram_dist/components/radio/radio.scss +50 -0
  156. package/miniprogram_dist/components/radio/radio.wxml +12 -0
  157. package/miniprogram_dist/components/radio-button/radio-button.js +39 -0
  158. package/miniprogram_dist/components/radio-button/radio-button.json +4 -0
  159. package/miniprogram_dist/components/radio-button/radio-button.scss +39 -0
  160. package/miniprogram_dist/components/radio-button/radio-button.wxml +8 -0
  161. package/miniprogram_dist/components/radio-group/radio-group.js +72 -0
  162. package/miniprogram_dist/components/radio-group/radio-group.json +4 -0
  163. package/miniprogram_dist/components/radio-group/radio-group.scss +9 -0
  164. package/miniprogram_dist/components/radio-group/radio-group.wxml +3 -0
  165. package/miniprogram_dist/components/rate/rate.js +90 -0
  166. package/miniprogram_dist/components/rate/rate.json +4 -0
  167. package/miniprogram_dist/components/rate/rate.scss +59 -0
  168. package/miniprogram_dist/components/rate/rate.wxml +16 -0
  169. package/miniprogram_dist/components/select/select.js +201 -0
  170. package/miniprogram_dist/components/select/select.json +7 -0
  171. package/miniprogram_dist/components/select/select.scss +235 -0
  172. package/miniprogram_dist/components/select/select.wxml +79 -0
  173. package/miniprogram_dist/components/stepper/stepper.js +113 -0
  174. package/miniprogram_dist/components/stepper/stepper.json +4 -0
  175. package/miniprogram_dist/components/stepper/stepper.scss +73 -0
  176. package/miniprogram_dist/components/stepper/stepper.wxml +23 -0
  177. package/miniprogram_dist/components/switch/switch.js +42 -0
  178. package/miniprogram_dist/components/switch/switch.json +4 -0
  179. package/miniprogram_dist/components/switch/switch.scss +77 -0
  180. package/miniprogram_dist/components/switch/switch.wxml +10 -0
  181. package/miniprogram_dist/components/tab-bar/tab-bar.js +53 -0
  182. package/miniprogram_dist/components/tab-bar/tab-bar.json +4 -0
  183. package/miniprogram_dist/components/tab-bar/tab-bar.scss +53 -0
  184. package/miniprogram_dist/components/tab-bar/tab-bar.wxml +12 -0
  185. package/miniprogram_dist/components/tag/tag.js +87 -0
  186. package/miniprogram_dist/components/tag/tag.json +4 -0
  187. package/miniprogram_dist/components/tag/tag.scss +138 -0
  188. package/miniprogram_dist/components/tag/tag.wxml +12 -0
  189. package/miniprogram_dist/components/textarea/textarea.js +46 -0
  190. package/miniprogram_dist/components/textarea/textarea.json +4 -0
  191. package/miniprogram_dist/components/textarea/textarea.scss +51 -0
  192. package/miniprogram_dist/components/textarea/textarea.wxml +20 -0
  193. package/miniprogram_dist/components/theme-provider/presets.js +101 -0
  194. package/miniprogram_dist/components/theme-provider/theme-provider.js +34 -0
  195. package/miniprogram_dist/components/theme-provider/theme-provider.json +4 -0
  196. package/miniprogram_dist/components/theme-provider/theme-provider.scss +3 -0
  197. package/miniprogram_dist/components/theme-provider/theme-provider.wxml +3 -0
  198. package/miniprogram_dist/components/time-picker/time-picker.js +136 -0
  199. package/miniprogram_dist/components/time-picker/time-picker.json +7 -0
  200. package/miniprogram_dist/components/time-picker/time-picker.scss +135 -0
  201. package/miniprogram_dist/components/time-picker/time-picker.wxml +47 -0
  202. package/miniprogram_dist/components/tooltip/tooltip.js +179 -0
  203. package/miniprogram_dist/components/tooltip/tooltip.json +4 -0
  204. package/miniprogram_dist/components/tooltip/tooltip.scss +66 -0
  205. package/miniprogram_dist/components/tooltip/tooltip.wxml +17 -0
  206. package/miniprogram_dist/components/tree/tree.js +647 -0
  207. package/miniprogram_dist/components/tree/tree.json +4 -0
  208. package/miniprogram_dist/components/tree/tree.scss +178 -0
  209. package/miniprogram_dist/components/tree/tree.wxml +59 -0
  210. package/miniprogram_dist/components/tree-select/tree-select.js +260 -0
  211. package/miniprogram_dist/components/tree-select/tree-select.json +8 -0
  212. package/miniprogram_dist/components/tree-select/tree-select.scss +250 -0
  213. package/miniprogram_dist/components/tree-select/tree-select.wxml +118 -0
  214. package/miniprogram_dist/components/upload/upload.js +387 -0
  215. package/miniprogram_dist/components/upload/upload.json +4 -0
  216. package/miniprogram_dist/components/upload/upload.scss +258 -0
  217. package/miniprogram_dist/components/upload/upload.wxml +142 -0
  218. package/miniprogram_dist/components/watermark/watermark.js +260 -0
  219. package/miniprogram_dist/components/watermark/watermark.json +4 -0
  220. package/miniprogram_dist/components/watermark/watermark.scss +35 -0
  221. package/miniprogram_dist/components/watermark/watermark.wxml +13 -0
  222. package/miniprogram_dist/libs/qrcodegen.js +714 -0
  223. package/miniprogram_dist/libs/seemly.min.js +547 -0
  224. package/miniprogram_dist/libs/tempo_1_0_0.js +1264 -0
  225. package/miniprogram_dist/libs/validator_13_56_26.min.js +5282 -0
  226. package/miniprogram_dist/styles/demo.scss +96 -0
  227. package/miniprogram_dist/styles/iconfont.scss +91 -0
  228. package/miniprogram_dist/styles/theme.scss +126 -0
  229. package/miniprogram_dist/styles/tokens.scss +292 -0
  230. package/miniprogram_dist/utils/relations.js +21 -0
  231. package/package.json +25 -0
@@ -0,0 +1,13 @@
1
+ .w-layout-sider {
2
+ flex-shrink: 0;
3
+ background: var(--layout-sider-bg);
4
+ height: 100%;
5
+
6
+ &__scroll {
7
+ height: 100%;
8
+ }
9
+
10
+ &--bordered {
11
+ border-right: 1rpx solid var(--layout-border-color);
12
+ }
13
+ }
@@ -0,0 +1,5 @@
1
+ <view class="w-layout-sider {{bordered ? 'w-layout-sider--bordered' : ''}}" style="{{_style}}">
2
+ <scroll-view class="w-layout-sider__scroll" scroll-y="{{scrollY}}" bindscroll="_onScroll">
3
+ <slot></slot>
4
+ </scroll-view>
5
+ </view>
@@ -0,0 +1,55 @@
1
+ Component({
2
+ options: {
3
+ multipleSlots: true,
4
+ },
5
+
6
+ relations: {
7
+ '../list-item/list-item': {
8
+ type: 'descendant',
9
+ linked() {
10
+ this._updateChildren();
11
+ },
12
+ unlinked() {
13
+ this._updateChildren();
14
+ },
15
+ },
16
+ },
17
+
18
+ properties: {
19
+ bordered: {
20
+ type: Boolean,
21
+ value: false,
22
+ },
23
+ showDivider: {
24
+ type: Boolean,
25
+ value: true,
26
+ },
27
+ size: {
28
+ type: String,
29
+ value: 'medium',
30
+ },
31
+ },
32
+
33
+ observers: {
34
+ 'showDivider, size': function () {
35
+ this._updateChildren();
36
+ },
37
+ },
38
+
39
+ methods: {
40
+ _updateChildren() {
41
+ const items = this.getRelationNodes('../list-item/list-item');
42
+ if (!items || !items.length) return;
43
+
44
+ const { showDivider, size } = this.data;
45
+ const lastIndex = items.length - 1;
46
+
47
+ items.forEach((item, index) => {
48
+ item.setData({
49
+ _showDivider: showDivider && index < lastIndex,
50
+ _size: size,
51
+ });
52
+ });
53
+ },
54
+ },
55
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "apply-shared"
4
+ }
@@ -0,0 +1,51 @@
1
+ .w-list {
2
+ background-color: var(--w-list-bg);
3
+ color: var(--color-text-primary);
4
+ font-size: var(--font-size-md);
5
+
6
+ &--bordered {
7
+ border: 2rpx solid var(--w-list-border);
8
+ border-radius: var(--radius-lg);
9
+ }
10
+
11
+ &__header:empty,
12
+ &__footer:empty {
13
+ display: none;
14
+ }
15
+
16
+ &__header,
17
+ &__footer {
18
+ padding: var(--spacing-md) var(--spacing-lg);
19
+ font-size: var(--font-size-md);
20
+ color: var(--color-text-secondary);
21
+ font-weight: 500;
22
+ }
23
+
24
+ &__header {
25
+ border-bottom: 2rpx solid var(--w-list-border);
26
+ }
27
+
28
+ &__footer {
29
+ border-top: 2rpx solid var(--w-list-border);
30
+ }
31
+
32
+ &--small {
33
+ font-size: var(--font-size-sm);
34
+
35
+ .w-list__header,
36
+ .w-list__footer {
37
+ padding: var(--spacing-sm) var(--spacing-lg);
38
+ font-size: var(--font-size-sm);
39
+ }
40
+ }
41
+
42
+ &--large {
43
+ font-size: var(--font-size-lg);
44
+
45
+ .w-list__header,
46
+ .w-list__footer {
47
+ padding: var(--spacing-lg) var(--spacing-lg);
48
+ font-size: var(--font-size-lg);
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,9 @@
1
+ <view class="w-list {{bordered ? 'w-list--bordered' : ''}} w-list--{{size}}">
2
+ <view class="w-list__header">
3
+ <slot name="header" />
4
+ </view>
5
+ <slot />
6
+ <view class="w-list__footer">
7
+ <slot name="footer" />
8
+ </view>
9
+ </view>
@@ -0,0 +1,24 @@
1
+ Component({
2
+ options: {
3
+ multipleSlots: true,
4
+ },
5
+
6
+ relations: {
7
+ '../list/list': {
8
+ type: 'ancestor',
9
+ },
10
+ },
11
+
12
+ properties: {},
13
+
14
+ data: {
15
+ _showDivider: false,
16
+ _size: 'medium',
17
+ },
18
+
19
+ methods: {
20
+ handleTap(e) {
21
+ this.triggerEvent('tap', e.detail);
22
+ },
23
+ },
24
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "apply-shared"
4
+ }
@@ -0,0 +1,51 @@
1
+ .w-list-item {
2
+ position: relative;
3
+
4
+ &__body {
5
+ display: flex;
6
+ align-items: center;
7
+ padding: var(--spacing-md) var(--spacing-lg);
8
+ }
9
+
10
+ &__prefix:empty {
11
+ display: none;
12
+ }
13
+
14
+ &__prefix {
15
+ flex-shrink: 0;
16
+ margin-right: var(--spacing-lg);
17
+ }
18
+
19
+ &__main {
20
+ flex: 1;
21
+ min-width: 0;
22
+ }
23
+
24
+ &__suffix:empty {
25
+ display: none;
26
+ }
27
+
28
+ &__suffix {
29
+ flex-shrink: 0;
30
+ margin-left: var(--spacing-lg);
31
+ }
32
+
33
+ &__divider {
34
+ height: 2rpx;
35
+ background-color: var(--w-list-border);
36
+ margin: 0 var(--spacing-lg);
37
+ }
38
+
39
+ /* Size variants */
40
+ &--small {
41
+ .w-list-item__body {
42
+ padding: var(--spacing-sm) var(--spacing-lg);
43
+ }
44
+ }
45
+
46
+ &--large {
47
+ .w-list-item__body {
48
+ padding: var(--spacing-lg) var(--spacing-lg);
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,14 @@
1
+ <view class="w-list-item w-list-item--{{_size}}" bindtap="handleTap">
2
+ <view class="w-list-item__body">
3
+ <view class="w-list-item__prefix">
4
+ <slot name="prefix" />
5
+ </view>
6
+ <view class="w-list-item__main">
7
+ <slot />
8
+ </view>
9
+ <view class="w-list-item__suffix">
10
+ <slot name="suffix" />
11
+ </view>
12
+ </view>
13
+ <view class="w-list-item__divider" wx:if="{{_showDivider}}"></view>
14
+ </view>
@@ -0,0 +1,77 @@
1
+ Component({
2
+ options: {
3
+ multipleSlots: true,
4
+ },
5
+
6
+ properties: {
7
+ title: {
8
+ type: String,
9
+ value: '',
10
+ },
11
+ back: {
12
+ type: Boolean,
13
+ value: true,
14
+ },
15
+ useBackSlot: {
16
+ type: Boolean,
17
+ value: false,
18
+ },
19
+ useTitleSlot: {
20
+ type: Boolean,
21
+ value: false,
22
+ },
23
+ useContentSlot: {
24
+ type: Boolean,
25
+ value: false,
26
+ },
27
+ preventBack: {
28
+ type: Boolean,
29
+ value: false,
30
+ },
31
+ },
32
+
33
+ data: {
34
+ _statusBarHeight: 0,
35
+ _navbarHeight: 44,
36
+ _capsuleWidth: 0,
37
+ _showBack: false,
38
+ },
39
+
40
+ lifetimes: {
41
+ attached() {
42
+ const { statusBarHeight, windowWidth } = wx.getWindowInfo();
43
+ const { platform } = wx.getDeviceInfo();
44
+ const rect = wx.getMenuButtonBoundingClientRect();
45
+ const pages = getCurrentPages();
46
+
47
+ // 导航栏高度 = 胶囊按钮垂直居中所需高度
48
+ const navbarHeight = (rect.top - statusBarHeight) * 2 + rect.height;
49
+ // 右侧需要避让胶囊按钮的宽度
50
+ const capsuleWidth = windowWidth - rect.left;
51
+
52
+ this.setData({
53
+ _statusBarHeight: statusBarHeight,
54
+ _navbarHeight: navbarHeight,
55
+ _capsuleWidth: capsuleWidth,
56
+ _showBack: this.data.back && pages.length > 1,
57
+ _platform: platform,
58
+ });
59
+ },
60
+ },
61
+
62
+ observers: {
63
+ back(val) {
64
+ const pages = getCurrentPages();
65
+ this.setData({ _showBack: val && pages.length > 1 });
66
+ },
67
+ },
68
+
69
+ methods: {
70
+ _onBack() {
71
+ this.triggerEvent('back');
72
+ if (!this.data.preventBack) {
73
+ wx.navigateBack();
74
+ }
75
+ },
76
+ },
77
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "apply-shared"
4
+ }
@@ -0,0 +1,63 @@
1
+ @import '../../styles/iconfont.scss';
2
+
3
+ .w-navbar {
4
+ background-color: var(--navbar-bg);
5
+ }
6
+
7
+ .w-navbar__content {
8
+ position: relative;
9
+ display: flex;
10
+ align-items: center;
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ .w-navbar__back {
15
+ position: relative;
16
+ z-index: 1;
17
+ display: flex;
18
+ align-items: center;
19
+ justify-content: center;
20
+ width: 88rpx;
21
+ height: 100%;
22
+ }
23
+
24
+ .w-navbar__back--hover {
25
+ opacity: 0.5;
26
+ }
27
+
28
+ .w-navbar__back-slot {
29
+ display: flex;
30
+ align-items: center;
31
+ height: 100%;
32
+ }
33
+
34
+ .w-navbar__back-icon {
35
+ font-size: 52rpx;
36
+ color: var(--navbar-icon-color);
37
+ }
38
+
39
+ .w-navbar__custom-content {
40
+ flex: 1;
41
+ display: flex;
42
+ align-items: center;
43
+ height: 100%;
44
+ overflow: hidden;
45
+ }
46
+
47
+ .w-navbar__title {
48
+ position: absolute;
49
+ left: 0;
50
+ right: 0;
51
+ top: 0;
52
+ bottom: 0;
53
+ display: flex;
54
+ align-items: center;
55
+ justify-content: center;
56
+ font-size: var(--font-size-lg);
57
+ font-weight: 600;
58
+ color: var(--navbar-title-color);
59
+ box-sizing: border-box;
60
+ overflow: hidden;
61
+ white-space: nowrap;
62
+ text-overflow: ellipsis;
63
+ }
@@ -0,0 +1,35 @@
1
+ <view class="w-navbar" style="padding-top: {{_statusBarHeight}}px;">
2
+ <view
3
+ class="w-navbar__content"
4
+ style="height: {{_navbarHeight}}px; padding-right: {{_capsuleWidth}}px;"
5
+ >
6
+ <!-- content 插槽模式:占据胶囊左侧所有空间 -->
7
+ <view wx:if="{{useContentSlot}}" class="w-navbar__custom-content">
8
+ <slot name="content" />
9
+ </view>
10
+
11
+ <!-- 默认模式:返回按钮 + 标题 -->
12
+ <block wx:else>
13
+ <view
14
+ wx:if="{{_showBack}}"
15
+ class="w-navbar__back"
16
+ hover-class="w-navbar__back--hover"
17
+ bind:tap="_onBack"
18
+ >
19
+ <view wx:if="{{useBackSlot}}" class="w-navbar__back-slot">
20
+ <slot name="back" />
21
+ </view>
22
+ <view wx:else class="iconfont icon-left w-navbar__back-icon"></view>
23
+ </view>
24
+
25
+ <view
26
+ wx:if="{{useTitleSlot}}"
27
+ class="w-navbar__title"
28
+ style="padding: 0 {{_capsuleWidth}}px;"
29
+ >
30
+ <slot name="title" />
31
+ </view>
32
+ <view wx:else class="w-navbar__title" style="padding: 0 {{_capsuleWidth}}px;">{{title}}</view>
33
+ </block>
34
+ </view>
35
+ </view>
@@ -0,0 +1,124 @@
1
+ Component({
2
+ properties: {
3
+ from: {
4
+ type: Number,
5
+ value: 0,
6
+ },
7
+ to: {
8
+ type: Number,
9
+ value: 0,
10
+ },
11
+ duration: {
12
+ type: Number,
13
+ value: 2000,
14
+ },
15
+ precision: {
16
+ type: Number,
17
+ value: 0,
18
+ },
19
+ showSeparator: {
20
+ type: Boolean,
21
+ value: false,
22
+ },
23
+ active: {
24
+ type: Boolean,
25
+ value: true,
26
+ },
27
+ color: {
28
+ type: String,
29
+ value: '',
30
+ },
31
+ fontSize: {
32
+ type: String,
33
+ value: '',
34
+ },
35
+ },
36
+
37
+ data: {
38
+ _displayValue: '0',
39
+ _style: '',
40
+ },
41
+
42
+ lifetimes: {
43
+ attached() {
44
+ this._initialized = true;
45
+ this._animating = false;
46
+ this._timer = null;
47
+ this._currentValue = this.data.from;
48
+ if (this.data.active) {
49
+ this._animate(this.data.from, this.data.to);
50
+ } else {
51
+ this._updateDisplay(this.data.from);
52
+ }
53
+ },
54
+
55
+ detached() {
56
+ this._stopAnimation();
57
+ },
58
+ },
59
+
60
+ observers: {
61
+ to(to) {
62
+ if (!this._initialized || !this.data.active) return;
63
+ this._animate(this._currentValue ?? this.data.from, to);
64
+ },
65
+ 'color, fontSize'(color, fontSize) {
66
+ const parts = [];
67
+ if (color) parts.push(`color: ${color}`);
68
+ if (fontSize) parts.push(`font-size: ${fontSize}`);
69
+ this.setData({ _style: parts.join('; ') });
70
+ },
71
+ },
72
+
73
+ methods: {
74
+ play() {
75
+ this._animate(this.data.from, this.data.to);
76
+ },
77
+
78
+ _animate(from, to) {
79
+ this._stopAnimation();
80
+ this._animating = true;
81
+
82
+ const { duration } = this.data;
83
+ const startTime = Date.now();
84
+
85
+ this._timer = setInterval(() => {
86
+ const elapsed = Math.min(Date.now() - startTime, duration);
87
+ const progress = elapsed / duration;
88
+ // easeOut quintic: 1 - (1 - t)^5
89
+ const eased = 1 - Math.pow(1 - progress, 5);
90
+ const current = from + (to - from) * eased;
91
+
92
+ this._updateDisplay(current);
93
+
94
+ if (elapsed >= duration) {
95
+ this._stopAnimation();
96
+ this._updateDisplay(to);
97
+ this.triggerEvent('finish');
98
+ }
99
+ }, 16);
100
+ },
101
+
102
+ _stopAnimation() {
103
+ if (this._timer) {
104
+ clearInterval(this._timer);
105
+ this._timer = null;
106
+ }
107
+ this._animating = false;
108
+ },
109
+
110
+ _updateDisplay(value) {
111
+ this._currentValue = value;
112
+ const { precision, showSeparator } = this.data;
113
+ let str = value.toFixed(precision);
114
+
115
+ if (showSeparator) {
116
+ const parts = str.split('.');
117
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
118
+ str = parts.join('.');
119
+ }
120
+
121
+ this.setData({ _displayValue: str });
122
+ },
123
+ },
124
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "apply-shared"
4
+ }
@@ -0,0 +1,3 @@
1
+ .w-number-animation {
2
+ display: inline;
3
+ }
@@ -0,0 +1 @@
1
+ <text class="w-number-animation" style="{{_style}}">{{_displayValue}}</text>