@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,355 @@
1
+ <template>
2
+ <uv-picker
3
+ ref="picker"
4
+ :closeOnClickOverlay="closeOnClickOverlay"
5
+ :closeOnClickConfirm="closeOnClickConfirm"
6
+ :columns="columns"
7
+ :title="title"
8
+ :itemHeight="itemHeight"
9
+ :showToolbar="showToolbar"
10
+ :visibleItemCount="visibleItemCount"
11
+ :defaultIndex="innerDefaultIndex"
12
+ :cancelText="cancelText"
13
+ :confirmText="confirmText"
14
+ :cancelColor="cancelColor"
15
+ :confirmColor="confirmColor"
16
+ :round="round"
17
+ @close="close"
18
+ @cancel="cancel"
19
+ @confirm="confirm"
20
+ @change="change"
21
+ >
22
+ </uv-picker>
23
+ </template>
24
+ <script>
25
+ function times(n, iteratee) {
26
+ let index = -1
27
+ const result = Array(n < 0 ? 0 : n)
28
+ while (++index < n) {
29
+ result[index] = iteratee(index)
30
+ }
31
+ return result
32
+ }
33
+ import mpMixin from '../../libs/mixin/mpMixin.js'
34
+ import mixin from '../../libs/mixin/mixin.js'
35
+ import props from './props.js';
36
+ import dayjs from '../../libs/util/dayjs.js'
37
+ /**
38
+ * DatetimePicker 时间日期选择器
39
+ * @description 此选择器用于时间日期
40
+ * @tutorial https://www.uvui.cn/components/datetimePicker.html
41
+ * @property {Boolean} showToolbar 是否显示顶部的操作栏 ( 默认 true )
42
+ * @property {String | Number} value 绑定值
43
+ * @property {String} title 顶部标题
44
+ * @property {String} mode 展示格式 mode=date为日期选择,mode=time为时间选择,mode=year-month为年月选择,mode=datetime为日期时间选择 ( 默认 ‘datetime )
45
+ * @property {Number} maxDate 可选的最大时间 默认值为后10年
46
+ * @property {Number} minDate 可选的最小时间 默认值为前10年
47
+ * @property {Number} minHour 可选的最小小时,仅mode=time有效 ( 默认 0 )
48
+ * @property {Number} maxHour 可选的最大小时,仅mode=time有效 ( 默认 23 )
49
+ * @property {Number} minMinute 可选的最小分钟,仅mode=time有效 ( 默认 0 )
50
+ * @property {Number} maxMinute 可选的最大分钟,仅mode=time有效 ( 默认 59 )
51
+ * @property {Function} filter 选项过滤函数
52
+ * @property {Function} formatter 选项格式化函数
53
+ * @property {Boolean} loading 是否显示加载中状态 ( 默认 false )
54
+ * @property {String | Number} itemHeight 各列中,单个选项的高度 ( 默认 44 )
55
+ * @property {String} cancelText 取消按钮的文字 ( 默认 '取消' )
56
+ * @property {String} confirmText 确认按钮的文字 ( 默认 '确认' )
57
+ * @property {String} cancelColor 取消按钮的颜色 ( 默认 '#909193' )
58
+ * @property {String} confirmColor 确认按钮的颜色 ( 默认 '#3c9cff' )
59
+ * @property {String | Number} visibleItemCount 每列中可见选项的数量 ( 默认 5 )
60
+ * @property {Boolean} closeOnClickOverlay 是否允许点击遮罩关闭选择器 ( 默认 true )
61
+ * @property {String | Number} round 圆角 ( 默认 0 )
62
+ * @event {Function} close 关闭选择器时触发
63
+ * @event {Function} confirm 点击确定按钮,返回当前选择的值
64
+ * @event {Function} change 当选择值变化时触发
65
+ * @event {Function} cancel 点击取消按钮
66
+ * @example <uv-datetime-picker ref="datetimepicker" :value="value1" mode="datetime" ></uv-datetime-picker>
67
+ */
68
+ export default {
69
+ name: 'uv-datetime-picker',
70
+ emits: ['close', 'cancel', 'confirm', 'input', 'change', 'update:modelValue'],
71
+ mixins: [mpMixin, mixin, props],
72
+ data() {
73
+ return {
74
+ columns: [],
75
+ innerDefaultIndex: [],
76
+ innerFormatter: (type, value) => value
77
+ }
78
+ },
79
+ watch: {
80
+ propsChange() {
81
+ this.init()
82
+ }
83
+ },
84
+ computed: {
85
+ // 如果以下这些变量发生了变化,意味着需要重新初始化各列的值
86
+ propsChange() {
87
+ const propsValue = this.value || this.modelValue;
88
+ return [this.mode, this.maxDate, this.minDate, this.minHour, this.maxHour, this.minMinute, this.maxMinute, this.filter, propsValue]
89
+ }
90
+ },
91
+ mounted() {
92
+ this.init()
93
+ },
94
+ methods: {
95
+ init() {
96
+ this.getValue();
97
+ this.updateColumnValue(this.innerValue)
98
+ },
99
+ getValue() {
100
+ const propsValue = this.value || this.modelValue;
101
+ this.innerValue = this.correctValue(propsValue)
102
+ },
103
+ // 在微信小程序中,不支持将函数当做props参数,故只能通过ref形式调用
104
+ setFormatter(e) {
105
+ this.innerFormatter = e
106
+ },
107
+ open() {
108
+ this.$refs.picker.open();
109
+ this.getValue();
110
+ this.updateColumnValue(this.innerValue);
111
+ },
112
+ close() {
113
+ this.$emit('close');
114
+ },
115
+ // 点击工具栏的取消按钮
116
+ cancel() {
117
+ this.$emit('cancel')
118
+ },
119
+ // 点击工具栏的确定按钮
120
+ confirm() {
121
+ this.$emit('confirm', {
122
+ value: this.innerValue,
123
+ mode: this.mode
124
+ })
125
+ if(!this.clearDate) {
126
+ this.$emit('input', this.innerValue)
127
+ this.$emit('update:modelValue', this.innerValue)
128
+ }
129
+ },
130
+ //用正则截取输出值,当出现多组数字时,抛出错误
131
+ intercept(e, type) {
132
+ let judge = e.match(/\d+/g)
133
+ //判断是否掺杂数字
134
+ if (judge.length > 1) {
135
+ this.$uv.error("请勿在过滤或格式化函数时添加数字")
136
+ return 0
137
+ } else if (type && judge[0].length == 4) { //判断是否是年份
138
+ return judge[0]
139
+ } else if (judge[0].length > 2) {
140
+ this.$uv.error("请勿在过滤或格式化函数时添加数字")
141
+ return 0
142
+ } else {
143
+ return judge[0]
144
+ }
145
+ },
146
+ // 列发生变化时触发
147
+ change(e) {
148
+ const { indexs, values } = e
149
+ let selectValue = ''
150
+ if (this.mode === 'time') {
151
+ // 根据value各列索引,从各列数组中,取出当前时间的选中值
152
+ selectValue = `${this.intercept(values[0][indexs[0]])}:${this.intercept(values[1][indexs[1]])}`
153
+ } else if (this.mode === 'year') {
154
+ const year = parseInt(this.intercept(values[0][indexs[0]], 'year'));
155
+ selectValue = Number(new Date(year, 0));
156
+ } else {
157
+ // 将选择的值转为数值,比如'03'转为数值的3,'2019'转为数值的2019
158
+ const year = parseInt(this.intercept(values[0][indexs[0]], 'year'))
159
+ const month = parseInt(this.intercept(values[1][indexs[1]]))
160
+ let date = parseInt(values[2] ? this.intercept(values[2][indexs[2]]) : 1)
161
+ let hour = 0,
162
+ minute = 0
163
+ // 此月份的最大天数
164
+ const maxDate = dayjs(`${year}-${month}`).daysInMonth()
165
+ // year-month模式下,date不会出现在列中,设置为1,为了符合后边需要减1的需求
166
+ if (this.mode === 'year-month') {
167
+ date = 1
168
+ }
169
+ // 不允许超过maxDate值
170
+ date = Math.min(maxDate, date)
171
+ if (this.mode === 'datetime') {
172
+ hour = parseInt(this.intercept(values[3][indexs[3]]))
173
+ minute = parseInt(this.intercept(values[4][indexs[4]]))
174
+ }
175
+ // 转为时间模式
176
+ selectValue = Number(new Date(year, month - 1, date, hour, minute))
177
+ }
178
+ // 取出准确的合法值,防止超越边界的情况
179
+ selectValue = this.correctValue(selectValue)
180
+ this.innerValue = selectValue
181
+ this.updateColumnValue(selectValue)
182
+ // 发出change时间,value为当前选中的时间戳
183
+ this.$emit('change', {
184
+ value: selectValue,
185
+ mode: this.mode
186
+ })
187
+ },
188
+ // 更新各列的值,进行补0、格式化等操作
189
+ updateColumnValue(value) {
190
+ this.innerValue = value
191
+ this.updateColumns()
192
+ this.updateIndexs(value)
193
+ },
194
+ // 更新索引
195
+ updateIndexs(value) {
196
+ let values = []
197
+ const formatter = this.formatter || this.innerFormatter;
198
+ if (this.mode === 'time') {
199
+ // 将time模式的时间用:分隔成数组
200
+ const timeArr = value.split(':')
201
+ // 使用formatter格式化方法进行管道处理
202
+ values = [formatter('hour', timeArr[0]), formatter('minute', timeArr[1])]
203
+ } else {
204
+ const date = new Date(value)
205
+ values = [
206
+ formatter('year', `${dayjs(value).year()}`),
207
+ // 月份补0
208
+ formatter('month', this.$uv.padZero(dayjs(value).month() + 1))
209
+ ]
210
+ if (this.mode === 'date') {
211
+ // date模式,需要添加天列
212
+ values.push(formatter('day', this.$uv.padZero(dayjs(value).date())))
213
+ }
214
+ if (this.mode === 'datetime') {
215
+ // 数组的push方法,可以写入多个参数
216
+ values.push(formatter('day', this.$uv.padZero(dayjs(value).date())), formatter('hour', this.$uv.padZero(dayjs(value).hour())), formatter('minute', this.$uv.padZero(dayjs(value).minute())))
217
+ }
218
+ }
219
+ // 根据当前各列的所有值,从各列默认值中找到默认值在各列中的索引
220
+ const indexs = this.columns.map((column, index) => {
221
+ // 通过取大值,可以保证不会出现找不到索引的-1情况
222
+ return Math.max(0, column.findIndex(item => item === values[index]))
223
+ })
224
+ this.$nextTick(()=>{
225
+ this.$uv.sleep(100).then(res=>{
226
+ this.$refs.picker.setIndexs(indexs,true);
227
+ })
228
+ })
229
+ },
230
+ // 更新各列的值
231
+ updateColumns() {
232
+ const formatter = this.formatter || this.innerFormatter
233
+ // 获取各列的值,并且map后,对各列的具体值进行补0操作
234
+ const results = this.getOriginColumns().map((column) => column.values.map((value) => formatter(column.type, value)))
235
+ this.columns = results
236
+ },
237
+ getOriginColumns() {
238
+ // 生成各列的值
239
+ const results = this.getRanges().map(({ type, range }) => {
240
+ let values = times(range[1] - range[0] + 1, (index) => {
241
+ let value = range[0] + index
242
+ value = type === 'year' ? `${value}` : this.$uv.padZero(value)
243
+ return value
244
+ })
245
+ // 进行过滤
246
+ if (this.filter) {
247
+ values = this.filter(type, values)
248
+ }
249
+ return { type, values }
250
+ })
251
+ return results
252
+ },
253
+ // 通过最大值和最小值生成数组
254
+ generateArray(start, end) {
255
+ return Array.from(new Array(end + 1).keys()).slice(start)
256
+ },
257
+ // 得出合法的时间
258
+ correctValue(value) {
259
+ const isDateMode = this.mode !== 'time'
260
+ if (isDateMode && !this.$uv.test.date(value)) {
261
+ // 如果是日期类型,但是又没有设置合法的当前时间的话,使用最小时间为当前时间
262
+ value = this.minDate
263
+ } else if (!isDateMode && !value) {
264
+ // 如果是时间类型,而又没有默认值的话,就用最小时间
265
+ value = `${this.$uv.padZero(this.minHour)}:${this.$uv.padZero(this.minMinute)}`
266
+ }
267
+ // 时间类型
268
+ if (!isDateMode) {
269
+ if (String(value).indexOf(':') === -1) return this.$uv.error('时间错误,请传递如12:24的格式')
270
+ let [hour, minute] = value.split(':')
271
+ // 对时间补零,同时控制在最小值和最大值之间
272
+ hour = this.$uv.padZero(this.$uv.range(this.minHour, this.maxHour, Number(hour)))
273
+ minute = this.$uv.padZero(this.$uv.range(this.minMinute, this.maxMinute, Number(minute)))
274
+ return `${ hour }:${ minute }`
275
+ } else {
276
+ // 如果是日期格式,控制在最小日期和最大日期之间
277
+ value = dayjs(value).isBefore(dayjs(this.minDate)) ? this.minDate : value
278
+ value = dayjs(value).isAfter(dayjs(this.maxDate)) ? this.maxDate : value
279
+ return value
280
+ }
281
+ },
282
+ // 获取每列的最大和最小值
283
+ getRanges() {
284
+ if (this.mode === 'time') {
285
+ return [{
286
+ type: 'hour',
287
+ range: [this.minHour, this.maxHour],
288
+ }, {
289
+ type: 'minute',
290
+ range: [this.minMinute, this.maxMinute],
291
+ }, ];
292
+ }
293
+ const { maxYear, maxDate, maxMonth, maxHour, maxMinute, } = this.getBoundary('max', this.innerValue);
294
+ const { minYear, minDate, minMonth, minHour, minMinute, } = this.getBoundary('min', this.innerValue);
295
+ const result = [{
296
+ type: 'year',
297
+ range: [minYear, maxYear],
298
+ }, {
299
+ type: 'month',
300
+ range: [minMonth, maxMonth],
301
+ }, {
302
+ type: 'day',
303
+ range: [minDate, maxDate],
304
+ }, {
305
+ type: 'hour',
306
+ range: [minHour, maxHour],
307
+ }, {
308
+ type: 'minute',
309
+ range: [minMinute, maxMinute],
310
+ }, ];
311
+ if (this.mode === 'date') result.splice(3, 2);
312
+ if (this.mode === 'year-month') result.splice(2, 3);
313
+ if (this.mode === 'year') result.splice(1, 4);
314
+ return result;
315
+ },
316
+ // 根据minDate、maxDate、minHour、maxHour等边界值,判断各列的开始和结束边界值
317
+ getBoundary(type, innerValue) {
318
+ const value = new Date(innerValue)
319
+ const boundary = new Date(this[`${type}Date`])
320
+ const year = dayjs(boundary).year()
321
+ let month = 1
322
+ let date = 1
323
+ let hour = 0
324
+ let minute = 0
325
+ if (type === 'max') {
326
+ month = 12
327
+ // 月份的天数
328
+ date = dayjs(value).daysInMonth()
329
+ hour = 23
330
+ minute = 59
331
+ }
332
+ // 获取边界值,逻辑是:当年达到了边界值(最大或最小年),就检查月允许的最大和最小值,以此类推
333
+ if (dayjs(value).year() === year) {
334
+ month = dayjs(boundary).month() + 1
335
+ if (dayjs(value).month() + 1 === month) {
336
+ date = dayjs(boundary).date()
337
+ if (dayjs(value).date() === date) {
338
+ hour = dayjs(boundary).hour()
339
+ if (dayjs(value).hour() === hour) {
340
+ minute = dayjs(boundary).minute()
341
+ }
342
+ }
343
+ }
344
+ }
345
+ return {
346
+ [`${type}Year`]: year,
347
+ [`${type}Month`]: month,
348
+ [`${type}Date`]: date,
349
+ [`${type}Hour`]: hour,
350
+ [`${type}Minute`]: minute
351
+ }
352
+ },
353
+ },
354
+ }
355
+ </script>
@@ -0,0 +1,45 @@
1
+ export default {
2
+ props: {
3
+ // 是否虚线
4
+ dashed: {
5
+ type: Boolean,
6
+ default: false
7
+ },
8
+ // 是否细线
9
+ hairline: {
10
+ type: Boolean,
11
+ default: true
12
+ },
13
+ // 是否以点替代文字,优先于text字段起作用
14
+ dot: {
15
+ type: Boolean,
16
+ default: false
17
+ },
18
+ // 内容文本的位置,left-左边,center-中间,right-右边
19
+ textPosition: {
20
+ type: String,
21
+ default: 'center'
22
+ },
23
+ // 文本内容
24
+ text: {
25
+ type: [String, Number],
26
+ default: ''
27
+ },
28
+ // 文本大小
29
+ textSize: {
30
+ type: [String, Number],
31
+ default: 14
32
+ },
33
+ // 文本颜色
34
+ textColor: {
35
+ type: String,
36
+ default: '#909399'
37
+ },
38
+ // 线条颜色
39
+ lineColor: {
40
+ type: String,
41
+ default: '#dcdfe6'
42
+ },
43
+ ...uni.$uv?.props?.divider
44
+ }
45
+ }
@@ -0,0 +1,113 @@
1
+ <template>
2
+ <view
3
+ class="uv-divider"
4
+ :style="[$uv.addStyle(customStyle)]"
5
+ @tap="click"
6
+ >
7
+ <uv-line
8
+ :color="lineColor"
9
+ :customStyle="leftLineStyle"
10
+ :hairline="hairline"
11
+ :dashed="dashed"></uv-line>
12
+ <text
13
+ v-if="dot"
14
+ class="uv-divider__dot"
15
+ >●</text>
16
+ <text
17
+ v-else-if="text"
18
+ class="uv-divider__text"
19
+ :style="[textStyle]"
20
+ >{{text}}</text>
21
+ <uv-line
22
+ :color="lineColor"
23
+ :customStyle="rightLineStyle"
24
+ :hairline="hairline"
25
+ :dashed="dashed"
26
+ ></uv-line>
27
+ </view>
28
+ </template>
29
+ <script>
30
+ import mpMixin from '../../libs/mixin/mpMixin.js'
31
+ import mixin from '../../libs/mixin/mixin.js'
32
+ import props from './props.js';
33
+ /**
34
+ * divider 分割线
35
+ * @description 区隔内容的分割线,一般用于页面底部"没有更多"的提示。
36
+ * @tutorial https://www.uvui.cn/components/divider.html
37
+ * @property {Boolean} dashed 是否虚线 (默认 false )
38
+ * @property {Boolean} hairline 是否细线 (默认 true )
39
+ * @property {Boolean} dot 是否以点替代文字,优先于text字段起作用 (默认 false )
40
+ * @property {String} textPosition 内容文本的位置,left-左边,center-中间,right-右边 (默认 'center' )
41
+ * @property {String | Number} text 文本内容
42
+ * @property {String | Number} textSize 文本大小 (默认 14)
43
+ * @property {String} textColor 文本颜色 (默认 '#909399' )
44
+ * @property {String} lineColor 线条颜色 (默认 '#dcdfe6' )
45
+ * @property {Object} customStyle 定义需要用到的外部样式
46
+ *
47
+ * @event {Function} click divider组件被点击时触发
48
+ * @example <uv-divider :color="color">锦瑟无端五十弦</uv-divider>
49
+ */
50
+ export default {
51
+ name: 'uv-divider',
52
+ mixins: [mpMixin, mixin, props],
53
+ emits: ['click'],
54
+ computed: {
55
+ textStyle() {
56
+ const style = {}
57
+ style.fontSize = this.$uv.addUnit(this.textSize)
58
+ style.color = this.textColor
59
+ return style
60
+ },
61
+ // 左边线条的的样式
62
+ leftLineStyle() {
63
+ const style = {}
64
+ // 如果是在左边,设置左边的宽度为固定值
65
+ if (this.textPosition === 'left') {
66
+ style.width = '80rpx'
67
+ } else {
68
+ style.flex = 1
69
+ }
70
+ return style
71
+ },
72
+ // 右边线条的的样式
73
+ rightLineStyle() {
74
+ const style = {}
75
+ // 如果是在右边,设置右边的宽度为固定值
76
+ if (this.textPosition === 'right') {
77
+ style.width = '80rpx'
78
+ } else {
79
+ style.flex = 1
80
+ }
81
+ return style
82
+ }
83
+ },
84
+ methods: {
85
+ // divider组件被点击时触发
86
+ click() {
87
+ this.$emit('click');
88
+ }
89
+ }
90
+ }
91
+ </script>
92
+ <style lang="scss" scoped>
93
+ @import '../../libs/css/components.scss';
94
+ $uv-divider-margin: 15px 0 !default;
95
+ $uv-divider-text-margin: 0 15px !default;
96
+ $uv-divider-dot-font-size: 12px !default;
97
+ $uv-divider-dot-margin: 0 12px !default;
98
+ $uv-divider-dot-color: #c0c4cc !default;
99
+ .uv-divider {
100
+ @include flex;
101
+ flex-direction: row;
102
+ align-items: center;
103
+ margin: $uv-divider-margin;
104
+ &__text {
105
+ margin: $uv-divider-text-margin;
106
+ }
107
+ &__dot {
108
+ font-size: $uv-divider-dot-font-size;
109
+ margin: $uv-divider-dot-margin;
110
+ color: $uv-divider-dot-color;
111
+ }
112
+ }
113
+ </style>
@@ -0,0 +1,135 @@
1
+ <template>
2
+ <uv-sticky :disabled="!isSticky">
3
+ <view ref="dropDownRef" class="uv-drop-down" :style="[$uv.addStyle(customStyle)]">
4
+ <slot></slot>
5
+ </view>
6
+ </uv-sticky>
7
+ </template>
8
+ <script>
9
+ import mpMixin from '../../libs/mixin/mpMixin.js';
10
+ import mixin from '../../libs/mixin/mixin.js';
11
+ // #ifdef APP-NVUE
12
+ const dom = uni.requireNativePlugin('dom');
13
+ // #endif
14
+ /**
15
+ * DropDown 下拉框
16
+ * @description 下拉筛选
17
+ * @tutorial https://ext.dcloud.net.cn/plugin?name=uv-drop-down
18
+ * @property {String | Number} sign 组件唯一标识,需要手动传
19
+ * @property {Boolean} is-sticky = [true|false] 是否吸顶
20
+ * @property {Array} default-value 默认值,表示参数value属于这里面的值,就说明是未选中即是默认展示的值。eg:上面示例中的{label: '全部',value: 'all'} 即是默认值。后续处理逻辑也可以根据是否是其中值进行过滤。
21
+ * @property {String} textSize 每项字体大小
22
+ * @property {String} textColor 每项文本颜色
23
+ * @property {String} textActiveSize 每项选中状态字体大小
24
+ * @property {String} textActiveColor 每项选中状态文本颜色
25
+ * @property {Object} extraIcon 每项右侧图标
26
+ * @property {Object} extraActiveIcon 每项选中后右侧图标
27
+ */
28
+ export default {
29
+ name: 'uv-drop-down',
30
+ mixins: [mpMixin, mixin],
31
+ emits: ['click'],
32
+ props: {
33
+ isSticky: {
34
+ type: Boolean,
35
+ default: true
36
+ },
37
+ sign: {
38
+ type: [String, Number],
39
+ default: 'UVDROPDOWN'
40
+ },
41
+ defaultValue: {
42
+ type: Array,
43
+ default: () => [0, '0', 'all']
44
+ },
45
+ textSize: {
46
+ type: String,
47
+ default: '30rpx'
48
+ },
49
+ textColor: {
50
+ type: String,
51
+ default: '#333'
52
+ },
53
+ textActiveSize: {
54
+ type: String,
55
+ default: '30rpx'
56
+ },
57
+ textActiveColor: {
58
+ type: String,
59
+ default: '#3c9cff'
60
+ },
61
+ extraIcon: {
62
+ type: Object,
63
+ default () {
64
+ return {
65
+ name: 'arrow-down',
66
+ size: '30rpx',
67
+ color: '#333'
68
+ }
69
+ }
70
+ },
71
+ extraActiveIcon: {
72
+ type: Object,
73
+ default () {
74
+ return {
75
+ name: 'arrow-up',
76
+ size: '30rpx',
77
+ color: '#3c9cff'
78
+ }
79
+ }
80
+ }
81
+ },
82
+ computed: {
83
+ parentData() {
84
+ return [this.defaultValue, this.textSize, this.textColor, this.textActiveColor, this.textActiveSize, this.extraIcon, this.extraActiveIcon, this.sign, this.clickHandler];
85
+ }
86
+ },
87
+ mounted() {
88
+ this.init();
89
+ },
90
+ methods: {
91
+ init() {
92
+ uni.$emit(`${this.sign}_CLICKMENU`, {
93
+ show: false
94
+ });
95
+ this.$nextTick(async () => {
96
+ const rect = await this.queryRect();
97
+ uni.$emit(`${this.sign}_GETRECT`, rect);
98
+ })
99
+ },
100
+ // 查询内容高度
101
+ queryRect() {
102
+ // #ifndef APP-NVUE
103
+ // 组件内部一般用this.$uvGetRect,对外的为getRect,二者功能一致,名称不同
104
+ return new Promise(resolve => {
105
+ this.$uvGetRect(`.uv-drop-down`).then(size => {
106
+ resolve(size)
107
+ })
108
+ })
109
+ // #endif
110
+ // #ifdef APP-NVUE
111
+ // nvue下,使用dom模块查询元素高度
112
+ // 返回一个promise,让调用此方法的主体能使用then回调
113
+ return new Promise(resolve => {
114
+ dom.getComponentRect(this.$refs.dropDownRef, res => {
115
+ res.size.top = res.size.top <= 0 ? 0 : res.size.top;
116
+ resolve(res.size)
117
+ })
118
+ })
119
+ // #endif
120
+ },
121
+ clickHandler(data) {
122
+ this.$emit('click', data);
123
+ }
124
+ }
125
+ }
126
+ </script>
127
+ <style scoped lang="scss">
128
+ @import '../../libs/css/components.scss';
129
+ .uv-drop-down {
130
+ @include flex;
131
+ justify-content: space-between;
132
+ background-color: #fff;
133
+ border-bottom: 1px solid #dadbde;
134
+ }
135
+ </style>