@kengic/uni 0.5.1 → 0.5.2-beta.1

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 (146) hide show
  1. package/dist/uni/uni-ui/uni-badge/uni-badge.vue +222 -219
  2. package/dist/uni/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +29 -29
  3. package/dist/uni/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +88 -88
  4. package/dist/uni/uni-ui/uni-calendar/calendar.js +936 -532
  5. package/dist/uni/uni-ui/uni-calendar/i18n/en.json +10 -10
  6. package/dist/uni/uni-ui/uni-calendar/i18n/index.js +8 -7
  7. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hans.json +10 -10
  8. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hant.json +10 -10
  9. package/dist/uni/uni-ui/uni-calendar/uni-calendar-item.vue +190 -168
  10. package/dist/uni/uni-ui/uni-calendar/uni-calendar.vue +459 -459
  11. package/dist/uni/uni-ui/uni-calendar/util.js +324 -340
  12. package/dist/uni/uni-ui/uni-card/uni-card.vue +8 -1
  13. package/dist/uni/uni-ui/uni-col/uni-col.vue +294 -287
  14. package/dist/uni/uni-ui/uni-collapse/uni-collapse.vue +139 -140
  15. package/dist/uni/uni-ui/uni-collapse-item/uni-collapse-item.vue +381 -378
  16. package/dist/uni/uni-ui/uni-combox/uni-combox.vue +280 -272
  17. package/dist/uni/uni-ui/uni-countdown/i18n/en.json +4 -4
  18. package/dist/uni/uni-ui/uni-countdown/i18n/index.js +8 -7
  19. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hans.json +4 -4
  20. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hant.json +4 -4
  21. package/dist/uni/uni-ui/uni-countdown/uni-countdown.vue +249 -257
  22. package/dist/uni/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +832 -813
  23. package/dist/uni/uni-ui/uni-data-picker/keypress.js +42 -42
  24. package/dist/uni/uni-ui/uni-data-picker/uni-data-picker.vue +535 -516
  25. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-picker.js +623 -618
  26. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +293 -288
  27. package/dist/uni/uni-ui/uni-data-select/uni-data-select.vue +495 -509
  28. package/dist/uni/uni-ui/uni-dateformat/date-format.js +181 -184
  29. package/dist/uni/uni-ui/uni-dateformat/uni-dateformat.vue +81 -82
  30. package/dist/uni/uni-ui/uni-datetime-picker/calendar-item.vue +176 -170
  31. package/dist/uni/uni-ui/uni-datetime-picker/calendar.vue +926 -920
  32. package/dist/uni/uni-ui/uni-datetime-picker/i18n/en.json +20 -20
  33. package/dist/uni/uni-ui/uni-datetime-picker/i18n/index.js +8 -7
  34. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +21 -21
  35. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +21 -21
  36. package/dist/uni/uni-ui/uni-datetime-picker/time-picker.vue +921 -926
  37. package/dist/uni/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1059 -1012
  38. package/dist/uni/uni-ui/uni-datetime-picker/util.js +366 -377
  39. package/dist/uni/uni-ui/uni-drawer/keypress.js +42 -42
  40. package/dist/uni/uni-ui/uni-drawer/uni-drawer.vue +176 -167
  41. package/dist/uni/uni-ui/uni-easyinput/common.js +40 -42
  42. package/dist/uni/uni-ui/uni-easyinput/uni-easyinput.vue +628 -547
  43. package/dist/uni/uni-ui/uni-fab/uni-fab.vue +507 -483
  44. package/dist/uni/uni-ui/uni-fav/i18n/en.json +2 -2
  45. package/dist/uni/uni-ui/uni-fav/i18n/index.js +8 -7
  46. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hans.json +2 -2
  47. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hant.json +2 -2
  48. package/dist/uni/uni-ui/uni-fav/uni-fav.vue +155 -147
  49. package/dist/uni/uni-ui/uni-file-picker/choose-and-upload-file.js +172 -198
  50. package/dist/uni/uni-ui/uni-file-picker/uni-file-picker.vue +636 -634
  51. package/dist/uni/uni-ui/uni-file-picker/upload-file.vue +294 -293
  52. package/dist/uni/uni-ui/uni-file-picker/upload-image.vue +267 -270
  53. package/dist/uni/uni-ui/uni-file-picker/utils.js +81 -82
  54. package/dist/uni/uni-ui/uni-forms/uni-forms.vue +360 -372
  55. package/dist/uni/uni-ui/uni-forms/utils.js +170 -174
  56. package/dist/uni/uni-ui/uni-forms/validate.js +447 -456
  57. package/dist/uni/uni-ui/uni-forms-item/uni-forms-item.vue +497 -497
  58. package/dist/uni/uni-ui/uni-goods-nav/i18n/en.json +4 -4
  59. package/dist/uni/uni-ui/uni-goods-nav/i18n/index.js +8 -7
  60. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hans.json +4 -4
  61. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hant.json +4 -4
  62. package/dist/uni/uni-ui/uni-goods-nav/uni-goods-nav.vue +238 -222
  63. package/dist/uni/uni-ui/uni-grid/uni-grid.vue +134 -134
  64. package/dist/uni/uni-ui/uni-grid-item/uni-grid-item.vue +121 -119
  65. package/dist/uni/uni-ui/uni-group/uni-group.vue +121 -121
  66. package/dist/uni/uni-ui/uni-icons/icons.js +1170 -1168
  67. package/dist/uni/uni-ui/uni-icons/uni-icons.vue +91 -86
  68. package/dist/uni/uni-ui/uni-icons/uniicons.css +166 -166
  69. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +129 -129
  70. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list.vue +352 -347
  71. package/dist/uni/uni-ui/uni-link/uni-link.vue +134 -119
  72. package/dist/uni/uni-ui/uni-list/uni-list.vue +119 -110
  73. package/dist/uni/uni-ui/uni-list/uni-refresh.vue +14 -14
  74. package/dist/uni/uni-ui/uni-list/uni-refresh.wxs +14 -14
  75. package/dist/uni/uni-ui/uni-list-ad/uni-list-ad.vue +101 -95
  76. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.scss +18 -18
  77. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.vue +602 -586
  78. package/dist/uni/uni-ui/uni-list-item/uni-list-item.vue +507 -503
  79. package/dist/uni/uni-ui/uni-load-more/i18n/en.json +3 -3
  80. package/dist/uni/uni-ui/uni-load-more/i18n/index.js +8 -7
  81. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hans.json +3 -3
  82. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hant.json +3 -3
  83. package/dist/uni/uni-ui/uni-load-more/uni-load-more.vue +402 -392
  84. package/dist/uni/uni-ui/uni-nav-bar/uni-nav-bar.vue +328 -330
  85. package/dist/uni/uni-ui/uni-nav-bar/uni-status-bar.vue +17 -17
  86. package/dist/uni/uni-ui/uni-notice-bar/uni-notice-bar.vue +422 -401
  87. package/dist/uni/uni-ui/uni-number-box/uni-number-box.vue +211 -205
  88. package/dist/uni/uni-ui/uni-pagination/i18n/en.json +3 -3
  89. package/dist/uni/uni-ui/uni-pagination/i18n/es.json +3 -3
  90. package/dist/uni/uni-ui/uni-pagination/i18n/fr.json +3 -3
  91. package/dist/uni/uni-ui/uni-pagination/i18n/index.js +12 -11
  92. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hans.json +3 -3
  93. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hant.json +3 -3
  94. package/dist/uni/uni-ui/uni-pagination/uni-pagination.vue +450 -433
  95. package/dist/uni/uni-ui/uni-popup/uni-popup.vue +404 -404
  96. package/dist/uni/uni-ui/uni-popup-dialog/keypress.js +42 -42
  97. package/dist/uni/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +1 -0
  98. package/dist/uni/uni-ui/uni-popup-message/uni-popup-message.vue +126 -125
  99. package/dist/uni/uni-ui/uni-popup-share/uni-popup-share.vue +172 -172
  100. package/dist/uni/uni-ui/uni-rate/uni-rate.vue +343 -347
  101. package/dist/uni/uni-ui/uni-row/uni-row.vue +180 -182
  102. package/dist/uni/uni-ui/uni-scss/changelog.md +11 -4
  103. package/dist/uni/uni-ui/uni-scss/package.json +73 -73
  104. package/dist/uni/uni-ui/uni-scss/readme.md +2 -1
  105. package/dist/uni/uni-ui/uni-scss/styles/setting/_border.scss +2 -2
  106. package/dist/uni/uni-ui/uni-scss/styles/setting/_color.scss +46 -47
  107. package/dist/uni/uni-ui/uni-scss/styles/setting/_radius.scss +49 -49
  108. package/dist/uni/uni-ui/uni-scss/styles/setting/_space.scss +52 -53
  109. package/dist/uni/uni-ui/uni-scss/styles/setting/_styles.scss +142 -147
  110. package/dist/uni/uni-ui/uni-scss/styles/setting/_text.scss +20 -20
  111. package/dist/uni/uni-ui/uni-scss/styles/setting/_variables.scss +111 -95
  112. package/dist/uni/uni-ui/uni-scss/styles/tools/functions.scss +28 -18
  113. package/dist/uni/uni-ui/uni-scss/theme.scss +10 -7
  114. package/dist/uni/uni-ui/uni-scss/variables.scss +42 -24
  115. package/dist/uni/uni-ui/uni-search-bar/i18n/en.json +3 -3
  116. package/dist/uni/uni-ui/uni-search-bar/i18n/index.js +8 -7
  117. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hans.json +2 -2
  118. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hant.json +2 -2
  119. package/dist/uni/uni-ui/uni-search-bar/uni-search-bar.vue +290 -281
  120. package/dist/uni/uni-ui/uni-section/uni-section.vue +149 -146
  121. package/dist/uni/uni-ui/uni-segmented-control/uni-segmented-control.vue +141 -131
  122. package/dist/uni/uni-ui/uni-steps/uni-steps.vue +255 -236
  123. package/dist/uni/uni-ui/uni-swipe-action/uni-swipe-action.vue +51 -51
  124. package/dist/uni/uni-ui/uni-swipe-action-item/bindingx.js +276 -282
  125. package/dist/uni/uni-ui/uni-swipe-action-item/isPC.js +10 -10
  126. package/dist/uni/uni-ui/uni-swipe-action-item/mpalipay.js +182 -187
  127. package/dist/uni/uni-ui/uni-swipe-action-item/mpother.js +235 -244
  128. package/dist/uni/uni-ui/uni-swipe-action-item/mpwxs.js +70 -75
  129. package/dist/uni/uni-ui/uni-swipe-action-item/render.js +238 -247
  130. package/dist/uni/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +387 -313
  131. package/dist/uni/uni-ui/uni-swipe-action-item/wx.wxs +206 -215
  132. package/dist/uni/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +241 -197
  133. package/dist/uni/uni-ui/uni-table/uni-table.vue +445 -447
  134. package/dist/uni/uni-ui/uni-tag/uni-tag.vue +234 -244
  135. package/dist/uni/uni-ui/uni-tbody/uni-tbody.vue +20 -23
  136. package/dist/uni/uni-ui/uni-td/uni-td.vue +79 -80
  137. package/dist/uni/uni-ui/uni-th/filter-dropdown.vue +510 -503
  138. package/dist/uni/uni-ui/uni-th/uni-th.vue +289 -273
  139. package/dist/uni/uni-ui/uni-thead/uni-thead.vue +115 -114
  140. package/dist/uni/uni-ui/uni-title/uni-title.vue +151 -154
  141. package/dist/uni/uni-ui/uni-tooltip/uni-tooltip.vue +55 -60
  142. package/dist/uni/uni-ui/uni-tr/table-checkbox.vue +162 -163
  143. package/dist/uni/uni-ui/uni-tr/uni-tr.vue +158 -157
  144. package/dist/uni/uni-ui/uni-transition/createAnimation.js +130 -113
  145. package/dist/uni/uni-ui/uni-transition/uni-transition.vue +274 -272
  146. package/package.json +1 -1
