index.vue 3.81 KB
<template>
  <div class="contaienr">
    <cliaims v-if="type == 'claims'"></cliaims>
     <van-empty image="error" v-if="showError" description="链接缺少type参数" />
  </div>
</template>
<script>
import { upload } from '@/api'
import cliaims from './components/claims.vue'
export default {
  components: {
    cliaims
  },
  data() {
    return {
      fileList: [],
      uploadList: [],
      fileURL: {},
      loadingFinish: false,
      type: '',
      showError:false
    }
  },
  created() {
    this.getQuery()
  },
  mounted() {},
  methods: {
    getQuery() {
      const { type } = window.vm.$route.query
      this.type = type
      this.showError = type?false:true
    },
    // 获取当前点击的位置
    toClickUpoload() {},
    beforeRead(e) {},
    checkRead(file) {
      if (file.size > 1024) {
        this.showLoading()
        return true
      }
      return true
    },
    afterRread(file, e) {
      this.uploadImage(file)
    },
    beforeDelete(file, e) {
      this.currentDelImg = file.url
      this.deleteFile()
    },
    // 上传图片
    uploadImage(file) {
      const imgFile = file.content
      //三种写法
      // 1.substring字符串截取  2.split方法截取 比如:let temp = file.name.split('.');temp = temp[temp.length-1]
      // 3.[].pop()
      let fileName = file.file.name
      let index = fileName.lastIndexOf('.')
      fileName = fileName.substring(index + 1, fileName.length)
      const base64 = fileName + '@' + imgFile.split(',')[1]
      let para = {
        file: base64,
        fileType: 'image'
      }
      this.hideLoading()
      // this.showLoading()
      // upload.uploadImageApi(para).then(res => {
      //   if (res.code == 0) {
      //     this.uploadFile(res.data)
      //   } else {
      //     this.showToast(res.message)
      //   }
      // })
    },
    // 上传附件
    uploadFile(url) {},
    // 删除附件
    deleteFile() {}
  }
}
</script>
<style lang="scss" scoped>
// .flex_ccc {
//   display: flex;
//   flex-direction: column;
//   align-items: center;
//   justify-content: center;
// }
// .flex_scb {
//   display: flex;
//   align-items: center;
// }
// .contaienr {
//   padding: 10px 16px;
//   .upload_box_wrapper {
//     width: 100%;
//     min-height: 156px;
//     padding-bottom: 16px;
//     background: #ffffff;
//     box-shadow: 0px 4px 8px 0px rgba(224, 224, 224, 0.5);
//     border-radius: 4px;
//     margin-bottom: 10px;
//     .title {
//       box-sizing: border-box;
//       padding: 16px 10px;
//       font-size: 16px;
//       color: #333333;
//       font-weight: 600;
//       .require {
//         font-size: 16px;
//         color: #fe4b00;
//         font-weight: 500;
//       }
//     }
//     .main_pannel {
//       box-sizing: border-box;
//       padding: 0 10px;
//       display: flex;
//       flex-wrap: wrap;
//       .box_wrap {
//         width: 102px;
//         height: 102px;
//         background: #f5f6fa;
//         > p {
//           font-size: 16px;
//           color: #999999;
//           font-weight: 400;
//           margin-top: 10px;
//         }
//       }
//       .deleteWrap {
//         position: absolute;
//         left: 0;
//         top: 0;
//         height: 20px;
//         width: 20px;
//         z-index: 999;
//         > img {
//           height: 20px;
//           width: 20px;
//         }
//       }
//     }
//     .main_pannel /deep/ .van-uploader__preview-delete {
//       left: 0;
//       width: 20px;
//       height: 20px;
//       border-radius: 50%;
//       display: flex;
//       align-items: center;
//       justify-content: center;
//       background: #3975c6;
//       background-image: url('https://img01.glsx.com.cn/weapp/resource/equity-h5-new/mini/deleteIcon.png');
//       background-size: 20px 20px;
//       > i {
//         display: none;
//       }
//     }
//   }
// }
</style>