MrShi
2 天以前 39fc2d6754953e41a7334a2166347baacfcfb40a
admin/src/components/common/UploadImage.vue
@@ -33,15 +33,15 @@
        </span>
      </div>
    </el-upload>
    <el-image-viewer
      v-if="showViewer"
    <el-image-viewer
      v-if="showViewer"
      :on-close="closeViewer"
      :initialIndex="tempIndex"
      :url-list="srcList"
      :z-index="3000"
    />
  </div>
</template>
<script>
@@ -59,12 +59,11 @@
  },
  data() {
    return {
      uploadImgUrl: process.env.VUE_APP_API_PREFIX + '/public/uploadLocal',
      uploadImgUrl: process.env.VUE_APP_API_PREFIX + '/visitsAdmin/cloudService/public/upload',
      realList: [],
      srcList: [],
      tempIndex: 0,
      showViewer: false,
      showViewer: false
    }
  },
  watch: {
@@ -76,20 +75,19 @@
          this.srcList = []
        }
      }
    }
  },
  methods: {
    beforeUpload(file) {
      this.$emit('beginUpload')
      return true
    },
     // 上传图片成功
     uploadSuccess (res, file, fileList) {
     uploadSuccess (res, file, fileList) {
      // console.log('this.fileList', this.fileList);
      // console.log('fileList', fileList);
      this.$emit('endUpload')
      this.$emit('uploadEnd')
      this.realList = fileList
      this.srcList.push(res.data.url)
      // console.log('file', file);
@@ -106,7 +104,7 @@
      }
    },
    fail (err, file, fileList) {
      this.$emit('endUpload')
      this.$emit('uploadEnd')
      this.$message.error('上传失败')
    },
    handlePictureCardPreview(file) {
@@ -127,7 +125,7 @@
      this.realList.splice(tempIndex, 1)
      this.fileList.splice(tempIndex, 1)
      this.srcList.splice(tempIndex, 1)
    },
  },
}