@@ -1,667 +1,669 @@
1
1
  <template>
2
- <view class="uni-file-picker">
3
- <view v-if="title" class="uni-file-picker__header">
4
- <text class="file-title">{{ title }}</text>
5
- <text class="file-count">{{ filesList.length }}/{{ limitLength }}</text>
6
- </view>
7
- <upload-image v-if="fileMediatype === 'image' && showType === 'grid'" :readonly="readonly"
8
- :image-styles="imageStyles" :files-list="filesList" :limit="limitLength" :disablePreview="disablePreview"
9
- :delIcon="delIcon" @uploadFiles="uploadFiles" @choose="choose" @delFile="delFile">
10
- <slot>
11
- <view class="is-add">
12
- <view class="icon-add"></view>
13
- <view class="icon-add rotate"></view>
14
- </view>
15
- </slot>
16
- </upload-image>
17
- <upload-file v-if="fileMediatype !== 'image' || showType !== 'grid'" :readonly="readonly"
18
- :list-styles="listStyles" :files-list="filesList" :showType="showType" :delIcon="delIcon"
19
- @uploadFiles="uploadFiles" @choose="choose" @delFile="delFile">
20
- <slot><button type="primary" size="mini">选择文件</button></slot>
21
- </upload-file>
22
- </view>
2
+ <view class="uni-file-picker">
3
+ <view v-if="title" class="uni-file-picker__header">
4
+ <text class="file-title">{{ title }}</text>
5
+ <text class="file-count">{{ filesList.length }}/{{ limitLength }}</text>
6
+ </view>
7
+ <upload-image
8
+ v-if="fileMediatype === 'image' && showType === 'grid'"
9
+ :readonly="readonly"
10
+ :image-styles="imageStyles"
11
+ :files-list="filesList"
12
+ :limit="limitLength"
13
+ :disablePreview="disablePreview"
14
+ :delIcon="delIcon"
15
+ @uploadFiles="uploadFiles"
16
+ @choose="choose"
17
+ @delFile="delFile"
18
+ >
19
+ <slot>
20
+ <view class="is-add">
21
+ <view class="icon-add"></view>
22
+ <view class="icon-add rotate"></view>
23
+ </view>
24
+ </slot>
25
+ </upload-image>
26
+ <upload-file
27
+ v-if="fileMediatype !== 'image' || showType !== 'grid'"
28
+ :readonly="readonly"
29
+ :list-styles="listStyles"
30
+ :files-list="filesList"
31
+ :showType="showType"
32
+ :delIcon="delIcon"
33
+ @uploadFiles="uploadFiles"
34
+ @choose="choose"
35
+ @delFile="delFile"
36
+ >
37
+ <slot><button type="primary" size="mini">选择文件</button></slot>
38
+ </upload-file>
39
+ </view>
23
40
  </template>
