uploadQrcode.vue 1.35 KB
Newer Older
1 2 3 4 5 6 7 8 9
<template>
  <div>
    <el-upload
      action="http://192.168.110.67/mall/file/image/upload"
      list-type="picture-card"
      :on-preview="handlePictureCardPreview"
      :on-remove="handleRemove"
      :on-success="handleAvatarSuccess"
      :headers="headers"
乐宝呗666's avatar
乐宝呗666 committed
10 11 12
      :file-list="fileList"
      :limit="1"
      :multiple ="false"
13 14 15 16 17 18 19 20 21 22 23
    >
      <i class="el-icon-plus"></i>
    </el-upload>
    <el-dialog :visible.sync="dialogVisible">
      <img width="100%" :src="dialogImageUrl" alt />
    </el-dialog>
  </div>
</template>

<script>
export default {
乐宝呗666's avatar
乐宝呗666 committed
24 25 26 27 28 29
  props:{
    fileList:{
      type:Array,
      default:[]
    },
  },
30 31 32 33 34 35 36 37 38
  data() {
    return {
      dialogImageUrl: "",
      dialogVisible: false
    };
  },
   computed: {
    headers() {
    //   return { 'token': this.backToken }
qzhxx's avatar
qzhxx committed
39
    return {'Authorization':localStorage.getItem('backToken')}
40 41 42 43 44 45
    }
  },
  methods: {
    // 图片上传成功的返回值
    handleAvatarSuccess(res, file) {
        console.log(res)
qzhxx's avatar
qzhxx committed
46 47
        // console.log(res.url)
        console.log(res.data.url)
qzhxx's avatar
qzhxx committed
48
        this.$emit('qrcodeUrl', res.data.url)
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
        // this.imageUrl = URL.createObjectURL(file.raw);
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    }
  }
};
</script>

<style>
</style>