@vtj/materials 0.10.5 → 0.10.7

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 (77) hide show
  1. package/dist/assets/antdv/index.umd.js +2 -2
  2. package/dist/assets/charts/index.umd.js +2 -2
  3. package/dist/assets/element/index.umd.js +2 -2
  4. package/dist/assets/ui/index.umd.js +2 -2
  5. package/dist/assets/uni-h5/index.umd.js +3 -3
  6. package/dist/assets/uni-ui/index.umd.js +3 -3
  7. package/dist/assets/vant/index.umd.js +2 -2
  8. package/dist/deps/@vtj/charts/index.umd.js +2 -2
  9. package/dist/deps/@vtj/icons/index.umd.js +2 -2
  10. package/dist/deps/@vtj/ui/index.umd.js +3 -3
  11. package/dist/deps/@vtj/utils/index.umd.js +20 -20
  12. package/dist/deps/@vueuse/core/index.iife.min.js +1 -1
  13. package/dist/deps/uni-ui/index.umd.js +1 -1
  14. package/dist/deps/uni-ui/style.css +1 -1
  15. package/package.json +7 -7
  16. package/src/uni-h5/components/input.ts +2 -2
  17. package/src/uni-h5/components/scrollView.ts +3 -3
  18. package/src/uni-h5/components/video.ts +1 -1
  19. package/src/uni-ui/components/badge.ts +1 -5
  20. package/src/uni-ui/components/breadcrumb.ts +1 -20
  21. package/src/uni-ui/components/collapse.ts +22 -23
  22. package/src/uni-ui/components/grid.ts +0 -9
  23. package/src/uni-ui/components/group.ts +1 -10
  24. package/src/uni-ui/components/index.ts +4 -4
  25. package/src/uni-ui/components/popup.ts +10 -2
  26. package/src/uni-ui/components/swiperDot.ts +21 -7
  27. package/src/uni-ui/components/table.ts +9 -3
  28. package/src/uni-ui/components/transition.ts +10 -1
  29. package/src/uni-ui/index.ts +19 -44
  30. package/src/uni-ui/lib/uni-collapse/uni-collapse.vue +153 -0
  31. package/src/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +425 -0
  32. package/src/uni-ui/lib/uni-data-picker/keypress.js +45 -0
  33. package/src/uni-ui/lib/uni-data-picker/uni-data-picker.vue +604 -0
  34. package/src/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +622 -0
  35. package/src/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.css +76 -0
  36. package/src/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +335 -0
  37. package/src/uni-ui/lib/uni-datetime-picker/calendar-item.vue +181 -170
  38. package/src/uni-ui/lib/uni-datetime-picker/calendar.vue +977 -939
  39. package/src/uni-ui/lib/uni-datetime-picker/time-picker.vue +1024 -932
  40. package/src/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +15 -17
  41. package/src/uni-ui/lib/uni-datetime-picker/util.js +419 -392
  42. package/src/uni-ui/lib/uni-fav/i18n/en.json +4 -0
  43. package/src/uni-ui/lib/uni-fav/i18n/index.js +8 -0
  44. package/src/uni-ui/lib/uni-fav/i18n/zh-Hans.json +4 -0
  45. package/src/uni-ui/lib/uni-fav/i18n/zh-Hant.json +4 -0
  46. package/src/uni-ui/lib/uni-fav/uni-fav.vue +170 -0
  47. package/src/uni-ui/lib/uni-file-picker/choose-and-upload-file.js +280 -0
  48. package/src/uni-ui/lib/uni-file-picker/uni-file-picker.vue +668 -0
  49. package/src/uni-ui/lib/uni-file-picker/upload-file.vue +325 -0
  50. package/src/uni-ui/lib/uni-file-picker/upload-image.vue +292 -0
  51. package/src/uni-ui/lib/uni-file-picker/utils.js +110 -0
  52. package/src/uni-ui/lib/uni-grid/uni-grid.vue +148 -0
  53. package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +152 -128
  54. package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +50 -50
  55. package/src/uni-ui/lib/uni-load-more/i18n/en.json +5 -0
  56. package/src/uni-ui/lib/uni-load-more/i18n/index.js +8 -0
  57. package/src/uni-ui/lib/uni-load-more/i18n/zh-Hans.json +5 -0
  58. package/src/uni-ui/lib/uni-load-more/i18n/zh-Hant.json +5 -0
  59. package/src/uni-ui/lib/uni-load-more/uni-load-more.vue +456 -0
  60. package/src/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +484 -0
  61. package/src/uni-ui/lib/uni-popup/uni-popup.vue +4 -4
  62. package/src/uni-ui/lib/uni-popup-message/uni-popup-message.vue +149 -0
  63. package/src/uni-ui/lib/uni-rate/uni-rate.vue +362 -343
  64. package/src/uni-ui/lib/uni-row/uni-row.vue +193 -0
  65. package/src/uni-ui/lib/uni-search-bar/i18n/en.json +4 -0
  66. package/src/uni-ui/lib/uni-search-bar/i18n/index.js +8 -0
  67. package/src/uni-ui/lib/uni-search-bar/i18n/zh-Hans.json +4 -0
  68. package/src/uni-ui/lib/uni-search-bar/i18n/zh-Hant.json +4 -0
  69. package/src/uni-ui/lib/uni-search-bar/uni-search-bar.vue +339 -0
  70. package/src/uni-ui/lib/uni-swipe-action-item/bindingx.js +294 -285
  71. package/src/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +8 -9
  72. package/src/uni-ui/lib/uni-th/filter-dropdown.vue +551 -503
  73. package/src/uni-ui/lib/uni-tr/table-checkbox.vue +165 -163
  74. package/src/uni-ui/lib/uni-tr/uni-tr.vue +6 -6
  75. package/src/uni-ui/lib/uni-transition/createAnimation.js +131 -0
  76. package/src/uni-ui/lib/uni-transition/uni-transition.vue +310 -0
  77. package/src/version.ts +2 -2