24
41
 
25
42
  <script>
26
- import {
27
- chooseAndUploadFile,
28
- uploadCloudFiles
29
- } from './choose-and-upload-file.js'
30
- import {
31
- get_file_ext,
32
- get_extname,
33
- get_files_and_is_max,
34
- get_file_info,
35
- get_file_data
36
- } from './utils.js'
37
- import uploadImage from './upload-image.vue'
38
- import uploadFile from './upload-file.vue'
39
- let fileInput = null
40
- /**
41
- * FilePicker 文件选择上传
42
- * @description 文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间
43
- * @tutorial https://ext.dcloud.net.cn/plugin?id=4079
44
- * @property {Object|Array} value 组件数据,通常用来回显 ,类型由return-type属性决定
45
- * @property {Boolean} disabled = [true|false] 组件禁用
46
- * @value true 禁用
47
- * @value false 取消禁用
48
- * @property {Boolean} readonly = [true|false] 组件只读,不可选择,不显示进度,不显示删除按钮
49
- * @value true 只读
50
- * @value false 取消只读
51
- * @property {String} return-type = [array|object] 限制 value 格式,当为 object 时 ,组件只能单选,且会覆盖
52
- * @value array 规定 value 属性的类型为数组
53
- * @value object 规定 value 属性的类型为对象
54
- * @property {Boolean} disable-preview = [true|false] 禁用图片预览,仅 mode:grid 时生效
55
- * @value true 禁用图片预览
56
- * @value false 取消禁用图片预览
57
- * @property {Boolean} del-icon = [true|false] 是否显示删除按钮
58
- * @value true 显示删除按钮
59
- * @value false 不显示删除按钮
60
- * @property {Boolean} auto-upload = [true|false] 是否自动上传,值为true则只触发@select,可自行上传
61
- * @value true 自动上传
62
- * @value false 取消自动上传
63
- * @property {Number|String} limit 最大选择个数 ,h5 会自动忽略多选的部分
64
- * @property {String} title 组件标题,右侧显示上传计数
65
- * @property {String} mode = [list|grid] 选择文件后的文件列表样式
66
- * @value list 列表显示
67
- * @value grid 宫格显示
68
- * @property {String} file-mediatype = [image|video|all] 选择文件类型
69
- * @value image 只选择图片
70
- * @value video 只选择视频
71
- * @value all 选择所有文件
72
- * @property {Array} file-extname 选择文件后缀,根据 file-mediatype 属性而不同
73
- * @property {Object} list-style mode:list 时的样式
74
- * @property {Object} image-styles 选择文件后缀,根据 file-mediatype 属性而不同
75
- * @event {Function} select 选择文件后触发
76
- * @event {Function} progress 文件上传时触发
77
- * @event {Function} success 上传成功触发
78
- * @event {Function} fail 上传失败触发
79
- * @event {Function} delete 文件从列表移除时触发
80
- */
81
- export default {
82
- name: 'uniFilePicker',
83
- components: {
84
- uploadImage,
85
- uploadFile
86
- },
87
- options: {
88
- virtualHost: true
89
- },
90
- emits: ['select', 'success', 'fail', 'progress', 'delete', 'update:modelValue', 'input'],
91
- props: {
92
- // #ifdef VUE3
93
- modelValue: {
94
- type: [Array, Object],
95
- default () {
96
- return []
97
- }
98
- },
99
- // #endif
43
+ import { chooseAndUploadFile, uploadCloudFiles } from './choose-and-upload-file.js';
44
+ import { get_extname, get_file_data, get_files_and_is_max } from './utils.js';
45
+ import uploadImage from './upload-image.vue';
46
+ import uploadFile from './upload-file.vue';
100
47
 
101
- // #ifndef VUE3
102
- value: {
103
- type: [Array, Object],
104
- default () {
105
- return []
106
- }
107
- },
108
- // #endif
48
+ let fileInput = null;
49
+ /**
50
+ * FilePicker 文件选择上传
51
+ * @description 文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间
52
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=4079
53
+ * @property {Object|Array} value 组件数据,通常用来回显 ,类型由return-type属性决定
54
+ * @property {Boolean} disabled = [true|false] 组件禁用
55
+ * @value true 禁用
56
+ * @value false 取消禁用
57
+ * @property {Boolean} readonly = [true|false] 组件只读,不可选择,不显示进度,不显示删除按钮
58
+ * @value true 只读
59
+ * @value false 取消只读
60
+ * @property {String} return-type = [array|object] 限制 value 格式,当为 object 时 ,组件只能单选,且会覆盖
61
+ * @value array 规定 value 属性的类型为数组
62
+ * @value object 规定 value 属性的类型为对象
63
+ * @property {Boolean} disable-preview = [true|false] 禁用图片预览,仅 mode:grid 时生效
64
+ * @value true 禁用图片预览
65
+ * @value false 取消禁用图片预览
66
+ * @property {Boolean} del-icon = [true|false] 是否显示删除按钮
67
+ * @value true 显示删除按钮
68
+ * @value false 不显示删除按钮
69
+ * @property {Boolean} auto-upload = [true|false] 是否自动上传,值为true则只触发@select,可自行上传
70
+ * @value true 自动上传
71
+ * @value false 取消自动上传
72
+ * @property {Number|String} limit 最大选择个数 ,h5 会自动忽略多选的部分
73
+ * @property {String} title 组件标题,右侧显示上传计数
74
+ * @property {String} mode = [list|grid] 选择文件后的文件列表样式
75
+ * @value list 列表显示
76
+ * @value grid 宫格显示
77
+ * @property {String} file-mediatype = [image|video|all] 选择文件类型
78
+ * @value image 只选择图片
79
+ * @value video 只选择视频
80
+ * @value all 选择所有文件
81
+ * @property {Array} file-extname 选择文件后缀,根据 file-mediatype 属性而不同
82
+ * @property {Object} list-style mode:list 时的样式
83
+ * @property {Object} image-styles 选择文件后缀,根据 file-mediatype 属性而不同
84
+ * @event {Function} select 选择文件后触发
85
+ * @event {Function} progress 文件上传时触发
86
+ * @event {Function} success 上传成功触发
87
+ * @event {Function} fail 上传失败触发
88
+ * @event {Function} delete 文件从列表移除时触发
89
+ */
90
+ export default {
91
+ name: 'uniFilePicker',
92
+ components: {
93
+ uploadImage,
94
+ uploadFile,
95
+ },
96
+ options: {
97
+ virtualHost: true,
98
+ },
99
+ emits: ['select', 'success', 'fail', 'progress', 'delete', 'update:modelValue', 'input'],
100
+ props: {
101
+ // #ifdef VUE3
102
+ modelValue: {
103
+ type: [Array, Object],
104
+ default() {
105
+ return [];
106
+ },
107
+ },
108
+ // #endif
109
109
 
110
- disabled: {
111
- type: Boolean,
112
- default: false
113
- },
114
- disablePreview: {
115
- type: Boolean,
116
- default: false
117
- },
118
- delIcon: {
119
- type: Boolean,
120
- default: true
121
- },
122
- // 自动上传
123
- autoUpload: {
124
- type: Boolean,
125
- default: true
126
- },
127
- // 最大选择个数 ,h5只能限制单选或是多选
128
- limit: {
129
- type: [Number, String],
130
- default: 9
131
- },
132
- // 列表样式 grid | list | list-card
133
- mode: {
134
- type: String,
135
- default: 'grid'
136
- },
137
- // 选择文件类型 image/video/all
138
- fileMediatype: {
139
- type: String,
140
- default: 'image'
141
- },
142
- // 文件类型筛选
143
- fileExtname: {
144
- type: [Array, String],
145
- default () {
146
- return []
147
- }
148
- },
149
- title: {
150
- type: String,
151
- default: ''
152
- },
153
- listStyles: {
154
- type: Object,
155
- default () {
156
- return {
157
- // 是否显示边框
158
- border: true,
159
- // 是否显示分隔线
160
- dividline: true,
161
- // 线条样式
162
- borderStyle: {}
163
- }
164
- }
165
- },
166
- imageStyles: {
167
- type: Object,
168
- default () {
169
- return {
170
- width: 'auto',
171
- height: 'auto'
172
- }
173
- }
174
- },
175
- readonly: {
176
- type: Boolean,
177
- default: false
178
- },
179
- returnType: {
180
- type: String,
181
- default: 'array'
182
- },
183
- sizeType: {
184
- type: Array,
185
- default () {
186
- return ['original', 'compressed']
187
- }
188
- },
189
- sourceType: {
190
- type: Array,
191
- default () {
192
- return ['album', 'camera']
193
- }
194
- }
195
- },
196
- data() {
197
- return {
198
- files: [],
199
- localValue: []
200
- }
201
- },
202
- watch: {
203
- // #ifndef VUE3
204
- value: {
205
- handler(newVal, oldVal) {
206
- this.setValue(newVal, oldVal)
207
- },
208
- immediate: true
209
- },
210
- // #endif
211
- // #ifdef VUE3
212
- modelValue: {
213
- handler(newVal, oldVal) {
214
- this.setValue(newVal, oldVal)
215
- },
216
- immediate: true
217
- },
218
- // #endif
219
- },
220
- computed: {
221
- filesList() {
222
- let files = []
223
- this.files.forEach(v => {
224
- files.push(v)
225
- })
226
- return files
227
- },
228
- showType() {
229
- if (this.fileMediatype === 'image') {
230
- return this.mode
231
- }
232
- return 'list'
233
- },
234
- limitLength() {
235
- if (this.returnType === 'object') {
236
- return 1
237
- }
238
- if (!this.limit) {
239
- return 1
240
- }
241
- if (this.limit >= 9) {
242
- return 9
243
- }
244
- return this.limit
245
- }
246
- },
247
- created() {
248
- // TODO 兼容不开通服务空间的情况
249
- if (!(uniCloud.config && uniCloud.config.provider)) {
250
- this.noSpace = true
251
- uniCloud.chooseAndUploadFile = chooseAndUploadFile
252
- }
253
- this.form = this.getForm('uniForms')
254
- this.formItem = this.getForm('uniFormsItem')
255
- if (this.form && this.formItem) {
256
- if (this.formItem.name) {
257
- this.rename = this.formItem.name
258
- this.form.inputChildrens.push(this)
259
- }
260
- }
261
- },
262
- methods: {
263
- /**
264
- * 公开用户使用,清空文件
265
- * @param {Object} index
266
- */
267
- clearFiles(index) {
268
- if (index !== 0 && !index) {
269
- this.files = []
270
- this.$nextTick(() => {
271
- this.setEmit()
272
- })
273
- } else {
274
- this.files.splice(index, 1)
275
- }
276
- this.$nextTick(() => {
277
- this.setEmit()
278
- })
279
- },
280
- /**
281
- * 公开用户使用,继续上传
282
- */
283
- upload() {
284
- let files = []
285
- this.files.forEach((v, index) => {
286
- if (v.status === 'ready' || v.status === 'error') {
287
- files.push(Object.assign({}, v))
288
- }
289
- })
290
- return this.uploadFiles(files)
291
- },
292
- async setValue(newVal, oldVal) {
293
- const newData = async (v) => {
294
- const reg = /cloud:\/\/([\w.]+\/?)\S*/
295
- let url = ''
296
- if(v.fileID){
297
- url = v.fileID
298
- }else{
299
- url = v.url
300
- }
301
- if (reg.test(url)) {
302
- v.fileID = url
303
- v.url = await this.getTempFileURL(url)
304
- }
305
- if(v.url) v.path = v.url
306
- return v
307
- }
308
- if (this.returnType === 'object') {
309
- if (newVal) {
310
- await newData(newVal)
311
- } else {
312
- newVal = {}
313
- }
314
- } else {
315
- if (!newVal) newVal = []
316
- for(let i =0 ;i < newVal.length ;i++){
317
- let v = newVal[i]
318
- await newData(v)
319
- }
320
- }
321
- this.localValue = newVal
322
- if (this.form && this.formItem &&!this.is_reset) {
323
- this.is_reset = false
324
- this.formItem.setValue(this.localValue)
325
- }
326
- let filesData = Object.keys(newVal).length > 0 ? newVal : [];
327
- this.files = [].concat(filesData)
328
- },
110
+ // #ifndef VUE3
111
+ value: {
112
+ type: [Array, Object],
113
+ default() {
114
+ return [];
115
+ },
116
+ },
117
+ // #endif
329
118
 
330
- /**
331
- * 选择文件
332
- */
333
- choose() {
119
+ disabled: {
120
+ type: Boolean,
121
+ default: false,
122
+ },
123
+ disablePreview: {
124
+ type: Boolean,
125
+ default: false,
126
+ },
127
+ delIcon: {
128
+ type: Boolean,
129
+ default: true,
130
+ },
131
+ // 自动上传
132
+ autoUpload: {
133
+ type: Boolean,
134
+ default: true,
135
+ },
136
+ // 最大选择个数 ,h5只能限制单选或是多选
137
+ limit: {
138
+ type: [Number, String],
139
+ default: 9,
140
+ },
141
+ // 列表样式 grid | list | list-card
142
+ mode: {
143
+ type: String,
144
+ default: 'grid',
145
+ },
146
+ // 选择文件类型 image/video/all
147
+ fileMediatype: {
148
+ type: String,
149
+ default: 'image',
150
+ },
151
+ // 文件类型筛选
152
+ fileExtname: {
153
+ type: [Array, String],
154
+ default() {
155
+ return [];
156
+ },
157
+ },
158
+ title: {
159
+ type: String,
160
+ default: '',
161
+ },
162
+ listStyles: {
163
+ type: Object,
164
+ default() {
165
+ return {
166
+ // 是否显示边框
167
+ border: true,
168
+ // 是否显示分隔线
169
+ dividline: true,
170
+ // 线条样式
171
+ borderStyle: {},
172
+ };
173
+ },
174
+ },
175
+ imageStyles: {
176
+ type: Object,
177
+ default() {
178
+ return {
179
+ width: 'auto',
180
+ height: 'auto',
181
+ };
182
+ },
183
+ },
184
+ readonly: {
185
+ type: Boolean,
186
+ default: false,
187
+ },
188
+ returnType: {
189
+ type: String,
190
+ default: 'array',
191
+ },
192
+ sizeType: {
193
+ type: Array,
194
+ default() {
195
+ return ['original', 'compressed'];
196
+ },
197
+ },
198
+ sourceType: {
199
+ type: Array,
200
+ default() {
201
+ return ['album', 'camera'];
202
+ },
203
+ },
204
+ },
205
+ data() {
206
+ return {
207
+ files: [],
208
+ localValue: [],
209
+ };
210
+ },
211
+ watch: {
212
+ // #ifndef VUE3
213
+ value: {
214
+ handler(newVal, oldVal) {
215
+ this.setValue(newVal, oldVal);
216
+ },
217
+ immediate: true,
218
+ },
219
+ // #endif
220
+ // #ifdef VUE3
221
+ modelValue: {
222
+ handler(newVal, oldVal) {
223
+ this.setValue(newVal, oldVal);
224
+ },
225
+ immediate: true,
226
+ },
227
+ // #endif
228
+ },
229
+ computed: {
230
+ filesList() {
231
+ let files = [];
232
+ this.files.forEach((v) => {
233
+ files.push(v);
234
+ });
235
+ return files;
236
+ },
237
+ showType() {
238
+ if (this.fileMediatype === 'image') {
239
+ return this.mode;
240
+ }
241
+ return 'list';
242
+ },
243
+ limitLength() {
244
+ if (this.returnType === 'object') {
245
+ return 1;
246
+ }
247
+ if (!this.limit) {
248
+ return 1;
249
+ }
250
+ if (this.limit >= 9) {
251
+ return 9;
252
+ }
253
+ return this.limit;
254
+ },
255
+ },
256
+ created() {
257
+ // TODO 兼容不开通服务空间的情况
258
+ if (!(uniCloud.config && uniCloud.config.provider)) {
259
+ this.noSpace = true;
260
+ uniCloud.chooseAndUploadFile = chooseAndUploadFile;
261
+ }
262
+ this.form = this.getForm('uniForms');
263
+ this.formItem = this.getForm('uniFormsItem');
264
+ if (this.form && this.formItem) {
265
+ if (this.formItem.name) {
266
+ this.rename = this.formItem.name;
267
+ this.form.inputChildrens.push(this);
268
+ }
269
+ }
270
+ },
271
+ methods: {
272
+ /**
273
+ * 公开用户使用,清空文件
274
+ * @param {Object} index
275
+ */
276
+ clearFiles(index) {
277
+ if (index !== 0 && !index) {
278
+ this.files = [];
279
+ this.$nextTick(() => {
280
+ this.setEmit();
281
+ });
282
+ } else {
283
+ this.files.splice(index, 1);
284
+ }
285
+ this.$nextTick(() => {
286
+ this.setEmit();
287
+ });
288
+ },
289
+ /**
290
+ * 公开用户使用,继续上传
291
+ */
292
+ upload() {
293
+ let files = [];
294
+ this.files.forEach((v, index) => {
295
+ if (v.status === 'ready' || v.status === 'error') {
296
+ files.push(Object.assign({}, v));
297
+ }
298
+ });
299
+ return this.uploadFiles(files);
300
+ },
301
+ async setValue(newVal, oldVal) {
302
+ const newData = async (v) => {
303
+ const reg = /cloud:\/\/([\w.]+\/?)\S*/;
304
+ let url = '';
305
+ if (v.fileID) {
306
+ url = v.fileID;
307
+ } else {
308
+ url = v.url;
309
+ }
310
+ if (reg.test(url)) {
311
+ v.fileID = url;
312
+ v.url = await this.getTempFileURL(url);
313
+ }
314
+ if (v.url) v.path = v.url;
315
+ return v;
316
+ };
317
+ if (this.returnType === 'object') {
318
+ if (newVal) {
319
+ await newData(newVal);
320
+ } else {
321
+ newVal = {};
322
+ }
323
+ } else {
324
+ if (!newVal) newVal = [];
325
+ for (let i = 0; i < newVal.length; i++) {
326
+ let v = newVal[i];
327
+ await newData(v);
328
+ }
329
+ }
330
+ this.localValue = newVal;
331
+ if (this.form && this.formItem && !this.is_reset) {
332
+ this.is_reset = false;
333
+ this.formItem.setValue(this.localValue);
334
+ }
335
+ let filesData = Object.keys(newVal).length > 0 ? newVal : [];
336
+ this.files = [].concat(filesData);
337
+ },
334
338
 
335
- if (this.disabled) return
336
- if (this.files.length >= Number(this.limitLength) && this.showType !== 'grid' && this.returnType ===
337
- 'array') {
338
- uni.showToast({
339
- title: `您最多选择 ${this.limitLength} 个文件`,
340
- icon: 'none'
341
- })
342
- return
343
- }
344
- this.chooseFiles()
345
- },
339
+ /**
340
+ * 选择文件
341
+ */
342
+ choose() {
343
+ if (this.disabled) return;
344
+ if (this.files.length >= Number(this.limitLength) && this.showType !== 'grid' && this.returnType === 'array') {
345
+ uni.showToast({
346
+ title: `您最多选择 ${this.limitLength} 个文件`,
347
+ icon: 'none',
348
+ });
349
+ return;
350
+ }
351
+ this.chooseFiles();
352
+ },
346
353
 
347
- /**
348
- * 选择文件并上传
349
- */
350
- chooseFiles() {
351
- const _extname = get_extname(this.fileExtname)
352
- // 获取后缀
353
- uniCloud
354
- .chooseAndUploadFile({
355
- type: this.fileMediatype,
356
- compressed: false,
357
- sizeType: this.sizeType,
358
- sourceType: this.sourceType,
359
- // TODO 如果为空,video 有问题
360
- extension: _extname.length > 0 ? _extname : undefined,
361
- count: this.limitLength - this.files.length, //默认9
362
- onChooseFile: this.chooseFileCallback,
363
- onUploadProgress: progressEvent => {
364
- this.setProgress(progressEvent, progressEvent.index)
365
- }
366
- })
367
- .then(result => {
368
- this.setSuccessAndError(result.tempFiles)
369
- })
370
- .catch(err => {
371
- console.log('选择失败', err)
372
- })
373
- },
354
+ /**
355
+ * 选择文件并上传
356
+ */
357
+ chooseFiles() {
358
+ const _extname = get_extname(this.fileExtname);
359
+ // 获取后缀
360
+ uniCloud
361
+ .chooseAndUploadFile({
362
+ type: this.fileMediatype,
363
+ compressed: false,
364
+ sizeType: this.sizeType,
365
+ sourceType: this.sourceType,
366
+ // TODO 如果为空,video 有问题
367
+ extension: _extname.length > 0 ? _extname : undefined,
368
+ count: this.limitLength - this.files.length, //默认9
369
+ onChooseFile: this.chooseFileCallback,
370
+ onUploadProgress: (progressEvent) => {
371
+ this.setProgress(progressEvent, progressEvent.index);
372
+ },
373
+ })
374
+ .then((result) => {
375
+ this.setSuccessAndError(result.tempFiles);
376
+ })
377
+ .catch((err) => {
378
+ console.log('选择失败', err);
379
+ });
380
+ },
374
381
 
375
- /**
376
- * 选择文件回调
377
- * @param {Object} res
378
- */
379
- async chooseFileCallback(res) {
380
- const _extname = get_extname(this.fileExtname)
381
- const is_one = (Number(this.limitLength) === 1 &&
382
- this.disablePreview &&
383
- !this.disabled) ||
384
- this.returnType === 'object'
385
- // 如果这有一个文件 ,需要清空本地缓存数据
386
- if (is_one) {
387
- this.files = []
388
- }
382
+ /**
383
+ * 选择文件回调
384
+ * @param {Object} res
385
+ */
386
+ async chooseFileCallback(res) {
387
+ const _extname = get_extname(this.fileExtname);
388
+ const is_one = (Number(this.limitLength) === 1 && this.disablePreview && !this.disabled) || this.returnType === 'object';
389
+ // 如果这有一个文件 ,需要清空本地缓存数据
390
+ if (is_one) {
391
+ this.files = [];
392
+ }
389
393
 
390
- let {
391
- filePaths,
392
- files
393
- } = get_files_and_is_max(res, _extname)
394
- if (!(_extname && _extname.length > 0)) {
395
- filePaths = res.tempFilePaths
396
- files = res.tempFiles
397
- }
394
+ let { filePaths, files } = get_files_and_is_max(res, _extname);
395
+ if (!(_extname && _extname.length > 0)) {
396
+ filePaths = res.tempFilePaths;
397
+ files = res.tempFiles;
398
+ }
398
399
 
399
- let currentData = []
400
- for (let i = 0; i < files.length; i++) {
401
- if (this.limitLength - this.files.length <= 0) break
402
- files[i].uuid = Date.now()
403
- let filedata = await get_file_data(files[i], this.fileMediatype)
404
- filedata.progress = 0
405
- filedata.status = 'ready'
406
- this.files.push(filedata)
407
- currentData.push({
408
- ...filedata,
409
- file: files[i]
410
- })
411
- }
412
- this.$emit('select', {
413
- tempFiles: currentData,
414
- tempFilePaths: filePaths
415
- })
416
- res.tempFiles = files
417
- // 停止自动上传
418
- if (!this.autoUpload || this.noSpace) {
419
- res.tempFiles = []
420
- }
421
- },
400
+ let currentData = [];
401
+ for (let i = 0; i < files.length; i++) {
402
+ if (this.limitLength - this.files.length <= 0) break;
403
+ files[i].uuid = Date.now();
404
+ let filedata = await get_file_data(files[i], this.fileMediatype);
405
+ filedata.progress = 0;
406
+ filedata.status = 'ready';
407
+ this.files.push(filedata);
408
+ currentData.push({
409
+ ...filedata,
410
+ file: files[i],
411
+ });
412
+ }
413
+ this.$emit('select', {
414
+ tempFiles: currentData,
415
+ tempFilePaths: filePaths,
416
+ });
417
+ res.tempFiles = files;
418
+ // 停止自动上传
419
+ if (!this.autoUpload || this.noSpace) {
420
+ res.tempFiles = [];
421
+ }
422
+ },
422
423
 
423
- /**
424
- * 批传
425
- * @param {Object} e
426
- */
427
- uploadFiles(files) {
428
- files = [].concat(files)
429
- return uploadCloudFiles.call(this, files, 5, res => {
430
- this.setProgress(res, res.index, true)
431
- })
432
- .then(result => {
433
- this.setSuccessAndError(result)
434
- return result;
435
- })
436
- .catch(err => {
437
- console.log(err)
438
- })
439
- },
424
+ /**
425
+ * 批传
426
+ * @param {Object} e
427
+ */
428
+ uploadFiles(files) {
429
+ files = [].concat(files);
430
+ return uploadCloudFiles
431
+ .call(this, files, 5, (res) => {
432
+ this.setProgress(res, res.index, true);
433
+ })
434
+ .then((result) => {
435
+ this.setSuccessAndError(result);
436
+ return result;
437
+ })
438
+ .catch((err) => {
439
+ console.log(err);
440
+ });
441
+ },
440
442
 
441
- /**
442
- * 成功或失败
443
- */
444
- async setSuccessAndError(res, fn) {
445
- let successData = []
446
- let errorData = []
447
- let tempFilePath = []
448
- let errorTempFilePath = []
449
- for (let i = 0; i < res.length; i++) {
450
- const item = res[i]
451
- const index = item.uuid ? this.files.findIndex(p => p.uuid === item.uuid) : item.index
443
+ /**
444
+ * 成功或失败
445
+ */
446
+ async setSuccessAndError(res, fn) {
447
+ let successData = [];
448
+ let errorData = [];
449
+ let tempFilePath = [];
450
+ let errorTempFilePath = [];
451
+ for (let i = 0; i < res.length; i++) {
452
+ const item = res[i];
453
+ const index = item.uuid ? this.files.findIndex((p) => p.uuid === item.uuid) : item.index;
452
454
 
453
- if (index === -1 || !this.files) break
454
- if (item.errMsg === 'request:fail') {
455
- this.files[index].url = item.path
456
- this.files[index].status = 'error'
457
- this.files[index].errMsg = item.errMsg
458
- // this.files[index].progress = -1
459
- errorData.push(this.files[index])
460
- errorTempFilePath.push(this.files[index].url)
461
- } else {
462
- this.files[index].errMsg = ''
463
- this.files[index].fileID = item.url
464
- const reg = /cloud:\/\/([\w.]+\/?)\S*/
465
- if (reg.test(item.url)) {
466
- this.files[index].url = await this.getTempFileURL(item.url)
467
- }else{
468
- this.files[index].url = item.url
469
- }
455
+ if (index === -1 || !this.files) break;
456
+ if (item.errMsg === 'request:fail') {
457
+ this.files[index].url = item.path;
458
+ this.files[index].status = 'error';
459
+ this.files[index].errMsg = item.errMsg;
460
+ // this.files[index].progress = -1
461
+ errorData.push(this.files[index]);
462
+ errorTempFilePath.push(this.files[index].url);
463
+ } else {
464
+ this.files[index].errMsg = '';
465
+ this.files[index].fileID = item.url;
466
+ const reg = /cloud:\/\/([\w.]+\/?)\S*/;
467
+ if (reg.test(item.url)) {
468
+ this.files[index].url = await this.getTempFileURL(item.url);
469
+ } else {
470
+ this.files[index].url = item.url;
471
+ }
470
472
 
471
- this.files[index].status = 'success'
472
- this.files[index].progress += 1
473
- successData.push(this.files[index])
474
- tempFilePath.push(this.files[index].fileID)
475
- }
476
- }
473
+ this.files[index].status = 'success';
474
+ this.files[index].progress += 1;
475
+ successData.push(this.files[index]);
476
+ tempFilePath.push(this.files[index].fileID);
477
+ }
478
+ }
477
479
 
478
- if (successData.length > 0) {
479
- this.setEmit()
480
- // 状态改变返回
481
- this.$emit('success', {
482
- tempFiles: this.backObject(successData),
483
- tempFilePaths: tempFilePath
484
- })
485
- }
480
+ if (successData.length > 0) {
481
+ this.setEmit();
482
+ // 状态改变返回
483
+ this.$emit('success', {
484
+ tempFiles: this.backObject(successData),
485
+ tempFilePaths: tempFilePath,
486
+ });
487
+ }
486
488
 
487
- if (errorData.length > 0) {
488
- this.$emit('fail', {
489
- tempFiles: this.backObject(errorData),
490
- tempFilePaths: errorTempFilePath
491
- })
492
- }
493
- },
489
+ if (errorData.length > 0) {
490
+ this.$emit('fail', {
491
+ tempFiles: this.backObject(errorData),
492
+ tempFilePaths: errorTempFilePath,
493
+ });
494
+ }
495
+ },
494
496
 
495
- /**
496
- * 获取进度
497
- * @param {Object} progressEvent
498
- * @param {Object} index
499
- * @param {Object} type
500
- */
501
- setProgress(progressEvent, index, type) {
502
- const fileLenth = this.files.length
503
- const percentNum = (index / fileLenth) * 100
504
- const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
505
- let idx = index
506
- if (!type) {
507
- idx = this.files.findIndex(p => p.uuid === progressEvent.tempFile.uuid)
508
- }
509
- if (idx === -1 || !this.files[idx]) return
510
- // fix by mehaotian 100 就会消失,-1 是为了让进度条消失
511
- this.files[idx].progress = percentCompleted - 1
512
- // 上传中
513
- this.$emit('progress', {
514
- index: idx,
515
- progress: parseInt(percentCompleted),
516
- tempFile: this.files[idx]
517
- })
518
- },
497
+ /**
498
+ * 获取进度
499
+ * @param {Object} progressEvent
500
+ * @param {Object} index
501
+ * @param {Object} type
502
+ */
503
+ setProgress(progressEvent, index, type) {
504
+ const fileLenth = this.files.length;
505
+ const percentNum = (index / fileLenth) * 100;
506
+ const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
507
+ let idx = index;
508
+ if (!type) {
509
+ idx = this.files.findIndex((p) => p.uuid === progressEvent.tempFile.uuid);
510
+ }
511
+ if (idx === -1 || !this.files[idx]) return;
512
+ // fix by mehaotian 100 就会消失,-1 是为了让进度条消失
513
+ this.files[idx].progress = percentCompleted - 1;
514
+ // 上传中
515
+ this.$emit('progress', {
516
+ index: idx,
517
+ progress: parseInt(percentCompleted),
518
+ tempFile: this.files[idx],
519
+ });
520
+ },
519
521
 
520
- /**
521
- * 删除文件
522
- * @param {Object} index
523
- */
524
- delFile(index) {
525
- this.$emit('delete', {
526
- tempFile: this.files[index],
527
- tempFilePath: this.files[index].url
528
- })
529
- this.files.splice(index, 1)
530
- this.$nextTick(() => {
531
- this.setEmit()
532
- })
533
- },
522
+ /**
523
+ * 删除文件
524
+ * @param {Object} index
525
+ */
526
+ delFile(index) {
527
+ this.$emit('delete', {
528
+ tempFile: this.files[index],
529
+ tempFilePath: this.files[index].url,
530
+ });
531
+ this.files.splice(index, 1);
532
+ this.$nextTick(() => {
533
+ this.setEmit();
534
+ });
535
+ },
534
536
 
535
- /**
536
- * 获取文件名和后缀
537
- * @param {Object} name
538
- */
539
- getFileExt(name) {
540
- const last_len = name.lastIndexOf('.')
541
- const len = name.length
542
- return {
543
- name: name.substring(0, last_len),
544
- ext: name.substring(last_len + 1, len)
545
- }
546
- },
537
+ /**
538
+ * 获取文件名和后缀
539
+ * @param {Object} name
540
+ */
541
+ getFileExt(name) {
542
+ const last_len = name.lastIndexOf('.');
543
+ const len = name.length;
544
+ return {
545
+ name: name.substring(0, last_len),
546
+ ext: name.substring(last_len + 1, len),
547
+ };
548
+ },
547
549
 
548
- /**
549
- * 处理返回事件
550
- */
551
- setEmit() {
552
- let data = []
553
- if (this.returnType === 'object') {
554
- data = this.backObject(this.files)[0]
555
- this.localValue = data?data:null
556
- } else {
557
- data = this.backObject(this.files)
558
- if (!this.localValue) {
559
- this.localValue = []
560
- }
561
- this.localValue = [...data]
562
- }
563
- // #ifdef VUE3
564
- this.$emit('update:modelValue', this.localValue)
565
- // #endif
566
- // #ifndef VUE3
567
- this.$emit('input', this.localValue)
568
- // #endif
569
- },
550
+ /**
551
+ * 处理返回事件
552
+ */
553
+ setEmit() {
554
+ let data = [];
555
+ if (this.returnType === 'object') {
556
+ data = this.backObject(this.files)[0];
557
+ this.localValue = data ? data : null;
558
+ } else {
559
+ data = this.backObject(this.files);
560
+ if (!this.localValue) {
561
+ this.localValue = [];
562
+ }
563
+ this.localValue = [...data];
564
+ }
565
+ // #ifdef VUE3
566
+ this.$emit('update:modelValue', this.localValue);
567
+ // #endif
568
+ // #ifndef VUE3
569
+ this.$emit('input', this.localValue);
570
+ // #endif
571
+ },
570
572
 
571
- /**
572
- * 处理返回参数
573
- * @param {Object} files
574
- */
575
- backObject(files) {
576
- let newFilesData = []
577
- files.forEach(v => {
578
- newFilesData.push({
579
- extname: v.extname,
580
- fileType: v.fileType,
581
- image: v.image,
582
- name: v.name,
583
- path: v.path,
584
- size: v.size,
585
- fileID:v.fileID,
586
- url: v.url,
587
- // 修改删除一个文件后不能再上传的bug, #694
588
- uuid: v.uuid,
589
- status: v.status,
590
- cloudPath: v.cloudPath
591
- })
592
- })
593
- return newFilesData
594
- },
595
- async getTempFileURL(fileList) {
596
- fileList = {
597
- fileList: [].concat(fileList)
598
- }
599
- const urls = await uniCloud.getTempFileURL(fileList)
600
- return urls.fileList[0].tempFileURL || ''
601
- },
602
- /**
603
- * 获取父元素实例
604
- */
605
- getForm(name = 'uniForms') {
606
- let parent = this.$parent;
607
- let parentName = parent.$options.name;
608
- while (parentName !== name) {
609
- parent = parent.$parent;
610
- if (!parent) return false;
611
- parentName = parent.$options.name;
612
- }
613
- return parent;
614
- }
615
- }
616
- }
573
+ /**
574
+ * 处理返回参数
575
+ * @param {Object} files
576
+ */
577
+ backObject(files) {
578
+ let newFilesData = [];
579
+ files.forEach((v) => {
580
+ newFilesData.push({
581
+ extname: v.extname,
582
+ fileType: v.fileType,
583
+ image: v.image,
584
+ name: v.name,
585
+ path: v.path,
586
+ size: v.size,
587
+ fileID: v.fileID,
588
+ url: v.url,
589
+ // 修改删除一个文件后不能再上传的bug, #694
590
+ uuid: v.uuid,
591
+ status: v.status,
592
+ cloudPath: v.cloudPath,
593
+ });
594
+ });
595
+ return newFilesData;
596
+ },
597
+ async getTempFileURL(fileList) {
598
+ fileList = {
599
+ fileList: [].concat(fileList),
600
+ };
601
+ const urls = await uniCloud.getTempFileURL(fileList);
602
+ return urls.fileList[0].tempFileURL || '';
603
+ },
604
+ /**
605
+ * 获取父元素实例
606
+ */
607
+ getForm(name = 'uniForms') {
608
+ let parent = this.$parent;
609
+ let parentName = parent.$options.name;
610
+ while (parentName !== name) {
611
+ parent = parent.$parent;
612
+ if (!parent) return false;
613
+ parentName = parent.$options.name;
614
+ }
615
+ return parent;
616
+ },
617
+ },
618
+ };
617
619
  </script>
