From ef819706ab4ac1bf5928adc1c920052df7b13458 Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Thu, 26 Aug 2021 11:03:18 +0800 Subject: [PATCH] 微调单项框样式 --- forms/imagePicker/CImagePicker.vue | 47 ++++++++++++++++++----------------------------- 1 files changed, 18 insertions(+), 29 deletions(-) diff --git a/forms/imagePicker/CImagePicker.vue b/forms/imagePicker/CImagePicker.vue index d69f25c..108a27a 100644 --- a/forms/imagePicker/CImagePicker.vue +++ b/forms/imagePicker/CImagePicker.vue @@ -23,18 +23,6 @@ :onFail="evt=>handleFail(evt)" :onImageClick="(index, file)=>handleImgView(index,file)" /> - <AtCurtain - class="c-image-picker-view" - closeBtnPosition="top-right" - :isOpened="showImg" - :onClose="evt=>handleImgClose()" - > - <image - class="img" - mode="aspectFit" - :src="curtainImg" - /> - </AtCurtain> <CImageCompressor ref="compressor" /> </view> </template> @@ -43,7 +31,7 @@ import Taro from '@tarojs/taro'; import { $ } from '@tarojs/extend'; import { AtInput, AtImagePicker, AtCurtain } from 'taro-ui-vue'; -import { $fetcherCommon } from '@fetchers/FCommon'; +import { $fetchCommon } from '@fetchers/FCommon'; import CImageCompressor from './CImageCompressor.vue'; import './cImagePicker.scss'; @@ -60,10 +48,7 @@ itemRes: Object, }, data() { - return { - showImg: false, - curtainImg: '', - }; + return {}; }, computed: { files() { @@ -93,7 +78,7 @@ // 添加图片 if (operationType === 'add') { const needs = files - .map((file, index) => { + .map((file, needIndex) => { const fileInfo = file.file; // 没有 file 信息对象,或者不是 blob 类型 if (!fileInfo || fileInfo.path.indexOf('blob') < 0) { @@ -103,19 +88,18 @@ if (fileInfo.size < 1 * 1024 * 1024) { return false; } - return [fileInfo, index]; + return [fileInfo, needIndex]; }) .filter(Boolean); // 存在需要压缩的图片,一次性压缩 if (needs.length > 0) { const files2 = [...files]; - const needPath = needs.map(need => need[0].path); - this.$refs.compressor.$compress(needPath, compressedFiles => { - compressedFiles.forEach((cpFile, index) => { - const filesIndex = needs[index][1]; + const needPaths = needs.map(need => need[0].path); + this.$refs.compressor.$compress(needPaths, compressedFiles => { + compressedFiles.forEach((cpPath, cpIndex) => { + const filesIndex = needs[cpIndex][1]; files2[filesIndex] = { - url: cpFile.path, - file: cpFile, + url: cpPath.compress, }; }); this.triggerChange(files2); @@ -132,8 +116,13 @@ } }, handleImgView(index, file) { - this.curtainImg = file.url; - this.showImg = true; + const urls = this.files + .map(file => (file.type === 'btn' ? false : file.url)) + .filter(Boolean); + Taro.previewImage({ + current: file.url, // 当前显示图片的http链接 + urls, // 需要预览的图片http链接列表 + }); }, handleImgClose() { this.showImg = false; @@ -148,7 +137,7 @@ }); }, $uploadImage(callback) { - const url = $fetcherCommon.getUploadImgURL(); + const url = $fetchCommon.getUploadImgURL(); const uploadTeam = []; const imgs = []; this.files.forEach(file => { @@ -171,7 +160,7 @@ : res.data; if (res2.state.code === 2000) { resolve( - $fetcherCommon.transImgPath( + $fetchCommon.transImgPath( 'fix', res2.data.src ) -- Gitblit v1.9.1