|
|
@@ -7,6 +7,7 @@
|
|
|
v-if="formData.processStatus != 1 || formData.displayRewardTaskEditable">
|
|
|
<div class="addImg">
|
|
|
<uploadVNormalTaskPhoto
|
|
|
+ :imgArr="imgs"
|
|
|
:formData="formData"
|
|
|
:shouws="true"
|
|
|
:storeGroupId="storeGroupId"
|
|
|
@@ -23,18 +24,14 @@
|
|
|
ref="uploadVNormal" />
|
|
|
</div>
|
|
|
</van-col>
|
|
|
- <van-col span="6" v-for="(urls, index) in imgArr" :key="index">
|
|
|
+ <van-col span="6" v-for="(urls, index) in imgs" :key="index">
|
|
|
<div class="imgview">
|
|
|
<van-icon
|
|
|
v-if="formData.processStatus != 1 || formData.displayRewardTaskEditable"
|
|
|
name="close"
|
|
|
size="20"
|
|
|
- v-on:click="deleteImg(index, urls)" />
|
|
|
- <img
|
|
|
- :src="urls.fileUrl || urls.mediaFileUrl"
|
|
|
- width="100px"
|
|
|
- height="100px"
|
|
|
- @click="previewsImg(index)" />
|
|
|
+ v-on:click="deleteImg(index, urls.fileIdSplicing)" />
|
|
|
+ <img :src="urls.fileUrl" width="100px" height="100px" @click="previewsImg(index)" />
|
|
|
<!-- <img
|
|
|
v-else
|
|
|
:src="urls.fileUrl"
|
|
|
@@ -117,24 +114,16 @@ export default {
|
|
|
return [];
|
|
|
},
|
|
|
},
|
|
|
+ imgs: {
|
|
|
+ type: Array,
|
|
|
+ default() {
|
|
|
+ return [];
|
|
|
+ },
|
|
|
+ },
|
|
|
},
|
|
|
watch: {
|
|
|
- formData: {
|
|
|
- handler(val) {
|
|
|
- // <!-- 0=企业微信,1=H5相机 -->
|
|
|
- if (this.userInfo.photoMethod == '1') {
|
|
|
- this.imgArr = this.fileInfoList || [];
|
|
|
- } else {
|
|
|
- this.imgArr = val.mediaInfos || [];
|
|
|
- // if (this.formData.mediaInfos) {
|
|
|
- // getTicketFun(['downloadImage']).then(() => {
|
|
|
- // this.toastLoading(0, '加载中,请稍候...', true);
|
|
|
- // let mediaInfosCopy = JSON.parse(JSON.stringify(this.formData.mediaInfos));
|
|
|
- // this.downloadImage(mediaInfosCopy);
|
|
|
- // });
|
|
|
- // }
|
|
|
- }
|
|
|
- },
|
|
|
+ imgs: {
|
|
|
+ handler(val) {},
|
|
|
deep: true,
|
|
|
immediate: true,
|
|
|
},
|
|
|
@@ -142,119 +131,35 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
url: process.env.VUE_APP_Target1 + process.env.VUE_APP_BASE_API,
|
|
|
- imgArr: [],
|
|
|
- mediaIds: [],
|
|
|
- locationRemark: '',
|
|
|
- isUploadImg: true,
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
|
- downloadImage(mediaInfos) {
|
|
|
- if (!mediaInfos.length) {
|
|
|
- this.toastLoading().clear();
|
|
|
- return;
|
|
|
- } else {
|
|
|
- let mediaitem = mediaInfos.pop();
|
|
|
- if (mediaitem.fileUrl) {
|
|
|
- this.imgArr.push(mediaitem);
|
|
|
- this.downloadImage(mediaInfos);
|
|
|
+ deleteImg(index, fileIdList) {
|
|
|
+ this.toastLoading(0, '请稍候...', true);
|
|
|
+ removePhotoBatch({ fileIdList: fileIdList.split(',') }).then((res) => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.$emit('upDataDetail');
|
|
|
} else {
|
|
|
- wx.downloadImage({
|
|
|
- serverId: mediaitem.mediaId,
|
|
|
- isShowProgressTips: 0, // 默认为1,显示进度提示
|
|
|
- success: (res) => {
|
|
|
- wx.getLocalImgData({
|
|
|
- localId: res.localId,
|
|
|
- success: (res2) => {
|
|
|
- this.imgArr.push({
|
|
|
- mediaId: mediaitem.mediaId,
|
|
|
- mediaFileUrl: res2.localData,
|
|
|
- });
|
|
|
- this.downloadImage(mediaInfos);
|
|
|
- },
|
|
|
- fail: (err) => {
|
|
|
- console.error('获取本地图片数据失败:', err);
|
|
|
- this.$toast('获取图片数据失败');
|
|
|
- this.toastLoading().clear();
|
|
|
- this.downloadImage(mediaInfos);
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
- fail: (err) => {
|
|
|
- console.error('下载图片失败:', err);
|
|
|
- this.$toast('下载图片失败,请重试');
|
|
|
- // 可以选择继续下载其他图片或停止
|
|
|
- this.downloadImage(mediaInfos);
|
|
|
- },
|
|
|
- });
|
|
|
+ this.$toast('删除失败!');
|
|
|
}
|
|
|
- }
|
|
|
- },
|
|
|
- deleteImg(index, urls) {
|
|
|
- // <!-- 0=企业微信,1=H5相机 -->
|
|
|
- if (this.userInfo.photoMethod == '1') {
|
|
|
- removePhotoBatch({ fileIdList: urls.fileIdSplicing.split(',') }).then((res) => {
|
|
|
- if (res.code == 200) {
|
|
|
- this.$toast('删除成功!');
|
|
|
- this.$emit('upDataDetail');
|
|
|
- } else {
|
|
|
- this.$toast('删除失败!');
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.imgArr.splice(index, 1);
|
|
|
- }
|
|
|
+ });
|
|
|
},
|
|
|
previewsImg(index) {
|
|
|
- let urls = this.imgArr.map((item) => item.fileUrl || item.mediaFileUrl);
|
|
|
+ var arrimg = [];
|
|
|
+ for (var imgi = 0; imgi < this.imgs.length; imgi++) {
|
|
|
+ arrimg.push(this.imgs[imgi].fileUrl);
|
|
|
+ }
|
|
|
ImagePreview({
|
|
|
- images: urls,
|
|
|
+ images: arrimg,
|
|
|
startPosition: index,
|
|
|
+ onClose() {
|
|
|
+ // do something
|
|
|
+ },
|
|
|
});
|
|
|
},
|
|
|
- newimgarr(data) {
|
|
|
- const { localIds, locationRemark, source } = data;
|
|
|
- this.locationRemark = locationRemark;
|
|
|
- console.log(source);
|
|
|
- // 0=企业微信,1=H5相机
|
|
|
- if (this.userInfo.photoMethod == '0') {
|
|
|
- this.isUploadImg = false;
|
|
|
- const startIndex = this.imgArr.length;
|
|
|
- this.imgArr = this.imgArr.concat(
|
|
|
- localIds.map((item) => {
|
|
|
- return {
|
|
|
- mediaId: '',
|
|
|
- mediaFileUrl: item,
|
|
|
- };
|
|
|
- }),
|
|
|
- );
|
|
|
- // this.$nextTick(() => {
|
|
|
- // this.syncUpload(localIds, startIndex);
|
|
|
- // });
|
|
|
- } else {
|
|
|
- this.$emit('upDataDetail');
|
|
|
- }
|
|
|
+ newimgarr() {
|
|
|
+ this.$emit('upDataDetail');
|
|
|
},
|
|
|
- // syncUpload(localIds, baseIndex = 0, callback) {
|
|
|
- // if (!localIds.length) {
|
|
|
- // this.isUploadImg = true;
|
|
|
- // callback && callback();
|
|
|
- // return;
|
|
|
- // } else {
|
|
|
- // var localId = localIds.pop();
|
|
|
- // wx.uploadImage({
|
|
|
- // localId: localId,
|
|
|
- // isShowProgressTips: 0, // 默认为1,显示进度提示
|
|
|
- // success: (res) => {
|
|
|
- // const index = baseIndex + localIds.length;
|
|
|
- // if (this.imgArr[index]) {
|
|
|
- // this.imgArr[index].mediaId = res.serverId;
|
|
|
- // }
|
|
|
- // this.syncUpload(localIds, baseIndex, callback);
|
|
|
- // },
|
|
|
- // });
|
|
|
- // }
|
|
|
- // },
|
|
|
},
|
|
|
};
|
|
|
</script>
|