|
|
@@ -11,13 +11,13 @@ |
|
|
|
<view class="grid col-4 grid-square flex-sub"> |
|
|
|
<view v-for="(file, index) in value" :key="index" class="bg-img"> |
|
|
|
<image |
|
|
|
v-if="isImgFile(file.type)" |
|
|
|
v-if="isImgFile(file)" |
|
|
|
@click="fileClick(index)" |
|
|
|
:src="file.path?file.path:file" |
|
|
|
:webp="file.type === 'webp'" |
|
|
|
mode="aspectFill" |
|
|
|
></image> |
|
|
|
<view v-else-if="isDocFile(file.type)" @click="fileClick(index)" class="file-icon solids"> |
|
|
|
<view v-else-if="isDocFile(file)" @click="fileClick(index)" class="file-icon solids"> |
|
|
|
<l-icon type="text" /> |
|
|
|
</view> |
|
|
|
<view v-else class="file-icon solids"><l-icon type="text" /></view> |
|
|
@@ -51,16 +51,16 @@ export default { |
|
|
|
getFileExt(path) { |
|
|
|
return /\.(\w{2,5})$/.exec(path)[1] || null |
|
|
|
}, |
|
|
|
|
|
|
|
isImgFile(type) { |
|
|
|
const typeString = (type || '').toLowerCase() |
|
|
|
//return ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'image'].includes(typeString) |
|
|
|
return true; |
|
|
|
|
|
|
|
isImgFile(file) { |
|
|
|
const typeString = (file.type || '').toLowerCase() |
|
|
|
return ['jpg','image/jpg','jpeg','image/jpeg', 'png', 'image/png','gif', 'image/gif','bmp', 'image/bmp','webp', 'image/webp','image'].includes(typeString) |
|
|
|
}, |
|
|
|
|
|
|
|
isDocFile(type) { |
|
|
|
const typeString = (type || '').toLowerCase() |
|
|
|
isDocFile(file) { |
|
|
|
const typeString = (file.type || '').toLowerCase() |
|
|
|
return ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf'].includes(typeString) |
|
|
|
return true |
|
|
|
}, |
|
|
|
|
|
|
|
delFile(index) { |
|
|
@@ -93,9 +93,11 @@ export default { |
|
|
|
count: Number(this.number), |
|
|
|
sizeType: ['original', 'compressed'], |
|
|
|
sourceType: ['album', 'camera'], |
|
|
|
success: ({ tempFilePaths }) => { |
|
|
|
success: ({ tempFilePaths,tempFiles }) => { |
|
|
|
console.log(tempFiles) |
|
|
|
const newList = JSON.parse(JSON.stringify(this.value || [])).concat( |
|
|
|
tempFilePaths//.map(t => ({ path: t, type: this.getFileExt(t) })) |
|
|
|
// tempFilePaths//.map(t => ({ path: t, type: this.getFileExt(t) })) |
|
|
|
tempFilePaths.map((t,i) => ({ path: t, type: tempFiles[i].type,size:tempFiles[i].size })) |
|
|
|
) |
|
|
|
this.$emit('input', newList) |
|
|
|
this.$emit('change', newList) |
|
|
@@ -107,9 +109,9 @@ export default { |
|
|
|
|
|
|
|
async fileClick(index) { |
|
|
|
const { path, type, uid, size = 0 } = this.value[index] |
|
|
|
if (this.isImgFile(type)) { |
|
|
|
if (this.isImgFile(this.value[index])) { |
|
|
|
uni.previewImage({ urls: [path], current: path }) |
|
|
|
} else if (this.isDocFile(type)) { |
|
|
|
} else if (this.isDocFile(this.value[index])) { |
|
|
|
// #ifndef H5 || MP-DINGTALK |
|
|
|
if (size >= 50 * 1024 * 1024) { |
|
|
|
this.TOAST('小程序端无法下载超过50MB的文件,此文件大小为${size}KB,超过限制') |
|
|
|