@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.
- package/CHANGELOG.md +295 -0
- package/LICENSE +21 -0
- package/README.md +164 -0
- package/components/uv-action-sheet/props.js +50 -0
- package/components/uv-action-sheet/uv-action-sheet.vue +280 -0
- package/components/uv-album/uv-album.vue +312 -0
- package/components/uv-alert/props.js +45 -0
- package/components/uv-alert/uv-alert.vue +246 -0
- package/components/uv-avatar/props.js +85 -0
- package/components/uv-avatar/uv-avatar.vue +182 -0
- package/components/uv-avatar-group/props.js +53 -0
- package/components/uv-avatar-group/uv-avatar-group.vue +106 -0
- package/components/uv-back-top/props.js +58 -0
- package/components/uv-back-top/uv-back-top.vue +116 -0
- package/components/uv-badge/props.js +73 -0
- package/components/uv-badge/uv-badge.vue +176 -0
- package/components/uv-button/nvue.scss +46 -0
- package/components/uv-button/props.js +163 -0
- package/components/uv-button/uv-button.vue +529 -0
- package/components/uv-button/vue.scss +93 -0
- package/components/uv-calendar/calendar.js +546 -0
- package/components/uv-calendar/header.vue +104 -0
- package/components/uv-calendar/month.vue +616 -0
- package/components/uv-calendar/props.js +145 -0
- package/components/uv-calendar/uv-calendar.vue +390 -0
- package/components/uv-calendars/calendar-body.vue +376 -0
- package/components/uv-calendars/calendar-item.vue +248 -0
- package/components/uv-calendars/calendar.js +546 -0
- package/components/uv-calendars/i18n/en.json +12 -0
- package/components/uv-calendars/i18n/index.js +8 -0
- package/components/uv-calendars/i18n/zh-Hans.json +12 -0
- package/components/uv-calendars/i18n/zh-Hant.json +12 -0
- package/components/uv-calendars/util.js +435 -0
- package/components/uv-calendars/uv-calendars.vue +452 -0
- package/components/uv-cell/props.js +116 -0
- package/components/uv-cell/uv-cell.vue +209 -0
- package/components/uv-cell-group/props.js +15 -0
- package/components/uv-cell-group/uv-cell-group.vue +63 -0
- package/components/uv-checkbox/props.js +70 -0
- package/components/uv-checkbox/uv-checkbox.vue +371 -0
- package/components/uv-checkbox-group/props.js +84 -0
- package/components/uv-checkbox-group/uv-checkbox-group.vue +119 -0
- package/components/uv-code/props.js +35 -0
- package/components/uv-code/uv-code.vue +136 -0
- package/components/uv-code-input/props.js +83 -0
- package/components/uv-code-input/uv-code-input.vue +272 -0
- package/components/uv-col/props.js +30 -0
- package/components/uv-col/uv-col.vue +165 -0
- package/components/uv-collapse/props.js +20 -0
- package/components/uv-collapse/uv-collapse.vue +86 -0
- package/components/uv-collapse-item/props.js +60 -0
- package/components/uv-collapse-item/uv-collapse-item.vue +228 -0
- package/components/uv-column-notice/props.js +61 -0
- package/components/uv-column-notice/uv-column-notice.vue +176 -0
- package/components/uv-count-down/props.js +25 -0
- package/components/uv-count-down/utils.js +62 -0
- package/components/uv-count-down/uv-count-down.vue +169 -0
- package/components/uv-count-to/props.js +60 -0
- package/components/uv-count-to/uv-count-to.vue +187 -0
- package/components/uv-datetime-picker/props.js +130 -0
- package/components/uv-datetime-picker/uv-datetime-picker.vue +355 -0
- package/components/uv-divider/props.js +45 -0
- package/components/uv-divider/uv-divider.vue +113 -0
- package/components/uv-drop-down/uv-drop-down.vue +135 -0
- package/components/uv-drop-down-item/uv-drop-down-item.vue +169 -0
- package/components/uv-drop-down-popup/uv-drop-down-popup.vue +242 -0
- package/components/uv-empty/props.js +60 -0
- package/components/uv-empty/uv-empty.vue +126 -0
- package/components/uv-form/props.js +46 -0
- package/components/uv-form/uv-form.vue +209 -0
- package/components/uv-form/valid.js +1343 -0
- package/components/uv-form-item/props.js +49 -0
- package/components/uv-form-item/uv-form-item.vue +226 -0
- package/components/uv-gap/props.js +25 -0
- package/components/uv-gap/uv-gap.vue +36 -0
- package/components/uv-grid/props.js +20 -0
- package/components/uv-grid/uv-grid.vue +100 -0
- package/components/uv-grid-item/props.js +15 -0
- package/components/uv-grid-item/uv-grid-item.vue +223 -0
- package/components/uv-icon/icons.js +160 -0
- package/components/uv-icon/props.js +90 -0
- package/components/uv-icon/uv-icon.vue +226 -0
- package/components/uv-icon/uvicons.ttf +0 -0
- package/components/uv-image/props.js +100 -0
- package/components/uv-image/uv-image.vue +296 -0
- package/components/uv-index-anchor/props.js +30 -0
- package/components/uv-index-anchor/uv-index-anchor.vue +98 -0
- package/components/uv-index-item/uv-index-item.vue +87 -0
- package/components/uv-index-list/props.js +30 -0
- package/components/uv-index-list/uv-index-list.vue +461 -0
- package/components/uv-input/props.js +175 -0
- package/components/uv-input/uv-input.vue +348 -0
- package/components/uv-keyboard/props.js +95 -0
- package/components/uv-keyboard/uv-keyboard.vue +180 -0
- package/components/uv-keyboard-car/props.js +24 -0
- package/components/uv-keyboard-car/uv-keyboard-car.vue +347 -0
- package/components/uv-keyboard-number/props.js +19 -0
- package/components/uv-keyboard-number/uv-keyboard-number.vue +201 -0
- package/components/uv-line/props.js +34 -0
- package/components/uv-line/uv-line.vue +60 -0
- package/components/uv-line-progress/props.js +29 -0
- package/components/uv-line-progress/uv-line-progress.vue +146 -0
- package/components/uv-link/props.js +40 -0
- package/components/uv-link/uv-link.vue +83 -0
- package/components/uv-list/uv-list.vue +147 -0
- package/components/uv-list-item/uv-list-item.vue +535 -0
- package/components/uv-load-more/props.js +95 -0
- package/components/uv-load-more/uv-load-more.vue +152 -0
- package/components/uv-loading-icon/props.js +67 -0
- package/components/uv-loading-icon/uv-loading-icon.vue +347 -0
- package/components/uv-loading-page/props.js +55 -0
- package/components/uv-loading-page/uv-loading-page.vue +96 -0
- package/components/uv-modal/props.js +90 -0
- package/components/uv-modal/uv-modal.vue +245 -0
- package/components/uv-navbar/props.js +89 -0
- package/components/uv-navbar/uv-navbar.vue +245 -0
- package/components/uv-no-network/props.js +20 -0
- package/components/uv-no-network/uv-no-network.vue +222 -0
- package/components/uv-notice-bar/props.js +76 -0
- package/components/uv-notice-bar/uv-notice-bar.vue +110 -0
- package/components/uv-notify/props.js +45 -0
- package/components/uv-notify/uv-notify.vue +220 -0
- package/components/uv-number-box/props.js +118 -0
- package/components/uv-number-box/uv-number-box.vue +397 -0
- package/components/uv-overlay/props.js +25 -0
- package/components/uv-overlay/uv-overlay.vue +85 -0
- package/components/uv-parse/node/node.vue +576 -0
- package/components/uv-parse/parser.js +1335 -0
- package/components/uv-parse/uv-parse.vue +498 -0
- package/components/uv-pick-color/colors.js +217 -0
- package/components/uv-pick-color/props.js +47 -0
- package/components/uv-pick-color/uv-pick-color.vue +551 -0
- package/components/uv-picker/props.js +95 -0
- package/components/uv-picker/uv-picker.vue +329 -0
- package/components/uv-popup/keypress.js +45 -0
- package/components/uv-popup/uv-popup.vue +537 -0
- package/components/uv-preview-video/uv-preview-video.vue +52 -0
- package/components/uv-qrcode/cache.js +1 -0
- package/components/uv-qrcode/gcanvas/bridge/bridge-weex.js +241 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStylePattern.js +8 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
- package/components/uv-qrcode/gcanvas/context-2d/RenderingContext.js +666 -0
- package/components/uv-qrcode/gcanvas/context-webgl/ActiveInfo.js +11 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Buffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Framebuffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLenum.js +298 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLmethod.js +142 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLtype.js +23 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Program.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Renderbuffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/RenderingContext.js +1191 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Shader.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Texture.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/UniformLocation.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/classUtils.js +3 -0
- package/components/uv-qrcode/gcanvas/env/canvas.js +74 -0
- package/components/uv-qrcode/gcanvas/env/image.js +96 -0
- package/components/uv-qrcode/gcanvas/env/tool.js +24 -0
- package/components/uv-qrcode/gcanvas/index.js +39 -0
- package/components/uv-qrcode/props.js +85 -0
- package/components/uv-qrcode/qrcode.js +34 -0
- package/components/uv-qrcode/queue.js +41 -0
- package/components/uv-qrcode/uv-qrcode.vue +1038 -0
- package/components/uv-radio/props.js +65 -0
- package/components/uv-radio/uv-radio.vue +349 -0
- package/components/uv-radio-group/props.js +89 -0
- package/components/uv-radio-group/uv-radio-group.vue +115 -0
- package/components/uv-rate/props.js +73 -0
- package/components/uv-rate/uv-rate.vue +274 -0
- package/components/uv-read-more/props.js +62 -0
- package/components/uv-read-more/uv-read-more.vue +162 -0
- package/components/uv-row/props.js +20 -0
- package/components/uv-row/uv-row.vue +95 -0
- package/components/uv-row-notice/props.js +40 -0
- package/components/uv-row-notice/uv-row-notice.vue +341 -0
- package/components/uv-safe-bottom/uv-safe-bottom.vue +67 -0
- package/components/uv-scroll-list/nvue.js +29 -0
- package/components/uv-scroll-list/props.js +35 -0
- package/components/uv-scroll-list/scrollWxs.wxs +51 -0
- package/components/uv-scroll-list/uv-scroll-list.vue +218 -0
- package/components/uv-search/props.js +127 -0
- package/components/uv-search/uv-search.vue +311 -0
- package/components/uv-skeleton/props.js +65 -0
- package/components/uv-skeleton/uv-skeleton.vue +250 -0
- package/components/uv-skeletons/uv-skeletons.vue +247 -0
- package/components/uv-slider/props.js +58 -0
- package/components/uv-slider/uv-slider.vue +58 -0
- package/components/uv-status-bar/props.js +8 -0
- package/components/uv-status-bar/uv-status-bar.vue +54 -0
- package/components/uv-steps/props.js +40 -0
- package/components/uv-steps/uv-steps.vue +83 -0
- package/components/uv-steps-item/props.js +25 -0
- package/components/uv-steps-item/uv-steps-item.vue +347 -0
- package/components/uv-sticky/props.js +41 -0
- package/components/uv-sticky/uv-sticky.vue +223 -0
- package/components/uv-subsection/props.js +54 -0
- package/components/uv-subsection/uv-subsection.vue +269 -0
- package/components/uv-swipe-action/props.js +10 -0
- package/components/uv-swipe-action/uv-swipe-action.vue +65 -0
- package/components/uv-swipe-action-item/index - backup.wxs +256 -0
- package/components/uv-swipe-action-item/index.wxs +225 -0
- package/components/uv-swipe-action-item/nvue - backup.js +264 -0
- package/components/uv-swipe-action-item/nvue.js +182 -0
- package/components/uv-swipe-action-item/props.js +40 -0
- package/components/uv-swipe-action-item/uv-swipe-action-item.vue +200 -0
- package/components/uv-swipe-action-item/wxs.js +15 -0
- package/components/uv-swiper/props.js +136 -0
- package/components/uv-swiper/uv-swiper.vue +263 -0
- package/components/uv-swiper-indicator/props.js +30 -0
- package/components/uv-swiper-indicator/uv-swiper-indicator.vue +112 -0
- package/components/uv-switch/props.js +58 -0
- package/components/uv-switch/uv-switch.vue +182 -0
- package/components/uv-tabbar/props.js +50 -0
- package/components/uv-tabbar/uv-tabbar.vue +146 -0
- package/components/uv-tabbar-item/props.js +40 -0
- package/components/uv-tabbar-item/uv-tabbar-item.vue +146 -0
- package/components/uv-tabs/props.js +71 -0
- package/components/uv-tabs/uv-tabs.vue +391 -0
- package/components/uv-tags/props.js +104 -0
- package/components/uv-tags/uv-tags.vue +379 -0
- package/components/uv-text/props.js +113 -0
- package/components/uv-text/uv-text.vue +218 -0
- package/components/uv-text/value.js +87 -0
- package/components/uv-textarea/props.js +138 -0
- package/components/uv-textarea/uv-textarea.vue +238 -0
- package/components/uv-toast/uv-toast.vue +292 -0
- package/components/uv-toolbar/props.js +40 -0
- package/components/uv-toolbar/uv-toolbar.vue +109 -0
- package/components/uv-tooltip/props.js +60 -0
- package/components/uv-tooltip/uv-tooltip.vue +372 -0
- package/components/uv-transition/createAnimation.js +131 -0
- package/components/uv-transition/props.js +31 -0
- package/components/uv-transition/uv-transition.vue +320 -0
- package/components/uv-upload/mixin.js +22 -0
- package/components/uv-upload/props.js +130 -0
- package/components/uv-upload/utils.js +151 -0
- package/components/uv-upload/uv-upload.vue +488 -0
- package/components/uv-vtabs/props.js +79 -0
- package/components/uv-vtabs/uv-vtabs.vue +438 -0
- package/components/uv-vtabs-item/uv-vtabs-item.vue +68 -0
- package/components/uv-waterfall/props.js +69 -0
- package/components/uv-waterfall/uv-waterfall.vue +265 -0
- package/index.js +82 -0
- package/index.scss +7 -0
- package/libs/config/config.js +34 -0
- package/libs/css/color.scss +32 -0
- package/libs/css/common.scss +100 -0
- package/libs/css/components.scss +23 -0
- package/libs/css/variable.scss +111 -0
- package/libs/css/vue.scss +40 -0
- package/libs/function/colorGradient.js +134 -0
- package/libs/function/compress.js +27 -0
- package/libs/function/debounce.js +29 -0
- package/libs/function/digit.js +167 -0
- package/libs/function/index.js +734 -0
- package/libs/function/platform.js +75 -0
- package/libs/function/test.js +287 -0
- package/libs/function/throttle.js +30 -0
- package/libs/luch-request/adapters/index.js +132 -0
- package/libs/luch-request/core/InterceptorManager.js +51 -0
- package/libs/luch-request/core/Request.js +201 -0
- package/libs/luch-request/core/buildFullPath.js +20 -0
- package/libs/luch-request/core/defaults.js +33 -0
- package/libs/luch-request/core/dispatchRequest.js +6 -0
- package/libs/luch-request/core/mergeConfig.js +126 -0
- package/libs/luch-request/core/settle.js +16 -0
- package/libs/luch-request/helpers/buildURL.js +64 -0
- package/libs/luch-request/helpers/combineURLs.js +14 -0
- package/libs/luch-request/helpers/isAbsoluteURL.js +14 -0
- package/libs/luch-request/index.d.ts +197 -0
- package/libs/luch-request/index.js +2 -0
- package/libs/luch-request/utils/clone.js +264 -0
- package/libs/luch-request/utils.js +135 -0
- package/libs/mixin/button.js +13 -0
- package/libs/mixin/mixin.js +172 -0
- package/libs/mixin/mpMixin.js +8 -0
- package/libs/mixin/mpShare.js +13 -0
- package/libs/mixin/openType.js +47 -0
- package/libs/mixin/touch.js +59 -0
- package/libs/util/dayjs.js +216 -0
- package/libs/util/route.js +126 -0
- package/package.json +28 -0
- package/theme.scss +43 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 注意:
|
|
3
|
+
* 此部分内容,在vue-cli模式下,需要在vue.config.js加入如下内容才有效:
|
|
4
|
+
* module.exports = {
|
|
5
|
+
* transpileDependencies: ['uview-v2']
|
|
6
|
+
* }
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
let platform = 'none'
|
|
10
|
+
|
|
11
|
+
// #ifdef VUE3
|
|
12
|
+
platform = 'vue3'
|
|
13
|
+
// #endif
|
|
14
|
+
|
|
15
|
+
// #ifdef VUE2
|
|
16
|
+
platform = 'vue2'
|
|
17
|
+
// #endif
|
|
18
|
+
|
|
19
|
+
// #ifdef APP-PLUS
|
|
20
|
+
platform = 'plus'
|
|
21
|
+
// #endif
|
|
22
|
+
|
|
23
|
+
// #ifdef APP-NVUE
|
|
24
|
+
platform = 'nvue'
|
|
25
|
+
// #endif
|
|
26
|
+
|
|
27
|
+
// #ifdef H5
|
|
28
|
+
platform = 'h5'
|
|
29
|
+
// #endif
|
|
30
|
+
|
|
31
|
+
// #ifdef MP-WEIXIN
|
|
32
|
+
platform = 'weixin'
|
|
33
|
+
// #endif
|
|
34
|
+
|
|
35
|
+
// #ifdef MP-ALIPAY
|
|
36
|
+
platform = 'alipay'
|
|
37
|
+
// #endif
|
|
38
|
+
|
|
39
|
+
// #ifdef MP-BAIDU
|
|
40
|
+
platform = 'baidu'
|
|
41
|
+
// #endif
|
|
42
|
+
|
|
43
|
+
// #ifdef MP-TOUTIAO
|
|
44
|
+
platform = 'toutiao'
|
|
45
|
+
// #endif
|
|
46
|
+
|
|
47
|
+
// #ifdef MP-QQ
|
|
48
|
+
platform = 'qq'
|
|
49
|
+
// #endif
|
|
50
|
+
|
|
51
|
+
// #ifdef MP-KUAISHOU
|
|
52
|
+
platform = 'kuaishou'
|
|
53
|
+
// #endif
|
|
54
|
+
|
|
55
|
+
// #ifdef MP-360
|
|
56
|
+
platform = '360'
|
|
57
|
+
// #endif
|
|
58
|
+
|
|
59
|
+
// #ifdef MP
|
|
60
|
+
platform = 'mp'
|
|
61
|
+
// #endif
|
|
62
|
+
|
|
63
|
+
// #ifdef QUICKAPP-WEBVIEW
|
|
64
|
+
platform = 'quickapp-webview'
|
|
65
|
+
// #endif
|
|
66
|
+
|
|
67
|
+
// #ifdef QUICKAPP-WEBVIEW-HUAWEI
|
|
68
|
+
platform = 'quickapp-webview-huawei'
|
|
69
|
+
// #endif
|
|
70
|
+
|
|
71
|
+
// #ifdef QUICKAPP-WEBVIEW-UNION
|
|
72
|
+
platform = 'quckapp-webview-union'
|
|
73
|
+
// #endif
|
|
74
|
+
|
|
75
|
+
export default platform
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 验证电子邮箱格式
|
|
3
|
+
*/
|
|
4
|
+
function email(value) {
|
|
5
|
+
return /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(value)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 验证手机格式
|
|
10
|
+
*/
|
|
11
|
+
function mobile(value) {
|
|
12
|
+
return /^1([3589]\d|4[5-9]|6[1-2,4-7]|7[0-8])\d{8}$/.test(value)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 验证URL格式
|
|
17
|
+
*/
|
|
18
|
+
function url(value) {
|
|
19
|
+
return /^((https|http|ftp|rtsp|mms):\/\/)(([0-9a-zA-Z_!~*'().&=+$%-]+: )?[0-9a-zA-Z_!~*'().&=+$%-]+@)?(([0-9]{1,3}.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z].[a-zA-Z]{2,6})(:[0-9]{1,4})?((\/?)|(\/[0-9a-zA-Z_!~*'().;?:@&=+$,%#-]+)+\/?)$/
|
|
20
|
+
.test(value)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 验证日期格式
|
|
25
|
+
*/
|
|
26
|
+
function date(value) {
|
|
27
|
+
if (!value) return false
|
|
28
|
+
// 判断是否数值或者字符串数值(意味着为时间戳),转为数值,否则new Date无法识别字符串时间戳
|
|
29
|
+
if (number(value)) value = +value
|
|
30
|
+
return !/Invalid|NaN/.test(new Date(value).toString())
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 验证ISO类型的日期格式
|
|
35
|
+
*/
|
|
36
|
+
function dateISO(value) {
|
|
37
|
+
return /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(value)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 验证十进制数字
|
|
42
|
+
*/
|
|
43
|
+
function number(value) {
|
|
44
|
+
return /^[\+-]?(\d+\.?\d*|\.\d+|\d\.\d+e\+\d+)$/.test(value)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 验证字符串
|
|
49
|
+
*/
|
|
50
|
+
function string(value) {
|
|
51
|
+
return typeof value === 'string'
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 验证整数
|
|
56
|
+
*/
|
|
57
|
+
function digits(value) {
|
|
58
|
+
return /^\d+$/.test(value)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 验证身份证号码
|
|
63
|
+
*/
|
|
64
|
+
function idCard(value) {
|
|
65
|
+
return /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(
|
|
66
|
+
value
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 是否车牌号
|
|
72
|
+
*/
|
|
73
|
+
function carNo(value) {
|
|
74
|
+
// 新能源车牌
|
|
75
|
+
const xreg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/
|
|
76
|
+
// 旧车牌
|
|
77
|
+
const creg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/
|
|
78
|
+
if (value.length === 7) {
|
|
79
|
+
return creg.test(value)
|
|
80
|
+
} if (value.length === 8) {
|
|
81
|
+
return xreg.test(value)
|
|
82
|
+
}
|
|
83
|
+
return false
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 金额,只允许2位小数
|
|
88
|
+
*/
|
|
89
|
+
function amount(value) {
|
|
90
|
+
// 金额,只允许保留两位小数
|
|
91
|
+
return /^[1-9]\d*(,\d{3})*(\.\d{1,2})?$|^0\.\d{1,2}$/.test(value)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 中文
|
|
96
|
+
*/
|
|
97
|
+
function chinese(value) {
|
|
98
|
+
const reg = /^[\u4e00-\u9fa5]+$/gi
|
|
99
|
+
return reg.test(value)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 只能输入字母
|
|
104
|
+
*/
|
|
105
|
+
function letter(value) {
|
|
106
|
+
return /^[a-zA-Z]*$/.test(value)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 只能是字母或者数字
|
|
111
|
+
*/
|
|
112
|
+
function enOrNum(value) {
|
|
113
|
+
// 英文或者数字
|
|
114
|
+
const reg = /^[0-9a-zA-Z]*$/g
|
|
115
|
+
return reg.test(value)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* 验证是否包含某个值
|
|
120
|
+
*/
|
|
121
|
+
function contains(value, param) {
|
|
122
|
+
return value.indexOf(param) >= 0
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* 验证一个值范围[min, max]
|
|
127
|
+
*/
|
|
128
|
+
function range(value, param) {
|
|
129
|
+
return value >= param[0] && value <= param[1]
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 验证一个长度范围[min, max]
|
|
134
|
+
*/
|
|
135
|
+
function rangeLength(value, param) {
|
|
136
|
+
return value.length >= param[0] && value.length <= param[1]
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 是否固定电话
|
|
141
|
+
*/
|
|
142
|
+
function landline(value) {
|
|
143
|
+
const reg = /^\d{3,4}-\d{7,8}(-\d{3,4})?$/
|
|
144
|
+
return reg.test(value)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* 判断是否为空
|
|
149
|
+
*/
|
|
150
|
+
function empty(value) {
|
|
151
|
+
switch (typeof value) {
|
|
152
|
+
case 'undefined':
|
|
153
|
+
return true
|
|
154
|
+
case 'string':
|
|
155
|
+
if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true
|
|
156
|
+
break
|
|
157
|
+
case 'boolean':
|
|
158
|
+
if (!value) return true
|
|
159
|
+
break
|
|
160
|
+
case 'number':
|
|
161
|
+
if (value === 0 || isNaN(value)) return true
|
|
162
|
+
break
|
|
163
|
+
case 'object':
|
|
164
|
+
if (value === null || value.length === 0) return true
|
|
165
|
+
for (const i in value) {
|
|
166
|
+
return false
|
|
167
|
+
}
|
|
168
|
+
return true
|
|
169
|
+
}
|
|
170
|
+
return false
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* 是否json字符串
|
|
175
|
+
*/
|
|
176
|
+
function jsonString(value) {
|
|
177
|
+
if (typeof value === 'string') {
|
|
178
|
+
try {
|
|
179
|
+
const obj = JSON.parse(value)
|
|
180
|
+
if (typeof obj === 'object' && obj) {
|
|
181
|
+
return true
|
|
182
|
+
}
|
|
183
|
+
return false
|
|
184
|
+
} catch (e) {
|
|
185
|
+
return false
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return false
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* 是否数组
|
|
193
|
+
*/
|
|
194
|
+
function array(value) {
|
|
195
|
+
if (typeof Array.isArray === 'function') {
|
|
196
|
+
return Array.isArray(value)
|
|
197
|
+
}
|
|
198
|
+
return Object.prototype.toString.call(value) === '[object Array]'
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* 是否对象
|
|
203
|
+
*/
|
|
204
|
+
function object(value) {
|
|
205
|
+
return Object.prototype.toString.call(value) === '[object Object]'
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* 是否短信验证码
|
|
210
|
+
*/
|
|
211
|
+
function code(value, len = 6) {
|
|
212
|
+
return new RegExp(`^\\d{${len}}$`).test(value)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* 是否函数方法
|
|
217
|
+
* @param {Object} value
|
|
218
|
+
*/
|
|
219
|
+
function func(value) {
|
|
220
|
+
return typeof value === 'function'
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* 是否promise对象
|
|
225
|
+
* @param {Object} value
|
|
226
|
+
*/
|
|
227
|
+
function promise(value) {
|
|
228
|
+
return object(value) && func(value.then) && func(value.catch)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** 是否图片格式
|
|
232
|
+
* @param {Object} value
|
|
233
|
+
*/
|
|
234
|
+
function image(value) {
|
|
235
|
+
const newValue = value.split('?')[0]
|
|
236
|
+
const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i
|
|
237
|
+
return IMAGE_REGEXP.test(newValue)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* 是否视频格式
|
|
242
|
+
* @param {Object} value
|
|
243
|
+
*/
|
|
244
|
+
function video(value) {
|
|
245
|
+
const VIDEO_REGEXP = /\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv|m3u8)/i
|
|
246
|
+
return VIDEO_REGEXP.test(value)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* 是否为正则对象
|
|
251
|
+
* @param {Object}
|
|
252
|
+
* @return {Boolean}
|
|
253
|
+
*/
|
|
254
|
+
function regExp(o) {
|
|
255
|
+
return o && Object.prototype.toString.call(o) === '[object RegExp]'
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export {
|
|
259
|
+
email,
|
|
260
|
+
mobile,
|
|
261
|
+
url,
|
|
262
|
+
date,
|
|
263
|
+
dateISO,
|
|
264
|
+
number,
|
|
265
|
+
digits,
|
|
266
|
+
idCard,
|
|
267
|
+
carNo,
|
|
268
|
+
amount,
|
|
269
|
+
chinese,
|
|
270
|
+
letter,
|
|
271
|
+
enOrNum,
|
|
272
|
+
contains,
|
|
273
|
+
range,
|
|
274
|
+
rangeLength,
|
|
275
|
+
empty,
|
|
276
|
+
jsonString,
|
|
277
|
+
landline,
|
|
278
|
+
object,
|
|
279
|
+
array,
|
|
280
|
+
code,
|
|
281
|
+
func,
|
|
282
|
+
promise,
|
|
283
|
+
video,
|
|
284
|
+
image,
|
|
285
|
+
regExp,
|
|
286
|
+
string
|
|
287
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
let timer; let
|
|
2
|
+
flag
|
|
3
|
+
/**
|
|
4
|
+
* 节流原理:在一定时间内,只能触发一次
|
|
5
|
+
*
|
|
6
|
+
* @param {Function} func 要执行的回调函数
|
|
7
|
+
* @param {Number} wait 延时的时间
|
|
8
|
+
* @param {Boolean} immediate 是否立即执行
|
|
9
|
+
* @return null
|
|
10
|
+
*/
|
|
11
|
+
function throttle(func, wait = 500, immediate = true) {
|
|
12
|
+
if (immediate) {
|
|
13
|
+
if (!flag) {
|
|
14
|
+
flag = true
|
|
15
|
+
// 如果是立即执行,则在wait毫秒内开始时执行
|
|
16
|
+
typeof func === 'function' && func()
|
|
17
|
+
timer = setTimeout(() => {
|
|
18
|
+
flag = false
|
|
19
|
+
}, wait)
|
|
20
|
+
}
|
|
21
|
+
} else if (!flag) {
|
|
22
|
+
flag = true
|
|
23
|
+
// 如果是非立即执行,则在wait毫秒内的结束处执行
|
|
24
|
+
timer = setTimeout(() => {
|
|
25
|
+
flag = false
|
|
26
|
+
typeof func === 'function' && func()
|
|
27
|
+
}, wait)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export default throttle
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import buildURL from '../helpers/buildURL'
|
|
2
|
+
import buildFullPath from '../core/buildFullPath'
|
|
3
|
+
import settle from '../core/settle'
|
|
4
|
+
import {isUndefined} from "../utils"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 返回可选值存在的配置
|
|
8
|
+
* @param {Array} keys - 可选值数组
|
|
9
|
+
* @param {Object} config2 - 配置
|
|
10
|
+
* @return {{}} - 存在的配置项
|
|
11
|
+
*/
|
|
12
|
+
const mergeKeys = (keys, config2) => {
|
|
13
|
+
let config = {}
|
|
14
|
+
keys.forEach(prop => {
|
|
15
|
+
if (!isUndefined(config2[prop])) {
|
|
16
|
+
config[prop] = config2[prop]
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
return config
|
|
20
|
+
}
|
|
21
|
+
export default (config) => {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
let fullPath = buildURL(buildFullPath(config.baseURL, config.url), config.params, config.paramsSerializer)
|
|
24
|
+
const _config = {
|
|
25
|
+
url: fullPath,
|
|
26
|
+
header: config.header,
|
|
27
|
+
complete: (response) => {
|
|
28
|
+
config.fullPath = fullPath
|
|
29
|
+
response.config = config
|
|
30
|
+
response.rawData = response.data
|
|
31
|
+
try {
|
|
32
|
+
let jsonParseHandle = false
|
|
33
|
+
const forcedJSONParsingType = typeof config.forcedJSONParsing
|
|
34
|
+
if (forcedJSONParsingType === 'boolean') {
|
|
35
|
+
jsonParseHandle = config.forcedJSONParsing
|
|
36
|
+
} else if (forcedJSONParsingType === 'object') {
|
|
37
|
+
const includesMethod = config.forcedJSONParsing.include || []
|
|
38
|
+
jsonParseHandle = includesMethod.includes(config.method)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 对可能字符串不是json 的情况容错
|
|
42
|
+
if (jsonParseHandle && typeof response.data === 'string') {
|
|
43
|
+
response.data = JSON.parse(response.data)
|
|
44
|
+
}
|
|
45
|
+
// eslint-disable-next-line no-empty
|
|
46
|
+
} catch (e) {
|
|
47
|
+
}
|
|
48
|
+
settle(resolve, reject, response)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
let requestTask
|
|
52
|
+
if (config.method === 'UPLOAD') {
|
|
53
|
+
delete _config.header['content-type']
|
|
54
|
+
delete _config.header['Content-Type']
|
|
55
|
+
let otherConfig = {
|
|
56
|
+
// #ifdef MP-ALIPAY
|
|
57
|
+
fileType: config.fileType,
|
|
58
|
+
// #endif
|
|
59
|
+
filePath: config.filePath,
|
|
60
|
+
name: config.name
|
|
61
|
+
}
|
|
62
|
+
const optionalKeys = [
|
|
63
|
+
// #ifdef APP-PLUS || H5
|
|
64
|
+
'files',
|
|
65
|
+
// #endif
|
|
66
|
+
// #ifdef H5
|
|
67
|
+
'file',
|
|
68
|
+
// #endif
|
|
69
|
+
// #ifdef H5 || APP-PLUS || MP-WEIXIN || MP-ALIPAY || MP-TOUTIAO || MP-KUAISHOU
|
|
70
|
+
'timeout',
|
|
71
|
+
// #endif
|
|
72
|
+
'formData'
|
|
73
|
+
]
|
|
74
|
+
requestTask = uni.uploadFile({..._config, ...otherConfig, ...mergeKeys(optionalKeys, config)})
|
|
75
|
+
} else if (config.method === 'DOWNLOAD') {
|
|
76
|
+
const optionalKeys = [
|
|
77
|
+
// #ifdef H5 || APP-PLUS || MP-WEIXIN || MP-ALIPAY || MP-TOUTIAO || MP-KUAISHOU
|
|
78
|
+
'timeout',
|
|
79
|
+
// #endif
|
|
80
|
+
// #ifdef MP
|
|
81
|
+
'filePath',
|
|
82
|
+
// #endif
|
|
83
|
+
]
|
|
84
|
+
requestTask = uni.downloadFile({..._config, ...mergeKeys(optionalKeys, config)})
|
|
85
|
+
} else {
|
|
86
|
+
const optionalKeys = [
|
|
87
|
+
'data',
|
|
88
|
+
'method',
|
|
89
|
+
// #ifdef H5 || APP-PLUS || MP-ALIPAY || MP-WEIXIN
|
|
90
|
+
'timeout',
|
|
91
|
+
// #endif
|
|
92
|
+
'dataType',
|
|
93
|
+
// #ifndef MP-ALIPAY
|
|
94
|
+
'responseType',
|
|
95
|
+
// #endif
|
|
96
|
+
// #ifdef APP-PLUS
|
|
97
|
+
'sslVerify',
|
|
98
|
+
// #endif
|
|
99
|
+
// #ifdef H5
|
|
100
|
+
'withCredentials',
|
|
101
|
+
// #endif
|
|
102
|
+
// #ifdef APP-PLUS
|
|
103
|
+
'firstIpv4',
|
|
104
|
+
// #endif
|
|
105
|
+
// #ifdef MP-WEIXIN
|
|
106
|
+
'enableHttp2',
|
|
107
|
+
'enableQuic',
|
|
108
|
+
// #endif
|
|
109
|
+
// #ifdef MP-TOUTIAO || MP-WEIXIN
|
|
110
|
+
'enableCache',
|
|
111
|
+
// #endif
|
|
112
|
+
// #ifdef MP-WEIXIN
|
|
113
|
+
'enableHttpDNS',
|
|
114
|
+
'httpDNSServiceId',
|
|
115
|
+
'enableChunked',
|
|
116
|
+
'forceCellularNetwork',
|
|
117
|
+
// #endif
|
|
118
|
+
// #ifdef MP-ALIPAY
|
|
119
|
+
'enableCookie',
|
|
120
|
+
// #endif
|
|
121
|
+
// #ifdef MP-BAIDU
|
|
122
|
+
'cloudCache',
|
|
123
|
+
'defer'
|
|
124
|
+
// #endif
|
|
125
|
+
]
|
|
126
|
+
requestTask = uni.request({..._config, ...mergeKeys(optionalKeys, config)})
|
|
127
|
+
}
|
|
128
|
+
if (config.getTask) {
|
|
129
|
+
config.getTask(requestTask, config)
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function InterceptorManager() {
|
|
5
|
+
this.handlers = []
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Add a new interceptor to the stack
|
|
10
|
+
*
|
|
11
|
+
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
12
|
+
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
13
|
+
*
|
|
14
|
+
* @return {Number} An ID used to remove interceptor later
|
|
15
|
+
*/
|
|
16
|
+
InterceptorManager.prototype.use = function use(fulfilled, rejected) {
|
|
17
|
+
this.handlers.push({
|
|
18
|
+
fulfilled: fulfilled,
|
|
19
|
+
rejected: rejected
|
|
20
|
+
})
|
|
21
|
+
return this.handlers.length - 1
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Remove an interceptor from the stack
|
|
26
|
+
*
|
|
27
|
+
* @param {Number} id The ID that was returned by `use`
|
|
28
|
+
*/
|
|
29
|
+
InterceptorManager.prototype.eject = function eject(id) {
|
|
30
|
+
if (this.handlers[id]) {
|
|
31
|
+
this.handlers[id] = null
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Iterate over all the registered interceptors
|
|
37
|
+
*
|
|
38
|
+
* This method is particularly useful for skipping over any
|
|
39
|
+
* interceptors that may have become `null` calling `eject`.
|
|
40
|
+
*
|
|
41
|
+
* @param {Function} fn The function to call for each interceptor
|
|
42
|
+
*/
|
|
43
|
+
InterceptorManager.prototype.forEach = function forEach(fn) {
|
|
44
|
+
this.handlers.forEach(h => {
|
|
45
|
+
if (h !== null) {
|
|
46
|
+
fn(h)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default InterceptorManager
|