<template>
	<u-upload :max-count="maxCount" :action="requertUrl" :header="header" :auto-upload="autoUpload" @on-uploaded="getImg"></u-upload>
	<!-- <u-upload max-count="1" :action="upUrl" :header="upHeader" ref="uUpload" @on-uploaded="setImg"></u-upload> -->
</template>

<script>
import { mapState } from 'vuex';
export default {
	props: {
		
		// 是否自动上传
		autoUpload: {
			type: Boolean,
			default: true
		},
		// 最大上传数量
		maxCount: {
			type: Number | String,
			default: 1
		},
		// 请求地址
		action: {
			default: ''
		},
		// 请求头
		header: {
			type: Object,
			default: function() {
				return {
					'Authori-zation': 'Bearer ' + uni.getStorageSync('token') || ''
				};
			}
		}
	},
	data() {
		return {
			refName:''
		};
	},
	computed: {
		...mapState(['baseURL']),
		// 默认请求地址
		requertUrl() {
			if (!this.action) {
				return this.baseURL + '/api/upload/image';
			} else {
				return this.action;
			}
		},
		getImg(e) {
			console.log(e);
			// this.$emit('on-uploaded', e);
		},
		// 手动上传
		upload(){
			this.$refs.upLoad.upload()
		}
	},
	created() {
		console.log(this);
	},
	methods: {}
};
</script>

<style></style>
