This commit is contained in:
2023-10-08 22:53:13 +08:00
parent b883b02fb9
commit e36d60d015
83 changed files with 18303 additions and 9590 deletions

View File

@@ -1,62 +1,61 @@
<template>
<view>
<nut-uploader
v-model:file-list="fileList"
:url="config.url"
:maximum="max"
:headers="config.headers"
@success="success"
@failure="failure"
:multiple="false"
></nut-uploader>
</view>
<nut-uploader
v-model:file-list="fileList"
:url="config.url"
:maximum="max"
:headers="config.headers"
@success="success"
@failure="failure"
:multiple="false"
>
</nut-uploader>
</template>
<script setup lang="ts">
import { BASE_URL } from "@/utils/request";
import { computed, ref } from "vue";
import Taro from "@tarojs/taro";
import {BASE_URL} from '@/utils/request'
import {computed, ref} from 'vue'
import Taro from '@tarojs/taro'
const props = defineProps({
list: {
type: Array,
default: () => [],
default: () => []
},
max: {
type: Number,
default: 1,
},
});
default: 1
}
})
const emits = defineEmits(["update:list"]);
const emits = defineEmits(['update:list'])
const fileList = computed({
get: () => props.list,
set: (val) => emits("update:list", val),
});
set: (val) => emits('update:list', val)
})
const config = ref({
url: `${BASE_URL}/upload`,
headers: {
token: Taro.getStorageSync("token"),
},
});
token: Taro.getStorageSync('token')
}
})
const success = (res: any) => {
const data = JSON.parse(res.responseText.data);
res.fileItem.url = data.data.data;
const data = JSON.parse(res.responseText.data)
res.fileItem.url = data.data.data
Taro.showToast({
title: "上传成功",
icon: "success",
});
};
title: '上传成功',
icon: 'success'
})
}
const failure = () => {
Taro.showToast({
title: "上传失败",
icon: "error",
});
};
title: '上传失败',
icon: 'error'
})
}
</script>
<style lang="scss"></style>