Zupload.vue 1002 B

123456789101112131415161718192021222324252627282930313233343536
  1. <script setup lang="ts">
  2. import { uploadProps } from 'wot-design-uni/components/wd-upload/types'
  3. import { BASE_URL, StaticUrl } from '@/config'
  4. const props = defineProps(uploadProps)
  5. const emit = defineEmits(['update:value'])
  6. const { token } = storeToRefs(useUserStore())
  7. const fileSubmitList = computed({
  8. get() {
  9. console.log(props.fileList, ' props.fileList')
  10. return props.fileList
  11. },
  12. set(val) {
  13. const fileData = val.map((item) => {
  14. return {
  15. url: JSON.parse(String(item.response)).data.url,
  16. }
  17. })
  18. emit('update:value', fileData)
  19. },
  20. })
  21. </script>
  22. <template>
  23. <wd-upload
  24. v-bind="props" v-model:file-list="fileSubmitList" image-mode="aspectFill"
  25. :action="`${BASE_URL}/smqjh-system/api/v1/files`" :header="{
  26. authorization: token,
  27. }"
  28. >
  29. <view class="h120rpx w120rpx flex items-center justify-center rounded-32rpx bg-white">
  30. <image :src="`${StaticUrl}/upload.png`" class="h40rpx w40rpx" />
  31. </view>
  32. </wd-upload>
  33. </template>