|
@@ -19,10 +19,10 @@
|
|
|
ref="uploadVNormal" />
|
|
ref="uploadVNormal" />
|
|
|
</div>
|
|
</div>
|
|
|
</van-col>
|
|
</van-col>
|
|
|
- <van-col span="6" v-for="(id, index) in imgArr" :key="index">
|
|
|
|
|
|
|
+ <van-col span="6" v-for="(item, index) in imgArr" :key="index">
|
|
|
<div class="imgview">
|
|
<div class="imgview">
|
|
|
<van-icon v-if="insert == '1'" name="close" size="16" v-on:click="deleteImg(index)" />
|
|
<van-icon v-if="insert == '1'" name="close" size="16" v-on:click="deleteImg(index)" />
|
|
|
- <img :src="id" width="100px" height="100px" @click="previewsImg(index)" />
|
|
|
|
|
|
|
+ <img :src="item.serverId" width="100px" height="100px" @click="previewsImg(index)" />
|
|
|
<!-- <img
|
|
<!-- <img
|
|
|
v-else
|
|
v-else
|
|
|
:src="urls.fileUrl"
|
|
:src="urls.fileUrl"
|
|
@@ -96,7 +96,7 @@ export default {
|
|
|
watch: {
|
|
watch: {
|
|
|
imgs: {
|
|
imgs: {
|
|
|
handler(val) {
|
|
handler(val) {
|
|
|
- this.imgArr = val || [];
|
|
|
|
|
|
|
+ if (val) this.imgArr = val;
|
|
|
},
|
|
},
|
|
|
deep: true,
|
|
deep: true,
|
|
|
immediate: true,
|
|
immediate: true,
|
|
@@ -106,6 +106,7 @@ export default {
|
|
|
return {
|
|
return {
|
|
|
url: process.env.VUE_APP_Target1 + process.env.VUE_APP_BASE_API,
|
|
url: process.env.VUE_APP_Target1 + process.env.VUE_APP_BASE_API,
|
|
|
imgArr: [],
|
|
imgArr: [],
|
|
|
|
|
+ mediaIds: [],
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
@@ -113,20 +114,41 @@ export default {
|
|
|
this.imgArr.splice(index, 1);
|
|
this.imgArr.splice(index, 1);
|
|
|
},
|
|
},
|
|
|
previewsImg(index) {
|
|
previewsImg(index) {
|
|
|
|
|
+ let urls = this.imgArr.map((item) => item.serverId);
|
|
|
ImagePreview({
|
|
ImagePreview({
|
|
|
- images: this.imgArr,
|
|
|
|
|
|
|
+ images: urls,
|
|
|
startPosition: index,
|
|
startPosition: index,
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
newimgarr(localIds) {
|
|
newimgarr(localIds) {
|
|
|
- if (this.isIOS()) {
|
|
|
|
|
- this.imgArr = this.imgArr.concat([...localIds]);
|
|
|
|
|
- // 解决ios微信localId无法直接使用的问题,获取base64后再上传
|
|
|
|
|
- // this.setIosImg(localIds);
|
|
|
|
|
|
|
+ this.syncUpload(localIds);
|
|
|
|
|
+ // if (this.isIOS()) {
|
|
|
|
|
+ // this.imgArr = this.imgArr.concat([...localIds]);
|
|
|
|
|
+ // // 解决ios微信localId无法直接使用的问题,获取base64后再上传
|
|
|
|
|
+ // // this.setIosImg(localIds);
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // this.imgArr = this.imgArr.concat([...localIds]);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // this.$emit('upDataDetail');
|
|
|
|
|
+ },
|
|
|
|
|
+ syncUpload(localIds, callback) {
|
|
|
|
|
+ if (!localIds.length) {
|
|
|
|
|
+ callback && callback();
|
|
|
|
|
+ return;
|
|
|
} else {
|
|
} else {
|
|
|
- this.imgArr = this.imgArr.concat([...localIds]);
|
|
|
|
|
|
|
+ var localId = localIds.pop();
|
|
|
|
|
+ wx.uploadImage({
|
|
|
|
|
+ localId: localId,
|
|
|
|
|
+ isShowProgressTips: 1, // 默认为1,显示进度提示
|
|
|
|
|
+ success: (res) => {
|
|
|
|
|
+ this.imgArr.push({
|
|
|
|
|
+ mediaId: res.serverId,
|
|
|
|
|
+ serverId: localId,
|
|
|
|
|
+ });
|
|
|
|
|
+ this.syncUpload(localIds, callback);
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
- // this.$emit('upDataDetail');
|
|
|
|
|
},
|
|
},
|
|
|
isIOS() {
|
|
isIOS() {
|
|
|
return /iPhone|iPad|iPod/i.test(navigator.userAgent);
|
|
return /iPhone|iPad|iPod/i.test(navigator.userAgent);
|