<template>
	<view>
		<view class="single_Phone">
			<span style="color:red;margin-right:5rpx;" v-show="CompData.IsRequire">*</span>{{CompData.Name}}
		</view>
		 <u-upload ref="uUpload" :action="action" :show-tips="false" @on-remove="onRemove"
		 @on-oversize="onversize"
		 @on-exceed="onexceed"
		  :max-size="CompData.FileSizeLimit * 1024 * 1024"
		  :max-count="CompData.FileCount"
		  :file-list="fileList"
		  @on-success="uploadSuccessHandler"
		  ></u-upload>
		<view class="single_Remark" v-if="CompData.Remark">{{CompData.Remark}}</view>
	</view>
</template>

<script>
	export default {
		props: ["CompData",'index'],
		
		data(){
			return{
				action: this.host2 + "/api/File/UploadTencent",
				fileList:[],
			}
		},
		created() {
			let MallBaseId = uni.getStorageSync("mall_UserInfo").MallBaseId ? uni.getStorageSync("mall_UserInfo").MallBaseId : 1;
			this.action = this.host2 + '/api/File/UploadTencent?MallBaseId=' + MallBaseId
			
		},
		methods:{
			uploadSuccessHandler(data, index, lists) {
				let r = JSON.parse(data);
				this.CompData.FileList.push(r.data);
				this.$emit('success', this.CompData, this.index)
				
			},
			onRemove(index) {
				this.CompData.FileList.splice(index, 1);
			},
			onversize(){
				uni.showToast({
					title: '超出允许的文件大小',
					icon: "none"
				});
			},
			onexceed(){
				uni.showToast({
					title: '超出最大允许的文件个数',
					icon: "none"
				});
				
			}
		}
	}
</script>

<style>
</style>
