<script setup>
import { REQUEST } from '~/utils/request';

const props = defineProps({
  part: String,
  full: String,
})


const fileList = $ref([])

const handleAfterRead = (fileProxy) => {
  fileProxy.status = 'uploading'
  fileProxy.message = '上传中...'
  const { file } = fileProxy
  REQUEST['upload']({
    url: 'upload/main/file',
    data: { filedata: file }
  }).then(res => {
    console.log('res :>> ', res)
    console.log('fileList :>> ', fileList);
    if (res.code === '0') {
      // fileList.value.push(res.data)
      fileProxy.status = 'done'
      fileProxy.message = ''
    } else {
      fileProxy.status = 'failed'
      fileProxy.message = '上传失败'
    }
  }).catch((err) => {
    console.error(err)
  })
}



</script>

<template>
  <van-uploader :after-read="handleAfterRead" v-model="fileList"></van-uploader>
</template>