618
620
 
619
621
  <style>
620
- .uni-file-picker {
621
- /* #ifndef APP-NVUE */
622
- box-sizing: border-box;
623
- overflow: hidden;
624
- width: 100%;
625
- /* #endif */
626
- flex: 1;
627
- }
622
+ .uni-file-picker {
623
+ /* #ifndef APP-NVUE */
624
+ box-sizing: border-box;
625
+ overflow: hidden;
626
+ width: 100%;
627
+ /* #endif */
628
+ flex: 1;
629
+ }
628
630
 
629
- .uni-file-picker__header {
630
- padding-top: 5px;
631
- padding-bottom: 10px;
632
- /* #ifndef APP-NVUE */
633
- display: flex;
634
- /* #endif */
635
- justify-content: space-between;
636
- }
631
+ .uni-file-picker__header {
632
+ padding-top: 5px;
633
+ padding-bottom: 10px;
634
+ /* #ifndef APP-NVUE */
635
+ display: flex;
636
+ /* #endif */
637
+ justify-content: space-between;
638
+ }
637
639
 
638
- .file-title {
639
- font-size: 14px;
640
- color: #333;
641
- }
640
+ .file-title {
641
+ font-size: 14px;
642
+ color: #333;
643
+ }
642
644
 
643
- .file-count {
644
- font-size: 14px;
645
- color: #999;
646
- }
645
+ .file-count {
646
+ font-size: 14px;
647
+ color: #999;
648
+ }
647
649
 
648
- .is-add {
649
- /* #ifndef APP-NVUE */
650
- display: flex;
651
- /* #endif */
652
- align-items: center;
653
- justify-content: center;
654
- }
650
+ .is-add {
651
+ /* #ifndef APP-NVUE */
652
+ display: flex;
653
+ /* #endif */
654
+ align-items: center;
655
+ justify-content: center;
656
+ }
655
657
 
656
- .icon-add {
657
- width: 50px;
658
- height: 5px;
659
- background-color: #f1f1f1;
660
- border-radius: 2px;
661
- }
658
+ .icon-add {
659
+ width: 50px;
660
+ height: 5px;
661
+ background-color: #f1f1f1;
662
+ border-radius: 2px;
663
+ }
662
664
 
663
- .rotate {
664
- position: absolute;
665
- transform: rotate(90deg);
666
- }
665
+ .rotate {
666
+ position: absolute;
667
+ transform: rotate(90deg);
668
+ }
667
669
  </style>