@gmcb/uv-ui 0.2.26

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 (285) hide show
  1. package/CHANGELOG.md +295 -0
  2. package/LICENSE +21 -0
  3. package/README.md +164 -0
  4. package/components/uv-action-sheet/props.js +50 -0
  5. package/components/uv-action-sheet/uv-action-sheet.vue +280 -0
  6. package/components/uv-album/uv-album.vue +312 -0
  7. package/components/uv-alert/props.js +45 -0
  8. package/components/uv-alert/uv-alert.vue +246 -0
  9. package/components/uv-avatar/props.js +85 -0
  10. package/components/uv-avatar/uv-avatar.vue +182 -0
  11. package/components/uv-avatar-group/props.js +53 -0
  12. package/components/uv-avatar-group/uv-avatar-group.vue +106 -0
  13. package/components/uv-back-top/props.js +58 -0
  14. package/components/uv-back-top/uv-back-top.vue +116 -0
  15. package/components/uv-badge/props.js +73 -0
  16. package/components/uv-badge/uv-badge.vue +176 -0
  17. package/components/uv-button/nvue.scss +46 -0
  18. package/components/uv-button/props.js +163 -0
  19. package/components/uv-button/uv-button.vue +529 -0
  20. package/components/uv-button/vue.scss +93 -0
  21. package/components/uv-calendar/calendar.js +546 -0
  22. package/components/uv-calendar/header.vue +104 -0
  23. package/components/uv-calendar/month.vue +616 -0
  24. package/components/uv-calendar/props.js +145 -0
  25. package/components/uv-calendar/uv-calendar.vue +390 -0
  26. package/components/uv-calendars/calendar-body.vue +376 -0
  27. package/components/uv-calendars/calendar-item.vue +248 -0
  28. package/components/uv-calendars/calendar.js +546 -0
  29. package/components/uv-calendars/i18n/en.json +12 -0
  30. package/components/uv-calendars/i18n/index.js +8 -0
  31. package/components/uv-calendars/i18n/zh-Hans.json +12 -0
  32. package/components/uv-calendars/i18n/zh-Hant.json +12 -0
  33. package/components/uv-calendars/util.js +435 -0
  34. package/components/uv-calendars/uv-calendars.vue +452 -0
  35. package/components/uv-cell/props.js +116 -0
  36. package/components/uv-cell/uv-cell.vue +209 -0
  37. package/components/uv-cell-group/props.js +15 -0
  38. package/components/uv-cell-group/uv-cell-group.vue +63 -0
  39. package/components/uv-checkbox/props.js +70 -0
  40. package/components/uv-checkbox/uv-checkbox.vue +371 -0
  41. package/components/uv-checkbox-group/props.js +84 -0
  42. package/components/uv-checkbox-group/uv-checkbox-group.vue +119 -0
  43. package/components/uv-code/props.js +35 -0
  44. package/components/uv-code/uv-code.vue +136 -0
  45. package/components/uv-code-input/props.js +83 -0
  46. package/components/uv-code-input/uv-code-input.vue +272 -0
  47. package/components/uv-col/props.js +30 -0
  48. package/components/uv-col/uv-col.vue +165 -0
  49. package/components/uv-collapse/props.js +20 -0
  50. package/components/uv-collapse/uv-collapse.vue +86 -0
  51. package/components/uv-collapse-item/props.js +60 -0
  52. package/components/uv-collapse-item/uv-collapse-item.vue +228 -0
  53. package/components/uv-column-notice/props.js +61 -0
  54. package/components/uv-column-notice/uv-column-notice.vue +176 -0
  55. package/components/uv-count-down/props.js +25 -0
  56. package/components/uv-count-down/utils.js +62 -0
  57. package/components/uv-count-down/uv-count-down.vue +169 -0
  58. package/components/uv-count-to/props.js +60 -0
  59. package/components/uv-count-to/uv-count-to.vue +187 -0
  60. package/components/uv-datetime-picker/props.js +130 -0
  61. package/components/uv-datetime-picker/uv-datetime-picker.vue +355 -0
  62. package/components/uv-divider/props.js +45 -0
  63. package/components/uv-divider/uv-divider.vue +113 -0
  64. package/components/uv-drop-down/uv-drop-down.vue +135 -0
  65. package/components/uv-drop-down-item/uv-drop-down-item.vue +169 -0
  66. package/components/uv-drop-down-popup/uv-drop-down-popup.vue +242 -0
  67. package/components/uv-empty/props.js +60 -0
  68. package/components/uv-empty/uv-empty.vue +126 -0
  69. package/components/uv-form/props.js +46 -0
  70. package/components/uv-form/uv-form.vue +209 -0
  71. package/components/uv-form/valid.js +1343 -0
  72. package/components/uv-form-item/props.js +49 -0
  73. package/components/uv-form-item/uv-form-item.vue +226 -0
  74. package/components/uv-gap/props.js +25 -0
  75. package/components/uv-gap/uv-gap.vue +36 -0
  76. package/components/uv-grid/props.js +20 -0
  77. package/components/uv-grid/uv-grid.vue +100 -0
  78. package/components/uv-grid-item/props.js +15 -0
  79. package/components/uv-grid-item/uv-grid-item.vue +223 -0
  80. package/components/uv-icon/icons.js +160 -0
  81. package/components/uv-icon/props.js +90 -0
  82. package/components/uv-icon/uv-icon.vue +226 -0
  83. package/components/uv-icon/uvicons.ttf +0 -0
  84. package/components/uv-image/props.js +100 -0
  85. package/components/uv-image/uv-image.vue +296 -0
  86. package/components/uv-index-anchor/props.js +30 -0
  87. package/components/uv-index-anchor/uv-index-anchor.vue +98 -0
  88. package/components/uv-index-item/uv-index-item.vue +87 -0
  89. package/components/uv-index-list/props.js +30 -0
  90. package/components/uv-index-list/uv-index-list.vue +461 -0
  91. package/components/uv-input/props.js +175 -0
  92. package/components/uv-input/uv-input.vue +348 -0
  93. package/components/uv-keyboard/props.js +95 -0
  94. package/components/uv-keyboard/uv-keyboard.vue +180 -0
  95. package/components/uv-keyboard-car/props.js +24 -0
  96. package/components/uv-keyboard-car/uv-keyboard-car.vue +347 -0
  97. package/components/uv-keyboard-number/props.js +19 -0
  98. package/components/uv-keyboard-number/uv-keyboard-number.vue +201 -0
  99. package/components/uv-line/props.js +34 -0
  100. package/components/uv-line/uv-line.vue +60 -0
  101. package/components/uv-line-progress/props.js +29 -0
  102. package/components/uv-line-progress/uv-line-progress.vue +146 -0
  103. package/components/uv-link/props.js +40 -0
  104. package/components/uv-link/uv-link.vue +83 -0
  105. package/components/uv-list/uv-list.vue +147 -0
  106. package/components/uv-list-item/uv-list-item.vue +535 -0
  107. package/components/uv-load-more/props.js +95 -0
  108. package/components/uv-load-more/uv-load-more.vue +152 -0
  109. package/components/uv-loading-icon/props.js +67 -0
  110. package/components/uv-loading-icon/uv-loading-icon.vue +347 -0
  111. package/components/uv-loading-page/props.js +55 -0
  112. package/components/uv-loading-page/uv-loading-page.vue +96 -0
  113. package/components/uv-modal/props.js +90 -0
  114. package/components/uv-modal/uv-modal.vue +245 -0
  115. package/components/uv-navbar/props.js +89 -0
  116. package/components/uv-navbar/uv-navbar.vue +245 -0
  117. package/components/uv-no-network/props.js +20 -0
  118. package/components/uv-no-network/uv-no-network.vue +222 -0
  119. package/components/uv-notice-bar/props.js +76 -0
  120. package/components/uv-notice-bar/uv-notice-bar.vue +110 -0
  121. package/components/uv-notify/props.js +45 -0
  122. package/components/uv-notify/uv-notify.vue +220 -0
  123. package/components/uv-number-box/props.js +118 -0
  124. package/components/uv-number-box/uv-number-box.vue +397 -0
  125. package/components/uv-overlay/props.js +25 -0
  126. package/components/uv-overlay/uv-overlay.vue +85 -0
  127. package/components/uv-parse/node/node.vue +576 -0
  128. package/components/uv-parse/parser.js +1335 -0
  129. package/components/uv-parse/uv-parse.vue +498 -0
  130. package/components/uv-pick-color/colors.js +217 -0
  131. package/components/uv-pick-color/props.js +47 -0
  132. package/components/uv-pick-color/uv-pick-color.vue +551 -0
  133. package/components/uv-picker/props.js +95 -0
  134. package/components/uv-picker/uv-picker.vue +329 -0
  135. package/components/uv-popup/keypress.js +45 -0
  136. package/components/uv-popup/uv-popup.vue +537 -0
  137. package/components/uv-preview-video/uv-preview-video.vue +52 -0
  138. package/components/uv-qrcode/cache.js +1 -0
  139. package/components/uv-qrcode/gcanvas/bridge/bridge-weex.js +241 -0
  140. package/components/uv-qrcode/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
  141. package/components/uv-qrcode/gcanvas/context-2d/FillStylePattern.js +8 -0
  142. package/components/uv-qrcode/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
  143. package/components/uv-qrcode/gcanvas/context-2d/RenderingContext.js +666 -0
  144. package/components/uv-qrcode/gcanvas/context-webgl/ActiveInfo.js +11 -0
  145. package/components/uv-qrcode/gcanvas/context-webgl/Buffer.js +21 -0
  146. package/components/uv-qrcode/gcanvas/context-webgl/Framebuffer.js +21 -0
  147. package/components/uv-qrcode/gcanvas/context-webgl/GLenum.js +298 -0
  148. package/components/uv-qrcode/gcanvas/context-webgl/GLmethod.js +142 -0
  149. package/components/uv-qrcode/gcanvas/context-webgl/GLtype.js +23 -0
  150. package/components/uv-qrcode/gcanvas/context-webgl/Program.js +21 -0
  151. package/components/uv-qrcode/gcanvas/context-webgl/Renderbuffer.js +21 -0
  152. package/components/uv-qrcode/gcanvas/context-webgl/RenderingContext.js +1191 -0
  153. package/components/uv-qrcode/gcanvas/context-webgl/Shader.js +22 -0
  154. package/components/uv-qrcode/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
  155. package/components/uv-qrcode/gcanvas/context-webgl/Texture.js +22 -0
  156. package/components/uv-qrcode/gcanvas/context-webgl/UniformLocation.js +22 -0
  157. package/components/uv-qrcode/gcanvas/context-webgl/classUtils.js +3 -0
  158. package/components/uv-qrcode/gcanvas/env/canvas.js +74 -0
  159. package/components/uv-qrcode/gcanvas/env/image.js +96 -0
  160. package/components/uv-qrcode/gcanvas/env/tool.js +24 -0
  161. package/components/uv-qrcode/gcanvas/index.js +39 -0
  162. package/components/uv-qrcode/props.js +85 -0
  163. package/components/uv-qrcode/qrcode.js +34 -0
  164. package/components/uv-qrcode/queue.js +41 -0
  165. package/components/uv-qrcode/uv-qrcode.vue +1038 -0
  166. package/components/uv-radio/props.js +65 -0
  167. package/components/uv-radio/uv-radio.vue +349 -0
  168. package/components/uv-radio-group/props.js +89 -0
  169. package/components/uv-radio-group/uv-radio-group.vue +115 -0
  170. package/components/uv-rate/props.js +73 -0
  171. package/components/uv-rate/uv-rate.vue +274 -0
  172. package/components/uv-read-more/props.js +62 -0
  173. package/components/uv-read-more/uv-read-more.vue +162 -0
  174. package/components/uv-row/props.js +20 -0
  175. package/components/uv-row/uv-row.vue +95 -0
  176. package/components/uv-row-notice/props.js +40 -0
  177. package/components/uv-row-notice/uv-row-notice.vue +341 -0
  178. package/components/uv-safe-bottom/uv-safe-bottom.vue +67 -0
  179. package/components/uv-scroll-list/nvue.js +29 -0
  180. package/components/uv-scroll-list/props.js +35 -0
  181. package/components/uv-scroll-list/scrollWxs.wxs +51 -0
  182. package/components/uv-scroll-list/uv-scroll-list.vue +218 -0
  183. package/components/uv-search/props.js +127 -0
  184. package/components/uv-search/uv-search.vue +311 -0
  185. package/components/uv-skeleton/props.js +65 -0
  186. package/components/uv-skeleton/uv-skeleton.vue +250 -0
  187. package/components/uv-skeletons/uv-skeletons.vue +247 -0
  188. package/components/uv-slider/props.js +58 -0
  189. package/components/uv-slider/uv-slider.vue +58 -0
  190. package/components/uv-status-bar/props.js +8 -0
  191. package/components/uv-status-bar/uv-status-bar.vue +54 -0
  192. package/components/uv-steps/props.js +40 -0
  193. package/components/uv-steps/uv-steps.vue +83 -0
  194. package/components/uv-steps-item/props.js +25 -0
  195. package/components/uv-steps-item/uv-steps-item.vue +347 -0
  196. package/components/uv-sticky/props.js +41 -0
  197. package/components/uv-sticky/uv-sticky.vue +223 -0
  198. package/components/uv-subsection/props.js +54 -0
  199. package/components/uv-subsection/uv-subsection.vue +269 -0
  200. package/components/uv-swipe-action/props.js +10 -0
  201. package/components/uv-swipe-action/uv-swipe-action.vue +65 -0
  202. package/components/uv-swipe-action-item/index - backup.wxs +256 -0
  203. package/components/uv-swipe-action-item/index.wxs +225 -0
  204. package/components/uv-swipe-action-item/nvue - backup.js +264 -0
  205. package/components/uv-swipe-action-item/nvue.js +182 -0
  206. package/components/uv-swipe-action-item/props.js +40 -0
  207. package/components/uv-swipe-action-item/uv-swipe-action-item.vue +200 -0
  208. package/components/uv-swipe-action-item/wxs.js +15 -0
  209. package/components/uv-swiper/props.js +136 -0
  210. package/components/uv-swiper/uv-swiper.vue +263 -0
  211. package/components/uv-swiper-indicator/props.js +30 -0
  212. package/components/uv-swiper-indicator/uv-swiper-indicator.vue +112 -0
  213. package/components/uv-switch/props.js +58 -0
  214. package/components/uv-switch/uv-switch.vue +182 -0
  215. package/components/uv-tabbar/props.js +50 -0
  216. package/components/uv-tabbar/uv-tabbar.vue +146 -0
  217. package/components/uv-tabbar-item/props.js +40 -0
  218. package/components/uv-tabbar-item/uv-tabbar-item.vue +146 -0
  219. package/components/uv-tabs/props.js +71 -0
  220. package/components/uv-tabs/uv-tabs.vue +391 -0
  221. package/components/uv-tags/props.js +104 -0
  222. package/components/uv-tags/uv-tags.vue +379 -0
  223. package/components/uv-text/props.js +113 -0
  224. package/components/uv-text/uv-text.vue +218 -0
  225. package/components/uv-text/value.js +87 -0
  226. package/components/uv-textarea/props.js +138 -0
  227. package/components/uv-textarea/uv-textarea.vue +238 -0
  228. package/components/uv-toast/uv-toast.vue +292 -0
  229. package/components/uv-toolbar/props.js +40 -0
  230. package/components/uv-toolbar/uv-toolbar.vue +109 -0
  231. package/components/uv-tooltip/props.js +60 -0
  232. package/components/uv-tooltip/uv-tooltip.vue +372 -0
  233. package/components/uv-transition/createAnimation.js +131 -0
  234. package/components/uv-transition/props.js +31 -0
  235. package/components/uv-transition/uv-transition.vue +320 -0
  236. package/components/uv-upload/mixin.js +22 -0
  237. package/components/uv-upload/props.js +130 -0
  238. package/components/uv-upload/utils.js +151 -0
  239. package/components/uv-upload/uv-upload.vue +488 -0
  240. package/components/uv-vtabs/props.js +79 -0
  241. package/components/uv-vtabs/uv-vtabs.vue +438 -0
  242. package/components/uv-vtabs-item/uv-vtabs-item.vue +68 -0
  243. package/components/uv-waterfall/props.js +69 -0
  244. package/components/uv-waterfall/uv-waterfall.vue +265 -0
  245. package/index.js +82 -0
  246. package/index.scss +7 -0
  247. package/libs/config/config.js +34 -0
  248. package/libs/css/color.scss +32 -0
  249. package/libs/css/common.scss +100 -0
  250. package/libs/css/components.scss +23 -0
  251. package/libs/css/variable.scss +111 -0
  252. package/libs/css/vue.scss +40 -0
  253. package/libs/function/colorGradient.js +134 -0
  254. package/libs/function/compress.js +27 -0
  255. package/libs/function/debounce.js +29 -0
  256. package/libs/function/digit.js +167 -0
  257. package/libs/function/index.js +734 -0
  258. package/libs/function/platform.js +75 -0
  259. package/libs/function/test.js +287 -0
  260. package/libs/function/throttle.js +30 -0
  261. package/libs/luch-request/adapters/index.js +132 -0
  262. package/libs/luch-request/core/InterceptorManager.js +51 -0
  263. package/libs/luch-request/core/Request.js +201 -0
  264. package/libs/luch-request/core/buildFullPath.js +20 -0
  265. package/libs/luch-request/core/defaults.js +33 -0
  266. package/libs/luch-request/core/dispatchRequest.js +6 -0
  267. package/libs/luch-request/core/mergeConfig.js +126 -0
  268. package/libs/luch-request/core/settle.js +16 -0
  269. package/libs/luch-request/helpers/buildURL.js +64 -0
  270. package/libs/luch-request/helpers/combineURLs.js +14 -0
  271. package/libs/luch-request/helpers/isAbsoluteURL.js +14 -0
  272. package/libs/luch-request/index.d.ts +197 -0
  273. package/libs/luch-request/index.js +2 -0
  274. package/libs/luch-request/utils/clone.js +264 -0
  275. package/libs/luch-request/utils.js +135 -0
  276. package/libs/mixin/button.js +13 -0
  277. package/libs/mixin/mixin.js +172 -0
  278. package/libs/mixin/mpMixin.js +8 -0
  279. package/libs/mixin/mpShare.js +13 -0
  280. package/libs/mixin/openType.js +47 -0
  281. package/libs/mixin/touch.js +59 -0
  282. package/libs/util/dayjs.js +216 -0
  283. package/libs/util/route.js +126 -0
  284. package/package.json +28 -0
  285. package/theme.scss +43 -0