@@ -0,0 +1,325 @@
1
+ <template>
2
+ <view class="uni-file-picker__files">
3
+ <view v-if="!readonly" class="files-button" @click="choose">
4
+ <slot></slot>
5
+ </view>
6
+ <!-- :class="{'is-text-box':showType === 'list'}" -->
7
+ <view v-if="list.length > 0" class="uni-file-picker__lists is-text-box" :style="borderStyle">
8
+ <!-- ,'is-list-card':showType === 'list-card' -->
9
+
10
+ <view class="uni-file-picker__lists-box" v-for="(item ,index) in list" :key="index" :class="{
11
+ 'files-border':index !== 0 && styles.dividline}"
12
+ :style="index !== 0 && styles.dividline &&borderLineStyle">
13
+ <view class="uni-file-picker__item">
14
+ <!-- :class="{'is-text-image':showType === 'list'}" -->
15
+ <!-- <view class="files__image is-text-image">
16
+ <image class="header-image" :src="item.logo" mode="aspectFit"></image>
17
+ </view> -->
18
+ <view class="files__name">{{item.name}}</view>
19
+ <view v-if="delIcon&&!readonly" class="icon-del-box icon-files" @click="delFile(index)">
20
+ <view class="icon-del icon-files"></view>
21
+ <view class="icon-del rotate"></view>
22
+ </view>
23
+ </view>
24
+ <view v-if="(item.progress && item.progress !== 100) ||item.progress===0 " class="file-picker__progress">
25
+ <progress class="file-picker__progress-item" :percent="item.progress === -1?0:item.progress" stroke-width="4"
26
+ :backgroundColor="item.errMsg?'#ff5a5f':'#EBEBEB'" />
27
+ </view>
28
+ <view v-if="item.status === 'error'" class="file-picker__mask" @click.stop="uploadFiles(item,index)">
29
+ 点击重试
30
+ </view>
31
+ </view>
32
+
33
+ </view>
34
+ </view>
35
+ </template>
36
+
37
+ <script>
38
+ export default {
39
+ name: "uploadFile",
40
+ emits:['uploadFiles','choose','delFile'],
41
+ props: {
42
+ filesList: {
43
+ type: Array,
44
+ default () {
45
+ return []
46
+ }
47
+ },
48
+ delIcon: {
49
+ type: Boolean,
50
+ default: true
51
+ },
52
+ limit: {
53
+ type: [Number, String],
54
+ default: 9
55
+ },
56
+ showType: {
57
+ type: String,
58
+ default: ''
59
+ },
60
+ listStyles: {
61
+ type: Object,
62
+ default () {
63
+ return {
64
+ // 是否显示边框
65
+ border: true,
66
+ // 是否显示分隔线
67
+ dividline: true,
68
+ // 线条样式
69
+ borderStyle: {}
70
+ }
71
+ }
72
+ },
73
+ readonly:{
74
+ type:Boolean,
75
+ default:false
76
+ }
77
+ },
78
+ computed: {
79
+ list() {
80
+ let files = []
81
+ this.filesList.forEach(v => {
82
+ files.push(v)
83
+ })
84
+ return files
85
+ },
86
+ styles() {
87
+ let styles = {
88
+ border: true,
89
+ dividline: true,
90
+ 'border-style': {}
91
+ }
92
+ return Object.assign(styles, this.listStyles)
93
+ },
94
+ borderStyle() {
95
+ let {
96
+ borderStyle,
97
+ border
98
+ } = this.styles
99
+ let obj = {}
100
+ if (!border) {
101
+ obj.border = 'none'
102
+ } else {
103
+ let width = (borderStyle && borderStyle.width) || 1
104
+ width = this.value2px(width)
105
+ let radius = (borderStyle && borderStyle.radius) || 5
106
+ radius = this.value2px(radius)
107
+ obj = {
108
+ 'border-width': width,
109
+ 'border-style': (borderStyle && borderStyle.style) || 'solid',
110
+ 'border-color': (borderStyle && borderStyle.color) || '#eee',
111
+ 'border-radius': radius
112
+ }
113
+ }
114
+ let classles = ''
115
+ for (let i in obj) {
116
+ classles += `${i}:${obj[i]};`
117
+ }
118
+ return classles
119
+ },
120
+ borderLineStyle() {
121
+ let obj = {}
122
+ let {
123
+ borderStyle
124
+ } = this.styles
125
+ if (borderStyle && borderStyle.color) {
126
+ obj['border-color'] = borderStyle.color
127
+ }
128
+ if (borderStyle && borderStyle.width) {
129
+ let width = borderStyle && borderStyle.width || 1
130
+ let style = borderStyle && borderStyle.style || 0
131
+ if (typeof width === 'number') {
132
+ width += 'px'
133
+ } else {
134
+ width = width.indexOf('px') ? width : width + 'px'
135
+ }
136
+ obj['border-width'] = width
137
+
138
+ if (typeof style === 'number') {
139
+ style += 'px'
140
+ } else {
141
+ style = style.indexOf('px') ? style : style + 'px'
142
+ }
143
+ obj['border-top-style'] = style
144
+ }
145
+ let classles = ''
146
+ for (let i in obj) {
147
+ classles += `${i}:${obj[i]};`
148
+ }
149
+ return classles
150
+ }
151
+ },
152
+
153
+ methods: {
154
+ uploadFiles(item, index) {
155
+ this.$emit("uploadFiles", {
156
+ item,
157
+ index
158
+ })
159
+ },
160
+ choose() {
161
+ this.$emit("choose")
162
+ },
163
+ delFile(index) {
164
+ this.$emit('delFile', index)
165
+ },
166
+ value2px(value) {
167
+ if (typeof value === 'number') {
168
+ value += 'px'
169
+ } else {
170
+ value = value.indexOf('px') !== -1 ? value : value + 'px'
171
+ }
172
+ return value
173
+ }
174
+ }
175
+ }
176
+ </script>
177
+
178
+ <style lang="scss">
179
+ .uni-file-picker__files {
180
+ /* #ifndef APP-NVUE */
181
+ display: flex;
182
+ /* #endif */
183
+ flex-direction: column;
184
+ justify-content: flex-start;
185
+ }
186
+
187
+ .files-button {
188
+ // border: 1px red solid;
189
+ }
190
+
191
+ .uni-file-picker__lists {
192
+ position: relative;
193
+ margin-top: 5px;
194
+ overflow: hidden;
195
+ }
196
+
197
+ .file-picker__mask {
198
+ /* #ifndef APP-NVUE */
199
+ display: flex;
200
+ /* #endif */
201
+ justify-content: center;
202
+ align-items: center;
203
+ position: absolute;
204
+ right: 0;
205
+ top: 0;
206
+ bottom: 0;
207
+ left: 0;
208
+ color: #fff;
209
+ font-size: 14px;
210
+ background-color: rgba(0, 0, 0, 0.4);
211
+ }
212
+
213
+ .uni-file-picker__lists-box {
214
+ position: relative;
215
+ }
216
+
217
+ .uni-file-picker__item {
218
+ /* #ifndef APP-NVUE */
219
+ display: flex;
220
+ /* #endif */
221
+ align-items: center;
222
+ padding: 8px 10px;
223
+ padding-right: 5px;
224
+ padding-left: 10px;
225
+ }
226
+
227
+ .files-border {
228
+ border-top: 1px #eee solid;
229
+ }
230
+
231
+ .files__name {
232
+ flex: 1;
233
+ font-size: 14px;
234
+ color: #666;
235
+ margin-right: 25px;
236
+ /* #ifndef APP-NVUE */
237
+ word-break: break-all;
238
+ word-wrap: break-word;
239
+ /* #endif */
240
+ }
241
+
242
+ .icon-files {
243
+ /* #ifndef APP-NVUE */
244
+ position: static;
245
+ background-color: initial;
246
+ /* #endif */
247
+ }
248
+
249
+ // .icon-files .icon-del {
250
+ // background-color: #333;
251
+ // width: 12px;
252
+ // height: 1px;
253
+ // }
254
+
255
+
256
+ .is-list-card {
257
+ border: 1px #eee solid;
258
+ margin-bottom: 5px;
259
+ border-radius: 5px;
260
+ box-shadow: 0 0 2px 0px rgba(0, 0, 0, 0.1);
261
+ padding: 5px;
262
+ }
263
+
264
+ .files__image {
265
+ width: 40px;
266
+ height: 40px;
267
+ margin-right: 10px;
268
+ }
269
+
270
+ .header-image {
271
+ width: 100%;
272
+ height: 100%;
273
+ }
274
+
275
+ .is-text-box {
276
+ border: 1px #eee solid;
277
+ border-radius: 5px;
278
+ }
279
+
280
+ .is-text-image {
281
+ width: 25px;
282
+ height: 25px;
283
+ margin-left: 5px;
284
+ }
285
+
286
+ .rotate {
287
+ position: absolute;
288
+ transform: rotate(90deg);
289
+ }
290
+
291
+ .icon-del-box {
292
+ /* #ifndef APP-NVUE */
293
+ display: flex;
294
+ margin: auto 0;
295
+ /* #endif */
296
+ align-items: center;
297
+ justify-content: center;
298
+ position: absolute;
299
+ top: 0px;
300
+ bottom: 0;
301
+ right: 5px;
302
+ height: 26px;
303
+ width: 26px;
304
+ // border-radius: 50%;
305
+ // background-color: rgba(0, 0, 0, 0.5);
306
+ z-index: 2;
307
+ transform: rotate(-45deg);
308
+ }
309
+
310
+ .icon-del {
311
+ width: 15px;
312
+ height: 1px;
313
+ background-color: #333;
314
+ // border-radius: 1px;
315
+ }
316
+
317
+ /* #ifdef H5 */
318
+ @media all and (min-width: 768px) {
319
+ .uni-file-picker__files {
320
+ max-width: 375px;
321
+ }
322
+ }
323
+
324
+ /* #endif */
325
+ </style>
@@ -0,0 +1,292 @@
1
+ <template>
2
+ <view class="uni-file-picker__container">
3
+ <view class="file-picker__box" v-for="(item,index) in filesList" :key="index" :style="boxStyle">
4
+ <view class="file-picker__box-content" :style="borderStyle">
5
+ <image class="file-image" :src="item.url" mode="aspectFill" @click.stop="prviewImage(item,index)"></image>
6
+ <view v-if="delIcon && !readonly" class="icon-del-box" @click.stop="delFile(index)">
7
+ <view class="icon-del"></view>
8
+ <view class="icon-del rotate"></view>
9
+ </view>
10
+ <view v-if="(item.progress && item.progress !== 100) ||item.progress===0 " class="file-picker__progress">
11
+ <progress class="file-picker__progress-item" :percent="item.progress === -1?0:item.progress" stroke-width="4"
12
+ :backgroundColor="item.errMsg?'#ff5a5f':'#EBEBEB'" />
13
+ </view>
14
+ <view v-if="item.errMsg" class="file-picker__mask" @click.stop="uploadFiles(item,index)">
15
+ 点击重试
16
+ </view>
17
+ </view>
18
+ </view>
19
+ <view v-if="filesList.length < limit && !readonly" class="file-picker__box" :style="boxStyle">
20
+ <view class="file-picker__box-content is-add" :style="borderStyle" @click="choose">
21
+ <slot>
22
+ <view class="icon-add"></view>
23
+ <view class="icon-add rotate"></view>
24
+ </slot>
25
+ </view>
26
+ </view>
27
+ </view>
28
+ </template>
29
+
30
+ <script>
31
+ export default {
32
+ name: "uploadImage",
33
+ emits:['uploadFiles','choose','delFile'],
34
+ props: {
35
+ filesList: {
36
+ type: Array,
37
+ default () {
38
+ return []
39
+ }
40
+ },
41
+ disabled:{
42
+ type: Boolean,
43
+ default: false
44
+ },
45
+ disablePreview: {
46
+ type: Boolean,
47
+ default: false
48
+ },
49
+ limit: {
50
+ type: [Number, String],
51
+ default: 9
52
+ },
53
+ imageStyles: {
54
+ type: Object,
55
+ default () {
56
+ return {
57
+ width: 'auto',
58
+ height: 'auto',
59
+ border: {}
60
+ }
61
+ }
62
+ },
63
+ delIcon: {
64
+ type: Boolean,
65
+ default: true
66
+ },
67
+ readonly:{
68
+ type:Boolean,
69
+ default:false
70
+ }
71
+ },
72
+ computed: {
73
+ styles() {
74
+ let styles = {
75
+ width: 'auto',
76
+ height: 'auto',
77
+ border: {}
78
+ }
79
+ return Object.assign(styles, this.imageStyles)
80
+ },
81
+ boxStyle() {
82
+ const {
83
+ width = 'auto',
84
+ height = 'auto'
85
+ } = this.styles
86
+ let obj = {}
87
+ if (height === 'auto') {
88
+ if (width !== 'auto') {
89
+ obj.height = this.value2px(width)
90
+ obj['padding-top'] = 0
91
+ } else {
92
+ obj.height = 0
93
+ }
94
+ } else {
95
+ obj.height = this.value2px(height)
96
+ obj['padding-top'] = 0
97
+ }
98
+
99
+ if (width === 'auto') {
100
+ if (height !== 'auto') {
101
+ obj.width = this.value2px(height)
102
+ } else {
103
+ obj.width = '33.3%'
104
+ }
105
+ } else {
106
+ obj.width = this.value2px(width)
107
+ }
108
+
109
+ let classles = ''
110
+ for(let i in obj){
111
+ classles+= `${i}:${obj[i]};`
112
+ }
113
+ return classles
114
+ },
115
+ borderStyle() {
116
+ let {
117
+ border
118
+ } = this.styles
119
+ let obj = {}
120
+ const widthDefaultValue = 1
121
+ const radiusDefaultValue = 3
122
+ if (typeof border === 'boolean') {
123
+ obj.border = border ? '1px #eee solid' : 'none'
124
+ } else {
125
+ let width = (border && border.width) || widthDefaultValue
126
+ width = this.value2px(width)
127
+ let radius = (border && border.radius) || radiusDefaultValue
128
+ radius = this.value2px(radius)
129
+ obj = {
130
+ 'border-width': width,
131
+ 'border-style': (border && border.style) || 'solid',
132
+ 'border-color': (border && border.color) || '#eee',
133
+ 'border-radius': radius
134
+ }
135
+ }
136
+ let classles = ''
137
+ for(let i in obj){
138
+ classles+= `${i}:${obj[i]};`
139
+ }
140
+ return classles
141
+ }
142
+ },
143
+ methods: {
144
+ uploadFiles(item, index) {
145
+ this.$emit("uploadFiles", item)
146
+ },
147
+ choose() {
148
+ this.$emit("choose")
149
+ },
150
+ delFile(index) {
151
+ this.$emit('delFile', index)
152
+ },
153
+ prviewImage(img, index) {
154
+ let urls = []
155
+ if(Number(this.limit) === 1&&this.disablePreview&&!this.disabled){
156
+ this.$emit("choose")
157
+ }
158
+ if(this.disablePreview) return
159
+ this.filesList.forEach(i => {
160
+ urls.push(i.url)
161
+ })
162
+
163
+ uni.previewImage({
164
+ urls: urls,
165
+ current: index
166
+ });
167
+ },
168
+ value2px(value) {
169
+ if (typeof value === 'number') {
170
+ value += 'px'
171
+ } else {
172
+ if (value.indexOf('%') === -1) {
173
+ value = value.indexOf('px') !== -1 ? value : value + 'px'
174
+ }
175
+ }
176
+ return value
177
+ }
178
+ }
179
+ }
180
+ </script>
181
+
182
+ <style lang="scss">
183
+ .uni-file-picker__container {
184
+ /* #ifndef APP-NVUE */
185
+ display: flex;
186
+ box-sizing: border-box;
187
+ /* #endif */
188
+ flex-wrap: wrap;
189
+ margin: -5px;
190
+ }
191
+
192
+ .file-picker__box {
193
+ position: relative;
194
+ // flex: 0 0 33.3%;
195
+ width: 33.3%;
196
+ height: 0;
197
+ padding-top: 33.33%;
198
+ /* #ifndef APP-NVUE */
199
+ box-sizing: border-box;
200
+ /* #endif */
201
+ }
202
+
203
+ .file-picker__box-content {
204
+ position: absolute;
205
+ top: 0;
206
+ right: 0;
207
+ bottom: 0;
208
+ left: 0;
209
+ margin: 5px;
210
+ border: 1px #eee solid;
211
+ border-radius: 5px;
212
+ overflow: hidden;
213
+ }
214
+
215
+ .file-picker__progress {
216
+ position: absolute;
217
+ bottom: 0;
218
+ left: 0;
219
+ right: 0;
220
+ /* border: 1px red solid; */
221
+ z-index: 2;
222
+ }
223
+
224
+ .file-picker__progress-item {
225
+ width: 100%;
226
+ }
227
+
228
+ .file-picker__mask {
229
+ /* #ifndef APP-NVUE */
230
+ display: flex;
231
+ /* #endif */
232
+ justify-content: center;
233
+ align-items: center;
234
+ position: absolute;
235
+ right: 0;
236
+ top: 0;
237
+ bottom: 0;
238
+ left: 0;
239
+ color: #fff;
240
+ font-size: 12px;
241
+ background-color: rgba(0, 0, 0, 0.4);
242
+ }
243
+
244
+ .file-image {
245
+ width: 100%;
246
+ height: 100%;
247
+ }
248
+
249
+ .is-add {
250
+ /* #ifndef APP-NVUE */
251
+ display: flex;
252
+ /* #endif */
253
+ align-items: center;
254
+ justify-content: center;
255
+ }
256
+
257
+ .icon-add {
258
+ width: 50px;
259
+ height: 5px;
260
+ background-color: #f1f1f1;
261
+ border-radius: 2px;
262
+ }
263
+
264
+ .rotate {
265
+ position: absolute;
266
+ transform: rotate(90deg);
267
+ }
268
+
269
+ .icon-del-box {
270
+ /* #ifndef APP-NVUE */
271
+ display: flex;
272
+ /* #endif */
273
+ align-items: center;
274
+ justify-content: center;
275
+ position: absolute;
276
+ top: 3px;
277
+ right: 3px;
278
+ height: 26px;
279
+ width: 26px;
280
+ border-radius: 50%;
281
+ background-color: rgba(0, 0, 0, 0.5);
282
+ z-index: 2;
283
+ transform: rotate(-45deg);
284
+ }
285
+
286
+ .icon-del {
287
+ width: 15px;
288
+ height: 2px;
289
+ background-color: #fff;
290
+ border-radius: 2px;
291
+ }
292
+ </style>
@@ -0,0 +1,110 @@
1
+ /**
2
+ * 获取文件名和后缀
3
+ * @param {String} name
4
+ */
5
+ export const get_file_ext = (name) => {
6
+ const last_len = name.lastIndexOf('.')
7
+ const len = name.length
8
+ return {
9
+ name: name.substring(0, last_len),
10
+ ext: name.substring(last_len + 1, len)
11
+ }
12
+ }
13
+
14
+ /**
15
+ * 获取扩展名
16
+ * @param {Array} fileExtname
17
+ */
18
+ export const get_extname = (fileExtname) => {
19
+ if (!Array.isArray(fileExtname)) {
20
+ let extname = fileExtname.replace(/(\[|\])/g, '')
21
+ return extname.split(',')
22
+ } else {
23
+ return fileExtname
24
+ }
25
+ return []
26
+ }
27
+
28
+ /**
29
+ * 获取文件和检测是否可选
30
+ */
31
+ export const get_files_and_is_max = (res, _extname) => {
32
+ let filePaths = []
33
+ let files = []
34
+ if(!_extname || _extname.length === 0){
35
+ return {
36
+ filePaths,
37
+ files
38
+ }
39
+ }
40
+ res.tempFiles.forEach(v => {
41
+ let fileFullName = get_file_ext(v.name)
42
+ const extname = fileFullName.ext.toLowerCase()
43
+ if (_extname.indexOf(extname) !== -1) {
44
+ files.push(v)
45
+ filePaths.push(v.path)
46
+ }
47
+ })
48
+ if (files.length !== res.tempFiles.length) {
49
+ uni.showToast({
50
+ title: `当前选择了${res.tempFiles.length}个文件 ,${res.tempFiles.length - files.length} 个文件格式不正确`,
51
+ icon: 'none',
52
+ duration: 5000
53
+ })
54
+ }
55
+
56
+ return {
57
+ filePaths,
58
+ files
59
+ }
60
+ }
61
+
62
+
63
+ /**
64
+ * 获取图片信息
65
+ * @param {Object} filepath
66
+ */
67
+ export const get_file_info = (filepath) => {
68
+ return new Promise((resolve, reject) => {
69
+ uni.getImageInfo({
70
+ src: filepath,
71
+ success(res) {
72
+ resolve(res)
73
+ },
74
+ fail(err) {
75
+ reject(err)
76
+ }
77
+ })
78
+ })
79
+ }
80
+ /**
81
+ * 获取封装数据
82
+ */
83
+ export const get_file_data = async (files, type = 'image') => {
84
+ // 最终需要上传数据库的数据
85
+ let fileFullName = get_file_ext(files.name)
86
+ const extname = fileFullName.ext.toLowerCase()
87
+ let filedata = {
88
+ name: files.name,
89
+ uuid: files.uuid,
90
+ extname: extname || '',
91
+ cloudPath: files.cloudPath,
92
+ fileType: files.fileType,
93
+ thumbTempFilePath: files.thumbTempFilePath,
94
+ url: files.path || files.path,
95
+ size: files.size, //单位是字节
96
+ image: {},
97
+ path: files.path,
98
+ video: {}
99
+ }
100
+ if (type === 'image') {
101
+ const imageinfo = await get_file_info(files.path)
102
+ delete filedata.video
103
+ filedata.image.width = imageinfo.width
104
+ filedata.image.height = imageinfo.height
105
+ filedata.image.location = imageinfo.path
106
+ } else {
107
+ delete filedata.image
108
+ }
109
+ return filedata
110
+ }