@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,320 @@
1
+ <template>
2
+ <!-- #ifndef APP-NVUE -->
3
+ <view
4
+ v-if="isShow"
5
+ ref="ani"
6
+ :animation="animationData"
7
+ :class="customClass"
8
+ :style="transformStyles"
9
+ @click="onClick">
10
+ <slot></slot>
11
+ </view>
12
+ <!-- #endif -->
13
+ <!-- #ifdef APP-NVUE -->
14
+ <view
15
+ v-if="isShow"
16
+ ref="ani"
17
+ :animation="animationData"
18
+ :class="customClass"
19
+ :style="transformStyles"
20
+ @click="onClick">
21
+ <slot></slot>
22
+ </view>
23
+ <!-- #endif -->
24
+ </template>
25
+ <script>
26
+ import mpMixin from '../../libs/mixin/mpMixin.js'
27
+ import mixin from '../../libs/mixin/mixin.js'
28
+ import { createAnimation } from './createAnimation'
29
+ /**
30
+ * transition 动画组件
31
+ * @description
32
+ * @tutorial
33
+ * @property {Boolean} show 控制组件显示或关闭 (默认 false )
34
+ * @property {Array | String } mode 内置过渡动画类型 (默认 'fade' )
35
+ * @value fade 渐隐渐出过渡
36
+ * @value slide-top 由上至下过渡
37
+ * @value slide-bottom 由下至上过渡
38
+ * @value slide-left 由左至右过渡
39
+ * @value slide-right 由右至左过渡
40
+ * @value zoom-in 由小到大过渡
41
+ * @value zoom-out 由大到小过渡
42
+ * @property {String | Number} duration 动画的执行时间,单位ms (默认 300 )
43
+ * @property {String} timingFunction 使用的动画过渡函数 (默认 'ease-out' )
44
+ * @property {Object} customStyle 自定义样式
45
+ * @property {String} customClass 自定义类名
46
+ * @event {Function} click 点击组件触发
47
+ * @event {Function} change 过渡动画结束时触发
48
+ * @example
49
+ */
50
+ export default {
51
+ name: 'uv-transition',
52
+ mixins: [mpMixin,mixin],
53
+ emits:['click','change'],
54
+ props: {
55
+ // 是否展示组件
56
+ show: {
57
+ type: Boolean,
58
+ default: false
59
+ },
60
+ // 使用的动画模式
61
+ mode: {
62
+ type: [Array, String, null],
63
+ default() {
64
+ return 'fade'
65
+ }
66
+ },
67
+ // 动画的执行时间,单位ms
68
+ duration: {
69
+ type: [String, Number],
70
+ default: 300
71
+ },
72
+ // 使用的动画过渡函数
73
+ timingFunction: {
74
+ type: String,
75
+ default: 'ease-out'
76
+ },
77
+ customClass: {
78
+ type: String,
79
+ default: ''
80
+ },
81
+ // nvue模式下 是否直接显示,在uv-list等cell下面使用就需要设置
82
+ cellChild: {
83
+ type: Boolean,
84
+ default: false
85
+ }
86
+ },
87
+ data(){
88
+ return {
89
+ isShow: false,
90
+ transform: '',
91
+ opacity: 1,
92
+ animationData: {},
93
+ durationTime: 300,
94
+ config: {}
95
+ }
96
+ },
97
+ watch: {
98
+ show: {
99
+ handler(newVal) {
100
+ if (newVal) {
101
+ this.open();
102
+ } else {
103
+ // 避免上来就执行 close,导致动画错乱
104
+ if (this.isShow) {
105
+ this.close();
106
+ }
107
+ }
108
+ },
109
+ immediate: true
110
+ }
111
+ },
112
+ computed: {
113
+ // 初始化动画条件
114
+ transformStyles() {
115
+ const style = {
116
+ transform: this.transform,
117
+ opacity: this.opacity,
118
+ ...this.$uv.addStyle(this.customStyle),
119
+ 'transition-duration': `${this.duration / 1000}s`
120
+ };
121
+ return this.$uv.addStyle(style,'string');
122
+ }
123
+ },
124
+ created() {
125
+ // 动画默认配置
126
+ this.config = {
127
+ duration: this.duration,
128
+ timingFunction: this.timingFunction,
129
+ transformOrigin: '50% 50%',
130
+ delay: 0
131
+ };
132
+ this.durationTime = this.duration;
133
+ },
134
+ methods: {
135
+ /**
136
+ * ref 触发 初始化动画
137
+ */
138
+ init(obj = {}) {
139
+ if (obj.duration) {
140
+ this.durationTime = obj.duration;
141
+ }
142
+ this.animation = createAnimation(Object.assign(this.config, obj),this);
143
+ },
144
+ /**
145
+ * 点击组件触发回调
146
+ */
147
+ onClick() {
148
+ this.$emit('click', {
149
+ detail: this.isShow
150
+ })
151
+ },
152
+ /**
153
+ * ref 触发 动画分组
154
+ * @param {Object} obj
155
+ */
156
+ step(obj, config = {}) {
157
+ if (!this.animation) return;
158
+ for (let i in obj) {
159
+ try {
160
+ if(typeof obj[i] === 'object'){
161
+ this.animation[i](...obj[i]);
162
+ }else{
163
+ this.animation[i](obj[i]);
164
+ }
165
+ } catch (e) {
166
+ console.error(`方法 ${i} 不存在`);
167
+ }
168
+ }
169
+ this.animation.step(config);
170
+ return this;
171
+ },
172
+ /**
173
+ * ref 触发 执行动画
174
+ */
175
+ run(fn) {
176
+ if (!this.animation) return;
177
+ this.animation.run(fn);
178
+ },
179
+ // 开始过度动画
180
+ open() {
181
+ clearTimeout(this.timer);
182
+ this.transform = '';
183
+ this.isShow = true;
184
+ let { opacity, transform } = this.styleInit(false);
185
+ if (typeof opacity !== 'undefined') {
186
+ this.opacity = opacity;
187
+ }
188
+ this.transform = transform;
189
+ // 确保动态样式已经生效后,执行动画,如果不加 nextTick ,会导致 wx 动画执行异常
190
+ this.$nextTick(() => {
191
+ // TODO 定时器保证动画完全执行,目前有些问题,后面会取消定时器
192
+ this.timer = setTimeout(() => {
193
+ this.animation = createAnimation(this.config, this);
194
+ this.tranfromInit(false).step();
195
+ // #ifdef APP-NVUE
196
+ if(this.cellChild) {
197
+ this.opacity = 1;
198
+ } else{
199
+ this.animation.run();
200
+ }
201
+ // #endif
202
+ // #ifndef APP-NVUE
203
+ this.animation.run();
204
+ // #endif
205
+ // #ifdef VUE3
206
+ // #ifdef H5
207
+ this.opacity = 1;
208
+ // #endif
209
+ // #endif
210
+ this.$emit('change', {
211
+ detail: this.isShow
212
+ })
213
+ // #ifdef H5
214
+ // #ifdef VUE3
215
+ this.transform = '';
216
+ // #endif
217
+ // #endif
218
+ }, 20);
219
+ })
220
+ },
221
+ // 关闭过渡动画
222
+ close(type) {
223
+ if (!this.animation) return;
224
+ this.tranfromInit(true)
225
+ .step()
226
+ .run(() => {
227
+ this.isShow = false;
228
+ this.animationData = null;
229
+ this.animation = null;
230
+ let { opacity, transform } = this.styleInit(false);
231
+ this.opacity = opacity || 1;
232
+ this.transform = transform;
233
+ this.$emit('change', {
234
+ detail: this.isShow
235
+ });
236
+ })
237
+ },
238
+ // 处理动画开始前的默认样式
239
+ styleInit(type) {
240
+ let styles = {
241
+ transform: ''
242
+ };
243
+ let buildStyle = (type, mode) => {
244
+ if (mode === 'fade') {
245
+ styles.opacity = this.animationType(type)[mode];
246
+ } else {
247
+ styles.transform += this.animationType(type)[mode] + ' ';
248
+ }
249
+ }
250
+ if (typeof this.mode === 'string') {
251
+ buildStyle(type, this.mode);
252
+ } else {
253
+ this.mode.forEach(mode => {
254
+ buildStyle(type, mode)
255
+ })
256
+ }
257
+ return styles
258
+ },
259
+ // 处理内置组合动画
260
+ tranfromInit(type) {
261
+ let buildTranfrom = (type, mode) => {
262
+ let aniNum = null;
263
+ if (mode === 'fade') {
264
+ aniNum = type ? 0 : 1;
265
+ } else {
266
+ aniNum = type ? '-100%' : '0';
267
+ if (mode === 'zoom-in') {
268
+ aniNum = type ? 0.8 : 1
269
+ }
270
+ if (mode === 'zoom-out') {
271
+ aniNum = type ? 1.2 : 1
272
+ }
273
+ if (mode === 'slide-right') {
274
+ aniNum = type ? '100%' : '0'
275
+ }
276
+ if (mode === 'slide-bottom') {
277
+ aniNum = type ? '100%' : '0'
278
+ }
279
+ }
280
+ this.animation[this.animationMode()[mode]](aniNum)
281
+ }
282
+ if (typeof this.mode === 'string') {
283
+ buildTranfrom(type, this.mode)
284
+ } else {
285
+ this.mode.forEach(mode => {
286
+ buildTranfrom(type, mode)
287
+ })
288
+ }
289
+ return this.animation;
290
+ },
291
+ animationType(type) {
292
+ return {
293
+ fade: type ? 1 : 0,
294
+ 'slide-top': `translateY(${type ? '0' : '-100%'})`,
295
+ 'slide-right': `translateX(${type ? '0' : '100%'})`,
296
+ 'slide-bottom': `translateY(${type ? '0' : '100%'})`,
297
+ 'slide-left': `translateX(${type ? '0' : '-100%'})`,
298
+ 'zoom-in': `scaleX(${type ? 1 : 0.8}) scaleY(${type ? 1 : 0.8})`,
299
+ 'zoom-out': `scaleX(${type ? 1 : 1.2}) scaleY(${type ? 1 : 1.2})`
300
+ }
301
+ },
302
+ // 内置动画类型与实际动画对应字典
303
+ animationMode() {
304
+ return {
305
+ fade: 'opacity',
306
+ 'slide-top': 'translateY',
307
+ 'slide-right': 'translateX',
308
+ 'slide-bottom': 'translateY',
309
+ 'slide-left': 'translateX',
310
+ 'zoom-in': 'scale',
311
+ 'zoom-out': 'scale'
312
+ }
313
+ },
314
+ // 驼峰转中横线
315
+ toLine(name) {
316
+ return name.replace(/([A-Z])/g, '-$1').toLowerCase()
317
+ }
318
+ }
319
+ }
320
+ </script>
@@ -0,0 +1,22 @@
1
+ import { error } from '../../libs/function/index.js'
2
+ export default {
3
+ watch: {
4
+ // 监听accept的变化,判断是否符合个平台要求
5
+ // 只有微信小程序才支持选择媒体,文件类型,所以这里做一个判断提示
6
+ accept: {
7
+ immediate: true,
8
+ handler(val) {
9
+ // #ifndef MP-WEIXIN
10
+ if (val === 'all' || val === 'media') {
11
+ error('只有微信小程序才支持把accept配置为all、media之一')
12
+ }
13
+ // #endif
14
+ // #ifndef H5 || MP-WEIXIN
15
+ if (val === 'file') {
16
+ error('只有微信小程序和H5(HX2.9.9)才支持把accept配置为file')
17
+ }
18
+ // #endif
19
+ }
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,130 @@
1
+ export default {
2
+ props: {
3
+ // 接受的文件类型, 可选值为all media image file video
4
+ accept: {
5
+ type: String,
6
+ default: 'image'
7
+ },
8
+ // 图片或视频拾取模式,当accept为image类型时设置capture可选额外camera可以直接调起摄像头
9
+ capture: {
10
+ type: [String, Array],
11
+ default: () => ['album', 'camera']
12
+ },
13
+ // 当accept为video时生效,是否压缩视频,默认为true
14
+ compressed: {
15
+ type: Boolean,
16
+ default: true
17
+ },
18
+ // 当accept为video时生效,可选值为back或front
19
+ camera: {
20
+ type: String,
21
+ default: 'back'
22
+ },
23
+ // 当accept为video时生效,拍摄视频最长拍摄时间,单位秒
24
+ maxDuration: {
25
+ type: Number,
26
+ default: 60
27
+ },
28
+ // 上传区域的图标,只能内置图标
29
+ uploadIcon: {
30
+ type: String,
31
+ default: 'camera-fill'
32
+ },
33
+ // 上传区域的图标的颜色,默认
34
+ uploadIconColor: {
35
+ type: String,
36
+ default: '#D3D4D6'
37
+ },
38
+ // 是否开启文件读取前事件
39
+ useBeforeRead: {
40
+ type: Boolean,
41
+ default: false
42
+ },
43
+ // 读取后的处理函数
44
+ afterRead: {
45
+ type: Function,
46
+ default: null
47
+ },
48
+ // 读取前的处理函数
49
+ beforeRead: {
50
+ type: Function,
51
+ default: null
52
+ },
53
+ // 是否开启图片预览功能
54
+ previewFullImage: {
55
+ type: Boolean,
56
+ default: true
57
+ },
58
+ // 是否开启视频预览功能
59
+ previewFullVideo: {
60
+ type: Boolean,
61
+ default: true
62
+ },
63
+ // 最大上传数量
64
+ maxCount: {
65
+ type: [String, Number],
66
+ default: 52
67
+ },
68
+ // 是否禁用
69
+ disabled: {
70
+ type: Boolean,
71
+ default: false
72
+ },
73
+ // 预览上传的图片时的裁剪模式,和image组件mode属性一致
74
+ imageMode: {
75
+ type: String,
76
+ default: 'aspectFill'
77
+ },
78
+ // 标识符,可以在回调函数的第二项参数中获取
79
+ name: {
80
+ type: String,
81
+ default: ''
82
+ },
83
+ // 所选的图片的尺寸, 可选值为original compressed
84
+ sizeType: {
85
+ type: Array,
86
+ default: () => ['original', 'compressed']
87
+ },
88
+ // 是否开启图片多选,部分安卓机型不支持
89
+ multiple: {
90
+ type: Boolean,
91
+ default: false
92
+ },
93
+ // 是否展示删除按钮
94
+ deletable: {
95
+ type: Boolean,
96
+ default: true
97
+ },
98
+ // 文件大小限制,单位为byte
99
+ maxSize: {
100
+ type: [String, Number],
101
+ default: Number.MAX_VALUE
102
+ },
103
+ // 显示已上传的文件列表
104
+ fileList: {
105
+ type: Array,
106
+ default: () => []
107
+ },
108
+ // 上传区域的提示文字
109
+ uploadText: {
110
+ type: String,
111
+ default: ''
112
+ },
113
+ // 内部预览图片区域和选择图片按钮的区域宽度
114
+ width: {
115
+ type: [String, Number],
116
+ default: 80
117
+ },
118
+ // 内部预览图片区域和选择图片按钮的区域高度
119
+ height: {
120
+ type: [String, Number],
121
+ default: 80
122
+ },
123
+ // 是否在上传完成后展示预览图
124
+ previewImage: {
125
+ type: Boolean,
126
+ default: true
127
+ },
128
+ ...uni.$uv?.props?.upload
129
+ }
130
+ }
@@ -0,0 +1,151 @@
1
+ function pickExclude(obj, keys) {
2
+ // 某些情况下,type可能会为
3
+ if (!['[object Object]', '[object File]'].includes(Object.prototype.toString.call(obj))) {
4
+ return {}
5
+ }
6
+ return Object.keys(obj).reduce((prev, key) => {
7
+ if (!keys.includes(key)) {
8
+ prev[key] = obj[key]
9
+ }
10
+ return prev
11
+ }, {})
12
+ }
13
+
14
+ function formatImage(res) {
15
+ return res.tempFiles.map((item) => ({
16
+ ...pickExclude(item, ['path']),
17
+ type: 'image',
18
+ url: item.path,
19
+ thumb: item.path,
20
+ size: item.size,
21
+ // #ifdef H5
22
+ name: item.name
23
+ // #endif
24
+ }))
25
+ }
26
+
27
+ function formatVideo(res) {
28
+ return [
29
+ {
30
+ ...pickExclude(res, ['tempFilePath', 'thumbTempFilePath', 'errMsg']),
31
+ type: 'video',
32
+ url: res.tempFilePath,
33
+ thumb: res.thumbTempFilePath,
34
+ size: res.size,
35
+ // #ifdef H5
36
+ name: res.name
37
+ // #endif
38
+ }
39
+ ]
40
+ }
41
+
42
+ function formatMedia(res) {
43
+ return res.tempFiles.map((item) => ({
44
+ ...pickExclude(item, ['fileType', 'thumbTempFilePath', 'tempFilePath']),
45
+ type: res.type,
46
+ url: item.tempFilePath,
47
+ thumb: res.type === 'video' ? item.thumbTempFilePath : item.tempFilePath,
48
+ size: item.size
49
+ }))
50
+ }
51
+
52
+ function formatFile(res) {
53
+ return res.tempFiles.map((item) => ({
54
+ ...pickExclude(item, ['path']),
55
+ url: item.path,
56
+ size:item.size,
57
+ // #ifdef H5
58
+ name: item.name,
59
+ type: item.type
60
+ // #endif
61
+ }))
62
+ }
63
+ export function chooseFile({
64
+ accept,
65
+ multiple,
66
+ capture,
67
+ compressed,
68
+ maxDuration,
69
+ sizeType,
70
+ camera,
71
+ maxCount
72
+ }) {
73
+ return new Promise((resolve, reject) => {
74
+ switch (accept) {
75
+ case 'image':
76
+ uni.chooseImage({
77
+ count: multiple ? Math.min(maxCount, 9) : 1,
78
+ sourceType: capture,
79
+ sizeType,
80
+ success: (res) => resolve(formatImage(res)),
81
+ fail: reject
82
+ })
83
+ break
84
+ // #ifdef MP-WEIXIN
85
+ // 只有微信小程序才支持chooseMedia接口
86
+ case 'media':
87
+ wx.chooseMedia({
88
+ count: multiple ? Math.min(maxCount, 9) : 1,
89
+ sourceType: capture,
90
+ maxDuration,
91
+ sizeType,
92
+ camera,
93
+ success: (res) => resolve(formatMedia(res)),
94
+ fail: reject
95
+ })
96
+ break
97
+ // #endif
98
+ case 'video':
99
+ uni.chooseVideo({
100
+ sourceType: capture,
101
+ compressed,
102
+ maxDuration,
103
+ camera,
104
+ success: (res) => resolve(formatVideo(res)),
105
+ fail: reject
106
+ })
107
+ break
108
+ // #ifdef MP-WEIXIN || H5
109
+ // 只有微信小程序才支持chooseMessageFile接口
110
+ case 'file':
111
+ // #ifdef MP-WEIXIN
112
+ wx.chooseMessageFile({
113
+ count: multiple ? maxCount : 1,
114
+ type: accept,
115
+ success: (res) => resolve(formatFile(res)),
116
+ fail: reject
117
+ })
118
+ // #endif
119
+ // #ifdef H5
120
+ // 需要hx2.9.9以上才支持uni.chooseFile
121
+ uni.chooseFile({
122
+ count: multiple ? maxCount : 1,
123
+ type: accept,
124
+ success: (res) => resolve(formatFile(res)),
125
+ fail: reject
126
+ })
127
+ // #endif
128
+ break
129
+ // #endif
130
+ default:
131
+ // 此为保底选项,在accept不为上面任意一项的时候选取全部文件
132
+ // #ifdef MP-WEIXIN
133
+ wx.chooseMessageFile({
134
+ count: multiple ? maxCount : 1,
135
+ type: 'all',
136
+ success: (res) => resolve(formatFile(res)),
137
+ fail: reject
138
+ })
139
+ // #endif
140
+ // #ifdef H5
141
+ // 需要hx2.9.9以上才支持uni.chooseFile
142
+ uni.chooseFile({
143
+ count: multiple ? maxCount : 1,
144
+ type: 'all',
145
+ success: (res) => resolve(formatFile(res)),
146
+ fail: reject
147
+ })
148
+ // #endif
149
+ }
150
+ })
151
+ }