sadais-piui 1.2.7-beta125 → 1.2.7-beta127
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
* @Author: zhangzhenfei
|
|
3
3
|
* @Date: 2021-08-13 11:31:57
|
|
4
|
-
* @LastEditTime: 2024-
|
|
4
|
+
* @LastEditTime: 2024-10-22 10:42:41
|
|
5
5
|
* @LastEditors: zhangzhenfei
|
|
6
6
|
* @Description: 图片上传组件
|
|
7
7
|
* @FilePath: /piui-awesome/src/piui/components/pi-upload-img/index.vue
|
|
@@ -35,8 +35,10 @@
|
|
|
35
35
|
class="pi-rela pi-of-hidden pi-radius-8"
|
|
36
36
|
:style="[getItemStyle]"
|
|
37
37
|
>
|
|
38
|
-
<view class="file-mask">
|
|
39
|
-
|
|
38
|
+
<view class="file-mask" :class="[{'no-bg': fileIconMap[getFileType(imgField ? img[imgField] : img)]}]">
|
|
39
|
+
<image v-if="fileIconMap[getFileType(imgField ? img[imgField] : img)]" :src="fileIconMap[getFileType(imgField ? img[imgField] : img)]" mode="widthFix" style="width: 100%;"/>
|
|
40
|
+
<template v-else>
|
|
41
|
+
<pi-icon
|
|
40
42
|
:name="
|
|
41
43
|
isVideoFilename(imgField ? img[imgField] : img)
|
|
42
44
|
? 'videofill'
|
|
@@ -48,6 +50,7 @@
|
|
|
48
50
|
<view class="pi-mg-top-12 pi-fz-22">
|
|
49
51
|
{{ getFileType(imgField ? img[imgField] : img) }}
|
|
50
52
|
</view>
|
|
53
|
+
</template>
|
|
51
54
|
</view>
|
|
52
55
|
</view>
|
|
53
56
|
</view>
|
|
@@ -382,6 +385,13 @@ export default {
|
|
|
382
385
|
default() {
|
|
383
386
|
return uploadImg.chooseVideoOpts
|
|
384
387
|
}
|
|
388
|
+
},
|
|
389
|
+
// 文件类型和图标映射关系,对象形式({PDF: 'https://xxx'})
|
|
390
|
+
fileIconMap: {
|
|
391
|
+
type: Object,
|
|
392
|
+
default() {
|
|
393
|
+
return uploadImg.fileIconMap
|
|
394
|
+
}
|
|
385
395
|
}
|
|
386
396
|
},
|
|
387
397
|
data() {
|
|
@@ -409,6 +419,9 @@ export default {
|
|
|
409
419
|
}
|
|
410
420
|
]
|
|
411
421
|
},
|
|
422
|
+
selectOnlyFile() {
|
|
423
|
+
return this.type === 'all' && this.fileTypes.length === 0
|
|
424
|
+
},
|
|
412
425
|
isValString() {
|
|
413
426
|
return this.$pi.lang.isString(this.val)
|
|
414
427
|
},
|
|
@@ -719,7 +732,7 @@ export default {
|
|
|
719
732
|
if (this.$pi.lang.isEmpty(this.headers)) {
|
|
720
733
|
console.log(TAG, '当前图片上传headers为空,请检查是否需要配置授权信息')
|
|
721
734
|
}
|
|
722
|
-
console.log('
|
|
735
|
+
console.log('当前上传文件类型:', this.type)
|
|
723
736
|
if (this.type === 'all') {
|
|
724
737
|
// #ifndef MP-WEIXIN
|
|
725
738
|
this.handleChooseFile()
|
|
@@ -728,6 +741,11 @@ export default {
|
|
|
728
741
|
// #ifdef MP-WEIXIN
|
|
729
742
|
const { fromWxMessage } = this.getChooseFileOpts
|
|
730
743
|
if (fromWxMessage) {
|
|
744
|
+
if (this.selectOnlyFile) {
|
|
745
|
+
this.handleSelectMessageFile()
|
|
746
|
+
return
|
|
747
|
+
}
|
|
748
|
+
this.$emit('show-actions')
|
|
731
749
|
this.showActionSheet = true
|
|
732
750
|
} else {
|
|
733
751
|
this.handleChooseMedia()
|
|
@@ -786,7 +804,7 @@ export default {
|
|
|
786
804
|
const [, result] = await uni.chooseMessageFile({
|
|
787
805
|
count: this.getUploadMaxCount,
|
|
788
806
|
type:
|
|
789
|
-
this.fileTypes.includes('
|
|
807
|
+
this.fileTypes.includes('image') || this.fileTypes.includes('video')
|
|
790
808
|
? 'all'
|
|
791
809
|
: 'file'
|
|
792
810
|
})
|
|
@@ -977,6 +995,9 @@ export default {
|
|
|
977
995
|
align-items: center;
|
|
978
996
|
justify-content: center;
|
|
979
997
|
background: rgba(0, 0, 0, 0.3);
|
|
998
|
+
&.no-bg {
|
|
999
|
+
background: transparent;
|
|
1000
|
+
}
|
|
980
1001
|
}
|
|
981
1002
|
}
|
|
982
1003
|
</style>
|
package/config/uploadImg.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: zhangzhenfei
|
|
3
3
|
* @Date: 2021-08-13 11:29:02
|
|
4
|
-
* @LastEditTime: 2024-
|
|
4
|
+
* @LastEditTime: 2024-10-22 10:43:21
|
|
5
5
|
* @LastEditors: zhangzhenfei
|
|
6
6
|
* @Description: 图片上传
|
|
7
|
-
* @FilePath: /
|
|
7
|
+
* @FilePath: /piui-awesome/src/piui/config/uploadImg.js
|
|
8
8
|
*/
|
|
9
9
|
import icon from './icon.js'
|
|
10
10
|
import cropOption from './imgCropper.js'
|
|
@@ -77,5 +77,6 @@ export default {
|
|
|
77
77
|
},
|
|
78
78
|
beforeUpload: null, // 上传之前的钩子
|
|
79
79
|
onProgress: null, // 文件上传时的钩子
|
|
80
|
-
beforeRemove: null // 删除之前的钩子
|
|
80
|
+
beforeRemove: null, // 删除之前的钩子
|
|
81
|
+
fileIconMap: {} // 文件类型和图标映射关系,对象形式({PDF: 'https://xxx'})
|
|
81
82
|
}
|