@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,397 @@
1
+ <template>
2
+ <view class="uv-number-box">
3
+ <view
4
+ class="uv-number-box__slot"
5
+ @tap.stop="clickHandler('minus')"
6
+ @touchstart="onTouchStart('minus')"
7
+ @touchend.stop="clearTimeout"
8
+ v-if="showMinus && $slots.minus"
9
+ >
10
+ <slot name="minus" />
11
+ </view>
12
+ <view
13
+ v-else-if="showMinus"
14
+ class="uv-number-box__minus"
15
+ @tap.stop="clickHandler('minus')"
16
+ @touchstart="onTouchStart('minus')"
17
+ @touchend.stop="clearTimeout"
18
+ hover-class="uv-number-box__minus--hover"
19
+ hover-stay-time="150"
20
+ :class="{ 'uv-number-box__minus--disabled': isDisabled('minus') }"
21
+ :style="[buttonStyle('minus')]"
22
+ >
23
+ <uv-icon
24
+ name="minus"
25
+ :color="isDisabled('minus') ? '#c8c9cc' : '#323233'"
26
+ size="15"
27
+ bold
28
+ :customStyle="iconStyle"
29
+ ></uv-icon>
30
+ </view>
31
+ <slot name="input">
32
+ <input
33
+ :disabled="disabledInput || disabled"
34
+ :cursor-spacing="getCursorSpacing"
35
+ :adjust-position="adjustPosition"
36
+ :class="{ 'uv-number-box__input--disabled': disabled || disabledInput }"
37
+ v-model="currentValue"
38
+ class="uv-number-box__input"
39
+ @blur="onBlur"
40
+ @focus="onFocus"
41
+ @input="onInput"
42
+ type="number"
43
+ :style="[inputStyle]"
44
+ />
45
+ </slot>
46
+ <view
47
+ class="uv-number-box__slot"
48
+ @tap.stop="clickHandler('plus')"
49
+ @touchstart="onTouchStart('plus')"
50
+ @touchend.stop="clearTimeout"
51
+ v-if="showPlus && $slots.plus"
52
+ >
53
+ <slot name="plus" />
54
+ </view>
55
+ <view
56
+ v-else-if="showPlus"
57
+ class="uv-number-box__plus"
58
+ @tap.stop="clickHandler('plus')"
59
+ @touchstart="onTouchStart('plus')"
60
+ @touchend.stop="clearTimeout"
61
+ hover-class="uv-number-box__plus--hover"
62
+ hover-stay-time="150"
63
+ :class="{ 'uv-number-box__minus--disabled': isDisabled('plus') }"
64
+ :style="[buttonStyle('plus')]"
65
+ >
66
+ <uv-icon
67
+ name="plus"
68
+ :color="isDisabled('plus') ? '#c8c9cc' : '#323233'"
69
+ size="15"
70
+ bold
71
+ :customStyle="iconStyle"
72
+ ></uv-icon>
73
+ </view>
74
+ </view>
75
+ </template>
76
+ <script>
77
+ import mpMixin from '../../libs/mixin/mpMixin.js'
78
+ import mixin from '../../libs/mixin/mixin.js'
79
+ import props from './props.js';
80
+ /**
81
+ * numberBox 步进器
82
+ * @description 该组件一般用于商城购物选择物品数量的场景。
83
+ * @tutorial https://www.uvui.cn/components/numberBox.html
84
+ * @property {String | Number} value / v-model 用于双向绑定的值,初始化时设置设为默认min值(最小值) (默认 0 )
85
+ * @property {String | Number} name 步进器标识符,在change回调返回
86
+ * @property {String | Number} min 最小值 (默认 1 )
87
+ * @property {String | Number} max 最大值 (默认 Number.MAX_SAFE_INTEGER )
88
+ * @property {String | Number} step 加减的步长,可为小数 (默认 1 )
89
+ * @property {Boolean} integer 是否只允许输入整数 (默认 false )
90
+ * @property {Boolean} disabled 是否禁用,包括输入框,加减按钮 (默认 false )
91
+ * @property {Boolean} disabledInput 是否禁用输入框 (默认 false )
92
+ * @property {Boolean} asyncChange 是否开启异步变更,开启后需要手动控制输入值 (默认 false )
93
+ * @property {String | Number} inputWidth 输入框宽度,单位为px (默认 35 )
94
+ * @property {Boolean} showMinus 是否显示减少按钮 (默认 true )
95
+ * @property {Boolean} showPlus 是否显示增加按钮 (默认 true )
96
+ * @property {String | Number} decimalLength 显示的小数位数
97
+ * @property {Boolean} longPress 是否开启长按加减手势 (默认 true )
98
+ * @property {String} color 输入框文字和加减按钮图标的颜色 (默认 '#323233' )
99
+ * @property {String | Number} buttonSize 按钮大小,宽高等于此值,单位px,输入框高度和此值保持一致 (默认 30 )
100
+ * @property {String} bgColor 输入框和按钮的背景颜色 (默认 '#EBECEE' )
101
+ * @property {String | Number} cursorSpacing 指定光标于键盘的距离,避免键盘遮挡输入框,单位px (默认 100 )
102
+ * @property {Boolean} disablePlus 是否禁用增加按钮 (默认 false )
103
+ * @property {Boolean} disableMinus 是否禁用减少按钮 (默认 false )
104
+ * @property {Boolean} adjustPosition 键盘弹起时,是否自动上推页面 (默认 true )
105
+ * @property {Object | String} iconStyle 加减按钮图标的样式
106
+ * @event {Function} onFocus 输入框活动焦点
107
+ * @event {Function} onBlur 输入框失去焦点
108
+ * @event {Function} onInput 输入框值发生变化
109
+ * @event {Function} onChange
110
+ * @example <uv-number-box v-model="value" @change="valChange"></uv-number-box>
111
+ */
112
+ export default {
113
+ name: 'uv-number-box',
114
+ mixins: [mpMixin, mixin, props],
115
+ data() {
116
+ return {
117
+ // 输入框实际操作的值
118
+ currentValue: '',
119
+ // 定时器
120
+ longPressTimer: null
121
+ }
122
+ },
123
+ watch: {
124
+ // 多个值之间,只要一个值发生变化,都要重新检查check()函数
125
+ watchChange(n) {
126
+ this.check()
127
+ },
128
+ value(newVal) {
129
+ if (newVal !== this.currentValue) {
130
+ this.currentValue = this.format(this.value)
131
+ }
132
+ },
133
+ modelValue(newVal) {
134
+ if (newVal !== this.currentValue) {
135
+ this.currentValue = this.format(this.modelValue)
136
+ }
137
+ }
138
+ },
139
+ computed: {
140
+ getCursorSpacing() {
141
+ // 判断传入的单位,如果为px单位,需要转成px
142
+ return this.$uv.getPx(this.cursorSpacing)
143
+ },
144
+ // 按钮的样式
145
+ buttonStyle() {
146
+ return (type) => {
147
+ const style = {
148
+ backgroundColor: this.bgColor,
149
+ height: this.$uv.addUnit(this.buttonSize),
150
+ color: this.color
151
+ }
152
+ if (this.isDisabled(type)) {
153
+ style.backgroundColor = '#f7f8fa'
154
+ }
155
+ return style
156
+ }
157
+ },
158
+ // 输入框的样式
159
+ inputStyle() {
160
+ const disabled = this.disabled || this.disabledInput
161
+ const style = {
162
+ color: this.color,
163
+ backgroundColor: this.bgColor,
164
+ height: this.$uv.addUnit(this.buttonSize),
165
+ width: this.$uv.addUnit(this.inputWidth)
166
+ }
167
+ return style
168
+ },
169
+ // 用于监听多个值发生变化
170
+ watchChange() {
171
+ return [this.integer, this.decimalLength, this.min, this.max]
172
+ },
173
+ isDisabled() {
174
+ return (type) => {
175
+ if (type === 'plus') {
176
+ // 在点击增加按钮情况下,判断整体的disabled,是否单独禁用增加按钮,以及当前值是否大于最大的允许值
177
+ return (
178
+ this.disabled ||
179
+ this.disablePlus ||
180
+ this.currentValue >= this.max
181
+ )
182
+ }
183
+ // 点击减少按钮同理
184
+ return (
185
+ this.disabled ||
186
+ this.disableMinus ||
187
+ this.currentValue <= this.min
188
+ )
189
+ }
190
+ },
191
+ },
192
+ created() {
193
+ this.init()
194
+ },
195
+ methods: {
196
+ init() {
197
+ const value = this.value || this.modelValue;
198
+ this.currentValue = this.format(value)
199
+ },
200
+ // 格式化整理数据,限制范围
201
+ format(value) {
202
+ value = this.filter(value)
203
+ // 如果为空字符串,那么设置为0,同时将值转为Number类型
204
+ value = value === '' ? 0 : +value
205
+ // 对比最大最小值,取在min和max之间的值
206
+ value = Math.max(Math.min(this.max, value), this.min)
207
+ // 如果设定了最大的小数位数,使用toFixed去进行格式化
208
+ if (this.decimalLength !== null) {
209
+ value = value.toFixed(this.decimalLength)
210
+ }
211
+ return value
212
+ },
213
+ // 过滤非法的字符
214
+ filter(value) {
215
+ // 只允许0-9之间的数字,"."为小数点,"-"为负数时候使用
216
+ value = String(value).replace(/[^0-9.-]/g, '')
217
+ // 如果只允许输入整数,则过滤掉小数点后的部分
218
+ if (this.integer && value.indexOf('.') !== -1) {
219
+ value = value.split('.')[0]
220
+ }
221
+ return value;
222
+ },
223
+ check() {
224
+ // 格式化了之后,如果前后的值不相等,那么设置为格式化后的值
225
+ const val = this.format(this.currentValue);
226
+ if (val !== this.currentValue) {
227
+ this.currentValue = val
228
+ }
229
+ },
230
+ // 输入框活动焦点
231
+ onFocus(event) {
232
+ this.$emit('focus', {
233
+ ...event.detail,
234
+ name: this.name,
235
+ })
236
+ },
237
+ // 输入框失去焦点
238
+ onBlur(event) {
239
+ // 对输入值进行格式化
240
+ const value = this.format(event.detail.value)
241
+ // 发出blur事件
242
+ this.$emit(
243
+ 'blur', {
244
+ ...event.detail,
245
+ name: this.name,
246
+ }
247
+ )
248
+ },
249
+ // 输入框值发生变化
250
+ onInput(e) {
251
+ const {
252
+ value = ''
253
+ } = e.detail || {}
254
+ // 为空返回
255
+ if (value === '') return
256
+ let formatted = this.filter(value)
257
+ // 最大允许的小数长度
258
+ if (this.decimalLength !== null && formatted.indexOf('.') !== -1) {
259
+ const pair = formatted.split('.');
260
+ formatted = `${pair[0]}.${pair[1].slice(0, this.decimalLength)}`
261
+ }
262
+ formatted = this.format(formatted)
263
+ this.emitChange(formatted);
264
+ },
265
+ // 发出change事件
266
+ emitChange(value) {
267
+ // 如果开启了异步变更值,则不修改内部的值,需要用户手动在外部通过v-model变更
268
+ if (!this.asyncChange) {
269
+ this.$nextTick(() => {
270
+ this.$emit('input', value)
271
+ this.$emit('update:modelValue', value)
272
+ this.currentValue = value
273
+ this.$forceUpdate()
274
+ })
275
+ }
276
+ this.$emit('change', {
277
+ value,
278
+ name: this.name,
279
+ });
280
+ },
281
+ onChange() {
282
+ const {
283
+ type
284
+ } = this
285
+ if (this.isDisabled(type)) {
286
+ return this.$emit('overlimit', type)
287
+ }
288
+ const diff = type === 'minus' ? -this.step : +this.step
289
+ const value = this.format(this.add(+this.currentValue, diff))
290
+ this.emitChange(value)
291
+ this.$emit(type)
292
+ },
293
+ // 对值扩大后进行四舍五入,再除以扩大因子,避免出现浮点数操作的精度问题
294
+ add(num1, num2) {
295
+ const cardinal = Math.pow(10, 10);
296
+ return Math.round((num1 + num2) * cardinal) / cardinal
297
+ },
298
+ // 点击加减按钮
299
+ clickHandler(type) {
300
+ this.type = type
301
+ this.onChange()
302
+ },
303
+ longPressStep() {
304
+ // 每隔一段时间,重新调用longPressStep方法,实现长按加减
305
+ this.clearTimeout()
306
+ this.longPressTimer = setTimeout(() => {
307
+ this.onChange()
308
+ this.longPressStep()
309
+ }, 250);
310
+ },
311
+ onTouchStart(type) {
312
+ if (!this.longPress) return
313
+ this.clearTimeout()
314
+ this.type = type
315
+ // 一定时间后,默认达到长按状态
316
+ this.longPressTimer = setTimeout(() => {
317
+ this.onChange()
318
+ this.longPressStep()
319
+ }, 600)
320
+ },
321
+ // 触摸结束,清除定时器,停止长按加减
322
+ onTouchEnd() {
323
+ if (!this.longPress) return
324
+ this.clearTimeout()
325
+ },
326
+ // 清除定时器
327
+ clearTimeout() {
328
+ clearTimeout(this.longPressTimer)
329
+ this.longPressTimer = null
330
+ }
331
+ }
332
+ }
333
+ </script>
334
+
335
+ <style lang="scss" scoped>
336
+ @import '../../libs/css/components.scss';
337
+ @import '../../libs/css/color.scss';
338
+ $uv-numberBox-hover-bgColor: #E6E6E6 !default;
339
+ $uv-numberBox-disabled-color: #c8c9cc !default;
340
+ $uv-numberBox-disabled-bgColor: #f7f8fa !default;
341
+ $uv-numberBox-plus-radius: 4px !default;
342
+ $uv-numberBox-minus-radius: 4px !default;
343
+ $uv-numberBox-input-text-align: center !default;
344
+ $uv-numberBox-input-font-size: 15px !default;
345
+ $uv-numberBox-input-padding: 0 !default;
346
+ $uv-numberBox-input-margin: 0 2px !default;
347
+ $uv-numberBox-input-disabled-color: #c8c9cc !default;
348
+ $uv-numberBox-input-disabled-bgColor: #f2f3f5 !default;
349
+ .uv-number-box {
350
+ @include flex(row);
351
+ align-items: center;
352
+ &__slot {
353
+ /* #ifndef APP-NVUE */
354
+ touch-action: none;
355
+ /* #endif */
356
+ }
357
+ &__plus,
358
+ &__minus {
359
+ width: 35px;
360
+ @include flex;
361
+ justify-content: center;
362
+ align-items: center;
363
+ /* #ifndef APP-NVUE */
364
+ touch-action: none;
365
+ /* #endif */
366
+ &--hover {
367
+ background-color: $uv-numberBox-hover-bgColor !important;
368
+ }
369
+ &--disabled {
370
+ color: $uv-numberBox-disabled-color;
371
+ background-color: $uv-numberBox-disabled-bgColor;
372
+ }
373
+ }
374
+ &__plus {
375
+ border-top-right-radius: $uv-numberBox-plus-radius;
376
+ border-bottom-right-radius: $uv-numberBox-plus-radius;
377
+ }
378
+ &__minus {
379
+ border-top-left-radius: $uv-numberBox-minus-radius;
380
+ border-bottom-left-radius: $uv-numberBox-minus-radius;
381
+ }
382
+ &__input {
383
+ position: relative;
384
+ text-align: $uv-numberBox-input-text-align;
385
+ font-size: $uv-numberBox-input-font-size;
386
+ padding: $uv-numberBox-input-padding;
387
+ margin: $uv-numberBox-input-margin;
388
+ @include flex;
389
+ align-items: center;
390
+ justify-content: center;
391
+ &--disabled {
392
+ color: $uv-numberBox-input-disabled-color;
393
+ background-color: $uv-numberBox-input-disabled-bgColor;
394
+ }
395
+ }
396
+ }
397
+ </style>
@@ -0,0 +1,25 @@
1
+ export default {
2
+ props: {
3
+ // 是否显示遮罩
4
+ show: {
5
+ type: Boolean,
6
+ default: false
7
+ },
8
+ // 层级z-index
9
+ zIndex: {
10
+ type: [String, Number],
11
+ default: 10070
12
+ },
13
+ // 遮罩的过渡时间,单位为ms
14
+ duration: {
15
+ type: [String, Number],
16
+ default: 300
17
+ },
18
+ // 不透明度值,当做rgba的第四个参数
19
+ opacity: {
20
+ type: [String, Number],
21
+ default: 0.5
22
+ },
23
+ ...uni.$uv?.props?.overlay
24
+ }
25
+ }
@@ -0,0 +1,85 @@
1
+ <template>
2
+ <uv-transition
3
+ :show="show"
4
+ mode="fade"
5
+ custom-class="uv-overlay"
6
+ :duration="duration"
7
+ :custom-style="overlayStyle"
8
+ @click="clickHandler"
9
+ @touchmove.stop.prevent="clear"
10
+ >
11
+ <slot />
12
+ </uv-transition>
13
+ </template>
14
+
15
+ <script>
16
+ import mpMixin from '../../libs/mixin/mpMixin.js'
17
+ import mixin from '../../libs/mixin/mixin.js'
18
+ import props from './props.js';
19
+
20
+ /**
21
+ * overlay 遮罩
22
+ * @description 创建一个遮罩层,用于强调特定的页面元素,并阻止用户对遮罩下层的内容进行操作,一般用于弹窗场景
23
+ * @tutorial https://www.uvui.cn/components/overlay.html
24
+ * @property {Boolean} show 是否显示遮罩(默认 false )
25
+ * @property {String | Number} zIndex zIndex 层级(默认 10070 )
26
+ * @property {String | Number} duration 动画时长,单位毫秒(默认 300 )
27
+ * @property {String | Number} opacity 不透明度值,当做rgba的第四个参数 (默认 0.5 )
28
+ * @property {Object} customStyle 定义需要用到的外部样式
29
+ * @event {Function} click 点击遮罩发送事件
30
+ * @example <uv-overlay :show="show" @click="show = false"></uv-overlay>
31
+ */
32
+ export default {
33
+ name: "uv-overlay",
34
+ emits: ['click'],
35
+ mixins: [mpMixin, mixin, props],
36
+ watch: {
37
+ show(newVal){
38
+ // #ifdef H5
39
+ if(newVal){
40
+ document.querySelector('body').style.overflow = 'hidden';
41
+ }else{
42
+ document.querySelector('body').style.overflow = '';
43
+ }
44
+ // #endif
45
+ }
46
+ },
47
+ computed: {
48
+ overlayStyle() {
49
+ const style = {
50
+ position: 'fixed',
51
+ top: 0,
52
+ left: 0,
53
+ right: 0,
54
+ zIndex: this.zIndex,
55
+ bottom: 0,
56
+ 'background-color': `rgba(0, 0, 0, ${this.opacity})`
57
+ }
58
+ return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle))
59
+ }
60
+ },
61
+ methods: {
62
+ clickHandler() {
63
+ this.$emit('click')
64
+ },
65
+ clear() {}
66
+ }
67
+ }
68
+ </script>
69
+ <style lang="scss" scoped>
70
+ /* #ifndef APP-NVUE */
71
+ $uv-overlay-top:0 !default;
72
+ $uv-overlay-left:0 !default;
73
+ $uv-overlay-width:100% !default;
74
+ $uv-overlay-height:100% !default;
75
+ $uv-overlay-background-color:rgba(0, 0, 0, .7) !default;
76
+ .uv-overlay {
77
+ position: fixed;
78
+ top:$uv-overlay-top;
79
+ left:$uv-overlay-left;
80
+ width: $uv-overlay-width;
81
+ height:$uv-overlay-height;
82
+ background-color:$uv-overlay-background-color;
83
+ }
84
+ /* #endif */
85
+ </style>