@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,488 @@
1
+ <template>
2
+ <view class="uv-upload" :style="[$uv.addStyle(customStyle)]">
3
+ <view class="uv-upload__wrap">
4
+ <template v-if="previewImage">
5
+ <view class="uv-upload__wrap__preview" v-for="(item, index) in lists" :key="index">
6
+ <image
7
+ v-if="item.isImage || (item.type && item.type === 'image')"
8
+ :src="item.thumb || item.url" :mode="imageMode"
9
+ class="uv-upload__wrap__preview__image"
10
+ @tap="onPreviewImage(item,index)"
11
+ :style="[{
12
+ width: $uv.addUnit(width),
13
+ height: $uv.addUnit(height)
14
+ }]"
15
+ />
16
+ <view
17
+ v-else
18
+ class="uv-upload__wrap__preview__other"
19
+ @tap="onPreviewVideo(item,index)"
20
+ :style="[{
21
+ width: $uv.addUnit(width),
22
+ height: $uv.addUnit(height)
23
+ }]"
24
+ >
25
+ <uv-icon color="#80CBF9" size="26" :name="item.isVideo || (item.type && item.type === 'video') ? 'movie' : 'folder'"></uv-icon>
26
+ <text class="uv-upload__wrap__preview__other__text">{{item.isVideo || (item.type && item.type === 'video') ? '视频' : '文件'}}</text>
27
+ </view>
28
+ <view class="uv-upload__status" v-if="item.status === 'uploading' || item.status === 'failed'">
29
+ <view class="uv-upload__status__icon">
30
+ <uv-icon v-if="item.status === 'failed'" name="close-circle" color="#ffffff" size="25" />
31
+ <uv-loading-icon size="22" mode="circle" v-else />
32
+ </view>
33
+ <text v-if="item.message" class="uv-upload__status__message">{{ item.message }}</text>
34
+ </view>
35
+ <view class="uv-upload__deletable" v-if="item.status !== 'uploading' && (deletable || item.deletable)" @tap.stop="deleteItem(index)">
36
+ <view class="uv-upload__deletable__icon">
37
+ <uv-icon name="close" color="#ffffff" size="10"></uv-icon>
38
+ </view>
39
+ </view>
40
+ <view class="uv-upload__success" v-if="item.status === 'success'">
41
+ <!-- #ifdef APP-NVUE -->
42
+ <image :src="successIcon" class="uv-upload__success__icon"></image>
43
+ <!-- #endif -->
44
+ <!-- #ifndef APP-NVUE -->
45
+ <view class="uv-upload__success__icon">
46
+ <uv-icon name="checkmark" color="#ffffff" size="12"></uv-icon>
47
+ </view>
48
+ <!-- #endif -->
49
+ </view>
50
+ </view>
51
+ </template>
52
+ <template v-if="isInCount">
53
+ <view @tap="chooseFile">
54
+ <slot>
55
+ <view class="uv-upload__button" :hover-class="!disabled ? 'uv-upload__button--hover' : ''" hover-stay-time="150" @tap.stop="chooseFile" :class="[disabled && 'uv-upload__button--disabled']" :style="[{
56
+ width: $uv.addUnit(width),
57
+ height: $uv.addUnit(height)
58
+ }]">
59
+ <uv-icon :name="uploadIcon" size="26" :color="uploadIconColor"></uv-icon>
60
+ <text v-if="uploadText" class="uv-upload__button__text">{{ uploadText }}</text>
61
+ </view>
62
+ </slot>
63
+ </view>
64
+ </template>
65
+ </view>
66
+ <uv-preview-video ref="previewVideo"></uv-preview-video>
67
+ </view>
68
+ </template>
69
+
70
+ <script>
71
+ import { func, image, video, array, promise } from '../../libs/function/test.js';
72
+ import mpMixin from '../../libs/mixin/mpMixin.js'
73
+ import mixin from '../../libs/mixin/mixin.js'
74
+ import { chooseFile } from './utils';
75
+ import mixin_accept from './mixin.js';
76
+ import props from './props.js';
77
+ /**
78
+ * upload 上传
79
+ * @description 该组件用于上传图片场景
80
+ * @tutorial https://www.uvui.cn/components/upload.html
81
+ * @property {String} accept 接受的文件类型, 可选值为all media image file video (默认 'image' )
82
+ * @property {String | Array} capture 图片或视频拾取模式,当accept为image类型时设置capture可选额外camera可以直接调起摄像头(默认 ['album', 'camera'] )
83
+ * @property {Boolean} compressed 当accept为video时生效,是否压缩视频,默认为true(默认 true )
84
+ * @property {String} camera 当accept为video时生效,可选值为back或front(默认 'back' )
85
+ * @property {Number} maxDuration 当accept为video时生效,拍摄视频最长拍摄时间,单位秒(默认 60 )
86
+ * @property {String} uploadIcon 上传区域的图标,只能内置图标(默认 'camera-fill' )
87
+ * @property {String} uploadIconColor 上传区域的图标的字体颜色,只能内置图标(默认 #D3D4D6 )
88
+ * @property {Boolean} useBeforeRead 是否开启文件读取前事件(默认 false )
89
+ * @property {Boolean} previewFullImage 是否开启图片预览功能(默认 true )
90
+ * @property {Boolean} previewFullVideo 是否开启视频预览功能(默认 true )
91
+ * @property {String | Number} maxCount 最大上传数量(默认 52 )
92
+ * @property {Boolean} disabled 是否启用(默认 false )
93
+ * @property {String} imageMode 预览上传的图片时的裁剪模式,和image组件mode属性一致(默认 'aspectFill' )
94
+ * @property {String} name 标识符,可以在回调函数的第二项参数中获取
95
+ * @property {Array} sizeType 所选的图片的尺寸, 可选值为original compressed(默认 ['original', 'compressed'] )
96
+ * @property {Boolean} multiple 是否开启图片多选,部分安卓机型不支持 (默认 false )
97
+ * @property {Boolean} deletable 是否展示删除按钮(默认 true )
98
+ * @property {String | Number} maxSize 文件大小限制,单位为byte (默认 Number.MAX_VALUE )
99
+ * @property {Array} fileList 显示已上传的文件列表
100
+ * @property {String} uploadText 上传区域的提示文字
101
+ * @property {String | Number} width 内部预览图片区域和选择图片按钮的区域宽度(默认 80 )
102
+ * @property {String | Number} height 内部预览图片区域和选择图片按钮的区域高度(默认 80 )
103
+ * @property {Object} customStyle 组件的样式,对象形式
104
+ * @event {Function} afterRead 读取后的处理函数
105
+ * @event {Function} beforeRead 读取前的处理函数
106
+ * @event {Function} oversize 文件超出大小限制
107
+ * @event {Function} clickPreview 点击预览时触发
108
+ * @event {Function} delete 删除图片
109
+ * @example <uv-upload :action="action" :fileList="fileList" ></uv-upload>
110
+ */
111
+ export default {
112
+ name: "uv-upload",
113
+ // #ifdef VUE3
114
+ emits: ['error', 'beforeRead', 'oversize', 'afterRead', 'delete', 'clickPreview'],
115
+ // #endif
116
+ mixins: [mpMixin, mixin, mixin_accept, props],
117
+ data() {
118
+ return {
119
+ // #ifdef APP-NVUE
120
+ successIcon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAKKADAAQAAAABAAAAKAAAAAB65masAAACP0lEQVRYCc3YXygsURwH8K/dpcWyG3LF5u/6/+dKVylSypuUl6uUPMifKMWL8oKEB1EUT1KeUPdR3uTNUsSLxb2udG/cbvInNuvf2rVnazZ/ZndmZ87snjM1Z+Z3zpzfp9+Z5mEAhlvjRtZgCKs+gnPAOcAkkMOR4jEHfItjDvgRxxSQD8cM0BuOCaAvXNCBQrigAsXgggYUiwsK0B9cwIH+4gIKlIILGFAqLiBAOTjFgXJxigJp4BQD0sIpAqSJow6kjSNAFTnRaHJwLenD6Mud52VQAcrBfTd2oyq+HtGaGGWAcnAVcXWoM3bCZrdi+ncPfaAcXE5UKVpdW/vitGPqqAtn98d0gXJwX7Qp6MmegUYVhvmTIezdmHlxJCjpHRTCFerLkRRu4k0aqdajN3sWOo0BK//msHa+xDuPC/oNFMKRhTtM4xjIX0SCNpXL4+7VIaHuyiWEp2L7ahWLf8fejfPdqPmC3mJicORZUp1CQzm+GiphvljGk+PBvWRbxii+xVTj5M6CiZ/tsDufvaXyxEUDxeLIyvu3m0iOyEFWVAkydcVYdyFrE9tQk9iMq6f/GNlvwt3LjQfh60LUrw9/cFyyMJUW/XkLSNMV4Mi6C5ML+ui4x5ClAX9sB9w0wV6wglJwJCv5fOxcr6EstgbGiEw4XcfUry4cWrcEUW8n+ARKxXEJHhw2WG43UKSvwI/TSZgvl7kh0b3XLZaLEy0QmMgLZAVH7J+ALOE+AVnDvQOyiPMAWcW5gSzjCPAV+78S5WE0GrQAAAAASUVORK5CYII=',
121
+ // #endif
122
+ lists: [],
123
+ isInCount: true,
124
+ }
125
+ },
126
+ watch: {
127
+ // 监听文件列表的变化,重新整理内部数据
128
+ fileList: {
129
+ deep: true,
130
+ immediate: true,
131
+ handler() {
132
+ this.formatFileList()
133
+ }
134
+ },
135
+ deletable(newVal) {
136
+ if(!newVal) {
137
+ this.lists.map(item=>{
138
+ item.deletable = this.deletable;
139
+ })
140
+ }
141
+ }
142
+ },
143
+ methods: {
144
+ formatFileList() {
145
+ const {
146
+ fileList = [], maxCount
147
+ } = this;
148
+ const lists = fileList.map((item) =>
149
+ Object.assign(Object.assign({}, item), {
150
+ // 如果item.url为本地选择的blob文件的话,无法判断其为video还是image,此处优先通过accept做判断处理
151
+ isImage: this.accept === 'image' || image(item.url || item.thumb),
152
+ isVideo: this.accept === 'video' || video(item.url || item.thumb),
153
+ deletable: typeof(item.deletable) === 'boolean' ? item.deletable : this.deletable,
154
+ })
155
+ );
156
+ this.lists = lists
157
+ this.isInCount = lists.length < maxCount
158
+ },
159
+ chooseFile() {
160
+ this.timer && clearTimeout(this.timer);
161
+ this.timer = setTimeout(() => {
162
+ const {
163
+ maxCount,
164
+ multiple,
165
+ lists,
166
+ disabled
167
+ } = this;
168
+ if (disabled) return;
169
+ // 如果用户传入的是字符串,需要格式化成数组
170
+ let capture;
171
+ try {
172
+ capture = array(this.capture) ? this.capture : this.capture.split(',');
173
+ } catch (e) {
174
+ capture = [];
175
+ }
176
+ chooseFile(
177
+ Object.assign({
178
+ accept: this.accept,
179
+ multiple: this.multiple,
180
+ capture: capture,
181
+ compressed: this.compressed,
182
+ maxDuration: this.maxDuration,
183
+ sizeType: this.sizeType,
184
+ camera: this.camera,
185
+ }, {
186
+ maxCount: maxCount - lists.length,
187
+ })
188
+ )
189
+ .then((res) => {
190
+ this.onBeforeRead(multiple ? res : res[0]);
191
+ })
192
+ .catch((error) => {
193
+ this.$emit('error', error);
194
+ });
195
+ }, 100)
196
+ },
197
+ // 文件读取之前
198
+ onBeforeRead(file) {
199
+ const {
200
+ beforeRead,
201
+ useBeforeRead,
202
+ } = this;
203
+ let res = true
204
+ // beforeRead是否为一个方法
205
+ if (func(beforeRead)) {
206
+ // 如果用户定义了此方法,则去执行此方法,并传入读取的文件回调
207
+ res = beforeRead(file, this.getDetail());
208
+ }
209
+ if (useBeforeRead) {
210
+ res = new Promise((resolve, reject) => {
211
+ this.$emit(
212
+ 'beforeRead',
213
+ Object.assign(Object.assign({
214
+ file
215
+ }, this.getDetail()), {
216
+ callback: (ok) => {
217
+ ok ? resolve() : reject();
218
+ },
219
+ })
220
+ );
221
+ });
222
+ }
223
+ if (!res) {
224
+ return;
225
+ }
226
+ if (promise(res)) {
227
+ res.then((data) => this.onAfterRead(data || file));
228
+ } else {
229
+ this.onAfterRead(file);
230
+ }
231
+ },
232
+ getDetail(index) {
233
+ return {
234
+ name: this.name,
235
+ index: index == null ? this.fileList.length : index,
236
+ };
237
+ },
238
+ onAfterRead(file) {
239
+ const {
240
+ maxSize,
241
+ afterRead
242
+ } = this;
243
+ const oversize = Array.isArray(file) ?
244
+ file.some((item) => item.size > maxSize) :
245
+ file.size > maxSize;
246
+ if (oversize) {
247
+ this.$emit('oversize', Object.assign({
248
+ file
249
+ }, this.getDetail()));
250
+ return;
251
+ }
252
+ if (typeof afterRead === 'function') {
253
+ afterRead(file, this.getDetail());
254
+ }
255
+ this.$emit('afterRead', Object.assign({
256
+ file
257
+ }, this.getDetail()));
258
+ },
259
+ deleteItem(index) {
260
+ this.$emit(
261
+ 'delete',
262
+ Object.assign(Object.assign({}, this.getDetail(index)), {
263
+ file: this.fileList[index],
264
+ })
265
+ );
266
+ },
267
+ // 预览图片
268
+ onPreviewImage(item, index) {
269
+ const lists = this.$uv.deepClone(this.lists);
270
+ lists.map((i,j)=>{
271
+ if(j == index) {
272
+ i.current = true;
273
+ }
274
+ });
275
+ const filters = lists.filter(i=>i.isImage);
276
+ const findIndex = filters.findIndex(i=>i.current);
277
+ this.onClickPreview(item, index);
278
+ if (!item.isImage || !this.previewFullImage) return
279
+ uni.previewImage({
280
+ // 先filter找出为图片的item,再返回filter结果中的图片url
281
+ urls: this.lists.filter((item) => this.accept === 'image' || image(item.url || item.thumb)).map((item) => item.url || item.thumb),
282
+ current: findIndex,
283
+ fail() {
284
+ this.$uv.toast('预览图片失败')
285
+ },
286
+ });
287
+ },
288
+ onPreviewVideo(item, index) {
289
+ this.onClickPreview(item, index);
290
+ if (!this.previewFullVideo || !item.isVideo) return;
291
+ this.$refs.previewVideo.open(item.url);
292
+ },
293
+ onClickPreview(item, index) {
294
+ this.$emit(
295
+ 'clickPreview',
296
+ Object.assign(Object.assign({}, item), this.getDetail(index))
297
+ );
298
+ }
299
+ }
300
+ }
301
+ </script>
302
+
303
+ <style lang="scss" scoped>
304
+ @import '../../libs/css/components.scss';
305
+ @import '../../libs/css/color.scss';
306
+ $uv-upload-preview-border-radius: 2px !default;
307
+ $uv-upload-preview-margin: 0 8px 8px 0 !default;
308
+ $uv-upload-image-width: 80px !default;
309
+ $uv-upload-image-height: $uv-upload-image-width;
310
+ $uv-upload-other-bgColor: rgb(242, 242, 242) !default;
311
+ $uv-upload-other-flex: 1 !default;
312
+ $uv-upload-text-font-size: 11px !default;
313
+ $uv-upload-text-color: $uv-tips-color !default;
314
+ $uv-upload-text-margin-top: 2px !default;
315
+ $uv-upload-deletable-right: 0 !default;
316
+ $uv-upload-deletable-top: 0 !default;
317
+ $uv-upload-deletable-bgColor: rgb(55, 55, 55) !default;
318
+ $uv-upload-deletable-height: 14px !default;
319
+ $uv-upload-deletable-width: $uv-upload-deletable-height;
320
+ $uv-upload-deletable-boder-bottom-left-radius: 100px !default;
321
+ $uv-upload-deletable-zIndex: 3 !default;
322
+ $uv-upload-success-bottom: 0 !default;
323
+ $uv-upload-success-right: 0 !default;
324
+ $uv-upload-success-border-style: solid !default;
325
+ $uv-upload-success-border-top-color: transparent !default;
326
+ $uv-upload-success-border-left-color: transparent !default;
327
+ $uv-upload-success-border-bottom-color: $uv-success !default;
328
+ $uv-upload-success-border-right-color: $uv-upload-success-border-bottom-color;
329
+ $uv-upload-success-border-width: 9px !default;
330
+ $uv-upload-icon-top: 0px !default;
331
+ $uv-upload-icon-right: 0px !default;
332
+ $uv-upload-icon-h5-top: 1px !default;
333
+ $uv-upload-icon-h5-right: 0 !default;
334
+ $uv-upload-icon-width: 16px !default;
335
+ $uv-upload-icon-height: $uv-upload-icon-width;
336
+ $uv-upload-success-icon-bottom: -10px !default;
337
+ $uv-upload-success-icon-right: -10px !default;
338
+ $uv-upload-status-right: 0 !default;
339
+ $uv-upload-status-left: 0 !default;
340
+ $uv-upload-status-bottom: 0 !default;
341
+ $uv-upload-status-top: 0 !default;
342
+ $uv-upload-status-bgColor: rgba(0, 0, 0, 0.5) !default;
343
+ $uv-upload-status-icon-Zindex: 1 !default;
344
+ $uv-upload-message-font-size: 12px !default;
345
+ $uv-upload-message-color: #FFFFFF !default;
346
+ $uv-upload-message-margin-top: 5px !default;
347
+ $uv-upload-button-width: 80px !default;
348
+ $uv-upload-button-height: $uv-upload-button-width;
349
+ $uv-upload-button-bgColor: rgb(244, 245, 247) !default;
350
+ $uv-upload-button-border-radius: 2px !default;
351
+ $uv-upload-botton-margin: 0 8px 8px 0 !default;
352
+ $uv-upload-text-font-size: 11px !default;
353
+ $uv-upload-text-color: $uv-tips-color !default;
354
+ $uv-upload-text-margin-top: 2px !default;
355
+ $uv-upload-hover-bgColor: rgb(230, 231, 233) !default;
356
+ $uv-upload-disabled-opacity: .5 !default;
357
+ .uv-upload {
358
+ @include flex(column);
359
+ flex: 1;
360
+ &__wrap {
361
+ @include flex;
362
+ flex-wrap: wrap;
363
+ flex: 1;
364
+ &__preview {
365
+ border-radius: $uv-upload-preview-border-radius;
366
+ margin: $uv-upload-preview-margin;
367
+ position: relative;
368
+ overflow: hidden;
369
+ @include flex;
370
+ &__image {
371
+ width: $uv-upload-image-width;
372
+ height: $uv-upload-image-height;
373
+ }
374
+ &__other {
375
+ width: $uv-upload-image-width;
376
+ height: $uv-upload-image-height;
377
+ background-color: $uv-upload-other-bgColor;
378
+ flex: $uv-upload-other-flex;
379
+ @include flex(column);
380
+ justify-content: center;
381
+ align-items: center;
382
+ &__text {
383
+ font-size: $uv-upload-text-font-size;
384
+ color: $uv-upload-text-color;
385
+ margin-top: $uv-upload-text-margin-top;
386
+ }
387
+ }
388
+ }
389
+ }
390
+ &__deletable {
391
+ position: absolute;
392
+ top: $uv-upload-deletable-top;
393
+ right: $uv-upload-deletable-right;
394
+ background-color: $uv-upload-deletable-bgColor;
395
+ height: $uv-upload-deletable-height;
396
+ width: $uv-upload-deletable-width;
397
+ @include flex;
398
+ border-bottom-left-radius: $uv-upload-deletable-boder-bottom-left-radius;
399
+ align-items: center;
400
+ justify-content: center;
401
+ z-index: $uv-upload-deletable-zIndex;
402
+ &__icon {
403
+ position: absolute;
404
+ transform: scale(0.7);
405
+ top: $uv-upload-icon-top;
406
+ right: $uv-upload-icon-right;
407
+ /* #ifdef H5 */
408
+ top: $uv-upload-icon-h5-top;
409
+ right: $uv-upload-icon-h5-right;
410
+ /* #endif */
411
+ }
412
+ }
413
+ &__success {
414
+ position: absolute;
415
+ bottom: $uv-upload-success-bottom;
416
+ right: $uv-upload-success-right;
417
+ @include flex;
418
+ // 由于weex(nvue)为阿里巴巴的KPI(部门业绩考核)的laji产物,不支持css绘制三角形
419
+ // 所以在nvue下使用图片,非nvue下使用css实现
420
+ /* #ifndef APP-NVUE */
421
+ border-style: $uv-upload-success-border-style;
422
+ border-top-color: $uv-upload-success-border-top-color;
423
+ border-left-color: $uv-upload-success-border-left-color;
424
+ border-bottom-color: $uv-upload-success-border-bottom-color;
425
+ border-right-color: $uv-upload-success-border-right-color;
426
+ border-width: $uv-upload-success-border-width;
427
+ align-items: center;
428
+ justify-content: center;
429
+ /* #endif */
430
+ &__icon {
431
+ /* #ifndef APP-NVUE */
432
+ position: absolute;
433
+ transform: scale(0.7);
434
+ bottom: $uv-upload-success-icon-bottom;
435
+ right: $uv-upload-success-icon-right;
436
+ /* #endif */
437
+ /* #ifdef APP-NVUE */
438
+ width: $uv-upload-icon-width;
439
+ height: $uv-upload-icon-height;
440
+ /* #endif */
441
+ }
442
+ }
443
+ &__status {
444
+ position: absolute;
445
+ top: $uv-upload-status-top;
446
+ bottom: $uv-upload-status-bottom;
447
+ left: $uv-upload-status-left;
448
+ right: $uv-upload-status-right;
449
+ background-color: $uv-upload-status-bgColor;
450
+ @include flex(column);
451
+ align-items: center;
452
+ justify-content: center;
453
+ &__icon {
454
+ position: relative;
455
+ z-index: $uv-upload-status-icon-Zindex;
456
+ }
457
+ &__message {
458
+ font-size: $uv-upload-message-font-size;
459
+ color: $uv-upload-message-color;
460
+ margin-top: $uv-upload-message-margin-top;
461
+ }
462
+ }
463
+ &__button {
464
+ @include flex(column);
465
+ align-items: center;
466
+ justify-content: center;
467
+ width: $uv-upload-button-width;
468
+ height: $uv-upload-button-height;
469
+ background-color: $uv-upload-button-bgColor;
470
+ border-radius: $uv-upload-button-border-radius;
471
+ margin: $uv-upload-botton-margin;
472
+ /* #ifndef APP-NVUE */
473
+ box-sizing: border-box;
474
+ /* #endif */
475
+ &__text {
476
+ font-size: $uv-upload-text-font-size;
477
+ color: $uv-upload-text-color;
478
+ margin-top: $uv-upload-text-margin-top;
479
+ }
480
+ &--hover {
481
+ background-color: $uv-upload-hover-bgColor;
482
+ }
483
+ &--disabled {
484
+ opacity: $uv-upload-disabled-opacity;
485
+ }
486
+ }
487
+ }
488
+ </style>
@@ -0,0 +1,79 @@
1
+ export default {
2
+ props: {
3
+ // 列表数据
4
+ list: {
5
+ type: Array,
6
+ default: ()=>[]
7
+ },
8
+ // 从list元素对象中读取的键名,默认name
9
+ keyName: {
10
+ type: String,
11
+ default: 'name'
12
+ },
13
+ // 当前选中项
14
+ current: {
15
+ type: [Number, String],
16
+ default: 0
17
+ },
18
+ // 头部内容的高度
19
+ hdHeight: {
20
+ type: [Number, String],
21
+ default: 0
22
+ },
23
+ // 是否联动,默认开启联动
24
+ chain: {
25
+ type: Boolean,
26
+ default: true
27
+ },
28
+ // 整个列表的高度,默认auto屏幕高度
29
+ height: {
30
+ type: [Number, String],
31
+ default: 'auto'
32
+ },
33
+ // 左边列表的宽度,默认200rpx
34
+ barWidth: {
35
+ type: [Number, String],
36
+ default: '180rpx'
37
+ },
38
+ // 左边列表是否允许滚动
39
+ barScrollable: {
40
+ type: Boolean,
41
+ default: true
42
+ },
43
+ // 背景颜色 默认主题颜色 $bg-color
44
+ barBgColor: {
45
+ type: String,
46
+ default: ''
47
+ },
48
+ // 左边列表的自定义样式
49
+ barStyle: {
50
+ type: [Object, String],
51
+ default: ''
52
+ },
53
+ // 左边列表项的自定义样式
54
+ barItemStyle: {
55
+ type: [Object, String],
56
+ default: ''
57
+ },
58
+ // 左边选择项激活时的自定义样式
59
+ barItemActiveStyle: {
60
+ type: [Object, String],
61
+ default: ''
62
+ },
63
+ // 左边选择项激活时的左边线条自定义样式
64
+ barItemActiveLineStyle: {
65
+ type: [Object, String],
66
+ default: ''
67
+ },
68
+ // 菜单项中的徽标自定义样式,比如定位位置
69
+ barItemBadgeStyle: {
70
+ type: [Object, String],
71
+ default: ''
72
+ },
73
+ // 右边区域自定义样式
74
+ contentStyle: {
75
+ type: [Object, String],
76
+ default: ''
77
+ }
78
+ }
79
+ }