@@ -0,0 +1,169 @@
1
+ <template>
2
+ <view
3
+ class="uv-count-down"
4
+ :style="[$uv.addStyle(customStyle)]">
5
+ <slot>
6
+ <text class="uv-count-down__text">{{ formattedTime }}</text>
7
+ </slot>
8
+ </view>
9
+ </template>
10
+ <script>
11
+ import mpMixin from '../../libs/mixin/mpMixin.js'
12
+ import mixin from '../../libs/mixin/mixin.js'
13
+ import props from './props.js';
14
+ import {
15
+ isSameSecond,
16
+ parseFormat,
17
+ parseTimeData
18
+ } from './utils';
19
+ /**
20
+ * uv-count-down 倒计时
21
+ * @description 该组件一般使用于某个活动的截止时间上,通过数字的变化,给用户明确的时间感受,提示用户进行某一个行为操作。
22
+ * @tutorial https://www.uvui.cn/components/countDown.html
23
+ * @property {String | Number} time 倒计时时长,单位ms (默认 0 )
24
+ * @property {String} format 时间格式,DD-日,HH-时,mm-分,ss-秒,SSS-毫秒 (默认 'HH:mm:ss' )
25
+ * @property {Boolean} autoStart 是否自动开始倒计时 (默认 true )
26
+ * @property {Boolean} millisecond 是否展示毫秒倒计时 (默认 false )
27
+ * @event {Function} finish 倒计时结束时触发
28
+ * @event {Function} change 倒计时变化时触发
29
+ * @event {Function} start 开始倒计时
30
+ * @event {Function} pause 暂停倒计时
31
+ * @event {Function} reset 重设倒计时,若 auto-start 为 true,重设后会自动开始倒计时
32
+ * @example <uv-count-down :time="time"></uv-count-down>
33
+ */
34
+ export default {
35
+ name: 'uv-count-down',
36
+ mixins: [mpMixin, mixin, props],
37
+ data() {
38
+ return {
39
+ timer: null,
40
+ // 各单位(天,时,分等)剩余时间
41
+ timeData: parseTimeData(0),
42
+ // 格式化后的时间,如"03:23:21"
43
+ formattedTime: '0',
44
+ // 倒计时是否正在进行中
45
+ runing: false,
46
+ endTime: 0, // 结束的毫秒时间戳
47
+ remainTime: 0, // 剩余的毫秒时间
48
+ }
49
+ },
50
+ watch: {
51
+ time(n) {
52
+ this.reset()
53
+ }
54
+ },
55
+ mounted() {
56
+ this.init()
57
+ },
58
+ methods: {
59
+ init() {
60
+ this.reset()
61
+ },
62
+ // 开始倒计时
63
+ start() {
64
+ if (this.runing) return
65
+ // 标识为进行中
66
+ this.runing = true
67
+ // 结束时间戳 = 此刻时间戳 + 剩余的时间
68
+ this.endTime = Date.now() + this.remainTime
69
+ this.toTick()
70
+ },
71
+ // 根据是否展示毫秒,执行不同操作函数
72
+ toTick() {
73
+ if (this.millisecond) {
74
+ this.microTick()
75
+ } else {
76
+ this.macroTick()
77
+ }
78
+ },
79
+ macroTick() {
80
+ this.clearTimeout()
81
+ // 每隔一定时间,更新一遍定时器的值
82
+ // 同时此定时器的作用也能带来毫秒级的更新
83
+ this.timer = setTimeout(() => {
84
+ // 获取剩余时间
85
+ const remain = this.getRemainTime()
86
+ // 重设剩余时间
87
+ if (!isSameSecond(remain, this.remainTime) || remain === 0) {
88
+ this.setRemainTime(remain)
89
+ }
90
+ // 如果剩余时间不为0,则继续检查更新倒计时
91
+ if (this.remainTime !== 0) {
92
+ this.macroTick()
93
+ }
94
+ }, 30)
95
+ },
96
+ microTick() {
97
+ this.clearTimeout()
98
+ this.timer = setTimeout(() => {
99
+ this.setRemainTime(this.getRemainTime())
100
+ if (this.remainTime !== 0) {
101
+ this.microTick()
102
+ }
103
+ }, 50)
104
+ },
105
+ // 获取剩余的时间
106
+ getRemainTime() {
107
+ // 取最大值,防止出现小于0的剩余时间值
108
+ return Math.max(this.endTime - Date.now(), 0)
109
+ },
110
+ // 设置剩余的时间
111
+ setRemainTime(remain) {
112
+ this.remainTime = remain
113
+ // 根据剩余的毫秒时间,得出该有天,小时,分钟等的值,返回一个对象
114
+ const timeData = parseTimeData(remain)
115
+ this.$emit('change', timeData)
116
+ // 得出格式化后的时间
117
+ this.formattedTime = parseFormat(this.format, timeData)
118
+ // 如果时间已到,停止倒计时
119
+ if (remain <= 0) {
120
+ this.pause()
121
+ this.$emit('finish')
122
+ }
123
+ },
124
+ // 重置倒计时
125
+ reset() {
126
+ this.pause()
127
+ this.remainTime = this.time
128
+ this.setRemainTime(this.remainTime)
129
+ if (this.autoStart) {
130
+ this.start()
131
+ }
132
+ },
133
+ // 暂停倒计时
134
+ pause() {
135
+ this.runing = false;
136
+ this.clearTimeout()
137
+ },
138
+ // 清空定时器
139
+ clearTimeout() {
140
+ clearTimeout(this.timer)
141
+ this.timer = null
142
+ }
143
+ },
144
+ // #ifdef VUE2
145
+ beforeDestroy() {
146
+ this.clearTimeout()
147
+ },
148
+ // #endif
149
+ // #ifdef VUE3
150
+ unmounted() {
151
+ this.clearTimeout()
152
+ }
153
+ // #endif
154
+ }
155
+ </script>
156
+ <style lang="scss" scoped>
157
+ @import '../../libs/css/components.scss';
158
+ @import '../../libs/css/color.scss';
159
+ $uv-count-down-text-color: $uv-content-color !default;
160
+ $uv-count-down-text-font-size: 15px !default;
161
+ $uv-count-down-text-line-height: 22px !default;
162
+ .uv-count-down {
163
+ &__text {
164
+ color: $uv-count-down-text-color;
165
+ font-size: $uv-count-down-text-font-size;
166
+ line-height: $uv-count-down-text-line-height;
167
+ }
168
+ }
169
+ </style>
@@ -0,0 +1,60 @@
1
+ export default {
2
+ props: {
3
+ // 开始的数值,默认从0增长到某一个数
4
+ startVal: {
5
+ type: [String, Number],
6
+ default: 0
7
+ },
8
+ // 要滚动的目标数值,必须
9
+ endVal: {
10
+ type: [String, Number],
11
+ default: 0
12
+ },
13
+ // 滚动到目标数值的动画持续时间,单位为毫秒(ms)
14
+ duration: {
15
+ type: [String, Number],
16
+ default: 2000
17
+ },
18
+ // 设置数值后是否自动开始滚动
19
+ autoplay: {
20
+ type: Boolean,
21
+ default: true
22
+ },
23
+ // 要显示的小数位数
24
+ decimals: {
25
+ type: [String, Number],
26
+ default: 0
27
+ },
28
+ // 是否在即将到达目标数值的时候,使用缓慢滚动的效果
29
+ useEasing: {
30
+ type: Boolean,
31
+ default: true
32
+ },
33
+ // 十进制分割
34
+ decimal: {
35
+ type: [String, Number],
36
+ default: '.'
37
+ },
38
+ // 字体颜色
39
+ color: {
40
+ type: String,
41
+ default: '#606266'
42
+ },
43
+ // 字体大小
44
+ fontSize: {
45
+ type: [String, Number],
46
+ default: 22
47
+ },
48
+ // 是否加粗字体
49
+ bold: {
50
+ type: Boolean,
51
+ default: false
52
+ },
53
+ // 千位分隔符,类似金额的分割(¥23,321.05中的",")
54
+ separator: {
55
+ type: String,
56
+ default: ''
57
+ },
58
+ ...uni.$uv?.props?.countTo
59
+ }
60
+ }
@@ -0,0 +1,187 @@
1
+ <template>
2
+ <text
3
+ class="uv-count-num"
4
+ :style="[{
5
+ fontSize: $uv.addUnit(fontSize),
6
+ fontWeight: bold ? 'bold' : 'normal',
7
+ color: color
8
+ },$uv.addStyle(customStyle)]"
9
+ >{{ displayValue }}</text>
10
+ </template>
11
+
12
+ <script>
13
+ import mpMixin from '../../libs/mixin/mpMixin.js'
14
+ import mixin from '../../libs/mixin/mixin.js'
15
+ import props from './props.js';
16
+ /**
17
+ * countTo 数字滚动
18
+ * @description 该组件一般用于需要滚动数字到某一个值的场景,目标要求是一个递增的值。
19
+ * @tutorial https://www.uvui.cn/components/countTo.html
20
+ * @property {String | Number} startVal 开始的数值,默认从0增长到某一个数(默认 0 )
21
+ * @property {String | Number} endVal 要滚动的目标数值,必须 (默认 0 )
22
+ * @property {String | Number} duration 滚动到目标数值的动画持续时间,单位为毫秒(ms) (默认 2000 )
23
+ * @property {Boolean} autoplay 设置数值后是否自动开始滚动 (默认 true )
24
+ * @property {String | Number} decimals 要显示的小数位数,见官网说明(默认 0 )
25
+ * @property {Boolean} useEasing 滚动结束时,是否缓动结尾,见官网说明(默认 true )
26
+ * @property {String} decimal 十进制分割 ( 默认 "." )
27
+ * @property {String} color 字体颜色( 默认 '#606266' )
28
+ * @property {String | Number} fontSize 字体大小,单位px( 默认 22 )
29
+ * @property {Boolean} bold 字体是否加粗(默认 false )
30
+ * @property {String} separator 千位分隔符,见官网说明
31
+ * @event {Function} end 数值滚动到目标值时触发
32
+ * @example <uv-count-to ref="uCountTo" :end-val="endVal" :autoplay="autoplay"></uv-count-to>
33
+ */
34
+ export default {
35
+ name: 'uv-count-to',
36
+ data() {
37
+ return {
38
+ localStartVal: this.startVal,
39
+ displayValue: this.formatNumber(this.startVal),
40
+ printVal: null,
41
+ paused: false, // 是否暂停
42
+ localDuration: Number(this.duration),
43
+ startTime: null, // 开始的时间
44
+ timestamp: null, // 时间戳
45
+ remaining: null, // 停留的时间
46
+ rAF: null,
47
+ lastTime: 0 // 上一次的时间
48
+ };
49
+ },
50
+ mixins: [mpMixin, mixin, props],
51
+ computed: {
52
+ countDown() {
53
+ return this.startVal > this.endVal;
54
+ }
55
+ },
56
+ watch: {
57
+ startVal() {
58
+ this.autoplay && this.start();
59
+ },
60
+ endVal() {
61
+ this.autoplay && this.start();
62
+ }
63
+ },
64
+ mounted() {
65
+ this.autoplay && this.start();
66
+ },
67
+ methods: {
68
+ easingFn(t, b, c, d) {
69
+ return (c * (-Math.pow(2, (-10 * t) / d) + 1) * 1024) / 1023 + b;
70
+ },
71
+ requestAnimationFrame(callback) {
72
+ const currTime = new Date().getTime();
73
+ // 为了使setTimteout的尽可能的接近每秒60帧的效果
74
+ const timeToCall = Math.max(0, 16 - (currTime - this.lastTime));
75
+ const id = setTimeout(() => {
76
+ callback(currTime + timeToCall);
77
+ }, timeToCall);
78
+ this.lastTime = currTime + timeToCall;
79
+ return id;
80
+ },
81
+ cancelAnimationFrame(id) {
82
+ clearTimeout(id);
83
+ },
84
+ // 开始滚动数字
85
+ start() {
86
+ this.localStartVal = this.startVal;
87
+ this.startTime = null;
88
+ this.localDuration = this.duration;
89
+ this.paused = false;
90
+ this.rAF = this.requestAnimationFrame(this.count);
91
+ },
92
+ // 暂定状态,从暂停状态开始滚动;或者滚动状态下,暂停
93
+ restart() {
94
+ if (this.paused) {
95
+ this.resume();
96
+ this.paused = false;
97
+ } else {
98
+ this.stop();
99
+ this.paused = true;
100
+ }
101
+ },
102
+ // 暂停
103
+ stop() {
104
+ this.cancelAnimationFrame(this.rAF);
105
+ this.paused = true;
106
+ },
107
+ // 重新开始(暂停的情况下)
108
+ resume() {
109
+ if (!this.remaining) return;
110
+ this.startTime = 0;
111
+ this.localDuration = this.remaining;
112
+ this.localStartVal = this.printVal;
113
+ this.requestAnimationFrame(this.count);
114
+ },
115
+ // 重置
116
+ reset() {
117
+ this.startTime = null;
118
+ this.cancelAnimationFrame(this.rAF);
119
+ this.displayValue = this.formatNumber(this.startVal);
120
+ },
121
+ count(timestamp) {
122
+ if (!this.startTime) this.startTime = timestamp;
123
+ this.timestamp = timestamp;
124
+ const progress = timestamp - this.startTime;
125
+ this.remaining = this.localDuration - progress;
126
+ if (this.useEasing) {
127
+ if (this.countDown) {
128
+ this.printVal = this.localStartVal - this.easingFn(progress, 0, this.localStartVal - this.endVal, this.localDuration);
129
+ } else {
130
+ this.printVal = this.easingFn(progress, this.localStartVal, this.endVal - this.localStartVal, this.localDuration);
131
+ }
132
+ } else {
133
+ if (this.countDown) {
134
+ this.printVal = this.localStartVal - (this.localStartVal - this.endVal) * (progress / this.localDuration);
135
+ } else {
136
+ this.printVal = this.localStartVal + (this.endVal - this.localStartVal) * (progress / this.localDuration);
137
+ }
138
+ }
139
+ if (this.countDown) {
140
+ this.printVal = this.printVal < this.endVal ? this.endVal : this.printVal;
141
+ } else {
142
+ this.printVal = this.printVal > this.endVal ? this.endVal : this.printVal;
143
+ }
144
+ this.displayValue = this.formatNumber(this.printVal) || 0;
145
+ if (progress < this.localDuration) {
146
+ this.rAF = this.requestAnimationFrame(this.count);
147
+ } else {
148
+ this.$emit('end');
149
+ }
150
+ },
151
+ // 判断是否数字
152
+ isNumber(val) {
153
+ return !isNaN(parseFloat(val));
154
+ },
155
+ formatNumber(num) {
156
+ // 将num转为Number类型,因为其值可能为字符串数值,调用toFixed会报错
157
+ num = Number(num);
158
+ num = num.toFixed(Number(this.decimals));
159
+ num += '';
160
+ const x = num.split('.');
161
+ let x1 = x[0];
162
+ const x2 = x.length > 1 ? `${this.decimal}${x[1]}` : '';
163
+ const rgx = /(\d+)(\d{3})/;
164
+ if (this.separator && !this.isNumber(this.separator)) {
165
+ while (rgx.test(x1)) {
166
+ x1 = x1.replace(rgx, '$1' + this.separator + '$2');
167
+ }
168
+ }
169
+ return x1 + x2;
170
+ },
171
+ destroyed() {
172
+ this.cancelAnimationFrame(this.rAF);
173
+ }
174
+ }
175
+ };
176
+ </script>
177
+
178
+ <style lang="scss" scoped>
179
+ @import '../../libs/css/components.scss';
180
+
181
+ .uv-count-num {
182
+ /* #ifndef APP-NVUE */
183
+ display: inline-flex;
184
+ /* #endif */
185
+ text-align: center;
186
+ }
187
+ </style>
@@ -0,0 +1,130 @@
1
+ export default {
2
+ props: {
3
+ value: {
4
+ type: [String, Number],
5
+ default: ''
6
+ },
7
+ modelValue: {
8
+ type: [String, Number],
9
+ default: ''
10
+ },
11
+ // 是否打开组件
12
+ show: {
13
+ type: Boolean,
14
+ default: false
15
+ },
16
+ // 是否展示顶部的操作栏
17
+ showToolbar: {
18
+ type: Boolean,
19
+ default: true
20
+ },
21
+ // 顶部标题
22
+ title: {
23
+ type: String,
24
+ default: ''
25
+ },
26
+ // 展示格式,mode=date为日期选择,mode=time为时间选择,mode=year-month为年月选择,mode=datetime为日期时间选择
27
+ mode: {
28
+ type: String,
29
+ default: 'datetime'
30
+ },
31
+ // 可选的最大时间
32
+ maxDate: {
33
+ type: Number,
34
+ // 最大默认值为后10年
35
+ default: new Date(new Date().getFullYear() + 10, 0, 1).getTime()
36
+ },
37
+ // 可选的最小时间
38
+ minDate: {
39
+ type: Number,
40
+ // 最小默认值为前10年
41
+ default: new Date(new Date().getFullYear() - 10, 0, 1).getTime()
42
+ },
43
+ // 可选的最小小时,仅mode=time有效
44
+ minHour: {
45
+ type: Number,
46
+ default: 0
47
+ },
48
+ // 可选的最大小时,仅mode=time有效
49
+ maxHour: {
50
+ type: Number,
51
+ default: 23
52
+ },
53
+ // 可选的最小分钟,仅mode=time有效
54
+ minMinute: {
55
+ type: Number,
56
+ default: 0
57
+ },
58
+ // 可选的最大分钟,仅mode=time有效
59
+ maxMinute: {
60
+ type: Number,
61
+ default: 59
62
+ },
63
+ // 选项过滤函数
64
+ filter: {
65
+ type: [Function, null],
66
+ default: null
67
+ },
68
+ // 选项格式化函数
69
+ formatter: {
70
+ type: [Function, null],
71
+ default: null
72
+ },
73
+ // 是否显示加载中状态
74
+ loading: {
75
+ type: Boolean,
76
+ default: false
77
+ },
78
+ // 各列中,单个选项的高度
79
+ itemHeight: {
80
+ type: [String, Number],
81
+ default: 44
82
+ },
83
+ // 取消按钮的文字
84
+ cancelText: {
85
+ type: String,
86
+ default: '取消'
87
+ },
88
+ // 确认按钮的文字
89
+ confirmText: {
90
+ type: String,
91
+ default: '确认'
92
+ },
93
+ // 取消按钮的颜色
94
+ cancelColor: {
95
+ type: String,
96
+ default: '#909193'
97
+ },
98
+ // 确认按钮的颜色
99
+ confirmColor: {
100
+ type: String,
101
+ default: '#3c9cff'
102
+ },
103
+ // 每列中可见选项的数量
104
+ visibleItemCount: {
105
+ type: [String, Number],
106
+ default: 5
107
+ },
108
+ // 是否允许点击遮罩关闭选择器
109
+ closeOnClickOverlay: {
110
+ type: Boolean,
111
+ default: true
112
+ },
113
+ // 是否允许点击确认关闭选择器
114
+ closeOnClickConfirm: {
115
+ type: Boolean,
116
+ default: true
117
+ },
118
+ // 是否清空上次选择内容
119
+ clearDate: {
120
+ type: Boolean,
121
+ default: false
122
+ },
123
+ // 圆角
124
+ round: {
125
+ type: [String, Number],
126
+ default: 0
127
+ },
128
+ ...uni.$uv?.props?.datetimePicker
129
+ }
130
+ }